@Override public Connection connect(String url, Properties info) throws SQLException { if (!acceptsURL(url)) { return null; } final String prefix = getConnectStringPrefix(); assert url.startsWith(prefix); final String urlSuffix = url.substring(prefix.length()); final Properties info2 = ConnectStringParser.parse(urlSuffix, info); final AvaticaConnection connection = ((CalciteFactory) factory).newConnection(this, factory, url, info2, null, typeFactory); handler.onConnectionInit(connection); return connection; } }
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); }
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); }
@Override public Connection connect(String url, Properties info) throws SQLException { if (!acceptsURL(url)) { return null; } final String prefix = getConnectStringPrefix(); assert url.startsWith(prefix); final String urlSuffix = url.substring(prefix.length()); final Properties info2 = ConnectStringParser.parse(urlSuffix, info); final AvaticaConnection connection = ((CalciteFactory) factory).newConnection(this, factory, url, info2, null, typeFactory); handler.onConnectionInit(connection); return connection; } }