Skip to content

Commit 3db2e1d

Browse files
committed
List TOK_ALTERTABLE as not explanable command.
1 parent eb1fab7 commit 3db2e1d

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

sql/core/src/main/scala/org/apache/spark/sql/execution/SparkQl.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ import org.apache.spark.sql.types.StructType
3030

3131
private[sql] class SparkQl(conf: ParserConf = SimpleParserConf()) extends CatalystQl(conf) {
3232
/** Check if a command should not be explained. */
33-
protected def isNoExplainCommand(command: String): Boolean = "TOK_DESCTABLE" == command
33+
protected def isNoExplainCommand(command: String): Boolean =
34+
"TOK_DESCTABLE" == command || "TOK_ALTERTABLE" == command
3435

3536
protected override def nodeToPlan(node: ASTNode): LogicalPlan = {
3637
node match {
@@ -55,7 +56,7 @@ private[sql] class SparkQl(conf: ParserConf = SimpleParserConf()) extends Cataly
5556
getClauses(Seq("TOK_CREATETABLE", "FORMATTED", "EXTENDED"), explainArgs)
5657
ExplainCommand(nodeToPlan(crtTbl), extended = extended.isDefined)
5758

58-
case Token("TOK_EXPLAIN", explainArgs) =>
59+
case Token("TOK_EXPLAIN", explainArgs) if "TOK_QUERY" == explainArgs.head.text =>
5960
// Ignore FORMATTED if present.
6061
val Some(query) :: _ :: extended :: Nil =
6162
getClauses(Seq("TOK_QUERY", "FORMATTED", "EXTENDED"), explainArgs)

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ private[hive] class HiveQl(conf: ParserConf) extends SparkQl(conf) with Logging
147147
protected val noExplainCommands = Seq(
148148
"TOK_DESCTABLE",
149149
"TOK_SHOWTABLES",
150-
"TOK_TRUNCATETABLE" // truncate table" is a NativeCommand, does not need to explain.
150+
"TOK_TRUNCATETABLE", // truncate table" is a NativeCommand, does not need to explain.
151+
"TOK_ALTERTABLE"
151152
) ++ nativeCommands
152153

153154
/**

0 commit comments

Comments
 (0)