use of com.google.zetasql.Value in project beam by apache.
the class ZetaSqlDialectSpecTest method testCastStringToInt64.
@Test
public void testCastStringToInt64() {
String sql = "SELECT CAST(@p0 AS INT64)";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createStringValue("123"));
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addInt64Field("field1").build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValues(123L).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 testLTrim2.
@Test
public void testLTrim2() {
String sql = "SELECT ltrim(@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("xyzab").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 testNamedParameterQuery.
@Test
public void testNamedParameterQuery() {
String sql = "SELECT @ColA AS ColA";
ImmutableMap<String, Value> params = ImmutableMap.of("ColA", Value.createInt64Value(5));
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addInt64Field("field1").build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValues(5L).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 testSubstring.
@Test
public void testSubstring() {
String sql = "SELECT substring(@p0, @p1, @p2)";
ImmutableMap<String, Value> params = ImmutableMap.of("p0", Value.createStringValue("abc"), "p1", Value.createInt64Value(-2L), "p2", Value.createInt64Value(1L));
PCollection<Row> stream = execute(sql, params);
final Schema schema = Schema.builder().addStringField("field1").build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValues("b").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 testTrim2.
@Test
public void testTrim2() {
String sql = "SELECT trim(@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("xyz").build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
Aggregations