Skip to content

BUG: ADBC Postgres writer incorrectly names the table #57539

@LeonLuttenberger

Description

@LeonLuttenberger

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import adbc_driver_postgresql.dbapi as pg_dbapi
import pandas as pd

con = pg_dbapi.connect(uri="<PG_URI>")
table_name = "my_table"

df = pd.DataFrame({"c0": [1, 2, 3], "c1": ["foo", "boo", "bar"]})
df.to_sql(name=table_name, con=con, schema="public", if_exists="replace")

Issue Description

The table which ends up being created in the public schema ends up being named public.my_table, instead of just my_table. The table is then inaccessible, as the following code throws this error ValueError: Table my_table not found:

df_out = pd.read_sql_table(table, con, schema="public")

The created table can be found using the following code:

objects = con.adbc_get_objects(depth="tables", db_schema_filter="public", catalog_filter="postgres").read_all()
catalogs = objects.to_pylist()

all_tables = catalogs[0]["catalog_db_schemas"][0]["db_schema_tables"]
table = [x for x in all_tables if table in x["table_name"]][0]

Expected Behavior

Table gets created under the name specified, without including the schema name in the table name.

Installed Versions

INSTALLED VERSIONS ------------------ commit : fd3f571 python : 3.9.13.final.0 python-bits : 64 OS : Darwin OS-release : 23.3.0 Version : Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:27 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T8103 machine : arm64 processor : arm byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8

pandas : 2.2.0
numpy : 1.26.2
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 69.1.0
pip : 24.0
Cython : None
pytest : 8.0.1
hypothesis : None
sphinx : 7.1.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.3
html5lib : None
pymysql : 1.4.6
psycopg2 : None
jinja2 : 3.1.3
IPython : 8.12.3
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.2
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2023.12.2
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : 15.0.0
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

Labels

BugIO SQLto_sql, read_sql, read_sql_queryNeeds TriageIssue that has not been reviewed by a pandas team member

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy