-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[SPARK-52686][SQL] Union
should be resolved only if there are no duplicates
#51376
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Union false, false | ||
'Union false, false | ||
mihailotim-db marked this conversation as resolved.
Show resolved
Hide resolved
|
||
:- LocalRelation <empty>, [id#0L, a#0, b#0] | ||
+- LocalRelation <empty>, [id#0L, a#0, b#0] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Union false, false | ||
'Union false, false | ||
:- LocalRelation <empty>, [id#0L, a#0, b#0] | ||
+- LocalRelation <empty>, [id#0L, a#0, b#0] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4963,6 +4963,45 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark | |
) | ||
} | ||
|
||
test("SPARK-52686: Union should be resolved only if there are no duplicates") { | ||
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 newly added test has been causing failures in the Non-Ansi daily test since 5 days ago: ![]() We can reproduce it locally using the following command:
Could you take a look at this issue when you have time? thanks @mihailotim-db 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. Ah yes, the test is dependent on 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. Followup to fix the test: #51490 |
||
withTable("t1", "t2", "t3") { | ||
sql("CREATE TABLE t1 (col1 STRING, col2 STRING, col3 STRING)") | ||
sql("CREATE TABLE t2 (col1 STRING, col2 DOUBLE, col3 STRING)") | ||
sql("CREATE TABLE t3 (col1 STRING, col2 DOUBLE, a STRING, col3 STRING)") | ||
|
||
for (confValue <- Seq(false, true)) { | ||
withSQLConf( | ||
SQLConf.UNION_IS_RESOLVED_WHEN_DUPLICATES_PER_CHILD_RESOLVED.key -> confValue.toString | ||
) { | ||
val analyzedPlan = sql( | ||
"""SELECT | ||
| * | ||
|FROM ( | ||
| SELECT col1, col2, NULL AS a, col1 FROM t1 | ||
| UNION | ||
| SELECT col1, col2, NULL AS a, col3 FROM t2 | ||
| UNION | ||
| SELECT * FROM t3 | ||
|)""".stripMargin | ||
).queryExecution.analyzed | ||
|
||
val projectCount = analyzedPlan.collect { | ||
case project: Project => project | ||
}.size | ||
|
||
// When UNION_IS_RESOLVED_WHEN_DUPLICATES_PER_CHILD_RESOLVED is disabled, we resolve | ||
// outer Union before deduplicating ExprIds in inner union. Because of this we get an | ||
// additional unnecessary Project (see SPARK-52686). | ||
if (confValue) { | ||
assert(projectCount == 7) | ||
} else { | ||
assert(projectCount == 8) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
Seq(true, false).foreach { codegenEnabled => | ||
test(s"SPARK-52060: one row relation with codegen enabled - $codegenEnabled") { | ||
withSQLConf(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key -> codegenEnabled.toString) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.