dtenedor commented on code in PR #60697:
URL: https://github.com/apache/spark/pull/60697#discussion_r4633683632
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/pipeOperators.scala:
##########
@@ -70,11 +70,19 @@ case object ValidateAndStripPipeExpressions extends
Rule[LogicalPlan] {
_.containsPattern(PIPE_EXPRESSION), ruleId) {
case node: LogicalPlan =>
node.resolveExpressions {
- case p: PipeExpression if p.child.resolved =>
+ case p: PipeExpression if p.child.resolved ||
isResolvedOuterGenerator(p.child) =>
validateAndStripPipeExpression(p, p.child)
}
}
+ // GeneratorOuter is never resolved because ExtractGenerator replaces it.
Strip the wrapper once
+ // the inner generator is resolved; otherwise ExtractGenerator sees
+ // PipeExpression(GeneratorOuter(...)) as a generator nested inside another
expression.
+ private def isResolvedOuterGenerator(e: Expression): Boolean = e match {
+ case GeneratorOuter(g) => g.resolved
Review Comment:
Addressed in e2ffe8ee. The strip condition now also accepts
`MultiAlias(GeneratorOuter(g), names)` and `MultiAlias(g: Generator, names)`
once `g` is resolved, keeping `GeneratorOuter` and `MultiAlias` in place. I
added the requested golden cases for `|> EXTEND` and `|> AGGREGATE` with a
parenthesized alias list over `posexplode_outer`, `explode_outer` on a map,
`inline_outer` on two-field structs and non-outer `posexplode`, plus the three
negative cases. The analyzer output shows `Generate ..., true` for the
`*_outer` functions and `false` for `posexplode`, and regenerating the golden
files only adds the new cases.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/pipeOperators.scala:
##########
@@ -70,11 +70,19 @@ case object ValidateAndStripPipeExpressions extends
Rule[LogicalPlan] {
_.containsPattern(PIPE_EXPRESSION), ruleId) {
case node: LogicalPlan =>
node.resolveExpressions {
- case p: PipeExpression if p.child.resolved =>
+ case p: PipeExpression if p.child.resolved ||
isResolvedOuterGenerator(p.child) =>
validateAndStripPipeExpression(p, p.child)
}
}
+ // GeneratorOuter is never resolved because ExtractGenerator replaces it.
Strip the wrapper once
Review Comment:
Addressed in e2ffe8ee. The helper (now `isResolvedGeneratorItem`) has a
scaladoc saying the `PipeExpression` is stripped while `GeneratorOuter` and
`MultiAlias` stay in place, and it lists each accepted shape. The scaladocs on
`ValidateAndStripPipeExpressions` and `validateAndStripPipeExpression` now
describe children that are resolved or are one of those generator items, whose
generator is resolved but whose wrapper is not.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]