aboutsummaryrefslogtreecommitdiff
path: root/sql/hive
diff options
context:
space:
mode:
authorAndrew Or <andrew@databricks.com>2016-03-11 15:13:48 -0800
committerYin Huai <yhuai@databricks.com>2016-03-11 15:13:48 -0800
commit66d9d0edfef986895490bcdeacbc0ca38e091702 (patch)
tree84037a13e7040fa88e0ace5aab18087d3e206e95 /sql/hive
parent42afd72c654318e9fb1f2a204198221e797c2485 (diff)
downloadspark-66d9d0edfef986895490bcdeacbc0ca38e091702.tar.gz
spark-66d9d0edfef986895490bcdeacbc0ca38e091702.tar.bz2
spark-66d9d0edfef986895490bcdeacbc0ca38e091702.zip
[SPARK-13139][SQL] Parse Hive DDL commands ourselves
## What changes were proposed in this pull request? This patch is ported over from viirya's changes in #11048. Currently for most DDLs we just pass the query text directly to Hive. Instead, we should parse these commands ourselves and in the future (not part of this patch) use the `HiveCatalog` to process these DDLs. This is a pretext to merging `SQLContext` and `HiveContext`. Note: As of this patch we still pass the query text to Hive. The difference is that we now parse the commands ourselves so in the future we can just use our own catalog. ## How was this patch tested? Jenkins, new `DDLCommandSuite`, which comprises of about 40% of the changes here. Author: Andrew Or <andrew@databricks.com> Closes #11573 from andrewor14/parser-plus-plus.
Diffstat (limited to 'sql/hive')
-rw-r--r--sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala9
-rw-r--r--sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala18
2 files changed, 11 insertions, 16 deletions
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala
index 69669d79be..081d849a88 100644
--- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala
+++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala
@@ -535,6 +535,15 @@ class HiveContext private[hive](
}
}
+ /**
+ * Executes a SQL query without parsing it, but instead passing it directly to Hive.
+ * This is currently only used for DDLs and will be removed as soon as Spark can parse
+ * all supported Hive DDLs itself.
+ */
+ protected[sql] override def runNativeSql(sqlText: String): Seq[Row] = {
+ runSqlHive(sqlText).map { s => Row(s) }
+ }
+
/** Extends QueryExecution with hive specific features. */
protected[sql] class QueryExecution(logicalPlan: LogicalPlan)
extends org.apache.spark.sql.execution.QueryExecution(this, logicalPlan) {
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala
index 0bdebdc5fd..56acb87c80 100644
--- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala
+++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala
@@ -88,29 +88,14 @@ private[hive] class HiveQl(conf: ParserConf) extends SparkQl(conf) with Logging
"TOK_ALTERDATABASE_PROPERTIES",
"TOK_ALTERINDEX_PROPERTIES",
"TOK_ALTERINDEX_REBUILD",
- "TOK_ALTERTABLE",
- "TOK_ALTERTABLE_ADDCOLS",
- "TOK_ALTERTABLE_ADDPARTS",
"TOK_ALTERTABLE_ALTERPARTS",
- "TOK_ALTERTABLE_ARCHIVE",
- "TOK_ALTERTABLE_CLUSTER_SORT",
- "TOK_ALTERTABLE_DROPPARTS",
"TOK_ALTERTABLE_PARTITION",
- "TOK_ALTERTABLE_PROPERTIES",
- "TOK_ALTERTABLE_RENAME",
- "TOK_ALTERTABLE_RENAMECOL",
- "TOK_ALTERTABLE_REPLACECOLS",
- "TOK_ALTERTABLE_SKEWED",
- "TOK_ALTERTABLE_TOUCH",
- "TOK_ALTERTABLE_UNARCHIVE",
"TOK_ALTERVIEW_ADDPARTS",
"TOK_ALTERVIEW_AS",
"TOK_ALTERVIEW_DROPPARTS",
"TOK_ALTERVIEW_PROPERTIES",
"TOK_ALTERVIEW_RENAME",
- "TOK_CREATEDATABASE",
- "TOK_CREATEFUNCTION",
"TOK_CREATEINDEX",
"TOK_CREATEMACRO",
"TOK_CREATEROLE",
@@ -164,7 +149,8 @@ private[hive] class HiveQl(conf: ParserConf) extends SparkQl(conf) with Logging
protected val noExplainCommands = Seq(
"TOK_DESCTABLE",
"TOK_SHOWTABLES",
- "TOK_TRUNCATETABLE" // truncate table" is a NativeCommand, does not need to explain.
+ "TOK_TRUNCATETABLE", // truncate table" is a NativeCommand, does not need to explain.
+ "TOK_ALTERTABLE"
) ++ nativeCommands
/**