drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [drill] vvysotskyi commented on a change in pull request #1850: DRILL-7168: Implement ALTER SCHEMA ADD / REMOVE commands
Date Sat, 07 Sep 2019 17:47:04 GMT
vvysotskyi commented on a change in pull request #1850: DRILL-7168: Implement ALTER SCHEMA
ADD / REMOVE commands
URL: https://github.com/apache/drill/pull/1850#discussion_r321977051
 
 

 ##########
 File path: exec/java-exec/src/main/codegen/includes/parserImpls.ftl
 ##########
 @@ -534,6 +534,110 @@ SqlNode SqlDescribeSchema() :
    )
 }
 
+/**
+* Parses ALTER SCHEMA statements:
+*
+* ALTER SCHEMA
+* (FOR TABLE dfs.tmp.nation | PATH '/tmp/schema.json')
+* ADD [OR REPLACE]
+* [COLUMNS (col1 int, col2 varchar)]
+* [PROPERTIES ('prop1'='val1', 'prop2'='val2')]
+*
+* ALTER SCHEMA
+* (FOR TABLE dfs.tmp.nation | PATH '/tmp/schema.json')
+* REMOVE
+* [COLUMNS (`col1`, `col2`)]
+* [PROPERTIES ('prop1', 'prop2')]
+*/
+SqlNode SqlAlterSchema() :
+{
+   SqlParserPos pos;
+   SqlIdentifier table = null;
+   SqlNode path = null;
+}
+{
+   <ALTER> { pos = getPos(); }
+   <SCHEMA>
+    (
+        <FOR> <TABLE> { table = CompoundIdentifier(); }
+        |
+        <PATH> { path = StringLiteral(); }
+    )
+    (
+        <ADD> { return SqlAlterSchemaAdd(pos, table, path); }
+        |
+        <REMOVE> { return SqlAlterSchemaRemove(pos, table, path); }
+    )
+}
+
+SqlNode SqlAlterSchemaAdd(SqlParserPos pos, SqlIdentifier table, SqlNode path) :
+{
+   boolean replace = false;
+   SqlCharStringLiteral schema = null;
+   SqlNodeList properties = null;
+}
+{
+   [ <OR> <REPLACE> { replace = true; } ]
+   [ <COLUMNS> { schema = ParseSchema(); } ]
+   [
+       <PROPERTIES> <LPAREN>
+        {
+             properties = new SqlNodeList(getPos());
+             addProperty(properties);
+        }
+        (
+             <COMMA> { addProperty(properties); }
+        )*
+        <RPAREN>
+   ]
+   {
+        if (schema == null && properties == null) {
+             throw new ParseException("ALTER SCHEMA ADD command must have at least <COLUMNS>
or <PROPERTIES> keyword indicated.");
+        }
+        return new SqlSchema.Add(pos, table, path, SqlLiteral.createBoolean(replace, getPos()),
schema, properties);
+   }
+}
+
+SqlCharStringLiteral ParseSchema() :
 
 Review comment:
   Is it possible to reuse this code in `SqlCreateSchema`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message