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