org.apache.calcite.util.SourceStringReader Java Examples
The following examples show how to use
org.apache.calcite.util.SourceStringReader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CalciteParser.java From flink with Apache License 2.0 | 7 votes |
/** * 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 FlinkSqlParserImpl createFlinkParser(String expr) { SourceStringReader reader = new SourceStringReader(expr); FlinkSqlParserImpl parser = (FlinkSqlParserImpl) 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("DQID"); break; case BACK_TICK: parser.switchTo("BTID"); break; case BRACKET: parser.switchTo("DEFAULT"); break; } return parser; }
Example #2
Source File: CalciteParser.java From flink with Apache License 2.0 | 6 votes |
/** * 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("DQID"); break; case BACK_TICK: parser.switchTo("BTID"); break; case BRACKET: parser.switchTo("DEFAULT"); break; } return parser; }
Example #3
Source File: TableApiIdentifierParsingTest.java From flink with Apache License 2.0 | 5 votes |
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("BTID"); return parser; }
Example #4
Source File: FlinkDDLDataTypeTest.java From flink with Apache License 2.0 | 4 votes |
public SqlParser createParser(String sql) { return SqlParser.create(new SourceStringReader(sql), parserConfig); }
Example #5
Source File: SqlTestFactory.java From calcite with Apache License 2.0 | 4 votes |
public SqlParser createParser(String sql) { return SqlParser.create(new SourceStringReader(sql), parserConfig.get()); }
Example #6
Source File: SqlParser.java From Bats with Apache License 2.0 | 2 votes |
/** * Creates a <code>SqlParser</code> to parse the given string using the * parser implementation created from given {@link SqlParserImplFactory} * with given quoting syntax and casing policies for identifiers. * * @param sql A SQL statement or expression to parse * @param config The parser configuration (identifier max length, etc.) * @return A parser */ public static SqlParser create(String sql, Config config) { return create(new SourceStringReader(sql), config); }
Example #7
Source File: SqlParser.java From calcite with Apache License 2.0 | 2 votes |
/** * Creates a <code>SqlParser</code> to parse the given string using the * parser implementation created from given {@link SqlParserImplFactory} * with given quoting syntax and casing policies for identifiers. * * @param sql A SQL statement or expression to parse * @param config The parser configuration (identifier max length, etc.) * @return A parser */ public static SqlParser create(String sql, Config config) { return create(new SourceStringReader(sql), config); }
Example #8
Source File: Planner.java From calcite with Apache License 2.0 | 2 votes |
/** * Parses and validates a SQL statement. * * @param sql The SQL statement to parse. * @return The root node of the SQL parse tree. * @throws org.apache.calcite.sql.parser.SqlParseException on parse error */ default SqlNode parse(String sql) throws SqlParseException { return parse(new SourceStringReader(sql)); }