Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: ADBC Postgres writer incorrectly names the table #57539

Closed
2 of 3 tasks
LeonLuttenberger opened this issue Feb 20, 2024 · 1 comment · Fixed by #57974
Closed
2 of 3 tasks

BUG: ADBC Postgres writer incorrectly names the table #57539

LeonLuttenberger opened this issue Feb 20, 2024 · 1 comment · Fixed by #57974
Assignees
Labels
Bug IO SQL to_sql, read_sql, read_sql_query Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@LeonLuttenberger
Copy link

LeonLuttenberger commented Feb 20, 2024

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

@LeonLuttenberger LeonLuttenberger added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 20, 2024
@LeonLuttenberger LeonLuttenberger changed the title BUG: BUG: ADBC Postgres writer incorrectly names the table Feb 20, 2024
@rhshadrach rhshadrach added the IO SQL to_sql, read_sql, read_sql_query label Feb 27, 2024
@lithomas1 lithomas1 assigned lithomas1 and unassigned lithomas1 Mar 20, 2024
@shabab477
Copy link
Contributor

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO SQL to_sql, read_sql, read_sql_query Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants