-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-35742][SQL] Expression.semanticEquals should be symmetrical #32885
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 |
|---|---|---|
|
|
@@ -278,11 +278,6 @@ case class AttributeReference( | |
| case _ => false | ||
| } | ||
|
|
||
| override def semanticEquals(other: Expression): Boolean = other match { | ||
| case ar: AttributeReference => sameRef(ar) | ||
| case _ => false | ||
| } | ||
|
|
||
|
||
| override def semanticHash(): Int = { | ||
| this.exprId.hashCode() | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,13 +76,6 @@ abstract class SubqueryExpression( | |
| AttributeSet.fromAttributeSets(outerAttrs.map(_.references)) | ||
| override def children: Seq[Expression] = outerAttrs ++ joinCond | ||
| override def withNewPlan(plan: LogicalPlan): SubqueryExpression | ||
| override def semanticEquals(o: Expression): Boolean = o match { | ||
|
||
| case p: SubqueryExpression => | ||
| this.getClass.getName.equals(p.getClass.getName) && plan.sameResult(p.plan) && | ||
| children.length == p.children.length && | ||
| children.zip(p.children).forall(p => p._1.semanticEquals(p._2)) | ||
| case _ => false | ||
| } | ||
| } | ||
|
|
||
| object SubqueryExpression { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,7 +73,9 @@ case class HashAggregateExec( | |
| // This is for testing. We force TungstenAggregationIterator to fall back to the unsafe row hash | ||
| // map and/or the sort-based aggregation once it has processed a given number of input rows. | ||
| private val testFallbackStartsAt: Option[(Int, Int)] = { | ||
| sqlContext.getConf("spark.sql.TungstenAggregate.testFallbackStartsAt", null) match { | ||
| Option(sqlContext).map { sc => | ||
|
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. This is a hidden bug. This means, Spark may serialize and send It's hidden for a long time because I think it only affects common subquery elimination, and shouldn't be a serious bug.
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. In the long term, I think we should only send an "expression evaluator" to the executor side. The semantic check should only be done in the driver side.
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. Sorry for the late comment @cloud-fan, but I think I've run into this issue before:
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.
I have an idea to fix this problem in all physical plans:
@peter-toth what do you think? AFAIK the only reason to access
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. Sounds good to me.
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. I'm quite busy this week and may not have time to implement this idea recently. @peter-toth feel free to pick up this idea and open a PR if you have time, or I'll do it next or next next week. Thanks in advance!
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. Ok, thanks. I will try to open a PR this week.
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. Opened #32947. |
||
| sc.getConf("spark.sql.TungstenAggregate.testFallbackStartsAt", null) | ||
| }.orNull match { | ||
| case null | "" => None | ||
| case fallbackStartsAt => | ||
| val splits = fallbackStartsAt.split(",").map(_.trim) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,9 +71,8 @@ case class ScalarSubquery( | |
| override def toString: String = plan.simpleString(SQLConf.get.maxToStringFields) | ||
| override def withNewPlan(query: BaseSubqueryExec): ScalarSubquery = copy(plan = query) | ||
|
|
||
| override def semanticEquals(other: Expression): Boolean = other match { | ||
| case s: ScalarSubquery => plan.sameResult(s.plan) | ||
| case _ => false | ||
| override lazy val canonicalized: Expression = { | ||
| ScalarSubquery(plan.canonicalized.asInstanceOf[BaseSubqueryExec], ExprId(0)) | ||
| } | ||
|
|
||
| // the first column in first row from `query`. | ||
|
|
@@ -127,11 +126,6 @@ case class InSubqueryExec( | |
| override def withNewPlan(plan: BaseSubqueryExec): InSubqueryExec = copy(plan = plan) | ||
| final override def nodePatternsInternal: Seq[TreePattern] = Seq(IN_SUBQUERY_EXEC) | ||
|
|
||
| override def semanticEquals(other: Expression): Boolean = other match { | ||
| case in: InSubqueryExec => child.semanticEquals(in.child) && plan.sameResult(in.plan) | ||
| case _ => false | ||
| } | ||
|
|
||
|
||
| def updateResult(): Unit = { | ||
| val rows = plan.executeCollect() | ||
| result = if (plan.output.length > 1) { | ||
|
|
||
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.
Yes, I agree with the idea.