use of com.google.zetasql.Value in project beam by apache.
the class ZetaSqlDialectSpecTest method testCoalesceNullArray.
@Test
public void testCoalesceNullArray() {
String sql = "SELECT COALESCE(@p0, @p1) AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createNullValue(TypeFactory.createArrayType(TypeFactory.createSimpleType(TypeKind.TYPE_INT64))), "p1", Value.createNullValue(TypeFactory.createArrayType(TypeFactory.createSimpleType(TypeKind.TYPE_INT64))));
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addNullableField("field1", FieldType.array(FieldType.INT64)).build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValue(null).build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
use of com.google.zetasql.Value in project beam by apache.
the class ZetaSqlDialectSpecTest method testSubstrWithLargeValueExpectException.
@Test
public void testSubstrWithLargeValueExpectException() {
String sql = "SELECT substr(@p0, @p1, @p2)";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createStringValue("abc"), "p1", Value.createInt64Value(Integer.MAX_VALUE + 1L), "p2", Value.createInt64Value(Integer.MIN_VALUE - 1L));
ZetaSQLQueryPlanner zetaSQLQueryPlanner = new ZetaSQLQueryPlanner(config);
BeamRelNode beamRelNode = zetaSQLQueryPlanner.convertToBeamRel(sql, params);
BeamSqlRelUtils.toPCollection(pipeline, beamRelNode);
thrown.expect(RuntimeException.class);
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
use of com.google.zetasql.Value in project beam by apache.
the class ZetaSqlDialectSpecTest method testIsNotNull3.
@Test
public void testIsNotNull3() {
String sql = "SELECT @p0 IS NOT NULL AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createNullValue(TypeFactory.createStructType(Arrays.asList(new StructField("a", TypeFactory.createSimpleType(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(false).build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
use of com.google.zetasql.Value in project beam by apache.
the class ZetaSqlDialectSpecTest method testStartsWithString3.
@Test
public void testStartsWithString3() {
String sql = "SELECT STARTS_WITH(@p0, @p1)";
ImmutableMap<String, Value> params = ImmutableMap.<String, Value>builder().put("p0", Value.createSimpleNullValue(TypeKind.TYPE_STRING)).put("p1", Value.createSimpleNullValue(TypeKind.TYPE_STRING)).build();
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addNullableField("field1", FieldType.BOOLEAN).build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValues((Boolean) null).build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
use of com.google.zetasql.Value in project beam by apache.
the class ZetaSqlDialectSpecTest method testCoalesceBasic.
@Test
public void testCoalesceBasic() {
String sql = "SELECT COALESCE(@p0, @p1, @p2) AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createSimpleNullValue(TypeKind.TYPE_STRING), "p1", Value.createStringValue("yay"), "p2", Value.createStringValue("nay"));
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addNullableField("field1", FieldType.STRING).build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValues("yay").build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
Aggregations