Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
WangGuangxin committed Mar 5, 2024
1 parent 3a28733 commit 5bdd9fa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
21 changes: 17 additions & 4 deletions cpp/velox/substrait/VeloxToSubstraitExpr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,6 @@ const ::substrait::Expression_Literal_List& VeloxToSubstraitExprConvertor::toSub
::substrait::Expression_Literal_List* listLiteral =
google::protobuf::Arena::CreateMessage<::substrait::Expression_Literal_List>(&arena);
auto size = arrayVector->sizeAt(row);
if (size == 0) {
return *listLiteral;
}
auto offset = arrayVector->offsetAt(row);
if (arrayVector->elements()->isScalar()) {
VELOX_DYNAMIC_SCALAR_TYPE_DISPATCH(
Expand Down Expand Up @@ -581,7 +578,14 @@ const ::substrait::Expression_Literal& VeloxToSubstraitExprConvertor::toSubstrai
auto encoding = constantVector->valueVector()->encoding();
if (encoding == VectorEncoding::Simple::ARRAY) {
auto arrayVector = constantVector->valueVector()->as<ArrayVector>();
substraitField->mutable_list()->MergeFrom(toSubstraitLiteralList(arena, arrayVector, constantVector->index()));
auto row = constantVector->index();
auto size = arrayVector->sizeAt(row);
if (size == 0) {
substraitField->mutable_empty_list()->MergeFrom(
toSubstraitLiteralEmptyList(arena, arrayVector->elements()->type()));
} else {
substraitField->mutable_list()->MergeFrom(toSubstraitLiteralList(arena, arrayVector, row));
}
return *substraitField;
}
}
Expand All @@ -606,4 +610,13 @@ const ::substrait::Expression_Literal& VeloxToSubstraitExprConvertor::toSubstrai
return *substraitField;
}

const ::substrait::Type_List& VeloxToSubstraitExprConvertor::toSubstraitLiteralEmptyList(
google::protobuf::Arena& arena,
const velox::TypePtr& type) {
::substrait::Type_List* emptyListLiteral =
google::protobuf::Arena::CreateMessage<::substrait::Type_List>(&arena);
emptyListLiteral->mutable_type()->MergeFrom(typeConvertor_->toSubstraitType(arena, type));
return *emptyListLiteral;
}

} // namespace gluten
4 changes: 4 additions & 0 deletions cpp/velox/substrait/VeloxToSubstraitExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ class VeloxToSubstraitExprConvertor {
const ::substrait::Expression_Literal_List&
toSubstraitLiteralList(google::protobuf::Arena& arena, const ArrayVector* arrayVector, vector_size_t row);

/// Convert an empty Velox array vector to Substrait Literal Empty List.
const ::substrait::Type_List&
toSubstraitLiteralEmptyList(google::protobuf::Arena& arena, const velox::TypePtr& type);

/// Convert values in Velox complex vector to Substrait Literal.
const ::substrait::Expression_Literal& toSubstraitLiteralComplex(
google::protobuf::Arena& arena,
Expand Down

0 comments on commit 5bdd9fa

Please sign in to comment.