[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133132&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133132 ]
ASF GitHub Bot logged work on BEAM-5106: ---------------------------------------- Author: ASF GitHub Bot Created on: 09/Aug/18 18:30 Start Date: 09/Aug/18 18:30 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_r209034500 ########## File path: sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlDslSqlStdOperatorsTest.java ########## @@ -794,4 +794,33 @@ 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) + // Cannot assign null here to test NULLIF(5, 5), which is expected to return NULL. + // .addExpr("NULLIF(5, 5)", null) Review comment: Because addExpr needs a result type to build a schema. However, we don't have NULL type in `FieldType`, and NULL shouldn't be a type. See https://github.com/apache/beam/blob/master/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/integrationtest/BeamSqlBuiltinFunctionsIntegrationTestBase.java#L179 and https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/Schema.java#L399 ---------------------------------------------------------------- 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 133132) Time Spent: 1h 10m (was: 1h) > 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: 1h 10m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)