Search in sources :

Example 1 with StructType

use of com.google.zetasql.StructType in project beam by apache.

the class ZetaSqlDialectSpecTest method testParameterStructNested.

@Test
public void testParameterStructNested() {
    String sql = "SELECT @outer_struct.inner_struct.s as ColA";
    StructType innerStructType = TypeFactory.createStructType(ImmutableList.of(new StructType.StructField("s", TypeFactory.createSimpleType(TypeKind.TYPE_STRING))));
    ImmutableMap<String, Value> params = ImmutableMap.of("outer_struct", Value.createStructValue(TypeFactory.createStructType(ImmutableList.of(new StructType.StructField("inner_struct", innerStructType))), ImmutableList.of(Value.createStructValue(innerStructType, ImmutableList.of(Value.createStringValue("foo"))))));
    PCollection<Row> stream = execute(sql, params);
    final Schema schema = Schema.builder().addStringField("field1").build();
    PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValue("foo").build());
    pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
Also used : StructField(com.google.zetasql.StructType.StructField) StructType(com.google.zetasql.StructType) Schema(org.apache.beam.sdk.schemas.Schema) Value(com.google.zetasql.Value) ByteString(com.google.protobuf.ByteString) Row(org.apache.beam.sdk.values.Row) Test(org.junit.Test)

Aggregations

ByteString (com.google.protobuf.ByteString)1 StructType (com.google.zetasql.StructType)1 StructField (com.google.zetasql.StructType.StructField)1 Value (com.google.zetasql.Value)1 Schema (org.apache.beam.sdk.schemas.Schema)1 Row (org.apache.beam.sdk.values.Row)1 Test (org.junit.Test)1