-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-7269] [SQL] Incorrect analysis for aggregation(use semanticEquals) #6173
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 |
|---|---|---|
|
|
@@ -76,6 +76,19 @@ abstract class Expression extends TreeNode[Expression] { | |
| case u: UnresolvedAttribute => PrettyAttribute(u.name) | ||
| }.toString | ||
| } | ||
|
|
||
| /** | ||
| * Returns true if 2 expressions are equal in semantic, which is similar to equals method | ||
| * but has different definition on some leaf expressions like AttributeReference. | ||
| */ | ||
| def semanticEquals(other: Expression): Boolean = this.getClass == other.getClass && { | ||
|
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. scala doc please. |
||
| val elements1 = this.productIterator.toSeq | ||
| val elements2 = other.asInstanceOf[Product].productIterator.toSeq | ||
| elements1.length == elements2.length && elements1.zip(elements2).forall { | ||
| case (e1: Expression, e2: Expression) => e1 semanticEquals e2 | ||
| case (i1, i2) => i1 == i2 | ||
|
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. What about
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. The difficulty here is we probably never knows |
||
| } | ||
| } | ||
| } | ||
|
|
||
| abstract class BinaryExpression extends Expression with trees.BinaryNode[Expression] { | ||
|
|
||
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.
Returns true when two expressions will always compute the same result, even if they differ cosmetically (i.e. capitalization of names in attributes may be different).