JiajunBernoulli commented on code in PR #3289:
URL: https://github.com/apache/calcite/pull/3289#discussion_r1287839577
##########
core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java:
##########
@@ -224,6 +224,62 @@ private static boolean skipItem(RexNode expr) {
&& "item".equalsIgnoreCase(((RexCall) expr).getOperator().getName());
}
+ /**
+ * Test case for <a
href="https://issues.apache.org/jira/browse/CALCITE-5813">[CALCITE-5813]
+ * Type inference for REPEAT sql function is incorrect</a>. */
+ @Test void testRepeat() {
+ HepProgramBuilder builder = new HepProgramBuilder();
+ builder.addRuleClass(ReduceExpressionsRule.class);
+ HepPlanner hepPlanner = new HepPlanner(builder.build());
+ hepPlanner.addRule(CoreRules.PROJECT_REDUCE_EXPRESSIONS);
+
+ final String sql = "select REPEAT('abc', 2)";
+ fixture()
+ .withFactory(
+ t -> t.withOperatorTable(opTab ->
+ SqlLibraryOperatorTableFactory.INSTANCE.getOperatorTable(
+ SqlLibrary.BIG_QUERY))) // needed for REPEAT function
+ .sql(sql)
+ .withPlanner(hepPlanner)
+ .check();
+ }
+
+ /**
+ * Test case for <a
href="https://issues.apache.org/jira/browse/CALCITE-5813">[CALCITE-5813]
+ * Type inference for REPLACE sql function is incorrect</a>. */
+ @Test void testReplace() {
+ HepProgramBuilder builder = new HepProgramBuilder();
+ builder.addRuleClass(ReduceExpressionsRule.class);
+ HepPlanner hepPlanner = new HepPlanner(builder.build());
+ hepPlanner.addRule(CoreRules.PROJECT_REDUCE_EXPRESSIONS);
+
+ final String sql = "select REPLACE('abc', 'c', 'cd')";
+ fixture()
+ .sql(sql)
+ .withPlanner(hepPlanner)
+ .check();
+ }
+
+ /**
+ * Test case for <a
href="https://issues.apache.org/jira/browse/CALCITE-5813">[CALCITE-5813]
+ * Type inference for REPEAT sql function is incorrect</a>. */
Review Comment:
The java doc should be `Type inference for sql functions REPEAT, SPACE,
XML_TRANSFORM, and XML_EXTRACT is incorrect.`
##########
core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java:
##########
@@ -224,6 +224,63 @@ private static boolean skipItem(RexNode expr) {
&& "item".equalsIgnoreCase(((RexCall) expr).getOperator().getName());
}
+ /**
+ * Test case for <a
href="https://issues.apache.org/jira/browse/CALCITE-5813">[CALCITE-5813]
+ * Type inference for sql functions REPEAT, SPACE, XML_TRANSFORM,
+ * and XML_EXTRACT is incorrect</a>. */
+ @Test void testRepeat() {
+ HepProgramBuilder builder = new HepProgramBuilder();
+ builder.addRuleClass(ReduceExpressionsRule.class);
+ HepPlanner hepPlanner = new HepPlanner(builder.build());
+ hepPlanner.addRule(CoreRules.PROJECT_REDUCE_EXPRESSIONS);
+
+ final String sql = "select REPEAT('abc', 2)";
+ fixture()
+ .withFactory(
+ t -> t.withOperatorTable(opTab ->
+ SqlLibraryOperatorTableFactory.INSTANCE.getOperatorTable(
+ SqlLibrary.BIG_QUERY))) // needed for REPEAT function
+ .sql(sql)
+ .withPlanner(hepPlanner)
+ .check();
+ }
+
+ /**
+ * Test case for <a
href="https://issues.apache.org/jira/browse/CALCITE-5813">[CALCITE-5813]
+ * Type inference for REPLACE sql function is incorrect</a>. */
Review Comment:
The java doc should be `Type inference for sql functions REPEAT, SPACE,
XML_TRANSFORM, and XML_EXTRACT is incorrect.`
--
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]