@@ -28,9 +28,8 @@ import org.apache.spark.sql.catalyst.plans.logical.{LogicalPlan, Project}
2828
2929
3030/**
31- * Create or replace a view with given query plan. This command will convert the query plan to
32- * canonicalized SQL string, and store it as view text in metastore, if we need to create a
33- * permanent view.
31+ * Create Hive view on non-hive-compatible tables by specifying schema ourselves instead of
32+ * depending on Hive meta-store.
3433 *
3534 * @param tableDesc the catalog table
3635 * @param child the logical plan that represents the view; this is used to generate a canonicalized
@@ -60,8 +59,8 @@ case class CreateViewCommand(
6059 require(tableDesc.tableType == CatalogTableType .VIEW ,
6160 " The type of the table to created with CREATE VIEW must be 'CatalogTableType.VIEW'." )
6261 if (! isTemporary) {
63- require(tableDesc.viewOriginalText .isDefined,
64- " The table to created with CREATE VIEW must have 'viewOriginalText '." )
62+ require(tableDesc.viewText .isDefined,
63+ " The table to created with CREATE VIEW must have 'viewText '." )
6564 }
6665
6766 if (allowExisting && replace) {
@@ -179,8 +178,9 @@ case class CreateViewCommand(
179178 }
180179 }
181180
181+ val viewText = tableDesc.viewText.get
182182 val viewName = quote(tableDesc.identifier.table)
183- s " SELECT $viewOutput FROM ( ${tableDesc.viewOriginalText.get} ) $viewName"
183+ s " SELECT $viewOutput FROM ( $viewText ) $viewName"
184184 }
185185
186186 // Validate the view SQL - make sure we can parse it and analyze it.
0 commit comments