Github user jackylk commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2100#discussion_r177140390
--- Diff:
integration/spark2/src/main/scala/org/apache/spark/sql/parser/CarbonSpark2SqlParser.scala
---
@@ -150,34 +150,39 @@ class CarbonSpark2SqlParser extends
CarbonDDLSqlParser {
*/
protected lazy val createDataMap: Parser[LogicalPlan] =
CREATE ~> DATAMAP ~> opt(IF ~> NOT ~> EXISTS) ~ ident ~
- (ON ~ TABLE) ~ (ident <~ ".").? ~ ident ~
+ opt(ontable) ~
(USING ~> stringLit) ~ (DMPROPERTIES ~> "(" ~> repsep(loadOptions,
",") <~ ")").? ~
(AS ~> restInput).? <~ opt(";") ^^ {
- case ifnotexists ~ dmname ~ ontable ~ dbName ~ tableName ~ className
~ dmprops ~ query =>
+ case ifnotexists ~ dmname ~ tableIdent ~ className ~ dmprops ~ query
=>
+
val map = dmprops.getOrElse(List[(String,
String)]()).toMap[String, String]
- CarbonCreateDataMapCommand(
- dmname, TableIdentifier(tableName, dbName), className, map,
query, ifnotexists.isDefined)
+ CarbonCreateDataMapCommand(dmname, tableIdent, className, map,
query, ifnotexists.isDefined)
+ }
+
+ protected lazy val ontable: Parser[TableIdentifier] =
+ ON ~> TABLE ~> (ident <~ ".").? ~ ident ^^ {
+ case dbName ~ tableName =>
+ TableIdentifier(tableName, dbName)
}
/**
* The below syntax is used to drop the datamap.
* DROP DATAMAP IF EXISTS datamapName ON TABLE tablename
*/
protected lazy val dropDataMap: Parser[LogicalPlan] =
- DROP ~> DATAMAP ~> opt(IF ~> EXISTS) ~ ident ~ (ON ~ TABLE) ~
- (ident <~ ".").? ~ ident <~ opt(";") ^^ {
- case ifexists ~ dmname ~ ontable ~ dbName ~ tableName =>
- CarbonDropDataMapCommand(dmname, ifexists.isDefined, dbName,
tableName)
+ DROP ~> DATAMAP ~> opt(IF ~> EXISTS) ~ ident ~ opt(ontable) <~
opt(";") ^^ {
+ case ifexists ~ dmname ~ tableIdent =>
+ CarbonDropDataMapCommand(dmname, ifexists.isDefined, tableIdent)
}
/**
* The syntax of show datamap is used to show datamaps on the table
* SHOW DATAMAP ON TABLE tableName
--- End diff --
modify this description also: `SHOW DATAMAP [ON TABLE] tableName`
---