b-slim commented on a change in pull request #1386:
URL: https://github.com/apache/samza/pull/1386#discussion_r457602488



##########
File path: 
samza-sql/src/main/java/org/apache/samza/sql/planner/QueryPlanner.java
##########
@@ -110,46 +114,50 @@ private void registerSourceSchemas(SchemaPlus rootSchema) 
{
   }
 
   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));
-
-      // Using lenient so that !=,%,- are allowed.
-      FrameworkConfig frameworkConfig = Frameworks.newConfigBuilder()
-          .parserConfig(SqlParser.configBuilder()
-              .setLex(Lex.JAVA)
-              .setConformance(SqlConformanceEnum.LENIENT)
-              .setCaseSensitive(false) // Make Udfs case insensitive
-              .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);
-
+    SchemaPlus rootSchema = CalciteSchema.createRootSchema(true, false).plus();

Review comment:
       We do not need caching, it is a historic optimization flag that most of 
cases not really needed because schema changes all the time. In fact that is 
the default in Calcite.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to