Hi,

I am trying to Beam SQL. But something is wrong. I have nested row records.
I read them as Pcollection<Row> and apply Select * query and compare with
initial rows. Looks like nested rows are flatten by calcite. How do you
have any idea how can I avoid this?

I added a same testcase for my issue:

Schema nestedSchema =
    Schema.builder()
        .addInt32Field("f_nestedInt")
        .addStringField("f_nestedString")
        .addInt32Field("f_nestedIntPlusOne")
        .build();
Schema inputType =
    Schema.builder().addInt32Field("f_int").addRowField("f_row",
nestedSchema).build();

PCollection<Row> input =
    pipeline.apply(
        Create.of(
            Row.withSchema(inputType)
                .addValues(
                    1, Row.withSchema(nestedSchema).addValues(312,
"CC", 313).build())
                .build())
            .withRowSchema(inputType))
    .setRowSchema(inputType);

PCollection<Row> result =
    input
        .apply(
            SqlTransform.query(
                "SELECT * FROM PCOLLECTION"));

PAssert.that(result)
    .containsInAnyOrder(Row.withSchema(inputType)
        .addValues(
            1, Row.withSchema(nestedSchema).addValues(312, "CC", 313).build())
        .build());


Thank you so much in advance.

Reply via email to