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

    https://github.com/apache/spark/pull/12412#discussion_r59896060
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/commands.scala ---
    @@ -255,3 +258,83 @@ case class CreateMetastoreDataSourceAsSelect(
         Seq.empty[Row]
       }
     }
    +
    +/**
    + * A command that loads data into a Hive table.
    + *
    + * The syntax of this command is:
    + * {{{
    + *  LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE tablename
    + *  [PARTITION (partcol1=val1, partcol2=val2 ...)]
    + * }}}
    + */
    +case class LoadData(
    +    table: TableIdentifier,
    +    path: String,
    +    isLocal: Boolean,
    +    isOverwrite: Boolean,
    +    partition: Option[ExternalCatalog.TablePartitionSpec]) extends 
RunnableCommand {
    +
    +  override def run(sqlContext: SQLContext): Seq[Row] = {
    +    val catalog = sqlContext.sessionState.catalog
    +    if (!catalog.tableExists(table)) {
    +      throw new AnalysisException(
    +        s"Table in LOAD DATA does not exist: '$table'")
    +    }
    +
    +    val targetTable = catalog.getTableMetadataOption(table).getOrElse {
    --- End diff --
    
    For anyone questions about why don't use `isTemporaryTable` here to check 
it. Because the database name is optional. When there is no database name 
given, the logic of `isTemporaryTable` will check if temporary tables contain a 
table of the given name. If there is a temporary table of the same name, 
`isTemporaryTable` will return true. But actually now in current database there 
is also a table of the name.
    
    We can add current database name into the table identifier here then call 
`isTemporaryTable` to check. But it is too verbose.


---
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