[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133797=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133797 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 10/Aug/18 20:06 Start Date: 10/Aug/18 20:06 Worklog Time Spent: 10m Work Description: akedin commented on issue #6174: [BEAM-5106][SQL]test conditional operators and functions at DSL level URL: https://github.com/apache/beam/pull/6174#issuecomment-412191599 LGTM 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: 133797) Time Spent: 4h (was: 3h 50m) > 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: 4h > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133798=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133798 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 10/Aug/18 20:06 Start Date: 10/Aug/18 20:06 Worklog Time Spent: 10m Work Description: akedin closed pull request #6174: [BEAM-5106][SQL]test conditional operators and functions at DSL level URL: https://github.com/apache/beam/pull/6174 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlDslSqlStdOperatorsTest.java b/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlDslSqlStdOperatorsTest.java index 201059e92b4..f969f734af0 100644 --- a/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlDslSqlStdOperatorsTest.java +++ b/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlDslSqlStdOperatorsTest.java @@ -43,6 +43,7 @@ import java.util.stream.Collectors; import org.apache.beam.sdk.extensions.sql.integrationtest.BeamSqlBuiltinFunctionsIntegrationTestBase; import org.apache.beam.sdk.schemas.Schema; +import org.apache.beam.sdk.schemas.Schema.FieldType; import org.apache.calcite.runtime.SqlFunctions; import org.apache.calcite.sql.SqlKind; import org.apache.calcite.sql.SqlOperator; @@ -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) +.addExpr("COALESCE(1, 5) ", 1) +.addExpr("COALESCE(NULL, 5) ", 5) +.addExpr("COALESCE(NULL, 4, 5) ", 4) +.addExpr("COALESCE(NULL, NULL, 5) ", 5) +.addExpr("COALESCE(5, NULL) ", 5); + +checker.buildRunAndCheck(); + } } diff --git a/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/integrationtest/BeamSqlBuiltinFunctionsIntegrationTestBase.java b/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/integrationtest/BeamSqlBuiltinFunctionsIntegrationTestBase.java index 4380b0b7241..8ba5374ec8b 100644 --- a/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/integrationtest/BeamSqlBuiltinFunctionsIntegrationTestBase.java +++ b/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/integrationtest/BeamSqlBuiltinFunctionsIntegrationTestBase.java @@ -30,6 +30,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import javax.annotation.Nullable; import org.apache.beam.sdk.Pipeline; import org.apache.beam.sdk.extensions.sql.SqlTransform; import org.apache.beam.sdk.extensions.sql.TestUtils; @@ -128,6 +129,7 @@ private static ExpressionTestCase of( abstract String sqlExpr(); +@Nullable abstract Object expectedResult(); abstract FieldType resultFieldType(); @@ -176,7 +178,13 @@ public void buildRunAndCheck() { String expression = testCase.sqlExpr(); Object expectedValue = testCase.expectedResult(); String sql = String.format("SELECT %s FROM PCOLLECTION", expression); -Schema schema = Schema.builder().addField(expression, testCase.resultFieldType()).build(); +Schema schema; +if (expectedValue == null) { + schema = + Schema.builder().addNullableField(expression, testCase.resultFieldType()).build(); +} else { + schema = Schema.builder().addField(expression, testCase.resultFieldType()).build(); +} PCollection output =
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133398=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133398 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 09/Aug/18 23:42 Start Date: 09/Aug/18 23:42 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). That's why I am passing in a FieldType. 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: 133398) Time Spent: 3h 50m (was: 3h 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: 3h 50m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133396=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133396 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 09/Aug/18 23:40 Start Date: 09/Aug/18 23:40 Worklog Time Spent: 10m Work Description: amaliujia commented on issue #6174: [BEAM-5106][SQL]test conditional operators and functions at DSL level URL: https://github.com/apache/beam/pull/6174#issuecomment-411931452 Run Java PreCommit 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: 133396) Time Spent: 3.5h (was: 3h 20m) > 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: 3.5h > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133397=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133397 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 09/Aug/18 23:40 Start Date: 09/Aug/18 23:40 Worklog Time Spent: 10m Work Description: amaliujia removed a comment on issue #6174: [BEAM-5106][SQL]test conditional operators and functions at DSL level URL: https://github.com/apache/beam/pull/6174#issuecomment-411931452 Run Java PreCommit 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: 133397) Time Spent: 3h 40m (was: 3.5h) > 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: 3h 40m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=17=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-17 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 09/Aug/18 22:17 Start Date: 09/Aug/18 22:17 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_r209096193 ## 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: I could probably add a check for NULL before `expectedValue.getClass()` though. 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: 17) Time Spent: 3h 20m (was: 3h 10m) > 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: 3h 20m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133329=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133329 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 09/Aug/18 22:08 Start Date: 09/Aug/18 22:08 Worklog Time Spent: 10m Work Description: amaliujia commented on issue #6174: [BEAM-5106][SQL]test conditional operators and functions at DSL level URL: https://github.com/apache/beam/pull/6174#issuecomment-411913712 java run precommit 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: 133329) Time Spent: 3h (was: 2h 50m) > 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: 3h > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=10=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-10 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 09/Aug/18 22:08 Start Date: 09/Aug/18 22:08 Worklog Time Spent: 10m Work Description: amaliujia removed a comment on issue #6174: [BEAM-5106][SQL]test conditional operators and functions at DSL level URL: https://github.com/apache/beam/pull/6174#issuecomment-411913712 java run precommit 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: 10) Time Spent: 3h 10m (was: 3h) > 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: 3h 10m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133328=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: us...@infra.apache.org 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)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133319=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133319 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 09/Aug/18 21:54 Start Date: 09/Aug/18 21:54 Worklog Time Spent: 10m Work Description: akedin 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_r209091180 ## 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: I don't think I understand. If you mark the `expected` param of the `addExpr` as `@Nullable`, then you can have: ``` new ExpressionChecker() .addExpr("expr", (Integer) null) ``` 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: 133319) Time Spent: 2h 40m (was: 2.5h) > 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 40m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133207=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133207 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 09/Aug/18 19:55 Start Date: 09/Aug/18 19:55 Worklog Time Spent: 10m Work Description: amaliujia commented on issue #6174: [BEAM-5106][SQL]test conditional operators and functions at DSL level URL: https://github.com/apache/beam/pull/6174#issuecomment-411877387 run java precommit 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: 133207) Time Spent: 2h 20m (was: 2h 10m) > 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 20m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133208=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133208 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 09/Aug/18 19:55 Start Date: 09/Aug/18 19:55 Worklog Time Spent: 10m Work Description: amaliujia removed a comment on issue #6174: [BEAM-5106][SQL]test conditional operators and functions at DSL level URL: https://github.com/apache/beam/pull/6174#issuecomment-411877387 run java precommit 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: 133208) Time Spent: 2.5h (was: 2h 20m) > 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: 2.5h > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133206=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133206 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 09/Aug/18 19:55 Start Date: 09/Aug/18 19:55 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_r209058332 ## 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: The AutoValue tool we are using will generate code like this without `@Nullable`: ``` if (expectedResult == null) { throw new NullPointerException("Null expectedResult"); } ``` So any conversion won't pass this null check. Also, if without ``` if (expectedValue == null) { schema = Schema.builder().addNullableField(expression, testCase.resultFieldType()).build(); } else { schema = Schema.builder().addField(expression, testCase.resultFieldType()).build(); } ``` `Row` will also fail this code, see https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/values/Row.java#L402 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: 133206) Time Spent: 2h 10m (was: 2h) > 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 10m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133205=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133205 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 09/Aug/18 19:54 Start Date: 09/Aug/18 19:54 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_r209058332 ## 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: The AutoValue tool we are using will generate code like this without `@Nullable`: ``` if (expectedResult == null) { throw new NullPointerException("Null expectedResult"); } ``` So any conversion won't pass this null check. Also, if without ``` if (expectedValue == null) { schema = Schema.builder().addNullableField(expression, testCase.resultFieldType()).build(); } else { schema = Schema.builder().addField(expression, testCase.resultFieldType()).build(); } ```, `Row` will also fail this code, see https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/values/Row.java#L402 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: 133205) Time Spent: 2h (was: 1h 50m) > 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 > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133187=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133187 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 09/Aug/18 19:22 Start Date: 09/Aug/18 19:22 Worklog Time Spent: 10m Work Description: akedin 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_r209049827 ## 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: Wouldn't `(Integer) null` work? 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: 133187) Time Spent: 1h 50m (was: 1h 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: 1h 50m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133185=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133185 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 09/Aug/18 19:20 Start Date: 09/Aug/18 19:20 Worklog Time Spent: 10m Work Description: amaliujia commented on issue #6174: [BEAM-5106][SQL]test conditional operators and functions at DSL level URL: https://github.com/apache/beam/pull/6174#issuecomment-411867776 run java precommit 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: 133185) Time Spent: 1.5h (was: 1h 20m) > 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: 1.5h > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133186=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133186 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 09/Aug/18 19:20 Start Date: 09/Aug/18 19:20 Worklog Time Spent: 10m Work Description: amaliujia removed a comment on issue #6174: [BEAM-5106][SQL]test conditional operators and functions at DSL level URL: https://github.com/apache/beam/pull/6174#issuecomment-411867776 run java precommit 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: 133186) Time Spent: 1h 40m (was: 1.5h) > 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 40m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133135=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133135 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 09/Aug/18 18:33 Start Date: 09/Aug/18 18:33 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_r209035403 ## 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: O actually I am probably wrong. I can add a specific type with NULL value. Trying this idea. 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: 133135) Time Spent: 1h 20m (was: 1h 10m) > 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 20m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133130=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133130 ] 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`. I am also not sure if NULL count as 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: 133130) Time Spent: 50m (was: 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: 50m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133132=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)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=133131=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-133131 ] 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`. 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: 133131) Time Spent: 1h (was: 50m) > 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 > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=132705=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-132705 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 08/Aug/18 22:05 Start Date: 08/Aug/18 22:05 Worklog Time Spent: 10m Work Description: akedin 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_r208751346 ## 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: why? 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: 132705) Time Spent: 40m (was: 0.5h) > 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: 40m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=132287=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-132287 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 08/Aug/18 09:44 Start Date: 08/Aug/18 09:44 Worklog Time Spent: 10m Work Description: vectorijk commented on issue #6174: [BEAM-5106][SQL]test conditional operators and functions at DSL level URL: https://github.com/apache/beam/pull/6174#issuecomment-411349314 LGTM 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: 132287) Time Spent: 0.5h (was: 20m) > 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: 0.5h > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=132212=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-132212 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 08/Aug/18 05:25 Start Date: 08/Aug/18 05:25 Worklog Time Spent: 10m Work Description: amaliujia commented on issue #6174: [BEAM-5106][SQL]test conditional operators and functions at DSL level URL: https://github.com/apache/beam/pull/6174#issuecomment-411289118 R: @apilloud @akedin 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: 132212) Time Spent: 20m (was: 10m) > 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: 20m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-5106) Test conditional functions at DSL level
[ https://issues.apache.org/jira/browse/BEAM-5106?focusedWorklogId=132182=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-132182 ] ASF GitHub Bot logged work on BEAM-5106: Author: ASF GitHub Bot Created on: 08/Aug/18 02:35 Start Date: 08/Aug/18 02:35 Worklog Time Spent: 10m Work Description: amaliujia opened a new pull request #6174: [BEAM-5106][SQL]test conditional operators and functions at DSL level URL: https://github.com/apache/beam/pull/6174 test conditional operators and functions at DSL level and delete duplicate tests. Follow this checklist to help us incorporate your contribution quickly and easily: - [ ] Format the pull request title like `[BEAM-XXX] Fixes bug in ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue. - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). It will help us expedite review of your Pull Request if you tag someone (e.g. `@username`) to look at it. Post-Commit Tests Status (on master branch) Lang | SDK | Apex | Dataflow | Flink | Gearpump | Samza | Spark --- | --- | --- | --- | --- | --- | --- | --- Go | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Go_GradleBuild/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go_GradleBuild/lastCompletedBuild/) | --- | --- | --- | --- | --- | --- Java | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_GradleBuild/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_GradleBuild/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex_Gradle/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex_Gradle/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow_Gradle/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow_Gradle/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink_Gradle/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink_Gradle/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Gearpump_Gradle/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Gearpump_Gradle/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza_Gradle/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza_Gradle/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark_Gradle/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark_Gradle/lastCompletedBuild/) Python | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Python_Verify/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Python_Verify/lastCompletedBuild/) | --- | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Py_VR_Dataflow/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Py_VR_Dataflow/lastCompletedBuild/) [![Build Status](https://builds.apache.org/job/beam_PostCommit_Py_ValCont/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Py_ValCont/lastCompletedBuild/) | --- | --- | --- | --- 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: 132182) Time Spent: 10m Remaining Estimate: 0h > 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: 10m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA