use of com.google.zetasql.Value in project beam by apache.
the class ZetaSqlDialectSpecTest method testConcatPositionalParameterQuery.
@Test
public void testConcatPositionalParameterQuery() {
String sql = "SELECT CONCAT(?, ?, ?) AS ColA";
ImmutableList<Value> params = ImmutableList.of(Value.createStringValue("a"), Value.createStringValue("b"), Value.createStringValue("c"));
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addStringField("field1").build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValues("abc").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 testIfNullNegative.
@Test
public void testIfNullNegative() {
String sql = "SELECT IFNULL(@p0, @p1) AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createSimpleNullValue(TypeKind.TYPE_STRING), "p1", Value.createStringValue("yay"));
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));
}
use of com.google.zetasql.Value in project beam by apache.
the class ZetaSqlDialectSpecTest method testEQ1.
@Test
public void testEQ1() {
String sql = "SELECT @p0 = @p1 AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.<String, Value>builder().put("p0", Value.createSimpleNullValue(TypeKind.TYPE_BOOL)).put("p1", Value.createBoolValue(true)).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 testLTrim3.
@Test
public void testLTrim3() {
String sql = "SELECT ltrim(@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));
}
use of com.google.zetasql.Value in project beam by apache.
the class ZetaSqlDialectSpecTest method testIfTimestamp.
@Test
public void testIfTimestamp() {
String sql = "SELECT IF(@p0, @p1, @p2) AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createBoolValue(false), "p1", Value.createTimestampValueFromUnixMicros(0), "p2", Value.createTimestampValueFromUnixMicros(DateTime.parse("2019-01-01T00:00:00Z").getMillis() * 1000));
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addNullableField("field1", DATETIME).build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValues(DateTime.parse("2019-01-01T00:00:00Z")).build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
Aggregations