Re: [PR] [SPARK-48146][SQL] Fix aggregate function in With expression child assertion [spark]
kelvinjian-db commented on code in PR #46443: URL: https://github.com/apache/spark/pull/46443#discussion_r1597045459 ## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/With.scala: ## @@ -92,6 +95,21 @@ object With { val commonExprRefs = commonExprDefs.map(new CommonExpressionRef(_)) With(replaced(commonExprRefs), commonExprDefs) } + + private[sql] def childContainsUnsupportedAggExpr(withExpr: With): Boolean = { +lazy val commonExprIds = withExpr.defs.map(_.id).toSet +withExpr.child.exists { + case agg: AggregateExpression => Review Comment: i agree, or we could add some pruning-based tree traversal functions like `existsWithPruning` (similar to `transformWithPruning`) -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
Re: [PR] [SPARK-48146][SQL] Fix aggregate function in With expression child assertion [spark]
cloud-fan closed pull request #46443: [SPARK-48146][SQL] Fix aggregate function in With expression child assertion URL: https://github.com/apache/spark/pull/46443 -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
Re: [PR] [SPARK-48146][SQL] Fix aggregate function in With expression child assertion [spark]
cloud-fan commented on PR #46443: URL: https://github.com/apache/spark/pull/46443#issuecomment-2104728640 thanks, 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
Re: [PR] [SPARK-48146][SQL] Fix aggregate function in With expression child assertion [spark]
cloud-fan commented on code in PR #46443: URL: https://github.com/apache/spark/pull/46443#discussion_r1596840882 ## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/With.scala: ## @@ -92,6 +95,21 @@ object With { val commonExprRefs = commonExprDefs.map(new CommonExpressionRef(_)) With(replaced(commonExprRefs), commonExprDefs) } + + private[sql] def childContainsUnsupportedAggExpr(withExpr: With): Boolean = { +lazy val commonExprIds = withExpr.defs.map(_.id).toSet +withExpr.child.exists { + case agg: AggregateExpression => Review Comment: nit: ideally we can stop the traversal after hitting `AggregateExpression` because there can't be nested `AggregateExpression`. This requires to write a manual top down recursion instead of using `.exist`. -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
Re: [PR] [SPARK-48146][SQL] Fix aggregate function in With expression child assertion [spark]
cloud-fan commented on code in PR #46443: URL: https://github.com/apache/spark/pull/46443#discussion_r1596840882 ## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/With.scala: ## @@ -92,6 +95,21 @@ object With { val commonExprRefs = commonExprDefs.map(new CommonExpressionRef(_)) With(replaced(commonExprRefs), commonExprDefs) } + + private[sql] def childContainsUnsupportedAggExpr(withExpr: With): Boolean = { +lazy val commonExprIds = withExpr.defs.map(_.id).toSet +withExpr.child.exists { + case agg: AggregateExpression => Review Comment: nit: ideally we can stop the traversal after hitting `AggregateExpression` because there can't be nested `AggregateExpression`. This requires to write a manual recursion instead of using `.exist`. -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
Re: [PR] [SPARK-48146][SQL] Fix aggregate function in With expression child assertion [spark]
kelvinjian-db commented on code in PR #46443: URL: https://github.com/apache/spark/pull/46443#discussion_r1595803069 ## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/With.scala: ## @@ -92,6 +95,26 @@ object With { val commonExprRefs = commonExprDefs.map(new CommonExpressionRef(_)) With(replaced(commonExprRefs), commonExprDefs) } + + private def containsUnsupportedRef( +expr: Expression, +commonExprIds: Set[CommonExpressionId] + ): Boolean = { +expr match { + case _ if !expr.containsPattern(COMMON_EXPR_REF) => false + case w: With => containsUnsupportedAggExpr(w) Review Comment: updated the PR -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
Re: [PR] [SPARK-48146][SQL] Fix aggregate function in With expression child assertion [spark]
kelvinjian-db commented on code in PR #46443: URL: https://github.com/apache/spark/pull/46443#discussion_r1595796862 ## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/With.scala: ## @@ -92,6 +95,26 @@ object With { val commonExprRefs = commonExprDefs.map(new CommonExpressionRef(_)) With(replaced(commonExprRefs), commonExprDefs) } + + private def containsUnsupportedRef( +expr: Expression, +commonExprIds: Set[CommonExpressionId] + ): Boolean = { +expr match { + case _ if !expr.containsPattern(COMMON_EXPR_REF) => false + case w: With => containsUnsupportedAggExpr(w) Review Comment: good point, and we don't need to call `containsUnsupportedAggExpr` again on the inner With because we can't have nested aggregate expressions? -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
Re: [PR] [SPARK-48146][SQL] Fix aggregate function in With expression child assertion [spark]
cloud-fan commented on code in PR #46443: URL: https://github.com/apache/spark/pull/46443#discussion_r1594911102 ## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/With.scala: ## @@ -92,6 +95,26 @@ object With { val commonExprRefs = commonExprDefs.map(new CommonExpressionRef(_)) With(replaced(commonExprRefs), commonExprDefs) } + + private def containsUnsupportedRef( +expr: Expression, +commonExprIds: Set[CommonExpressionId] + ): Boolean = { +expr match { + case _ if !expr.containsPattern(COMMON_EXPR_REF) => false + case w: With => containsUnsupportedAggExpr(w) Review Comment: Shall we remove this case? I think it's possible that the inner With has references to the outer With's common expressions, and we should detect that. -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org