Skip to content

Commit

Permalink
support function arrays_zip
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyang-li committed Sep 9, 2024
1 parent 787403f commit e7b63c0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e7b63c0

Please sign in to comment.