diff options
author | Yin Huai <yhuai@databricks.com> | 2016-04-27 00:30:54 -0700 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2016-04-27 00:30:54 -0700 |
commit | 54a3eb8312bf4dfe97f9b294a2466785a1a17de6 (patch) | |
tree | 418d32c2ba458ff0618302430ee6694d1287d0be /sql/catalyst/src/main | |
parent | d73d67f623dd65b90d0edbd7ba62e9a6ce7ebd1e (diff) | |
download | spark-54a3eb8312bf4dfe97f9b294a2466785a1a17de6.tar.gz spark-54a3eb8312bf4dfe97f9b294a2466785a1a17de6.tar.bz2 spark-54a3eb8312bf4dfe97f9b294a2466785a1a17de6.zip |
[SPARK-14130][SQL] Throw exceptions for ALTER TABLE ADD/REPLACE/CHANGE COLUMN, ALTER TABLE SET FILEFORMAT, DFS, and transaction related commands
## What changes were proposed in this pull request?
This PR will make Spark SQL not allow ALTER TABLE ADD/REPLACE/CHANGE COLUMN, ALTER TABLE SET FILEFORMAT, DFS, and transaction related commands.
## How was this patch tested?
Existing tests. For those tests that I put in the blacklist, I am adding the useful parts back to SQLQuerySuite.
Author: Yin Huai <yhuai@databricks.com>
Closes #12714 from yhuai/banNativeCommand.
Diffstat (limited to 'sql/catalyst/src/main')
-rw-r--r-- | sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4 | 13 | ||||
-rw-r--r-- | sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserUtils.scala | 4 |
2 files changed, 10 insertions, 7 deletions
diff --git a/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4 b/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4 index 9de313ae87..6e04f6eb80 100644 --- a/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4 +++ b/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4 @@ -128,14 +128,8 @@ statement ; hiveNativeCommands - : DELETE FROM tableIdentifier (WHERE booleanExpression)? - | TRUNCATE TABLE tableIdentifier partitionSpec? + : TRUNCATE TABLE tableIdentifier partitionSpec? (COLUMNS identifierList)? - | START TRANSACTION (transactionMode (',' transactionMode)*)? - | COMMIT WORK? - | ROLLBACK WORK? - | SHOW PARTITIONS tableIdentifier partitionSpec? - | DFS .*? | (CREATE | ALTER | DROP | SHOW | DESC | DESCRIBE) .*? ; @@ -179,6 +173,11 @@ unsupportedHiveNativeCommands | kw1=ALTER kw2=TABLE tableIdentifier kw3=TOUCH | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=COMPACT | kw1=ALTER kw2=TABLE tableIdentifier partitionSpec? kw3=CONCATENATE + | kw1=START kw2=TRANSACTION + | kw1=COMMIT + | kw1=ROLLBACK + | kw1=DFS + | kw1=DELETE kw2=FROM ; createTableHeader diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserUtils.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserUtils.scala index cb9fefec8f..64713cddf4 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserUtils.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserUtils.scala @@ -39,6 +39,10 @@ object ParserUtils { stream.getText(Interval.of(0, stream.size())) } + def parseException(message: String, ctx: ParserRuleContext): ParseException = { + new ParseException(s"Operation not allowed: $message", ctx) + } + /** Get the code that creates the given node. */ def source(ctx: ParserRuleContext): String = { val stream = ctx.getStart.getInputStream |