[ 
https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133328&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133328
 ]

ASF GitHub Bot logged work on BEAM-5106:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 09/Aug/18 22:07
            Start Date: 09/Aug/18 22:07
    Worklog Time Spent: 10m 
      Work Description: amaliujia commented on a change in pull request #6174: 
[BEAM-5106][SQL]test conditional operators and functions at DSL level
URL: https://github.com/apache/beam/pull/6174#discussion_r209094143
 
 

 ##########
 File path: 
sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlDslSqlStdOperatorsTest.java
 ##########
 @@ -1170,4 +1171,32 @@ public void testTimestampMinusInterval() throws 
Exception {
                 parseDate("1983-01-19 01:01:58"));
     checker.buildRunAndCheck();
   }
+
+  @Test
+  @SqlOperatorTest(name = "CASE", kind = "CASE")
+  @SqlOperatorTest(name = "NULLIF", kind = "NULLIF")
+  @SqlOperatorTest(name = "COALESCE", kind = "COALESCE")
+  public void testConditionalOperatorsAndFunctions() {
+    ExpressionChecker checker =
+        new ExpressionChecker()
+            .addExpr("CASE 1 WHEN 1 THEN 'hello' ELSE 'world' END", "hello")
+            .addExpr(
+                "CASE 2 " + "WHEN 1 THEN 'hello' " + "WHEN 3 THEN 'bond' " + 
"ELSE 'world' END",
+                "world")
+            .addExpr(
+                "CASE 3 " + "WHEN 1 THEN 'hello' " + "WHEN 3 THEN 'bond' " + 
"ELSE 'world' END",
+                "bond")
+            .addExpr("CASE " + "WHEN 1 = 1 THEN 'hello' " + "ELSE 'world' 
END", "hello")
+            .addExpr("CASE " + "WHEN 1 > 1 THEN 'hello' " + "ELSE 'world' 
END", "world")
+            .addExpr("NULLIF(5, 4) ", 5)
+            .addExpr("NULLIF(4, 5) ", 4)
+            .addExpr("NULLIF(5, 5)", null, FieldType.INT32)
 
 Review comment:
   It won't work neither because of 
https://github.com/apache/beam/blob/master/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/integrationtest/BeamSqlBuiltinFunctionsIntegrationTestBase.java#L156
   
   
   So `null` cannot call `.getClass` because of NullPointerException even we 
convert it. (Compiler does not buy this conversion).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 133328)
    Time Spent: 2h 50m  (was: 2h 40m)

> Test conditional functions at DSL level
> ---------------------------------------
>
>                 Key: BEAM-5106
>                 URL: https://issues.apache.org/jira/browse/BEAM-5106
>             Project: Beam
>          Issue Type: Sub-task
>          Components: dsl-sql
>            Reporter: Rui Wang
>            Assignee: Rui Wang
>            Priority: Major
>          Time Spent: 2h 50m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to