use of org.apache.calcite.util.SourceStringReader 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;
}
use of org.apache.calcite.util.SourceStringReader in project flink by apache.
the class TableApiIdentifierParsingTest method createFlinkParser.
private FlinkSqlParserImpl createFlinkParser(String expr) {
SourceStringReader reader = new SourceStringReader(expr);
FlinkSqlParserImpl parser = (FlinkSqlParserImpl) FlinkSqlParserImpl.FACTORY.getParser(reader);
parser.setTabSize(1);
parser.setUnquotedCasing(Lex.JAVA.unquotedCasing);
parser.setQuotedCasing(Lex.JAVA.quotedCasing);
parser.setIdentifierMaxLength(256);
parser.setConformance(FlinkSqlConformance.DEFAULT);
parser.switchTo(SqlAbstractParserImpl.LexicalState.BTID);
return parser;
}
Aggregations