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: Pandas merge issue for Teradata empty result sets #1100

Merged
merged 1 commit into from
Feb 22, 2024
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
13 changes: 12 additions & 1 deletion third_party/ibis/ibis_teradata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,23 @@ def execute(

schema = self.ast_schema(query_ast, **kwargs)
# Date columns are in the Dataframe as "object", using parse_dates to ensure they have a better data type.
date_columns = [_ for _ in schema.names if schema.fields[_].is_date()]
date_columns = [
_
for _ in schema.names
if schema.fields[_].is_date() or schema.fields[_].is_timestamp()
]

with warnings.catch_warnings():
# Suppress pandas warning of SQLAlchemy connectable DB support
warnings.simplefilter("ignore")
df = pandas.read_sql(sql, self.client, parse_dates=date_columns)

if df.empty:
# Empty Dataframe infers an "object" data type, update to float64.
float_columns = {
_: float for _ in schema.names if schema.fields[_].is_float64()
}
df = df.astype(float_columns)
return df

# Methods we need to implement for BaseSQLBackend
Expand Down