This is an automated email from the ASF dual-hosted git repository.
philo 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 f6e882335 [GLUTEN-5662][VL] Fix literal array conversion with nested
empty array/map ahead of non-empty (#5663)
f6e882335 is described below
commit f6e882335feb99a69a42837cfbcf7e65554347dd
Author: Tengfei Huang <[email protected]>
AuthorDate: Fri May 10 11:24:02 2024 +0800
[GLUTEN-5662][VL] Fix literal array conversion with nested empty array/map
ahead of non-empty (#5663)
---
.../gluten/execution/VeloxLiteralSuite.scala | 2 ++
cpp/velox/substrait/SubstraitToVeloxExpr.cc | 38 ++++++++++++++--------
2 files changed, 27 insertions(+), 13 deletions(-)
diff --git
a/backends-velox/src/test/scala/org/apache/gluten/execution/VeloxLiteralSuite.scala
b/backends-velox/src/test/scala/org/apache/gluten/execution/VeloxLiteralSuite.scala
index 0ad26aa03..cf2e7257f 100644
---
a/backends-velox/src/test/scala/org/apache/gluten/execution/VeloxLiteralSuite.scala
+++
b/backends-velox/src/test/scala/org/apache/gluten/execution/VeloxLiteralSuite.scala
@@ -74,7 +74,9 @@ class VeloxLiteralSuite extends
VeloxWholeStageTransformerSuite {
test("Array Literal") {
validateOffloadResult("SELECT array()")
validateOffloadResult("SELECT array(array())")
+ validateOffloadResult("SELECT array(array(), array(1, 2))")
validateOffloadResult("SELECT array(map())")
+ validateOffloadResult("SELECT array(map(), map('red', 1))")
validateOffloadResult("SELECT array('Spark', '5')")
validateOffloadResult("SELECT array(5, 1, -1)")
validateOffloadResult("SELECT array(5S, 1S, -1S)")
diff --git a/cpp/velox/substrait/SubstraitToVeloxExpr.cc
b/cpp/velox/substrait/SubstraitToVeloxExpr.cc
old mode 100644
new mode 100755
index 03e91ac42..fb4861e4f
--- a/cpp/velox/substrait/SubstraitToVeloxExpr.cc
+++ b/cpp/velox/substrait/SubstraitToVeloxExpr.cc
@@ -430,11 +430,21 @@ VectorPtr SubstraitVeloxExprConverter::literalsToVector(
}
case
::substrait::Expression_Literal::LiteralTypeCase::kIntervalDayToSecond:
return constructFlatVector<TypeKind::BIGINT>(elementAtFunc, childSize,
INTERVAL_DAY_TIME(), pool_);
+ // Handle EmptyList and List together since the children could be either
case.
+ case ::substrait::Expression_Literal::LiteralTypeCase::kEmptyList:
case ::substrait::Expression_Literal::LiteralTypeCase::kList: {
ArrayVectorPtr elements;
for (int i = 0; i < childSize; i++) {
- auto element = elementAtFunc(i);
- ArrayVectorPtr grandVector = literalsToArrayVector(element);
+ auto child = elementAtFunc(i);
+ auto childType = child.literal_type_case();
+ ArrayVectorPtr grandVector;
+
+ if (childType ==
::substrait::Expression_Literal::LiteralTypeCase::kEmptyList) {
+ auto elementType =
SubstraitParser::parseType(child.empty_list().type());
+ grandVector = makeEmptyArrayVector(pool_, elementType);
+ } else {
+ grandVector = literalsToArrayVector(child);
+ }
if (!elements) {
elements = grandVector;
} else {
@@ -443,11 +453,22 @@ VectorPtr SubstraitVeloxExprConverter::literalsToVector(
}
return elements;
}
+ // Handle EmptyMap and Map together since the children could be either
case.
+ case ::substrait::Expression_Literal::LiteralTypeCase::kEmptyMap:
case ::substrait::Expression_Literal::LiteralTypeCase::kMap: {
MapVectorPtr mapVector;
for (int i = 0; i < childSize; i++) {
- auto element = elementAtFunc(i);
- MapVectorPtr grandVector = literalsToMapVector(element);
+ auto child = elementAtFunc(i);
+ auto childType = child.literal_type_case();
+ MapVectorPtr grandVector;
+
+ if (childType ==
::substrait::Expression_Literal::LiteralTypeCase::kEmptyMap) {
+ auto keyType = SubstraitParser::parseType(child.empty_map().key());
+ auto valueType =
SubstraitParser::parseType(child.empty_map().value());
+ grandVector = makeEmptyMapVector(pool_, keyType, valueType);
+ } else {
+ grandVector = literalsToMapVector(child);
+ }
if (!mapVector) {
mapVector = grandVector;
} else {
@@ -469,15 +490,6 @@ VectorPtr SubstraitVeloxExprConverter::literalsToVector(
}
return rowVector;
}
- case ::substrait::Expression_Literal::LiteralTypeCase::kEmptyList: {
- auto elementType =
SubstraitParser::parseType(childLiteral.empty_list().type());
- return BaseVector::wrapInConstant(1, 0, makeEmptyArrayVector(pool_,
elementType));
- }
- case ::substrait::Expression_Literal::LiteralTypeCase::kEmptyMap: {
- auto keyType =
SubstraitParser::parseType(childLiteral.empty_map().key());
- auto valueType =
SubstraitParser::parseType(childLiteral.empty_map().value());
- return BaseVector::wrapInConstant(1, 0, makeEmptyMapVector(pool_,
keyType, valueType));
- }
default:
auto veloxType = getScalarType(elementAtFunc(0));
if (veloxType) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]