File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed
core/src/main/scala/org/apache/spark/sql/execution/command
main/scala/org/apache/spark/sql/hive/client
test/scala/org/apache/spark/sql/hive Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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 (
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments