You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/06/11 08:25:49 UTC

[GitHub] [flink] wuchong commented on a change in pull request #8626: [FLINK-12742] Add insert into partition grammar as hive dialect

wuchong commented on a change in pull request #8626: [FLINK-12742] Add insert into partition grammar as hive dialect
URL: https://github.com/apache/flink/pull/8626#discussion_r292334900
 
 

 ##########
 File path: flink-table/flink-sql-parser/src/main/codegen/includes/parserImpls.ftl
 ##########
 @@ -236,6 +236,89 @@ SqlDrop SqlDropTable(Span s, boolean replace) :
     }
 }
 
+/**
+* Parses an INSERT statement.
+*/
+SqlNode RichSqlInsert() :
+{
+    final List<SqlLiteral> keywords = new ArrayList<SqlLiteral>();
+    final SqlNodeList keywordList;
+    SqlNode table;
+    SqlNodeList extendList = null;
+    SqlNode source;
+    final SqlNodeList partitionList = new SqlNodeList(getPos());
+    SqlNodeList columnList = null;
+    final Span s;
+}
+{
+    (
+        <INSERT>
+    |
+        <UPSERT> { keywords.add(SqlInsertKeyword.UPSERT.symbol(getPos())); }
+    )
+    { s = span(); }
+    SqlInsertKeywords(keywords) {
+        keywordList = new SqlNodeList(keywords, s.addAll(keywords).pos());
+    }
+    <INTO> table = CompoundIdentifier()
+    [
+        LOOKAHEAD(5)
+        [ <EXTEND> ]
+        extendList = ExtendList() {
+            table = extend(table, extendList);
+        }
+    ]
+    [
+        LOOKAHEAD(2)
+        { final Pair<SqlNodeList, SqlNodeList> p; }
+        p = ParenthesizedCompoundIdentifierList() {
+            if (p.right.size() > 0) {
+                table = extend(table, p.right);
+            }
+            if (p.left.size() > 0) {
+                columnList = p.left;
+            }
+        }
+    ]
+    [
+        <PARTITION> PartitionSpecCommaList(partitionList) {
+            if (this.conformance != FlinkSqlConformance.HIVE) {
 
 Review comment:
   I think we should add a method to `SqlConformance` such as `isInsertPartitionAllowed`. And use the method here instead of hard code a specific HIVE dialect. In this way, we can extend other dialect which also supports insert partition.

----------------------------------------------------------------
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