carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [34/47] incubator-carbondata git commit: [CARBONDATA-120] Explain extended command for carbon commands (#886)
Date Mon, 01 Aug 2016 10:05:32 GMT
[CARBONDATA-120] Explain extended command for carbon commands (#886)



Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/commit/b3779e46
Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/tree/b3779e46
Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/diff/b3779e46

Branch: refs/heads/master
Commit: b3779e46e43b432613922101d05ab5e21eef40c0
Parents: 935e0d3
Author: nareshpr <prnaresh.naresh@gmail.com>
Authored: Fri Jul 29 00:40:22 2016 +0530
Committer: Venkata Ramana G <g.ramana.v1@gmail.com>
Committed: Fri Jul 29 00:40:22 2016 +0530

----------------------------------------------------------------------
 .../scala/org/apache/spark/sql/CarbonSqlParser.scala | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/b3779e46/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
----------------------------------------------------------------------
diff --git a/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala b/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
index 0fd841d..5c25406 100644
--- a/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
+++ b/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
@@ -32,6 +32,7 @@ import org.apache.spark.sql.catalyst.{SqlLexical, _}
 import org.apache.spark.sql.catalyst.analysis._
 import org.apache.spark.sql.catalyst.plans.logical._
 import org.apache.spark.sql.catalyst.trees.CurrentOrigin
+import org.apache.spark.sql.execution.ExplainCommand
 import org.apache.spark.sql.execution.command.{DimensionRelation, _}
 import org.apache.spark.sql.execution.datasources.DescribeCommand
 import org.apache.spark.sql.hive.HiveQlWrapper
@@ -78,6 +79,7 @@ class CarbonSqlParser()
   protected val DROP = carbonKeyWord("DROP")
   protected val ESCAPECHAR = carbonKeyWord("ESCAPECHAR")
   protected val EXCLUDE = carbonKeyWord("EXCLUDE")
+  protected val EXPLAIN = carbonKeyWord("EXPLAIN")
   protected val EXTENDED = carbonKeyWord("EXTENDED")
   protected val FORMATTED = carbonKeyWord("FORMATTED")
   protected val FACT = carbonKeyWord("FACT")
@@ -199,7 +201,9 @@ class CarbonSqlParser()
   private def carbonKeyWord(keys: String) =
     ("(?i)" + keys).r
 
-  override protected lazy val start: Parser[LogicalPlan] =
+  override protected lazy val start: Parser[LogicalPlan] = explainPlan | startCommand
+
+  protected lazy val startCommand: Parser[LogicalPlan] =
     loadManagement | describeTable | showLoads | alterTable | createTable
 
   protected lazy val loadManagement: Parser[LogicalPlan] = deleteLoadsByID | deleteLoadsByLoadDate
|
@@ -1342,4 +1346,13 @@ class CarbonSqlParser()
       case schemaName ~ cubeName => CleanFiles(schemaName, cubeName.toLowerCase())
     }
 
+  protected lazy val explainPlan: Parser[LogicalPlan] =
+    (EXPLAIN ~> opt(EXTENDED)) ~ startCommand ^^ {
+      case isExtended ~ logicalPlan =>
+        logicalPlan match {
+          case plan: CreateTable => ExplainCommand(logicalPlan, extended = isExtended.isDefined)
+          case _ => ExplainCommand(OneRowRelation)
+      }
+    }
+
 }


Mime
View raw message