use of org.apache.calcite.sql.parser.SqlAbstractParserImpl in project flink by apache.
the class CalciteParser method createFlinkParser.
/**
* Equivalent to {@link SqlParser#create(Reader, SqlParser.Config)}. The only difference is we
* do not wrap the {@link FlinkSqlParserImpl} with {@link SqlParser}.
*
* <p>It is so that we can access specific parsing methods not accessible through the {@code
* SqlParser}.
*/
private SqlAbstractParserImpl createFlinkParser(String expr) {
SourceStringReader reader = new SourceStringReader(expr);
SqlAbstractParserImpl parser = config.parserFactory().getParser(reader);
parser.setTabSize(1);
parser.setQuotedCasing(config.quotedCasing());
parser.setUnquotedCasing(config.unquotedCasing());
parser.setIdentifierMaxLength(config.identifierMaxLength());
parser.setConformance(config.conformance());
switch(config.quoting()) {
case DOUBLE_QUOTE:
parser.switchTo(SqlAbstractParserImpl.LexicalState.DQID);
break;
case BACK_TICK:
parser.switchTo(SqlAbstractParserImpl.LexicalState.BTID);
break;
case BRACKET:
parser.switchTo(SqlAbstractParserImpl.LexicalState.DEFAULT);
break;
}
return parser;
}
Aggregations