use of org.apache.samza.sql.interfaces.SamzaSqlDriver in project samza by apache.
the class SamzaSqlQueryParser method createPlanner.
private static Planner createPlanner() {
Connection connection;
SchemaPlus rootSchema;
try {
JavaTypeFactory typeFactory = new SamzaSqlJavaTypeFactoryImpl();
SamzaSqlDriver driver = new SamzaSqlDriver(typeFactory);
DriverManager.deregisterDriver(DriverManager.getDriver("jdbc:calcite:"));
DriverManager.registerDriver(driver);
connection = driver.connect("jdbc:calcite:", new Properties());
CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
rootSchema = calciteConnection.getRootSchema();
} catch (SQLException e) {
throw new SamzaException(e);
}
final List<RelTraitDef> traitDefs = new ArrayList<>();
traitDefs.add(ConventionTraitDef.INSTANCE);
traitDefs.add(RelCollationTraitDef.INSTANCE);
FrameworkConfig frameworkConfig = Frameworks.newConfigBuilder().parserConfig(SqlParser.configBuilder().setLex(Lex.JAVA).build()).defaultSchema(rootSchema).operatorTable(SqlStdOperatorTable.instance()).traitDefs(traitDefs).context(Contexts.EMPTY_CONTEXT).costFactory(null).build();
return Frameworks.getPlanner(frameworkConfig);
}
Aggregations