ritesh-kapoor commented on a change in pull request #1755: CALCITE-3731 : Add
IF function for BigQuery, Hive and Spark Dialects
URL: https://github.com/apache/calcite/pull/1755#discussion_r365859669
##########
File path:
core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
##########
@@ -4504,6 +4504,27 @@ private void checkNullOperand(SqlTester tester, String
op) {
testerMysql.checkNull("reverse(cast(null as varchar(1)))");
}
+ @Test public void testIfFunc() {
+ final SqlTester testerBigQuery = tester(SqlLibrary.BIGQUERY);
+ testerBigQuery.setFor(SqlLibraryOperators.IF);
+ testerBigQuery.checkString("if(1 = 2, 1, 2)", "2", "INTEGER NOT NULL");
+ testerBigQuery.checkString("if('abc'='xyz', 'abc', 'xyz')", "xyz",
"CHAR(3) NOT NULL");
+ testerBigQuery.checkString("if(substring('abc',1,2)='ab', 'abc', 'xyz')",
"abc", "CHAR(3) NOT"
+ + " NULL");
+ final SqlTester testerHive = tester(SqlLibrary.HIVE);
+ testerHive.setFor(SqlLibraryOperators.IF);
+ testerHive.checkString("if(1 = 2, 1, 2)", "2", "INTEGER NOT NULL");
Review comment:
It would be great to have test cases with null values
----------------------------------------------------------------
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