jaystarshot commented on a change in pull request #2598:
URL: https://github.com/apache/calcite/pull/2598#discussion_r743262177



##########
File path: 
core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
##########
@@ -7202,6 +7218,41 @@ void assertSubFunReturns(boolean binary, String s, int 
start,
         "nvl(CAST(NULL AS VARCHAR(6)), cast(NULL AS VARCHAR(4)))");
   }
 
+
+  private RelNode transformSqlToRel(String sql) throws Exception {
+    final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
+    final SchemaPlus defSchema = rootSchema.add("hr", new HrClusteredSchema());
+    final FrameworkConfig config = Frameworks.newConfigBuilder()
+        .parserConfig(SqlParser.Config.DEFAULT)
+        .defaultSchema(defSchema)
+        .traitDefs(ConventionTraitDef.INSTANCE, RelCollationTraitDef.INSTANCE)
+        .operatorTable(SqlLibraryOperatorTableFactory.INSTANCE
+            .getOperatorTable(SqlLibrary.STANDARD, SqlLibrary.ORACLE))
+        .build();
+    Planner planner = Frameworks.getPlanner(config);
+    SqlNode parse = planner.parse(sql);
+    SqlNode validate = planner.validate(parse);
+    RelRoot planRoot = planner.rel(validate);
+    return planRoot.rel;
+
+  }
+
+  @Test public void testNvlOperands() throws Exception {

Review comment:
       The testNvlFunc tests the function output and not the operands, same 
with .iq tests. Am I missing something?

##########
File path: 
core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
##########
@@ -7202,6 +7218,41 @@ void assertSubFunReturns(boolean binary, String s, int 
start,
         "nvl(CAST(NULL AS VARCHAR(6)), cast(NULL AS VARCHAR(4)))");
   }
 
+
+  private RelNode transformSqlToRel(String sql) throws Exception {
+    final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
+    final SchemaPlus defSchema = rootSchema.add("hr", new HrClusteredSchema());
+    final FrameworkConfig config = Frameworks.newConfigBuilder()
+        .parserConfig(SqlParser.Config.DEFAULT)
+        .defaultSchema(defSchema)
+        .traitDefs(ConventionTraitDef.INSTANCE, RelCollationTraitDef.INSTANCE)
+        .operatorTable(SqlLibraryOperatorTableFactory.INSTANCE
+            .getOperatorTable(SqlLibrary.STANDARD, SqlLibrary.ORACLE))
+        .build();
+    Planner planner = Frameworks.getPlanner(config);
+    SqlNode parse = planner.parse(sql);
+    SqlNode validate = planner.validate(parse);
+    RelRoot planRoot = planner.rel(validate);
+    return planRoot.rel;
+
+  }
+
+  @Test public void testNvlOperands() throws Exception {

Review comment:
       @NobiGo The testNvlFunc tests the function output and not the operands, 
same with .iq tests. Am I missing something?

##########
File path: 
core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
##########
@@ -7202,6 +7218,41 @@ void assertSubFunReturns(boolean binary, String s, int 
start,
         "nvl(CAST(NULL AS VARCHAR(6)), cast(NULL AS VARCHAR(4)))");
   }
 
+
+  private RelNode transformSqlToRel(String sql) throws Exception {
+    final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
+    final SchemaPlus defSchema = rootSchema.add("hr", new HrClusteredSchema());
+    final FrameworkConfig config = Frameworks.newConfigBuilder()
+        .parserConfig(SqlParser.Config.DEFAULT)
+        .defaultSchema(defSchema)
+        .traitDefs(ConventionTraitDef.INSTANCE, RelCollationTraitDef.INSTANCE)
+        .operatorTable(SqlLibraryOperatorTableFactory.INSTANCE
+            .getOperatorTable(SqlLibrary.STANDARD, SqlLibrary.ORACLE))
+        .build();
+    Planner planner = Frameworks.getPlanner(config);
+    SqlNode parse = planner.parse(sql);
+    SqlNode validate = planner.validate(parse);
+    RelRoot planRoot = planner.rel(validate);
+    return planRoot.rel;
+
+  }
+
+  @Test public void testNvlOperands() throws Exception {

Review comment:
       Thanks @NobiGo. I am new here so when I run the tests in a .iq file I 
get 
   `No match found for function signature NVL(<CHARACTER>, <CHARACTER>)` . I 
guess its because NVl is supported only for Oracle Operator Tables. Is there a 
way to load it in the .iq tests?

##########
File path: 
core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
##########
@@ -7202,6 +7218,41 @@ void assertSubFunReturns(boolean binary, String s, int 
start,
         "nvl(CAST(NULL AS VARCHAR(6)), cast(NULL AS VARCHAR(4)))");
   }
 
