cloud-fan commented on a change in pull request #25204:
[SPARK-28441][SQL][Python] Fix error when non-foldable expression is used in
correlated scalar subquery
URL: https://github.com/apache/spark/pull/25204#discussion_r306370145
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/subquery.scala
##########
@@ -354,27 +384,39 @@ object RewriteCorrelatedScalarSubquery extends
Rule[LogicalPlan] {
* [[org.apache.spark.sql.catalyst.analysis.CheckAnalysis]]. If the checks in
* CheckAnalysis become less restrictive, this method will need to change.
*/
- private def evalSubqueryOnZeroTups(plan: LogicalPlan) : Option[Any] = {
+ private def evalSubqueryOnZeroTups(plan: LogicalPlan) : Option[Expression] =
{
// Inputs to this method will start with a chain of zero or more
SubqueryAlias
// and Project operators, followed by an optional Filter, followed by an
// Aggregate. Traverse the operators recursively.
- def evalPlan(lp : LogicalPlan) : Map[ExprId, Option[Any]] = lp match {
+ def evalPlan(lp : LogicalPlan) : Map[ExprId, Option[Expression]] = lp
match {
case SubqueryAlias(_, child) => evalPlan(child)
case Filter(condition, child) =>
val bindings = evalPlan(child)
- if (bindings.isEmpty) bindings
- else {
- val exprResult = evalExpr(condition, bindings).getOrElse(false)
- .asInstanceOf[Boolean]
- if (exprResult) bindings else Map.empty
+ if (bindings.isEmpty) {
+ bindings
+ } else {
+ val bindExpr = bindingExpr(condition, bindings)
+ .getOrElse(Literal.create(false, BooleanType))
Review comment:
For filter condition, null is the same as false. This is one place that
makes me think `bindingExpr` should return `Option[Expression]`.
If this is the only place, I think it's simpler to always return expression,
and handle null especially 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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]