MathematicalFunction { private static FunctionResolver log2() { return FunctionDSL.define(BuiltinFunctionName.LOG2.getName(), ExprCoreType.numberTypes().stream() .map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( v -> new ExprDoubleValue(Math.log(v.doubleValue()) / Math.log(2))), DOUBLE, type)) .collect(Collectors.toList())); }  static void register(BuiltinFunctionRepository repository);  }
@Test public void log2_null_value() { FunctionExpression log = dsl.log2( DSL.ref(DOUBLE_TYPE_NULL_VALUE_FIELD, DOUBLE)); assertEquals(DOUBLE, log.type()); assertTrue(log.valueOf(valueEnv()).isNull()); }
@Test public void log2_missing_value() { FunctionExpression log = dsl.log2( DSL.ref(DOUBLE_TYPE_MISSING_VALUE_FIELD, DOUBLE)); assertEquals(DOUBLE, log.type()); assertTrue(log.valueOf(valueEnv()).isMissing()); }