[
https://issues.apache.org/jira/browse/BEAM-11696?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17277525#comment-17277525
]
Sonam Ramchand commented on BEAM-11696:
---------------------------------------
Hi Robin, here is the written unit test:
{code:java}
@Test
//@Ignore("NULL values don't work correctly.
[https://issues.apache.org/jira/browse/BEAM-11696]")
public void testLogicalAndWithAllNullInputs() {
String sql = "SELECT LOGICAL_AND(x) AS logical_and FROM UNNEST([null, null,
null]) AS x";
ZetaSQLQueryPlanner zetaSQLQueryPlanner = new ZetaSQLQueryPlanner(config);
BeamRelNode beamRelNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
PCollection<Row> stream = BeamSqlRelUtils.toPCollection(pipeline, beamRelNode);
Schema schema = Schema.builder().addNullableField("bool_col",
FieldType.BOOLEAN).build();
PAssert.that(stream)
.containsInAnyOrder(Row.withSchema(schema).addValues((Boolean) null).build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}{code}
> NULL values don't work correctly when implementing LOGICAL_AND aggregation
> function in ZetaSQL
> ----------------------------------------------------------------------------------------------
>
> Key: BEAM-11696
> URL: https://issues.apache.org/jira/browse/BEAM-11696
> Project: Beam
> Issue Type: Bug
> Components: dsl-sql-zetasql
> Reporter: Sonam Ramchand
> Assignee: Kyle Weaver
> Priority: P3
> Fix For: Not applicable
>
>
> Reference:
> [https://github.com/google/zetasql/blob/master/docs/functions-and-operators.md#logical_and]
>
> Problems:
> After implementation, there is a problem:
> * When input contains all null values:
> {code:sql}
> SELECT LOGICAL_AND(a) AS logical_and FROM UNNEST([null, null, null]) AS a;
> {code}
> the output is:
> {code:java}
> No matching signature for aggregate function LOGICAL_AND for argument types:
> INT64. Supported signature: LOGICAL_AND(BOOL) {code}
> which is same behavior as of BigQuery console. Though, it should
> return null.
> How to test: unit tests
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)