Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
marin-ma committed Mar 6, 2024
1 parent f9210e7 commit 89d5740
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
1 change: 0 additions & 1 deletion cpp/velox/substrait/SubstraitToVeloxExpr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,6 @@ core::TypedExprPtr SubstraitVeloxExprConverter::toVeloxExpr(
core::TypedExprPtr SubstraitVeloxExprConverter::toVeloxExpr(
const ::substrait::Expression& substraitExpr,
const RowTypePtr& inputType) {
core::TypedExprPtr veloxExpr;
auto typeCase = substraitExpr.rex_type_case();
switch (typeCase) {
case ::substrait::Expression::RexTypeCase::kLiteral:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,26 +174,36 @@ case class GenerateExecTransformer(
context,
operatorId)
}
applyPostProjectOnGenerator(generateRel, context, operatorId, childOutput, validation)
}

private def applyPostProjectOnGenerator(
generateRel: RelNode,
context: SubstraitContext,
operatorId: Long,
childOutput: JList[ExpressionNode],
validation: Boolean): RelNode = {
generator match {
case Inline(_) =>
val requiredOutput = (0 until childOutput.size()).map {
case Inline(inlineChild) =>
inlineChild match {
case _: AttributeReference =>
case _ =>
throw new UnsupportedOperationException("Child of Inline is not AttributeReference.")
}
val requiredOutput = (0 until childOutput.size).map {
ExpressionBuilder.makeSelection(_)
}
val projectOutput = requiredOutput ++ generatorOutput.zipWithIndex.map {
case (attr, i) =>
ExpressionConverter
.replaceWithExpressionTransformer(
GetStructField(generator.asInstanceOf[UnaryExpression].child, i, Some(attr.name)),
child.output
)
.doTransform(context.registeredFunction)
val flattenStruct: Seq[ExpressionNode] = generatorOutput.indices.map {
i =>
val selectionNode = ExpressionBuilder.makeSelection(requiredOutput.size)
selectionNode.addNestedChildIdx(i)
}
val postProjectRel = RelBuilder.makeProjectRel(
generateRel,
projectOutput.asJava,
(requiredOutput ++ flattenStruct).asJava,
context,
operatorId,
1 + requiredOutput.size
1 + requiredOutput.size // 1 stands for the inner struct field from array.
)
if (validation) {
// No need to validate the project rel on the native side as
Expand Down

0 comments on commit 89d5740

Please sign in to comment.