Skip to content

Commit

Permalink
Bug fix to_date can not convert 1970-01-01 (#3563)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinyhZou authored Nov 6, 2023
1 parent 52552c9 commit d57fdf2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<DataTypeString>(), "%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<DataTypeString>(), "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'))
Expand Down

0 comments on commit d57fdf2

Please sign in to comment.