Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ case class ShowPartitionsExec(
val len = schema.length
val partitions = new Array[String](len)
val timeZoneId = SQLConf.get.sessionLocalTimeZone
partitionIdentifiers.map { row =>
val output = partitionIdentifiers.map { row =>
var i = 0
while (i < len) {
val dataType = schema(i).dataType
Expand All @@ -59,7 +59,8 @@ case class ShowPartitionsExec(
partitions(i) = escapePathName(schema(i).name) + "=" + escapePathName(partValueStr)
i += 1
}
InternalRow(UTF8String.fromString(partitions.mkString("/")))
partitions.mkString("/")
}
output.sorted.map(p => InternalRow(UTF8String.fromString(p)))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,21 @@ trait ShowPartitionsSuiteBase extends QueryTest with SQLTestUtils {
}
}
}

test("SPARK-33777: sorted output") {
withNamespace(s"$catalog.ns") {
sql(s"CREATE NAMESPACE $catalog.ns")
val table = s"$catalog.ns.dateTable"
withTable(table) {
sql(s"""
|CREATE TABLE $table (id int, part string)
|$defaultUsing
|PARTITIONED BY (part)""".stripMargin)
sql(s"ALTER TABLE $table ADD PARTITION(part = 'b')")
sql(s"ALTER TABLE $table ADD PARTITION(part = 'a')")
val partitions = sql(s"show partitions $table")
assert(partitions.first().getString(0) === "part=a")
}
}
}
}