-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-40615][SQL] Check unsupported data types when decorrelating subqueries #38050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,12 +19,13 @@ package org.apache.spark.sql.catalyst.optimizer | |
|
|
||
| import scala.collection.mutable.ArrayBuffer | ||
|
|
||
| import org.apache.spark.SparkException | ||
| import org.apache.spark.sql.catalyst.expressions._ | ||
| import org.apache.spark.sql.catalyst.expressions.SubExprUtils._ | ||
| import org.apache.spark.sql.catalyst.plans._ | ||
| import org.apache.spark.sql.catalyst.plans.logical._ | ||
| import org.apache.spark.sql.catalyst.trees.TreePattern.OUTER_REFERENCE | ||
| import org.apache.spark.sql.errors.QueryExecutionErrors | ||
| import org.apache.spark.sql.errors.{QueryCompilationErrors, QueryExecutionErrors} | ||
| import org.apache.spark.util.collection.Utils | ||
|
|
||
| /** | ||
|
|
@@ -360,7 +361,20 @@ object DecorrelateInnerQuery extends PredicateHelper { | |
| // +- Aggregate [a1] [a1 AS a'] | ||
| // +- OuterQuery | ||
| val conditions = outerReferenceMap.map { | ||
| case (o, a) => EqualNullSafe(a, OuterReference(o)) | ||
| case (o, a) => | ||
| val cond = EqualNullSafe(a, OuterReference(o)) | ||
| // SPARK-40615: Certain data types (e.g. MapType) do not support ordering, so | ||
| // the EqualNullSafe join condition can become unresolved. | ||
| if (!cond.resolved) { | ||
| if (!RowOrdering.isOrderable(a.dataType)) { | ||
| throw QueryCompilationErrors.unsupportedCorrelatedReferenceDataTypeError( | ||
| o, a.dataType, plan.origin) | ||
| } else { | ||
| throw SparkException.internalError(s"Unable to decorrelate subquery: " + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this change?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh I saw Wenchen's comment above.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #38050 (comment) |
||
| s"join condition '${cond.sql}' cannot be resolved.") | ||
| } | ||
| } | ||
| cond | ||
| } | ||
| (domainJoin, conditions.toSeq, AttributeMap(outerReferenceMap)) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 this is better!