use of org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode in project beam by apache.
the class ZetaSqlMathFunctionsTest method testExpDouble.
@Test
public void testExpDouble() {
String sql = "SELECT EXP(2.0)";
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().addDoubleField("f_double").build()).addValues(7.38905609893065).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 testPowNumeric.
@Test
public void testPowNumeric() {
String sql = "SELECT POW(NUMERIC '2', NUMERIC '3')";
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_numeric").build()).addValues(ZetaSqlTypesUtils.bigDecimalAsNumeric("8")).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 testSafeArithmeticFunctionsNumeric.
@Test
public void testSafeArithmeticFunctionsNumeric() {
String sql = "SELECT SAFE_ADD(NUMERIC '99999999999999999999999999999.999999999', NUMERIC '1'), " + "SAFE_SUBTRACT(NUMERIC '-99999999999999999999999999999.999999999', NUMERIC '1'), " + "SAFE_MULTIPLY(NUMERIC '99999999999999999999999999999.999999999', NUMERIC '2'), " + "SAFE_DIVIDE(NUMERIC '1.23456e05', NUMERIC '0'), " + "SAFE_NEGATE(NUMERIC '99999999999999999999999999999.999999999')";
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().addNullableField("f_numeric1", Schema.FieldType.DECIMAL).addNullableField("f_numeric2", Schema.FieldType.DECIMAL).addNullableField("f_numeric3", Schema.FieldType.DECIMAL).addNullableField("f_numeric4", Schema.FieldType.DECIMAL).addNullableField("f_numeric5", Schema.FieldType.DECIMAL).build()).addValues(null, null, null, null, ZetaSqlCalciteTranslationUtils.ZETASQL_NUMERIC_MIN_VALUE).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 testSafeDivide.
@Test
public void testSafeDivide() {
String sql = "SELECT SAFE_DIVIDE(1.0, 0.0)";
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().addNullableField("f_double", Schema.FieldType.DOUBLE).build()).addValue(null).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 testIeeeDivide.
@Test
public void testIeeeDivide() {
String sql = "SELECT IEEE_DIVIDE(1.0, 0.0)";
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().addDoubleField("f_double").build()).addValues(Double.POSITIVE_INFINITY).build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
Aggregations