Skip to content

Commit

Permalink
[VL] Enable arrays_zip function (#5609)
Browse files Browse the repository at this point in the history
[VL] Enable arrays_zip function.
  • Loading branch information
zhli1142015 authored May 6, 2024
1 parent 8efe3e4 commit 9e2ec55
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ object CHExpressionUtil {
ARRAY_EXCEPT -> DefaultValidator(),
ARRAY_REPEAT -> DefaultValidator(),
ARRAY_REMOVE -> DefaultValidator(),
ARRAYS_ZIP -> DefaultValidator(),
DATE_FROM_UNIX_DATE -> DefaultValidator(),
UNIX_DATE -> DefaultValidator(),
MONOTONICALLY_INCREASING_ID -> DefaultValidator(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,24 @@ class ScalarFunctionsValidateSuite extends FunctionsValidateTest {
}
}

test("arrays_zip") {
withTempPath {
path =>
Seq[(Seq[Integer], Seq[Integer])](
(Seq(1, 2, 3), Seq(3, 4)),
(Seq(5, null), Seq(null, 1, 2)))
.toDF("v1", "v2")
.write
.parquet(path.getCanonicalPath)

spark.read.parquet(path.getCanonicalPath).createOrReplaceTempView("array_tbl")

runQueryAndCompare("select arrays_zip(v1, v2) from array_tbl;") {
checkGlutenOperatorMatch[ProjectExecTransformer]
}
}
}

test("negative") {
runQueryAndCompare("select negative(l_orderkey) from lineitem") {
checkGlutenOperatorMatch[ProjectExecTransformer]
Expand Down
3 changes: 2 additions & 1 deletion cpp/velox/substrait/SubstraitParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ std::unordered_map<std::string, std::string> SubstraitParser::substraitVeloxFunc
{"try_add", "plus"},
{"forall", "all_match"},
{"exists", "any_match"},
{"negative", "unaryminus"}};
{"negative", "unaryminus"},
{"arrays_zip", "zip"}};

const std::unordered_map<std::string, std::string> SubstraitParser::typeMap_ = {
{"bool", "BOOLEAN"},
Expand Down
2 changes: 1 addition & 1 deletion docs/velox-backend-support-progress.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Gluten supports 199 functions. (Drag to right to see all data types)
| array_sort | array_sort | array_sort | S | | | | | | | | | | | | | | | | | | | |
| array_union | | | | | | | | | | | | | | | | | | | | | | |
| arrays_overlap | array_overlap | | | | | | | | | | | | | | | | | | | | | |
| arrays_zip | | | | | | | | | | | | | | | | | | | | | | |
| arrays_zip | zip | | S | | | | | | | | | | | | | | | | | | | |
| cardinality | cardinality | | | | | | | | | | | | | | | | | | | | | |
| element_at | element_at | element_at | S | | | | | | | | | | | | | | | | S | S | | |
| exists | any_match | | S | | | | | | | | | | | | | | | | | | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ object ExpressionMappings {
Sig[ArrayExcept](ARRAY_EXCEPT),
Sig[ArrayRepeat](ARRAY_REPEAT),
Sig[ArrayRemove](ARRAY_REMOVE),
Sig[ArraysZip](ARRAYS_ZIP),
Sig[ArrayFilter](FILTER),
Sig[ArrayForAll](FORALL),
Sig[ArrayExists](EXISTS),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ object ExpressionNames {
final val ARRAY_EXCEPT = "array_except"
final val ARRAY_REPEAT = "array_repeat"
final val ARRAY_REMOVE = "array_remove"
final val ARRAYS_ZIP = "arrays_zip"
final val FILTER = "filter"
final val FORALL = "forall"
final val EXISTS = "exists"
Expand Down

0 comments on commit 9e2ec55

Please sign in to comment.