This is an automated email from the ASF dual-hosted git repository.
liuneng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git
The following commit(s) were added to refs/heads/main by this push:
new 4b5f2c31f [GLUTEN-5910] [CH] add custom type to ASTLiteral (#5911)
4b5f2c31f is described below
commit 4b5f2c31fab15383097b12ecc22ab5f49af04dd6
Author: shuai.xu <[email protected]>
AuthorDate: Fri Jun 7 16:29:51 2024 +0800
[GLUTEN-5910] [CH] add custom type to ASTLiteral (#5911)
What changes were proposed in this pull request?
This pr based on ClickHouse/ClickHouse#64562, Type of Literal DateTime32
will be lost during parsing plan of CH as it will be convert to Int16.
(Fixes: #5910)
How was this patch tested?
This patch was tested manually.
---
.../GlutenClickHouseTPCHSaltNullParquetSuite.scala | 18 ++++++++++++++++++
cpp-ch/local-engine/Parser/SerializedPlanParser.cpp | 4 ++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenClickHouseTPCHSaltNullParquetSuite.scala
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenClickHouseTPCHSaltNullParquetSuite.scala
index ee495457e..84f390139 100644
---
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenClickHouseTPCHSaltNullParquetSuite.scala
+++
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenClickHouseTPCHSaltNullParquetSuite.scala
@@ -2612,5 +2612,23 @@ class GlutenClickHouseTPCHSaltNullParquetSuite extends
GlutenClickHouseTPCHAbstr
spark.sql("drop table ineq_join_t2")
}
}
+
+ test("GLUTEN-5910: Fix ASTLiteral type is lost in CH") {
+ spark.sql("create table test_tbl_5910_0(c_time bigint, type int) using
parquet")
+ spark.sql("create table test_tbl_5910_1(type int) using parquet")
+ spark.sql("insert into test_tbl_5910_0 values(1717209159, 12)")
+ spark.sql("insert into test_tbl_5910_1 values(12)")
+ val select_sql =
+ """
+ | select t1.cday, t2.type from (
+ | select type, to_date(from_unixtime(c_time)) as cday from
test_tbl_5910_0 ) t1
+ | left join (
+ | select type, "2024-06-01" as cday from test_tbl_5910_1 ) t2
+ | on t1.cday = t2.cday and t1.type = t2.type
+ |""".stripMargin
+ compareResultsAgainstVanillaSpark(select_sql, true, { _ => })
+ spark.sql("drop table test_tbl_5910_0")
+ spark.sql("drop table test_tbl_5910_1")
+ }
}
// scalastyle:on line.size.limit
diff --git a/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
b/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
index 1c907035a..5f2c9cc33 100644
--- a/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
+++ b/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
@@ -1888,8 +1888,8 @@ ASTPtr ASTParser::parseArgumentToAST(const Names & names,
const substrait::Expre
case substrait::Expression::RexTypeCase::kLiteral: {
DataTypePtr type;
Field field;
- std::tie(std::ignore, field) =
SerializedPlanParser::parseLiteral(rel.literal());
- return std::make_shared<ASTLiteral>(field);
+ std::tie(type, field) =
SerializedPlanParser::parseLiteral(rel.literal());
+ return std::make_shared<ASTLiteral>(field, type);
}
case substrait::Expression::RexTypeCase::kSelection: {
if (!rel.selection().has_direct_reference() ||
!rel.selection().direct_reference().has_struct_field())
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]