From d57fdf26fdf162cbd39e6b4811aebe4d6af17dd6 Mon Sep 17 00:00:00 2001 From: KevinyhZou <37431499+KevinyhZou@users.noreply.github.com> Date: Mon, 6 Nov 2023 21:27:18 +0800 Subject: [PATCH] Bug fix to_date can not convert 1970-01-01 (#3563) --- .../execution/GlutenClickHouseTPCHParquetSuite.scala | 3 ++- cpp-ch/local-engine/Parser/SerializedPlanParser.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backends-clickhouse/src/test/scala/io/glutenproject/execution/GlutenClickHouseTPCHParquetSuite.scala b/backends-clickhouse/src/test/scala/io/glutenproject/execution/GlutenClickHouseTPCHParquetSuite.scala index b4f0a6754169..2602ec452f42 100644 --- a/backends-clickhouse/src/test/scala/io/glutenproject/execution/GlutenClickHouseTPCHParquetSuite.scala +++ b/backends-clickhouse/src/test/scala/io/glutenproject/execution/GlutenClickHouseTPCHParquetSuite.scala @@ -2115,7 +2115,8 @@ class GlutenClickHouseTPCHParquetSuite extends GlutenClickHouseTPCHAbstractSuite |(3, '2023-09-02 00:00:01.333+11'), |(4, '2023-09-02 00:00:01.333-11'), |(5, ' 2023-09-02 agdfegfew'), - |(6, 'afe2023-09-02 11:22:33') + |(6, 'afe2023-09-02 11:22:33'), + |(7, '1970-01-01 00:00:00') |""".stripMargin spark.sql(create_table_sql) spark.sql(insert_data_sql) diff --git a/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp b/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp index bbdef36d874e..887aba04f8dc 100644 --- a/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp +++ b/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp @@ -1666,7 +1666,8 @@ const ActionsDAG::Node * SerializedPlanParser::parseExpression(ActionsDAGPtr act const auto * trim_string_node = toFunctionNode(actions_dag, "trimLeft", {args[0]}); const auto * substr_node = toFunctionNode(actions_dag, "substring", {trim_string_node, substr_offset_node, substr_length_node}); const auto * date_format_node = add_column(std::make_shared(), "%Y-%m-%d"); - const auto * parse_date_node = toFunctionNode(actions_dag, "parseDateTimeOrNull", {substr_node, date_format_node}); + const auto * utc_time_zone_node = add_column(std::make_shared(), "UTC"); + const auto * parse_date_node = toFunctionNode(actions_dag, "parseDateTimeOrNull", {substr_node, date_format_node, utc_time_zone_node}); const auto * parse_date_is_not_null_node = toFunctionNode(actions_dag, "isNotNull", {parse_date_node}); /// toDate32(parseDateTimeOrNull(substring(trimLeft(date), 1, 10), '%Y-%m-%d'))