use of com.google.zetasql.Value in project beam by apache.
the class ZetaSqlDialectSpecTest method testLTrim1.
@Test
public void testLTrim1() {
String sql = "SELECT ltrim(@p0)";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createStringValue(" a b c "));
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addStringField("field1").build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValues("a b c ").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 testEndsWithString3.
@Test
public void testEndsWithString3() {
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 testReplace4.
@Test
public void testReplace4() {
String sql = "SELECT REPLACE(@p0, @p1, @p2) AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createSimpleNullValue(TypeKind.TYPE_STRING), "p1", Value.createSimpleNullValue(TypeKind.TYPE_STRING), "p2", Value.createStringValue(""));
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));
}
use of com.google.zetasql.Value in project beam by apache.
the class ZetaSqlDialectSpecTest method testEQ3.
@Test
public void testEQ3() {
String sql = "SELECT @p0 = @p1 AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.<String, Value>builder().put("p0", Value.createSimpleNullValue(TypeKind.TYPE_DOUBLE)).put("p1", Value.createDoubleValue(3.14)).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 testEndsWithString2.
@Test
public void testEndsWithString2() {
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.createStringValue("")).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));
}
Aggregations