Java Code Examples for org.apache.beam.sdk.values.Row#nullRow()

The following examples show how to use org.apache.beam.sdk.values.Row#nullRow() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeamComplexTypeTest.java    From beam with Apache License 2.0 6 votes vote down vote up
@Test
public void testNullRows() {

  Row nullRow = Row.nullRow(nullableNestedRowWithArraySchema);

  PCollection<Row> outputRow =
      pipeline
          .apply(Create.of(nullRow))
          .setRowSchema(nullableNestedRowWithArraySchema)
          .apply(
              SqlTransform.query(
                  "select PCOLLECTION.field1.string_field as row_string_field, PCOLLECTION.field2[2].string_field as array_string_field from PCOLLECTION"));

  PAssert.that(outputRow)
      .containsInAnyOrder(
          Row.nullRow(
              Schema.builder()
                  .addNullableField("row_string_field", FieldType.STRING)
                  .addNullableField("array_string_field", FieldType.STRING)
                  .build()));

  pipeline.run().waitUntilFinish(Duration.standardMinutes(2));
}
 
Example 2
Source File: JavaBeanSchemaTest.java    From beam with Apache License 2.0 6 votes vote down vote up
@Test
public void testNullableFromRow() throws NoSuchSchemaException {
  SchemaRegistry registry = SchemaRegistry.createDefault();
  Row row = Row.nullRow(ALL_NULLABLE_BEAN_SCHEMA);

  AllNullableBean bean = registry.getFromRowFunction(AllNullableBean.class).apply(row);
  assertNull(bean.getStr());
  assertNull(bean.getaByte());
  assertNull(bean.getaShort());
  assertNull(bean.getAnInt());
  assertNull(bean.getaLong());
  assertNull(bean.isaBoolean());
  assertNull(bean.getDateTime());
  assertNull(bean.getInstant());
  assertNull(bean.getBytes());
  assertNull(bean.getByteBuffer());
  assertNull(bean.getBigDecimal());
  assertNull(bean.getStringBuilder());
}
 
Example 3
Source File: JavaFieldSchemaTest.java    From beam with Apache License 2.0 6 votes vote down vote up
@Test
public void testNullableFromRow() throws NoSuchSchemaException {
  SchemaRegistry registry = SchemaRegistry.createDefault();
  Row row = Row.nullRow(NULLABLE_POJO_SCHEMA);

  NullablePOJO pojo = registry.getFromRowFunction(NullablePOJO.class).apply(row);
  assertNull(pojo.str);
  assertNull(pojo.aByte);
  assertNull(pojo.aShort);
  assertNull(pojo.anInt);
  assertNull(pojo.aLong);
  assertNull(pojo.aBoolean);
  assertNull(pojo.dateTime);
  assertNull(pojo.instant);
  assertNull(pojo.bytes);
  assertNull(pojo.byteBuffer);
  assertNull(pojo.bigDecimal);
  assertNull(pojo.stringBuilder);
}