Source:
public RelRoot plan(String query) { try { Connection connection = DriverManager.getConnection("jdbc:calcite:"); CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class); SchemaPlus rootSchema = calciteConnection.getRootSchema(); fetchSourceSchema(rootSchema); List<SamzaSqlScalarFunctionImpl> samzaSqlFunctions = udfMetadata.stream() .map(x -> new SamzaSqlScalarFunctionImpl(x)) .collect(Collectors.toList()); final List<RelTraitDef> traitDefs = new ArrayList<>(); traitDefs.add(ConventionTraitDef.INSTANCE); traitDefs.add(RelCollationTraitDef.INSTANCE); List<SqlOperatorTable> sqlOperatorTables = new ArrayList<>(); sqlOperatorTables.add(new SamzaSqlOperatorTable()); sqlOperatorTables.add(new SamzaSqlUdfOperatorTable(samzaSqlFunctions)); FrameworkConfig frameworkConfig = Frameworks.newConfigBuilder() .parserConfig(SqlParser.configBuilder().setLex(Lex.JAVA).setConformance(SqlConformanceEnum.LENIENT).build()) .defaultSchema(rootSchema) .operatorTable(new ChainedSqlOperatorTable(sqlOperatorTables)) .sqlToRelConverterConfig(SqlToRelConverter.Config.DEFAULT) .traitDefs(traitDefs) .context(Contexts.EMPTY_CONTEXT) .costFactory(null) .build(); Planner planner = Frameworks.getPlanner(frameworkConfig); SqlNode sql = planner.parse(query); SqlNode validatedSql = planner.validate(sql); RelRoot relRoot = planner.rel(validatedSql); LOG.info("query plan:\n" + RelOptUtil.toString(relRoot.rel)); return relRoot; } catch (Exception e) { String errorMsg = SamzaSqlValidator.formatErrorString(query, e); LOG.error(errorMsg, e); throw new SamzaException(errorMsg, e); } }

Target:
public RelRoot plan(String query) { try { Connection connection = DriverManager.getConnection("jdbc:calcite:"); CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class); SchemaPlus rootSchema = calciteConnection.getRootSchema(); registerSourceSchemas(rootSchema); List<SamzaSqlScalarFunctionImpl> samzaSqlFunctions = udfMetadata.stream() .map(x -> new SamzaSqlScalarFunctionImpl(x)) .collect(Collectors.toList()); final List<RelTraitDef> traitDefs = new ArrayList<>(); traitDefs.add(ConventionTraitDef.INSTANCE); traitDefs.add(RelCollationTraitDef.INSTANCE); List<SqlOperatorTable> sqlOperatorTables = new ArrayList<>(); sqlOperatorTables.add(new SamzaSqlOperatorTable()); sqlOperatorTables.add(new SamzaSqlUdfOperatorTable(samzaSqlFunctions)); FrameworkConfig frameworkConfig = Frameworks.newConfigBuilder() .parserConfig(SqlParser.configBuilder().setLex(Lex.JAVA).setConformance(SqlConformanceEnum.LENIENT).build()) .defaultSchema(rootSchema) .operatorTable(new ChainedSqlOperatorTable(sqlOperatorTables)) .sqlToRelConverterConfig(SqlToRelConverter.Config.DEFAULT) .traitDefs(traitDefs) .context(Contexts.EMPTY_CONTEXT) .costFactory(null) .build(); Planner planner = Frameworks.getPlanner(frameworkConfig); SqlNode sql = planner.parse(query); SqlNode validatedSql = planner.validate(sql); RelRoot relRoot = planner.rel(validatedSql); LOG.info("query plan:\n" + RelOptUtil.toString(relRoot.rel)); return relRoot; } catch (Exception e) { String errorMsg = SamzaSqlValidator.formatErrorString(query, e); LOG.error(errorMsg, e); throw new SamzaException(errorMsg, e); } }