Skip to content

Commit 2a5afba

Browse files
RussellSpitzerGitHub Enterprise
authored andcommitted
rdar://111955881 (Differentiate Create Table Unordered from Create Table default) (apache#1810)
Co-authored-by: Russell Spitzer <[email protected]>
1 parent e1060ab commit 2a5afba

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4381,7 +4381,11 @@ class AstBuilder extends SqlBaseParserBaseVisitor[AnyRef] with SQLConfHelper wit
43814381
val ordering = toOrdering(orderingSpec)
43824382

43834383
val table = createUnresolvedTable(ctx.multipartIdentifier, "ALTER TABLE ... WRITE")
4384-
SetWriteDistributionAndOrdering(table, distributionMode, ordering)
4384+
if (distributionMode == "unordered") {
4385+
SetWriteDistributionAndOrdering(table, "none", ordering)
4386+
} else {
4387+
SetWriteDistributionAndOrdering(table, distributionMode, ordering)
4388+
}
43854389
}
43864390

43874391
private def toDistributionMode(
@@ -4391,7 +4395,8 @@ class AstBuilder extends SqlBaseParserBaseVisitor[AnyRef] with SQLConfHelper wit
43914395
if (distributionSpec != null) {
43924396
"hash"
43934397
} else if (orderingSpec.UNORDERED != null || orderingSpec.LOCALLY != null) {
4394-
"none"
4398+
// Need to distinguish between "none" (default) and explicitly unordered
4399+
"unordered"
43954400
} else {
43964401
"range"
43974402
}

sql/core/src/test/scala/org/apache/spark/sql/execution/command/PlanResolutionSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3134,7 +3134,7 @@ class PlanResolutionSuite extends AnalysisTest {
31343134
.add("description", StringType)
31353135
.add("point", new StructType().add("x", DoubleType).add("y", DoubleType)))
31363136
assert(create.partitioning == expectedPartitioning)
3137-
assert(create.distributionMode == "none")
3137+
assert(create.distributionMode == "unordered")
31383138
assert(create.ordering == expectedOrdering)
31393139
assert(create.tableSpec.properties == expectedProperties)
31403140
assert(create.ignoreIfExists)
@@ -3167,7 +3167,7 @@ class PlanResolutionSuite extends AnalysisTest {
31673167
assert(ctas.tableSpec.properties == expectedProperties)
31683168
assert(ctas.writeOptions.isEmpty)
31693169
assert(ctas.partitioning.isEmpty)
3170-
assert(ctas.distributionMode == "none")
3170+
assert(ctas.distributionMode == "unordered")
31713171
assert(ctas.ordering.isEmpty)
31723172
assert(ctas.ignoreIfExists)
31733173

0 commit comments

Comments
 (0)