Github user yhuai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14897#discussion_r80395895
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala ---
    @@ -197,6 +201,45 @@ case class CreateViewCommand(
       }
     }
     
    +
    +/**
    + * Create or replace a local/global temporary view with given data source.
    + */
    +case class CreateTempViewUsing(
    +    tableIdent: TableIdentifier,
    +    userSpecifiedSchema: Option[StructType],
    +    replace: Boolean,
    +    global: Boolean,
    +    provider: String,
    +    options: Map[String, String]) extends RunnableCommand {
    +
    +  if (tableIdent.database.isDefined) {
    +    throw new AnalysisException(
    +      s"Temporary view '$tableIdent' should not have specified a database")
    +  }
    +
    +  def run(sparkSession: SparkSession): Seq[Row] = {
    +    val dataSource = DataSource(
    +      sparkSession,
    +      userSpecifiedSchema = userSpecifiedSchema,
    +      className = provider,
    +      options = options)
    +
    +    val catalog = sparkSession.sessionState.catalog
    +    val viewDefinition = Dataset.ofRows(
    +      sparkSession, 
LogicalRelation(dataSource.resolveRelation())).logicalPlan
    +
    +    if (global) {
    +      catalog.createGlobalTempView(tableIdent.table, viewDefinition, 
replace)
    +    } else {
    +      catalog.createTempView(tableIdent.table, viewDefinition, replace)
    +    }
    +
    +    Seq.empty[Row]
    +  }
    +}
    --- End diff --
    
    Is this command moved from somewhere? If so, is it possible to move it in 
the follow-up pr?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to