Skip to content

Commit 1369332

Browse files
committed
fix test case failures
1 parent 4b0b7b4 commit 1369332

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,9 +767,14 @@ case class ShowCreateTableCommand(table: TableIdentifier) extends RunnableComman
767767
builder ++= partCols.mkString("PARTITIONED BY (", ", ", ")\n")
768768
}
769769

770-
if (metadata.bucketSpec.isDefined) {
771-
throw new UnsupportedOperationException(
772-
"Creating Hive table with bucket spec is not supported yet.")
770+
if (metadata.bucketSpec.nonEmpty) {
771+
val bucketSpec = metadata.bucketSpec.get
772+
builder ++= s"CLUSTERED BY (${bucketSpec.bucketColumnNames.mkString(",")})\n"
773+
774+
if (bucketSpec.sortColumnNames.nonEmpty) {
775+
builder ++= s"SORTED BY (${bucketSpec.sortColumnNames.map(_ + " ASC").mkString(", ")})\n"
776+
}
777+
builder ++= s"INTO ${bucketSpec.numBuckets} BUCKETS\n"
773778
}
774779
}
775780

sql/hive/src/test/scala/org/apache/spark/sql/hive/ShowCreateTableSuite.scala

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,21 +247,16 @@ class ShowCreateTableSuite extends QueryTest with SQLTestUtils with TestHiveSing
247247
}
248248
}
249249

250-
test("hive bucketing is not supported") {
250+
test("hive bucketing is supported") {
251251
withTable("t1") {
252-
createRawHiveTable(
252+
sql(
253253
s"""CREATE TABLE t1 (a INT, b STRING)
254254
|CLUSTERED BY (a)
255255
|SORTED BY (b)
256256
|INTO 2 BUCKETS
257257
""".stripMargin
258258
)
259-
260-
val cause = intercept[AnalysisException] {
261-
sql("SHOW CREATE TABLE t1")
262-
}
263-
264-
assert(cause.getMessage.contains(" - bucketing"))
259+
checkCreateTable("t1")
265260
}
266261
}
267262

sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,9 @@ class HiveDDLSuite
517517

518518
assert(sql("DESC FORMATTED tbl").collect().containsSlice(
519519
Seq(
520-
Row("Num Buckets", "8", null),
521-
Row("Bucket Columns", "id1", null),
522-
Row("Sort Columns", "id, name", null)
520+
Row("Num Buckets:", "1024", ""),
521+
Row("Bucket Columns:", "[id]", ""),
522+
Row("Sort Columns:", "[id, name]", "")
523523
)
524524
))
525525
}

0 commit comments

Comments
 (0)