From cc91fa296d25ae2490d00a897eb1933920a805d7 Mon Sep 17 00:00:00 2001 From: Neha Nene Date: Thu, 22 Feb 2024 13:55:04 -0500 Subject: [PATCH] fix: Fix merge issue for Teradata empty dataframes (#1100) --- third_party/ibis/ibis_teradata/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/third_party/ibis/ibis_teradata/__init__.py b/third_party/ibis/ibis_teradata/__init__.py index ee4bc4af1..98bd7341c 100644 --- a/third_party/ibis/ibis_teradata/__init__.py +++ b/third_party/ibis/ibis_teradata/__init__.py @@ -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