use of com.google.zetasql.Value in project beam by apache.
the class ZetaSqlDialectSpecTest method testRTrim2.
@Test
public void testRTrim2() {
String sql = "SELECT rtrim(@p0, @p1)";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createStringValue("abxyzab"), "p1", Value.createStringValue("ab"));
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addStringField("field1").build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValues("abxyz").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 testByteString.
@Test
public void testByteString() {
String sql = "SELECT @p0 IS NULL AS ColA";
ByteString byteString = ByteString.copyFrom(new byte[] { 0x62 });
ImmutableMap<String, Value> params = ImmutableMap.<String, Value>builder().put("p0", Value.createBytesValue(byteString)).build();
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addNullableField("ColA", 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 testZetaSQLSelectNullOffsetParam.
@Test
public void testZetaSQLSelectNullOffsetParam() {
String sql = "SELECT Key, Value FROM KeyValue LIMIT 1 OFFSET @lmt;";
ImmutableMap<String, Value> params = ImmutableMap.of("lmt", Value.createNullValue(TypeFactory.createSimpleType(TypeKind.TYPE_INT64)));
ZetaSQLQueryPlanner zetaSQLQueryPlanner = new ZetaSQLQueryPlanner(config);
thrown.expect(RuntimeException.class);
thrown.expectMessage("Limit requires non-null count and offset");
zetaSQLQueryPlanner.convertToBeamRel(sql, params);
}
use of com.google.zetasql.Value in project beam by apache.
the class ZetaSqlDialectSpecTest method testCoalesceSingleArgument.
@Test
public void testCoalesceSingleArgument() {
String sql = "SELECT COALESCE(@p0) AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createSimpleNullValue(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 testRTrim3.
@Test
public void testRTrim3() {
String sql = "SELECT rtrim(@p0, @p1)";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createSimpleNullValue(TypeKind.TYPE_STRING), "p1", Value.createSimpleNullValue(TypeKind.TYPE_STRING));
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addNullableField("field1", FieldType.STRING).build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValues((String) null).build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
Aggregations