use of org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode in project beam by apache.
the class ZetaSqlDialectSpecTest method testInt64SumUnderflow.
@Test
public void testInt64SumUnderflow() {
String sql = "SELECT SUM(col1)\n" + "FROM (SELECT CAST(-9223372036854775808 as int64) as col1 UNION ALL\n" + " SELECT CAST(-1 as int64))\n";
ZetaSQLQueryPlanner zetaSQLQueryPlanner = new ZetaSQLQueryPlanner(config);
BeamRelNode beamRelNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
BeamSqlRelUtils.toPCollection(pipeline, beamRelNode);
thrown.expect(RuntimeException.class);
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
use of org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode in project beam by apache.
the class ZetaSqlDialectSpecTest method testMakeArray.
@Test
@Ignore("$make_array is not implemented")
public void testMakeArray() {
String sql = "SELECT [s3, s1, s2] FROM (SELECT \"foo\" AS s1, \"bar\" AS s2, \"baz\" AS s3);";
ZetaSQLQueryPlanner zetaSQLQueryPlanner = new ZetaSQLQueryPlanner(config);
BeamRelNode beamRelNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
PCollection<Row> stream = BeamSqlRelUtils.toPCollection(pipeline, beamRelNode);
final Schema schema = Schema.builder().addNullableField("field1", FieldType.array(FieldType.STRING)).build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValue(ImmutableList.of("baz", "foo", "bar")).build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
use of org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode in project beam by apache.
the class ZetaSqlDialectSpecTest method testNamedUNNESTLiteralOffset.
@Test
public void testNamedUNNESTLiteralOffset() {
String sql = "SELECT x, p FROM UNNEST([3, 4]) AS x WITH OFFSET p";
ZetaSQLQueryPlanner zetaSQLQueryPlanner = new ZetaSQLQueryPlanner(config);
BeamRelNode beamRelNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
thrown.expect(UnsupportedOperationException.class);
BeamSqlRelUtils.toPCollection(pipeline, beamRelNode);
}
use of org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode in project beam by apache.
the class ZetaSqlDialectSpecTest method testZetaSQLFullOuterJoinTwo.
@Test
@Ignore("BeamSQL only supports equal join")
public void testZetaSQLFullOuterJoinTwo() {
String sql = "SELECT * " + "FROM KeyValue AS t1" + " FULL JOIN BigTable AS t2" + " on " + " t1.Key + t2.RowKey = 30";
ZetaSQLQueryPlanner zetaSQLQueryPlanner = new ZetaSQLQueryPlanner(config);
BeamRelNode beamRelNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
BeamSqlRelUtils.toPCollection(pipeline, beamRelNode);
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
use of org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode in project beam by apache.
the class ZetaSqlDialectSpecTest method testCoalesceNullStruct.
@Test
public void testCoalesceNullStruct() {
String sql = "SELECT COALESCE(NULL, STRUCT(\"a\" AS s, -33 AS i))";
ZetaSQLQueryPlanner zetaSQLQueryPlanner = new ZetaSQLQueryPlanner(config);
BeamRelNode beamRelNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
PCollection<Row> stream = BeamSqlRelUtils.toPCollection(pipeline, beamRelNode);
final Schema innerSchema = Schema.of(Field.of("s", FieldType.STRING), Field.of("i", FieldType.INT64));
final Schema schema = Schema.builder().addNullableField("field1", FieldType.row(innerSchema)).build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(schema).addValue(Row.withSchema(innerSchema).addValues("a", -33L).build()).build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
Aggregations