Skip to content

Commit 41e72f6

Browse files
committed
[SPARK-16715][TESTS] Fix a potential ExprId conflict for SubexpressionEliminationSuite."Semantic equals and hash"
## What changes were proposed in this pull request? SubexpressionEliminationSuite."Semantic equals and hash" assumes the default AttributeReference's exprId wont' be "ExprId(1)". However, that depends on when this test runs. It may happen to use "ExprId(1)". This PR detects the conflict and makes sure we create a different ExprId when the conflict happens. ## How was this patch tested? Jenkins unit tests. Author: Shixiong Zhu <shixiong@databricks.com> Closes #14350 from zsxwing/SPARK-16715. (cherry picked from commit 12f490b) Signed-off-by: Shixiong Zhu <shixiong@databricks.com>
1 parent 1b4f7cf commit 41e72f6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/SubexpressionEliminationSuite.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ import org.apache.spark.sql.types.IntegerType
2121

2222
class SubexpressionEliminationSuite extends SparkFunSuite {
2323
test("Semantic equals and hash") {
24-
val id = ExprId(1)
2524
val a: AttributeReference = AttributeReference("name", IntegerType)()
25+
val id = {
26+
// Make sure we use a "ExprId" different from "a.exprId"
27+
val _id = ExprId(1)
28+
if (a.exprId == _id) ExprId(2) else _id
29+
}
2630
val b1 = a.withName("name2").withExprId(id)
2731
val b2 = a.withExprId(id)
2832
val b3 = a.withQualifier(Some("qualifierName"))

0 commit comments

Comments
 (0)