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

fix: fix naive timestamps and int types in duckdb #148

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cumulus_library/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(self, db_file: str):
"from_iso8601_timestamp",
self._compat_from_iso8601_timestamp,
None,
duckdb.typing.TIMESTAMP_TZ,
duckdb.typing.TIMESTAMP,
)

def insert_tables(self, tables: dict[str, pyarrow.Table]) -> None:
Expand Down Expand Up @@ -151,7 +151,11 @@ def cursor(self) -> duckdb.DuckDBPyConnection:
return self.connection

def execute_as_pandas(self, sql: str) -> pandas.DataFrame:
return self.connection.execute(sql).df()
# We call convert_dtypes here in case there are integer columns.
# Pandas will normally cast nullable-int as a float type unless
# we call this to convert to its nullable int column type.
# PyAthena seems to do this correctly for us, but not DuckDB.
return self.connection.execute(sql).df().convert_dtypes()

def close(self) -> None:
self.connection.close()
Expand Down