Skip to content

Commit c6d3acd

Browse files
committed
fix.
1 parent 79159a1 commit c6d3acd

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ case class ShowCreateTableCommand(table: TableIdentifier) extends RunnableComman
697697
private def showCreateHiveTable(metadata: CatalogTable): String = {
698698
def reportUnsupportedError(features: Seq[String]): Unit = {
699699
throw new AnalysisException(
700-
s"Failed to execute SHOW CREATE TABLE against table ${metadata.identifier.quotedString}, " +
700+
s"Failed to execute SHOW CREATE TABLE against table/view ${metadata.identifier}, " +
701701
"which is created by Hive and uses the following unsupported feature(s)\n" +
702702
features.map(" - " + _).mkString("\n")
703703
)

sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ private[hive] class HiveClientImpl(
376376
unsupportedFeatures += "bucketing"
377377
}
378378

379+
if (h.getTableType == HiveTableType.VIRTUAL_VIEW && partCols.nonEmpty) {
380+
unsupportedFeatures += "partitioned view"
381+
}
382+
379383
val properties = Option(h.getParameters).map(_.asScala.toMap).orNull
380384

381385
CatalogTable(

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,34 @@ class ShowCreateTableSuite extends QueryTest with SQLTestUtils with TestHiveSing
265265
}
266266
}
267267

268+
test("hive partitioned view is not supported") {
269+
withTable("t1") {
270+
withView("v1") {
271+
sql(
272+
s"""
273+
|CREATE TABLE t1 (c1 INT, c2 STRING)
274+
|PARTITIONED BY (
275+
| p1 BIGINT COMMENT 'bla',
276+
| p2 STRING )
277+
""".stripMargin)
278+
279+
createRawHiveTable(
280+
s"""
281+
|CREATE VIEW v1
282+
|PARTITIONED ON (p1, p2)
283+
|AS SELECT * from t1
284+
""".stripMargin
285+
)
286+
287+
val cause = intercept[AnalysisException] {
288+
sql("SHOW CREATE TABLE v1")
289+
}
290+
291+
assert(cause.getMessage.contains(" - partitioned view"))
292+
}
293+
}
294+
}
295+
268296
private def createRawHiveTable(ddl: String): Unit = {
269297
hiveContext.sharedState.externalCatalog.asInstanceOf[HiveExternalCatalog].client.runSqlHive(ddl)
270298
}

0 commit comments

Comments
 (0)