xiangfu0 commented on code in PR #17939:
URL: https://github.com/apache/pinot/pull/17939#discussion_r4147716059
##########
pinot-common/src/main/codegen/includes/parserImpls.ftl:
##########
@@ -45,30 +45,79 @@ SqlNodeList DataFileDefList() :
}
}
+/// Parses a single VALUES row: (expr, expr, ...)
+private SqlNodeList ValuesRow() :
+{
+ SqlParserPos pos;
+ List<SqlNode> list = new ArrayList<SqlNode>();
+ SqlNode e;
+}
+{
+ <LPAREN> { pos = getPos(); }
+ e = Expression(ExprContext.ACCEPT_NON_QUERY) { list.add(e); }
+ ( <COMMA> e = Expression(ExprContext.ACCEPT_NON_QUERY) { list.add(e); } )*
+ <RPAREN>
+ {
+ return new SqlNodeList(list, pos.plus(getPos()));
+ }
+}
+
/// INSERT INTO [db_name.]table_name
-/// FROM [ FILE | ARCHIVE ] 'file_uri' [, [ FILE | ARCHIVE ] 'file_uri' ]
-SqlInsertFromFile SqlInsertFromFile() :
+/// FROM [ FILE | ARCHIVE ] 'file_uri' [, [ FILE | ARCHIVE ] 'file_uri' ]
+///
+/// INSERT INTO [db_name.]table_name [(col1, col2, ...)]
+/// VALUES (val1, val2, ...) [, (val1, val2, ...)]
+SqlNode SqlInsertStatement() :
{
SqlParserPos pos;
SqlIdentifier dbName = null;
SqlIdentifier tableName;
SqlNodeList fileList = null;
+ SqlNodeList columnList = null;
+ List<SqlNodeList> valuesList = null;
+ SqlNodeList row;
}
{
<INSERT> { pos = getPos(); }
<INTO>
[
+ LOOKAHEAD(2)
dbName = SimpleIdentifier()
<DOT>
]
tableName = SimpleIdentifier()
- [
+ (
+ // INSERT INTO t VALUES (...) without an explicit column list is not
supported.
+ // The parser rejects this shape immediately rather than building a
SqlNode that
+ // InsertIntoValues.parse would then reject — keeps error messages at
parse time.
+ LOOKAHEAD(<LPAREN>)
+ <LPAREN>
+ {
+ List<SqlNode> cols = new ArrayList<SqlNode>();
+ SqlParserPos colPos = getPos();
+ }
+ {
+ cols.add(SimpleIdentifier());
+ }
+ ( <COMMA> { cols.add(SimpleIdentifier()); } )*
+ <RPAREN>
+ <VALUES>
+ {
+ columnList = new SqlNodeList(cols, colPos.plus(getPos()));
+ valuesList = new ArrayList<SqlNodeList>();
+ }
+ row = ValuesRow() { valuesList.add(row); }
+ ( <COMMA> row = ValuesRow() { valuesList.add(row); } )*
+ {
+ return new SqlInsertIntoValues(pos, dbName, tableName, columnList,
valuesList);
+ }
+ |
fileList = DataFileDefList()
Review Comment:
The PR description now has a Grammar compatibility section explicitly
documenting this deliberate parse-time rejection. Valid VALUES and file-source
forms are retained; bare INSERT INTO t no longer creates a null-file-list
statement that fails only during execution.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]