KurtYoung 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_r292249140
########## 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) { + throw new ParseException("PARTITION expression encountered in illegal context"); Review comment: Need a cleaner error message ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services