use of org.apache.beam.sdk.schemas.FieldAccessDescriptor in project beam by apache.
the class SelectHelpersTest method testSelectAll.
@Test
public void testSelectAll() {
FieldAccessDescriptor fieldAccessDescriptor = FieldAccessDescriptor.withFieldNames("*").resolve(FLAT_SCHEMA);
Schema outputSchema = SelectHelpers.getOutputSchema(FLAT_SCHEMA, fieldAccessDescriptor);
assertEquals(FLAT_SCHEMA, outputSchema);
Row row = selectRow(FLAT_SCHEMA, fieldAccessDescriptor, FLAT_ROW);
assertEquals(FLAT_ROW, row);
}
use of org.apache.beam.sdk.schemas.FieldAccessDescriptor in project beam by apache.
the class SelectHelpersTest method testSelectedNested.
@Test
public void testSelectedNested() {
FieldAccessDescriptor fieldAccessDescriptor = FieldAccessDescriptor.withFieldNames("nested").resolve(NESTED_SCHEMA);
Schema outputSchema = SelectHelpers.getOutputSchema(NESTED_SCHEMA, fieldAccessDescriptor);
Schema expectedSchema = Schema.builder().addRowField("nested", FLAT_SCHEMA).build();
assertEquals(expectedSchema, outputSchema);
Row row = selectRow(NESTED_SCHEMA, fieldAccessDescriptor, NESTED_ROW);
Row expectedRow = Row.withSchema(expectedSchema).addValue(FLAT_ROW).build();
assertEquals(expectedRow, row);
}
use of org.apache.beam.sdk.schemas.FieldAccessDescriptor in project beam by apache.
the class SelectHelpersTest method testSelectedNestedSingle.
@Test
public void testSelectedNestedSingle() {
FieldAccessDescriptor fieldAccessDescriptor = FieldAccessDescriptor.withFieldNames("nested.field1").resolve(NESTED_SCHEMA);
Schema outputSchema = SelectHelpers.getOutputSchema(NESTED_SCHEMA, fieldAccessDescriptor);
Schema expectedSchema = Schema.builder().addStringField("field1").build();
assertEquals(expectedSchema, outputSchema);
Row row = selectRow(NESTED_SCHEMA, fieldAccessDescriptor, NESTED_ROW);
Row expectedRow = Row.withSchema(expectedSchema).addValue("first").build();
assertEquals(expectedRow, row);
}
use of org.apache.beam.sdk.schemas.FieldAccessDescriptor in project beam by apache.
the class SelectHelpersTest method testSelectIterableOfNestedRow.
@Test
public void testSelectIterableOfNestedRow() {
FieldAccessDescriptor fieldAccessDescriptor = FieldAccessDescriptor.withFieldNames("nestedRowIter[].nested.field1").resolve(ITERABLE_SCHEMA);
Schema outputSchema = SelectHelpers.getOutputSchema(ITERABLE_SCHEMA, fieldAccessDescriptor);
Schema.builder().addStringField("field1").build();
Schema expectedSchema = Schema.builder().addIterableField("field1", FieldType.STRING).build();
assertEquals(expectedSchema, outputSchema);
Row row = selectRow(ITERABLE_SCHEMA, fieldAccessDescriptor, ITERABLE_ROW);
Row expectedRow = Row.withSchema(expectedSchema).addIterable(ImmutableList.of("first", "first")).build();
assertEquals(expectedRow, row);
}
use of org.apache.beam.sdk.schemas.FieldAccessDescriptor in project beam by apache.
the class SelectHelpersTest method testSelectArrayOfRowPartial.
@Test
public void testSelectArrayOfRowPartial() {
FieldAccessDescriptor fieldAccessDescriptor = FieldAccessDescriptor.withFieldNames("rowArray[].field1").resolve(ARRAY_SCHEMA);
Schema outputSchema = SelectHelpers.getOutputSchema(ARRAY_SCHEMA, fieldAccessDescriptor);
Schema expectedSchema = Schema.builder().addArrayField("field1", FieldType.STRING).build();
assertEquals(expectedSchema, outputSchema);
Row row = selectRow(ARRAY_SCHEMA, fieldAccessDescriptor, ARRAY_ROW);
Row expectedRow = Row.withSchema(expectedSchema).addArray("first", "first").build();
assertEquals(expectedRow, row);
}
Aggregations