use of org.apache.beam.sdk.values.Row in project beam by apache.
the class ZetaSqlDialectSpecTest method testLikeNullPattern.
@Test
public void testLikeNullPattern() {
String sql = "SELECT @p0 LIKE @p1 AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createStringValue("ab%"), "p1", Value.createSimpleNullValue(TypeKind.TYPE_STRING));
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addNullableField("field1", FieldType.BOOLEAN).build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValues((Object) null).build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
use of org.apache.beam.sdk.values.Row in project beam by apache.
the class ZetaSqlDialectSpecTest method testCaseWithValueMultipleCases.
@Test
public void testCaseWithValueMultipleCases() {
String sql = "SELECT CASE 2 WHEN 1 THEN 'not possible' WHEN 2 THEN 'seems right' ELSE 'also not" + " possible' END";
PCollection<Row> stream = execute(sql);
PAssert.that(stream).containsInAnyOrder(Row.withSchema(Schema.builder().addStringField("str_field").build()).addValue("seems right").build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
use of org.apache.beam.sdk.values.Row in project beam by apache.
the class ZetaSqlDialectSpecTest method testStructOfStructRemap.
@Test
@Ignore("[BEAM-9378] This should work, but is currently unimplemented.")
public void testStructOfStructRemap() {
String sql = "SELECT STRUCT(row.row_id AS int_value_remapped) AS remapped FROM table_with_struct_of_struct";
PCollection<Row> stream = execute(sql);
Schema nested = Schema.builder().addInt64Field("int_value_remapped").build();
Schema schema = Schema.builder().addRowField("remapped", nested).build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).attachValues(Row.withSchema(nested).attachValues(1L)), Row.withSchema(schema).attachValues(Row.withSchema(nested).attachValues(2L)));
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
use of org.apache.beam.sdk.values.Row in project beam by apache.
the class ZetaSqlDialectSpecTest method testIfNullPositive.
@Test
public void testIfNullPositive() {
String sql = "SELECT IFNULL(@p0, @p1) AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createStringValue("foo"), "p1", Value.createStringValue("default"));
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addNullableField("field1", FieldType.STRING).build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValues("foo").build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
use of org.apache.beam.sdk.values.Row in project beam by apache.
the class ZetaSqlDialectSpecTest method testZetaSQLSelectFromTableWithStructType2.
@Test
public void testZetaSQLSelectFromTableWithStructType2() {
String sql = "SELECT table_with_struct.struct_col.struct_col_str FROM table_with_struct WHERE id = 1;";
PCollection<Row> stream = execute(sql);
final Schema schema = Schema.builder().addStringField("field").build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValue("row_one").build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
Aggregations