Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
List TOK_ALTERTABLE as not explanable command.
  • Loading branch information
viirya committed Feb 9, 2016
commit 3db2e1d867b5750eb157c751a303c542bdad110e
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import org.apache.spark.sql.types.StructType

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

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

case Token("TOK_EXPLAIN", explainArgs) =>
case Token("TOK_EXPLAIN", explainArgs) if "TOK_QUERY" == explainArgs.head.text =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not Token("TOK_EXPLAIN", Token("TOK_QUERY", query) :: explainArgs) => ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there other EXPLAIN cases possible?

// Ignore FORMATTED if present.
val Some(query) :: _ :: extended :: Nil =
getClauses(Seq("TOK_QUERY", "FORMATTED", "EXTENDED"), explainArgs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,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

/**
Expand Down