use of org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode in project beam by apache.
the class ZetaSqlNativeUdfTest method testNullaryUdtvf.
@Test
public void testNullaryUdtvf() {
String sql = "CREATE TABLE FUNCTION CustomerRange()\n" + " AS\n" + " SELECT *\n" + " FROM KeyValue;\n" + " SELECT key FROM CustomerRange()";
ZetaSQLQueryPlanner zetaSQLQueryPlanner = new ZetaSQLQueryPlanner(config);
BeamRelNode beamRelNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
PCollection<Row> stream = BeamSqlRelUtils.toPCollection(pipeline, beamRelNode);
Schema singleField = Schema.builder().addInt64Field("field1").build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(singleField).addValues(14L).build(), Row.withSchema(singleField).addValues(15L).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 ZetaSqlNativeUdfTest method testQualifiedNameUdfUnqualifiedCall.
@Test
public void testQualifiedNameUdfUnqualifiedCall() {
String sql = "CREATE FUNCTION foo.bar.baz() AS (\"uwu\"); SELECT baz();";
ZetaSQLQueryPlanner zetaSQLQueryPlanner = new ZetaSQLQueryPlanner(config);
BeamRelNode beamRelNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
PCollection<Row> stream = BeamSqlRelUtils.toPCollection(pipeline, beamRelNode);
PAssert.that(stream).containsInAnyOrder(Row.withSchema(Schema.builder().addStringField("x").build()).addValue("uwu").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 ZetaSqlMathFunctionsTest method testCeilNumeric.
@Test
public void testCeilNumeric() {
String sql = "SELECT CEIL(NUMERIC '1.23456e04'), CEIL(NUMERIC '-1.23456e04')";
ZetaSQLQueryPlanner zetaSQLQueryPlanner = new ZetaSQLQueryPlanner(config);
BeamRelNode beamRelNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
PCollection<Row> stream = BeamSqlRelUtils.toPCollection(pipeline, beamRelNode);
PAssert.that(stream).containsInAnyOrder(Row.withSchema(Schema.builder().addDecimalField("f_numeric1").addDecimalField("f_numeric2").build()).addValues(ZetaSqlTypesUtils.bigDecimalAsNumeric("12346"), ZetaSqlTypesUtils.bigDecimalAsNumeric("-12345")).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 ZetaSqlMathFunctionsTest method testSignInt64.
@Test
public void testSignInt64() {
String sql = "SELECT SIGN(0), SIGN(5), SIGN(-5)";
ZetaSQLQueryPlanner zetaSQLQueryPlanner = new ZetaSQLQueryPlanner(config);
BeamRelNode beamRelNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
PCollection<Row> stream = BeamSqlRelUtils.toPCollection(pipeline, beamRelNode);
PAssert.that(stream).containsInAnyOrder(Row.withSchema(Schema.builder().addInt64Field("f_int64_1").addInt64Field("f_int64_2").addInt64Field("f_int64_3").build()).addValues(0L, 1L, -1L).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 ZetaSqlMathFunctionsTest method testDivInt64.
@Test
public void testDivInt64() {
String sql = "SELECT DIV(1, 2), DIV(2, 1)";
ZetaSQLQueryPlanner zetaSQLQueryPlanner = new ZetaSQLQueryPlanner(config);
BeamRelNode beamRelNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
PCollection<Row> stream = BeamSqlRelUtils.toPCollection(pipeline, beamRelNode);
PAssert.that(stream).containsInAnyOrder(Row.withSchema(Schema.builder().addInt64Field("f_int64_1").addInt64Field("f_int64_2").build()).addValues(0L, 2L).build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
Aggregations