Skip to content

Commit

Permalink
fix: Fix merge issue for Teradata empty dataframes (#1100)
Browse files Browse the repository at this point in the history
  • Loading branch information
nehanene15 committed Feb 22, 2024
1 parent 90547ef commit cc91fa2
Showing 1 changed file with 12 additions and 1 deletion.
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

0 comments on commit cc91fa2

Please sign in to comment.