From e7b63c022f92768fa8642b9394c9a3f975f8553d Mon Sep 17 00:00:00 2001 From: taiyang-li <654010905@qq.com> Date: Wed, 28 Aug 2024 14:56:35 +0800 Subject: [PATCH] support function arrays_zip --- .../gluten/utils/CHExpressionUtil.scala | 1 - .../GlutenFunctionValidateSuite.scala | 30 +++++++++++++++++-- .../CommonScalarFunctionParser.cpp | 1 + 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/backends-clickhouse/src/main/scala/org/apache/gluten/utils/CHExpressionUtil.scala b/backends-clickhouse/src/main/scala/org/apache/gluten/utils/CHExpressionUtil.scala index bb4710ef21f11..e11debcb77d0f 100644 --- a/backends-clickhouse/src/main/scala/org/apache/gluten/utils/CHExpressionUtil.scala +++ b/backends-clickhouse/src/main/scala/org/apache/gluten/utils/CHExpressionUtil.scala @@ -197,7 +197,6 @@ object CHExpressionUtil { ENCODE -> EncodeDecodeValidator(), ARRAY_REPEAT -> DefaultValidator(), ARRAY_REMOVE -> DefaultValidator(), - ARRAYS_ZIP -> DefaultValidator(), DATE_FROM_UNIX_DATE -> DefaultValidator(), UNIX_DATE -> DefaultValidator(), UNIX_SECONDS -> DefaultValidator(), diff --git a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenFunctionValidateSuite.scala b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenFunctionValidateSuite.scala index 1278264b4970f..43306925b90b3 100644 --- a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenFunctionValidateSuite.scala +++ b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenFunctionValidateSuite.scala @@ -757,9 +757,35 @@ class GlutenFunctionValidateSuite extends GlutenClickHouseWholeStageTransformerS } test("test function array_except") { + val sql = + """ + |SELECT array_except(array(id, id+1, id+2), array(id+2, id+3)) + |FROM RANGE(10) + |""".stripMargin + runQueryAndCompare(sql)(checkGlutenOperatorMatch[ProjectExecTransformer]) + } + + test("test functions unix_seconds/unix_date/unix_millis/unix_micros") { + val sql = + """ + |SELECT + | id, + | unix_seconds(cast(concat('2024-09-03 17:23:1', + | cast(id as string)) as timestamp)), + | unix_date(cast(concat('2024-09-1', cast(id as string)) as date)), + | unix_millis(cast(concat('2024-09-03 17:23:10.11', + | cast(id as string)) as timestamp)), + | unix_micros(cast(concat('2024-09-03 17:23:10.12345', + | cast(id as string)) as timestamp)) + |FROM range(10) + |""".stripMargin + runQueryAndCompare(sql)(checkGlutenOperatorMatch[ProjectExecTransformer]) + } + + test("test function arrays_zip") { val sql = """ - |SELECT array_except(array(id, id+1, id+2), array(id+2, id+3)) - |FROM RANGE(10) + |SELECT arrays_zip(array(id, id+1, id+2), array(id, id-1, id-2)) + |FROM range(10) |""".stripMargin runQueryAndCompare(sql)(checkGlutenOperatorMatch[ProjectExecTransformer]) } diff --git a/cpp-ch/local-engine/Parser/scalar_function_parser/CommonScalarFunctionParser.cpp b/cpp-ch/local-engine/Parser/scalar_function_parser/CommonScalarFunctionParser.cpp index b65595ef82faf..04c3b7a405e74 100644 --- a/cpp-ch/local-engine/Parser/scalar_function_parser/CommonScalarFunctionParser.cpp +++ b/cpp-ch/local-engine/Parser/scalar_function_parser/CommonScalarFunctionParser.cpp @@ -160,6 +160,7 @@ REGISTER_COMMON_SCALAR_FUNCTION_PARSER(Shuffle, shuffle, arrayShuffle); REGISTER_COMMON_SCALAR_FUNCTION_PARSER(Range, range, range); REGISTER_COMMON_SCALAR_FUNCTION_PARSER(Flatten, flatten, sparkArrayFlatten); REGISTER_COMMON_SCALAR_FUNCTION_PARSER(ArrayJoin, array_join, sparkArrayJoin); +REGISTER_COMMON_SCALAR_FUNCTION_PARSER(ArraysZip, arrays_zip, arrayZip); // map functions REGISTER_COMMON_SCALAR_FUNCTION_PARSER(Map, map, map);