chunweilei commented on a change in pull request #1138: [CALCITE-1581] UDTF
like in hive
URL: https://github.com/apache/calcite/pull/1138#discussion_r314560079
##########
File path: core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
##########
@@ -11135,6 +11135,35 @@ private void checkCustomColumnResolving(String table)
{
}
}
+ @Test public void testTableFunction() {
+ tester = tester.withConformance(SqlConformance.HIVE);
+ sql("select n,c from (select TABLE_FUNC(1) as (n,c) from emp)")
+ .ok();
+ sql("select char_length(c)*2 from"
+ + " (select TABLE_FUNC(1) as (n,c) from emp) where char_length(c) >
1")
+ .ok();
+ sql("select char_length(c)*2, f0 from"
+ + " (select 1 as f0, TABLE_FUNC(1) as (n,c) from emp) where
char_length(c) > 1")
+ .ok();
+ sql("select TABLE_FUNC(1) as (n,c)")
+ .ok();
+
+ sql("select ^test_udf('1')^ as (n,c) from emp")
+ .fails("'TEST_UDF' should be a table function");
+
+ sql("^select TABLE_FUNC(1) as (n1,c1), TABLE_FUNC(2)^ as (n2,c2) from emp")
+ .fails("Only one table function is allowed in select list");
+
+ sql("select ^TABLE_FUNC(1)^ as (n1,c1) , count(1) from emp having count(1)
> 0")
+ .fails("Table function is not allowed in aggregate statement");
+
+ sql("select ^TABLE_FUNC(1)^ as (n1,c1) from emp group by empno")
+ .fails("Table function is not allowed in aggregate statement");
+
+ tester = tester.withConformance(SqlConformance.DEFAULT);
Review comment:
Could you please add some negative test case?
----------------------------------------------------------------
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]
With regards,
Apache Git Services