Description
Test case to reproduce:
Schema schema = Schema.builder() .addNullableField("f0", Schema.FieldType.BOOLEAN) .build(); String sql = "SELECT SUM(case when coalesce(f0, true) = true then 1 else 0 end) " + "FROM PCOLLECTION"; List<Row> rows = ImmutableList.of( Row.withSchema(schema).addValue(false).build(), Row.withSchema(schema).addValue(true).build(), Row.withSchema(schema).addValue(null).build()); PCollection<Row> input = pipeline.apply("rows", Create.of(rows).withRowSchema(schema)); PAssert.that(input.apply(SqlTransform.query(sql))).satisfies(matchesScalar(2)); pipeline.run();
Similar test case doesn't throw NPE, but fails:
Schema schema = Schema.builder() .addNullableField("f0", Schema.FieldType.BOOLEAN) .build(); String sql = "SELECT SUM(case when coalesce(f0, false) = true then 1 else 0 end) " + "FROM PCOLLECTION"; List<Row> rows = ImmutableList.of( Row.withSchema(schema).addValue(false).build(), Row.withSchema(schema).addValue(true).build(), Row.withSchema(schema).addValue(null).build()); PCollection<Row> input = pipeline.apply("rows", Create.of(rows).withRowSchema(schema)); PAssert.that(input.apply(SqlTransform.query(sql))).satisfies(matchesScalar(1)); pipeline.run();
Attachments
Issue Links
- is blocked by
-
CALCITE-2783 "COALESCE(s, TRUE) = TRUE" and "(s OR s IS UNKNOWN) = TRUE" causes NullPointerException
- Closed
- links to