MathematicalFunction { private static FunctionResolver atan2() { ImmutableList.Builder<SerializableFunction<FunctionName, Pair<FunctionSignature, FunctionBuilder>>> builder = new ImmutableList.Builder<>(); for (ExprType type : ExprCoreType.numberTypes()) { builder.add(FunctionDSL.impl(FunctionDSL .nullMissingHandling((y, x) -> new ExprDoubleValue(Math.atan2(y.doubleValue(), x.doubleValue()))), DOUBLE, type, type)); } return FunctionDSL.define(BuiltinFunctionName.ATAN2.getName(), builder.build()); }  static void register(BuiltinFunctionRepository repository);  }
@Test public void atan2_null_value() { FunctionExpression atan2 = dsl.atan2( DSL.ref(DOUBLE_TYPE_NULL_VALUE_FIELD, DOUBLE), DSL.literal(1)); assertEquals(DOUBLE, atan2.type()); assertTrue(atan2.valueOf(valueEnv()).isNull()); atan2 = dsl.atan2(DSL.literal(1), DSL.ref(DOUBLE_TYPE_NULL_VALUE_FIELD, DOUBLE)); assertEquals(DOUBLE, atan2.type()); assertTrue(atan2.valueOf(valueEnv()).isNull()); atan2 = dsl.atan2(DSL.ref(DOUBLE_TYPE_NULL_VALUE_FIELD, DOUBLE), DSL.ref(DOUBLE_TYPE_NULL_VALUE_FIELD, DOUBLE)); assertEquals(DOUBLE, atan2.type()); assertTrue(atan2.valueOf(valueEnv()).isNull()); }
@Test public void atan2_missing_value() { FunctionExpression atan2 = dsl.atan2( DSL.ref(DOUBLE_TYPE_MISSING_VALUE_FIELD, DOUBLE), DSL.literal(1)); assertEquals(DOUBLE, atan2.type()); assertTrue(atan2.valueOf(valueEnv()).isMissing()); atan2 = dsl.atan2(DSL.literal(1), DSL.ref(DOUBLE_TYPE_MISSING_VALUE_FIELD, DOUBLE)); assertEquals(DOUBLE, atan2.type()); assertTrue(atan2.valueOf(valueEnv()).isMissing()); atan2 = dsl.atan2(DSL.ref(DOUBLE_TYPE_MISSING_VALUE_FIELD, DOUBLE), DSL.ref(DOUBLE_TYPE_MISSING_VALUE_FIELD, DOUBLE)); assertEquals(DOUBLE, atan2.type()); assertTrue(atan2.valueOf(valueEnv()).isMissing()); }
@Test public void atan2_null_missing() { FunctionExpression atan2 = dsl.atan2( DSL.ref(DOUBLE_TYPE_MISSING_VALUE_FIELD, DOUBLE), DSL.ref(DOUBLE_TYPE_NULL_VALUE_FIELD, DOUBLE)); assertEquals(DOUBLE, atan2.type()); assertTrue(atan2.valueOf(valueEnv()).isMissing()); atan2 = dsl.atan2(DSL.ref(DOUBLE_TYPE_NULL_VALUE_FIELD, DOUBLE), DSL.ref(DOUBLE_TYPE_MISSING_VALUE_FIELD, DOUBLE)); assertEquals(DOUBLE, atan2.type()); assertTrue(atan2.valueOf(valueEnv()).isMissing()); }