Github user hvanhovell commented on a diff in the pull request:
https://github.com/apache/spark/pull/12412#discussion_r59856710
--- Diff:
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/commands.scala ---
@@ -255,3 +258,88 @@ 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'")
+ }
+ if (catalog.isTemporaryTable(table)) {
+ throw new AnalysisException(
+ s"Table in LOAD DATA cannot be temporary: '$table'")
+ }
+
+ val targetTable = catalog.getTableMetadata(table)
+ if (DDLUtils.isDatasourceTable(targetTable)) {
+ throw new AnalysisException(
+ "LOAD DATA is not supported for datasource tables")
+ }
+
+ if (targetTable.partitionColumnNames.nonEmpty) {
+ if (partition.isEmpty || targetTable.partitionColumnNames.size !=
partition.get.size) {
+ throw new AnalysisException(
+ "LOAD DATA to partitioned table must specify a specific
partition of " +
+ "the table by specifying values for all of the partitioning
columns.")
+ }
+
+ partition.get.keys.foreach { colName =>
+ if (!targetTable.partitionColumnNames.contains(colName)) {
+ throw new AnalysisException(
+ s"LOAD DATA to partitioned table specifies a non-existing
partition column: '$colName'")
+ }
+ }
+ } else {
+ if (partition.nonEmpty) {
+ throw new AnalysisException(
+ "LOAD DATA to non-partitioned table cannot specify partition.")
+ }
+ }
+
+ val hiveClient = sqlContext.asInstanceOf[HiveContext].metadataHive
+
+ val holdDDLTime = false
+
+ if (partition.nonEmpty) {
+ val orderedPartitionSpec = new util.LinkedHashMap[String, String]()
+ targetTable.partitionColumnNames.foreach { colName =>
+ orderedPartitionSpec.put(colName, partition.get(colName))
+ }
+
+ val inheritTableSpecs = true
+ val isSkewedStoreAsSubdir = false
--- End diff --
Minor: Constant?
---
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]