You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "Gleb Kanterov (JIRA)" <ji...@apache.org> on 2019/01/09 18:58:00 UTC

[jira] [Created] (BEAM-6401) NullPointerException and regression in BeamCalcRel

Gleb Kanterov created BEAM-6401:
-----------------------------------

             Summary: NullPointerException and regression in BeamCalcRel
                 Key: BEAM-6401
                 URL: https://issues.apache.org/jira/browse/BEAM-6401
             Project: Beam
          Issue Type: Bug
          Components: dsl-sql
            Reporter: Gleb Kanterov
            Assignee: Andrew Pilloud


Test case to reproduce:
{code}
    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();
{code}

Similar test case doesn't throw NPE, but fails:
{code}
    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();
{code}



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