use of com.google.zetasql.Value in project beam by apache.
the class ZetaSqlDialectSpecTest method testLikeBytes.
@Test
public void testLikeBytes() {
String sql = "SELECT @p0 LIKE @p1 AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createBytesValue(ByteString.copyFromUtf8("abcd")), "p1", Value.createBytesValue(ByteString.copyFromUtf8("__%")));
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addNullableField("field1", FieldType.BOOLEAN).build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValues(true).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 testNullIfCoercion.
@Test
public void testNullIfCoercion() {
String sql = "SELECT NULLIF(@p0, @p1) AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createInt64Value(3L), "p1", Value.createSimpleNullValue(TypeKind.TYPE_DOUBLE));
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addNullableField("field1", FieldType.DOUBLE).build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValue(3.0).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 testConcatWithNull2.
@Test
public void testConcatWithNull2() {
String sql = "SELECT CONCAT(@p0, @p1) AS ColA";
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 testEQ4.
@Test
public void testEQ4() {
String sql = "SELECT @p0 = @p1 AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.<String, Value>builder().put("p0", Value.createBytesValue(ByteString.copyFromUtf8("hello"))).put("p1", Value.createBytesValue(ByteString.copyFromUtf8("hello"))).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(true).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 testEQ2.
@Test
public void testEQ2() {
String sql = "SELECT @p0 = @p1 AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.<String, Value>builder().put("p0", Value.createDoubleValue(0)).put("p1", Value.createDoubleValue(Double.POSITIVE_INFINITY)).build();
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addBooleanField("field1").build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValues(false).build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
Aggregations