From 4535c3dd6bdef70d57cb115c6d2e3b6ea3abb5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D1=80=D1=82=D1=8B=D0=BD=D0=BE=D0=B2=20=D0=9C?= =?UTF-8?q?=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=B5=D1=80=D0=B3=D0=B5?= =?UTF-8?q?=D0=B5=D0=B2=D0=B8=D1=87?= Date: Fri, 12 Apr 2024 12:02:06 +0000 Subject: [PATCH] [DOP-13855] Fix Clickhouse HWM tests --- tests/fixtures/processing/clickhouse.py | 16 ++++++++++++++++ .../test_strategy_increment_clickhouse.py | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/tests/fixtures/processing/clickhouse.py b/tests/fixtures/processing/clickhouse.py index 1205fad6a..2b3e4cec1 100644 --- a/tests/fixtures/processing/clickhouse.py +++ b/tests/fixtures/processing/clickhouse.py @@ -152,3 +152,19 @@ def get_expected_dataframe( order_by: str | None = None, ) -> pandas.DataFrame: return self.connection.query_dataframe(self.get_expected_dataframe_ddl(schema, table, order_by)) + + def fix_pandas_df( + self, + df: pandas.DataFrame, + ) -> pandas.DataFrame: + df = super().fix_pandas_df(df) + + for column in df.columns: + column_name = column.lower() + + if "float" in column_name: + # somethere in chain Clickhouse -> Spark -> Pandas Float32 column is being converted to Float64, + # causing tests to fail. Convert it back to original type + df[column] = df[column].astype("float32") + + return df diff --git a/tests/tests_integration/tests_strategy_integration/tests_incremental_strategy_integration/test_strategy_increment_clickhouse.py b/tests/tests_integration/tests_strategy_integration/tests_incremental_strategy_integration/test_strategy_increment_clickhouse.py index 77ec071b3..30c040a39 100644 --- a/tests/tests_integration/tests_strategy_integration/tests_incremental_strategy_integration/test_strategy_increment_clickhouse.py +++ b/tests/tests_integration/tests_strategy_integration/tests_incremental_strategy_integration/test_strategy_increment_clickhouse.py @@ -308,6 +308,24 @@ def test_clickhouse_strategy_incremental_explicit_hwm_type( ColumnDateTimeHWM, lambda x: x.isoformat(), ), + ( + "hwm_datetime", + "CAST(text_string AS DateTime32)", + ColumnDateTimeHWM, + lambda x: x.isoformat(), + ), + ( + "hwm_datetime", + "CAST(text_string AS DateTime64)", + ColumnDateTimeHWM, + lambda x: x.isoformat(), + ), + ( + "hwm_datetime", + "CAST(text_string AS DateTime64(6))", + ColumnDateTimeHWM, + lambda x: x.isoformat(), + ), ], ) def test_clickhouse_strategy_incremental_with_hwm_expr(