This is an automated email from the ASF dual-hosted git repository.

felixybw 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 3888f45e0 [GLUTEN-5745][VL] Add more comments for GenerateRel 
conversion logic (#5746)
3888f45e0 is described below

commit 3888f45e060c4d8121c38190621282780b77a032
Author: James Xu <[email protected]>
AuthorDate: Wed May 15 02:20:43 2024 +0800

    [GLUTEN-5745][VL] Add more comments for GenerateRel conversion logic (#5746)
    
    Add more comments for GenerateRel conversion logic
---
 cpp/velox/substrait/SubstraitToVeloxPlan.cc | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/cpp/velox/substrait/SubstraitToVeloxPlan.cc 
b/cpp/velox/substrait/SubstraitToVeloxPlan.cc
index 6ee7ad827..366ab5abd 100644
--- a/cpp/velox/substrait/SubstraitToVeloxPlan.cc
+++ b/cpp/velox/substrait/SubstraitToVeloxPlan.cc
@@ -733,8 +733,14 @@ core::PlanNodePtr 
SubstraitToVeloxPlanConverter::toVeloxPlan(const ::substrait::
   auto projNode = std::dynamic_pointer_cast<const 
core::ProjectNode>(childNode);
 
   if (projNode != nullptr && projNode->names().size() > 
requiredChildOutput.size()) {
-    // generator is a scalarfunction node -> explode(array(col, 'all'))
-    // use the last one, this is ensure by scala code
+    // Generator function's input is not a field reference, e.g. 
explode(array(1,2,3)), a sample
+    // input substrait plan is like the following(the plan structure is 
ensured by scala code):
+    //
+    //  Generate explode([1,2,3] AS _pre_0#129), false, [col#126]
+    //  +- Project [fake_column#128, [1,2,3] AS _pre_0#129]
+    //   +- RewrittenNodeWall Scan OneRowRelation[fake_column#128]
+    //
+    // The last projection column in GeneratorRel's child(Project) is the 
column we need to unnest
     auto innerName = projNode->names().back();
     auto innerExpr = projNode->projections().back();
 
@@ -743,9 +749,12 @@ core::PlanNodePtr 
SubstraitToVeloxPlanConverter::toVeloxPlan(const ::substrait::
     VELOX_CHECK_NOT_NULL(unnestFieldExpr, " the key in unnest Operator only 
support field");
     unnest.emplace_back(unnestFieldExpr);
   } else {
-    // generator should be a array column -> explode(col)
-    auto explodeFunc = generator.scalar_function();
-    auto unnestExpr = 
exprConverter_->toVeloxExpr(explodeFunc.arguments(0).value(), inputType);
+    // Generator function's input is a field reference, e.g. explode(col), 
generator
+    // function's first argument is the field reference we need to unnest.
+    // This assumption holds for all the supported generator function:
+    // explode, posexplode, inline.
+    auto generatorFunc = generator.scalar_function();
+    auto unnestExpr = 
exprConverter_->toVeloxExpr(generatorFunc.arguments(0).value(), inputType);
     auto unnestFieldExpr = std::dynamic_pointer_cast<const 
core::FieldAccessTypedExpr>(unnestExpr);
     VELOX_CHECK_NOT_NULL(unnestFieldExpr, " the key in unnest Operator only 
support field");
     unnest.emplace_back(unnestFieldExpr);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to