Hello!
I hope this email finds you well. My name is Subin and I am an intern at
Google trying to utilize the Calcite Parser.
In trying to use the parser, I've been a bit struggling on how to leverage
the code in the Calcite code base through java. Essentially, I want to use
Calcite's Sql Parser and use it to parse a query. Below is an attempt that
I've made but it doesn't seem to be working: how should I set up my coding
environment in order to leverage all the code? Should I make the entire
Calcite repo code into a jar file, include it in my directory, and then
import from there?
Let me know what you think. Thank you for your time :)
Best,
Subin
class ParserExample {
public static void main(String[] args) {
String query1 = "SELECT * FROM (SELECT a FROM abc)";
// sets configuration of the parser
SqlParser.Config config = getParserConfig(SqlBabelParserImpl.FACTORY);
SqlParser myParser = SqlParser.create(query1, config);
SqlNode sqlNode = myParser.parseStmt();
SqlString sqlNode.toSqlString(CalciteSqlDialect.DEFAULT);
Syss
}
protected SqlParser.Config getParserConfig(SqlParserImplFactory factory {
return SqlParser.configBuilder()
.setParserFactory(factory)
.setQuotedCasing(Casing.UNCHANGED)
.setUnquotedCasing(Casing.UNCHANGED)
.setQuoting(Quoting.DOUBLE_QUOTE)
.build();
}
}