+
+  private RelNode transformSqlToRel(String sql) throws Exception {
+    final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
+    final SchemaPlus defSchema = rootSchema.add("hr", new HrClusteredSchema());
+    final FrameworkConfig config = Frameworks.newConfigBuilder()
+        .parserConfig(SqlParser.Config.DEFAULT)
+        .defaultSchema(defSchema)
+        .traitDefs(ConventionTraitDef.INSTANCE, RelCollationTraitDef.INSTANCE)
+        .operatorTable(SqlLibraryOperatorTableFactory.INSTANCE
+            .getOperatorTable(SqlLibrary.STANDARD, SqlLibrary.ORACLE))
+        .build();
+    Planner planner = Frameworks.getPlanner(config);
+    SqlNode parse = planner.parse(sql);
+    SqlNode validate = planner.validate(parse);
+    RelRoot planRoot = planner.rel(validate);
+    return planRoot.rel;
+
+  }
+
+  @Test public void testNvlOperands() throws Exception {

Review comment:
       I tried to change org/apache/calcite/prepare/CalcitePrepareImpl.java:721 
and added  oracle operators there, 
   ```
   final SqlOperatorTable opTab0 =
       context.config().fun(SqlOperatorTable.class,
           SqlLibraryOperatorTableFactory.INSTANCE
               .getOperatorTable(SqlLibrary.STANDARD, SqlLibrary.ORACLE));
   ```
   But i think we just want it configured for the Quidem tests and not in 
general.
    

##########
File path: 
core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
##########
@@ -7202,6 +7218,41 @@ void assertSubFunReturns(boolean binary, String s, int 
start,
         "nvl(CAST(NULL AS VARCHAR(6)), cast(NULL AS VARCHAR(4)))");
   }
 
+
+  private RelNode transformSqlToRel(String sql) throws Exception {
+    final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
+    final SchemaPlus defSchema = rootSchema.add("hr", new HrClusteredSchema());
+    final FrameworkConfig config = Frameworks.newConfigBuilder()
+        .parserConfig(SqlParser.Config.DEFAULT)
+        .defaultSchema(defSchema)
+        .traitDefs(ConventionTraitDef.INSTANCE, RelCollationTraitDef.INSTANCE)
+        .operatorTable(SqlLibraryOperatorTableFactory.INSTANCE
+            .getOperatorTable(SqlLibrary.STANDARD, SqlLibrary.ORACLE))
+        .build();
+    Planner planner = Frameworks.getPlanner(config);
+    SqlNode parse = planner.parse(sql);
+    SqlNode validate = planner.validate(parse);
+    RelRoot planRoot = planner.rel(validate);
+    return planRoot.rel;
+
+  }
+
+  @Test public void testNvlOperands() throws Exception {

Review comment:
       I tried to change org/apache/calcite/prepare/CalcitePrepareImpl.java:721 
and added  oracle operators there and the test works fine
   ```
   final SqlOperatorTable opTab0 =
       context.config().fun(SqlOperatorTable.class,
           SqlLibraryOperatorTableFactory.INSTANCE
               .getOperatorTable(SqlLibrary.STANDARD, SqlLibrary.ORACLE));
   ```
   But i think we just want it configured for the Quidem tests and not in 
general.
    

##########
File path: 
core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
##########
@@ -7202,6 +7218,41 @@ void assertSubFunReturns(boolean binary, String s, int 
start,
         "nvl(CAST(NULL AS VARCHAR(6)), cast(NULL AS VARCHAR(4)))");
   }
 
+
+  private RelNode transformSqlToRel(String sql) throws Exception {
+    final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
+    final SchemaPlus defSchema = rootSchema.add("hr", new HrClusteredSchema());
+    final FrameworkConfig config = Frameworks.newConfigBuilder()
+        .parserConfig(SqlParser.Config.DEFAULT)
+        .defaultSchema(defSchema)
+        .traitDefs(ConventionTraitDef.INSTANCE, RelCollationTraitDef.INSTANCE)
+        .operatorTable(SqlLibraryOperatorTableFactory.INSTANCE
+            .getOperatorTable(SqlLibrary.STANDARD, SqlLibrary.ORACLE))
+        .build();
+    Planner planner = Frameworks.getPlanner(config);
+    SqlNode parse = planner.parse(sql);
+    SqlNode validate = planner.validate(parse);
+    RelRoot planRoot = planner.rel(validate);
+    return planRoot.rel;
+
+  }
+
+  @Test public void testNvlOperands() throws Exception {

Review comment:
       Thanks a lot! Yes I think .iq test is enough as we are able to verify 
the type of the operand using the plan




-- 
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.

To unsubscribe, e-mail: [email protected]

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


Reply via email to