You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "dtenedor (via GitHub)" <gi...@apache.org> on 2025/12/10 20:10:11 UTC
[PR] [SPARK-54673][SQL] Refactor SQL pipe syntax analysis code for sharing and reuse [spark]
dtenedor opened a new pull request, #53431:
URL: https://github.com/apache/spark/pull/53431
### What changes were proposed in this pull request?
This PR adds a small refactor of the SQL pipe syntax analysis code for sharing and reuse.
### Why are the changes needed?
The new analyzer can refer to the refactored code without duplicating it.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
N/A, this is a small refactoring only.
### Was this patch authored or co-authored using generative AI tooling?
No
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54673][SQL] Refactor SQL pipe syntax analysis code for sharing and reuse [spark]
Posted by "dtenedor (via GitHub)" <gi...@apache.org>.
dtenedor closed pull request #53431: [SPARK-54673][SQL] Refactor SQL pipe syntax analysis code for sharing and reuse
URL: https://github.com/apache/spark/pull/53431
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54673][SQL] Refactor SQL pipe syntax analysis code for sharing and reuse [spark]
Posted by "mihailotim-db (via GitHub)" <gi...@apache.org>.
mihailotim-db commented on code in PR #53431:
URL: https://github.com/apache/spark/pull/53431#discussion_r2610086552
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/pipeOperators.scala:
##########
@@ -71,26 +71,44 @@ case object ValidateAndStripPipeExpressions extends Rule[LogicalPlan] {
case node: LogicalPlan =>
node.resolveExpressions {
case p: PipeExpression if p.child.resolved =>
- // Once the child expression is resolved, we can perform the necessary invariant checks
- // and then remove this expression, replacing it with the child expression instead.
- val firstAggregateFunction: Option[AggregateFunction] = findFirstAggregate(p.child)
- if (p.isAggregate && firstAggregateFunction.isEmpty) {
- throw QueryCompilationErrors
- .pipeOperatorAggregateExpressionContainsNoAggregateFunction(p.child)
- } else if (!p.isAggregate) {
- // For non-aggregate clauses, only allow aggregate functions in SELECT.
- // All other clauses (EXTEND, SET, etc.) disallow aggregates.
- val aggregateAllowed = p.clause == PipeOperators.selectClause
- if (!aggregateAllowed) {
- firstAggregateFunction.foreach { a =>
- throw QueryCompilationErrors.pipeOperatorContainsAggregateFunction(a, p.clause)
- }
- }
- }
- p.child
+ validateAndStripPipeExpression(p, p.child)
}
}
+ /**
+ * Validates aggregate function constraints for a [[PipeExpression]] and returns the resolved
+ * child expression (stripping the [[PipeExpression]] wrapper).
+ *
+ * This method is shared between the fixed-point analyzer rule and the single-pass resolver.
+ *
+ * @param pipeExpression The [[PipeExpression]] containing metadata about the pipe clause.
+ * @param resolvedChild The resolved child expression to validate and return.
+ * @return The resolved child expression after validation.
+ */
+ def validateAndStripPipeExpression(
+ pipeExpression: PipeExpression,
+ resolvedChild: Expression): Expression = {
+ val firstAggregateFunction: Option[AggregateFunction] = findFirstAggregate(resolvedChild)
Review Comment:
If possible, we should extract this outside this method and then pass it as an arg, because it is recursive.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54673][SQL] Refactor SQL pipe syntax analysis code for sharing and reuse [spark]
Posted by "dtenedor (via GitHub)" <gi...@apache.org>.
dtenedor commented on PR #53431:
URL: https://github.com/apache/spark/pull/53431#issuecomment-3643448704
I just looked at the test failure, it is unrelated.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54673][SQL] Refactor SQL pipe syntax analysis code for sharing and reuse [spark]
Posted by "dtenedor (via GitHub)" <gi...@apache.org>.
dtenedor commented on code in PR #53431:
URL: https://github.com/apache/spark/pull/53431#discussion_r2611807137
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/pipeOperators.scala:
##########
@@ -71,26 +71,44 @@ case object ValidateAndStripPipeExpressions extends Rule[LogicalPlan] {
case node: LogicalPlan =>
node.resolveExpressions {
case p: PipeExpression if p.child.resolved =>
- // Once the child expression is resolved, we can perform the necessary invariant checks
- // and then remove this expression, replacing it with the child expression instead.
- val firstAggregateFunction: Option[AggregateFunction] = findFirstAggregate(p.child)
- if (p.isAggregate && firstAggregateFunction.isEmpty) {
- throw QueryCompilationErrors
- .pipeOperatorAggregateExpressionContainsNoAggregateFunction(p.child)
- } else if (!p.isAggregate) {
- // For non-aggregate clauses, only allow aggregate functions in SELECT.
- // All other clauses (EXTEND, SET, etc.) disallow aggregates.
- val aggregateAllowed = p.clause == PipeOperators.selectClause
- if (!aggregateAllowed) {
- firstAggregateFunction.foreach { a =>
- throw QueryCompilationErrors.pipeOperatorContainsAggregateFunction(a, p.clause)
- }
- }
- }
- p.child
+ validateAndStripPipeExpression(p, p.child)
}
}
+ /**
+ * Validates aggregate function constraints for a [[PipeExpression]] and returns the resolved
+ * child expression (stripping the [[PipeExpression]] wrapper).
+ *
+ * This method is shared between the fixed-point analyzer rule and the single-pass resolver.
+ *
+ * @param pipeExpression The [[PipeExpression]] containing metadata about the pipe clause.
+ * @param resolvedChild The resolved child expression to validate and return.
+ * @return The resolved child expression after validation.
+ */
+ def validateAndStripPipeExpression(
+ pipeExpression: PipeExpression,
+ resolvedChild: Expression): Expression = {
+ val firstAggregateFunction: Option[AggregateFunction] = findFirstAggregate(resolvedChild)
Review Comment:
Thanks for review, I looked at this, it turns out we are always going to want to use the same expression-finding logic, so should be OK to leave this hard-coded in here.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54673][SQL] Refactor SQL pipe syntax analysis code for sharing and reuse [spark]
Posted by "dtenedor (via GitHub)" <gi...@apache.org>.
dtenedor commented on PR #53431:
URL: https://github.com/apache/spark/pull/53431#issuecomment-3643453043
Thanks all for review, merging to master.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org