Skip to content

Commit

Permalink
[GLUTEN-4039][VL] Add flatten function support (#5551)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivoson authored May 11, 2024
1 parent d0f611e commit d931006
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ object CHExpressionUtil {
UNIX_MILLIS -> DefaultValidator(),
UNIX_MICROS -> DefaultValidator(),
TIMESTAMP_MILLIS -> DefaultValidator(),
TIMESTAMP_MICROS -> DefaultValidator()
TIMESTAMP_MICROS -> DefaultValidator(),
FLATTEN -> DefaultValidator()
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -941,4 +941,24 @@ class ScalarFunctionsValidateSuite extends FunctionsValidateTest {
}
}

test("test flatten nested array") {
withTempPath {
path =>
Seq[Seq[Seq[Integer]]](
Seq(Seq(1, 2), Seq(4, 5)),
null,
Seq(null, Seq(1, 2)),
Seq(null, null),
Seq(Seq(1, 2, null), Seq(null, null), Seq(3, 4), Seq.empty))
.toDF("arrays")
.write
.parquet(path.getCanonicalPath)

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

runQueryAndCompare("select flatten(arrays) as res from array_tbl;") {
checkGlutenOperatorMatch[ProjectExecTransformer]
}
}
}
}
2 changes: 1 addition & 1 deletion docs/velox-backend-support-progress.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ Gluten supports 199 functions. (Drag to right to see all data types)
| explode_outer, explode | | | | | | | | | | | | | | | | | | | | | | |
| filter | filter | filter | S | Lambda with index argument not supported | | | | | | | | | | | | | | | | | | |
| forall | all_match | | S | | | | | | | | | | | | | | | | | | | |
| flatten | flatten | | | | | | | | | | | | | | | | | | | | | |
| flatten | flatten | flatten | S | | | | | | | | | | | | | | | | | | | |
| map | map | map | S | | | | | | | | | | | | | | | | | | | |
| map_concat | map_concat | | | | | | | | | | | | | | | | | | | | | |
| map_entries | map_entries | | | | | | | | | | | | | | | | | | | | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ object ExpressionMappings {
Sig[ArrayExists](EXISTS),
Sig[Shuffle](SHUFFLE),
Sig[ZipWith](ZIP_WITH),
Sig[Flatten](FLATTEN),
// Map functions
Sig[CreateMap](CREATE_MAP),
Sig[GetMapValue](GET_MAP_VALUE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ object ExpressionNames {
final val TRANSFORM = "transform"
final val SHUFFLE = "shuffle"
final val ZIP_WITH = "zip_with"
final val FLATTEN = "flatten"

// Map functions
final val CREATE_MAP = "map"
Expand Down

0 comments on commit d931006

Please sign in to comment.