BinaryPredicateOperator { private static FunctionResolver greater() { return FunctionDSL .define(BuiltinFunctionName.GREATER.getName(), ExprCoreType.coreTypes().stream() .map(type -> FunctionDSL .impl(FunctionDSL .nullMissingHandling((v1, v2) -> ExprBooleanValue.of(v1.compareTo(v2) > 0)), BOOLEAN, type, type)) .collect( Collectors.toList())); }  static void register(BuiltinFunctionRepository repository);  }
@Test public void test_greater_null() { FunctionExpression greater = dsl.greater(DSL.literal(1), DSL.ref(INT_TYPE_NULL_VALUE_FIELD, INTEGER)); assertEquals(BOOLEAN, greater.type()); assertEquals(LITERAL_NULL, greater.valueOf(valueEnv())); greater = dsl.greater(DSL.ref(INT_TYPE_NULL_VALUE_FIELD, INTEGER), DSL.literal(1)); assertEquals(BOOLEAN, greater.type()); assertEquals(LITERAL_NULL, greater.valueOf(valueEnv())); greater = dsl.greater(DSL.ref(INT_TYPE_NULL_VALUE_FIELD, INTEGER), DSL.ref(INT_TYPE_NULL_VALUE_FIELD, INTEGER)); assertEquals(BOOLEAN, greater.type()); assertEquals(LITERAL_NULL, greater.valueOf(valueEnv())); }
@Test public void test_greater_missing() { FunctionExpression greater = dsl.greater(DSL.literal(1), DSL.ref(INT_TYPE_MISSING_VALUE_FIELD, INTEGER)); assertEquals(BOOLEAN, greater.type()); assertEquals(LITERAL_MISSING, greater.valueOf(valueEnv())); greater = dsl.greater(DSL.ref(INT_TYPE_MISSING_VALUE_FIELD, INTEGER), DSL.literal(1)); assertEquals(BOOLEAN, greater.type()); assertEquals(LITERAL_MISSING, greater.valueOf(valueEnv())); greater = dsl.greater(DSL.ref(INT_TYPE_MISSING_VALUE_FIELD, INTEGER), DSL.ref(INT_TYPE_MISSING_VALUE_FIELD, INTEGER)); assertEquals(BOOLEAN, greater.type()); assertEquals(LITERAL_MISSING, greater.valueOf(valueEnv())); }
@Test public void test_null_greater_missing() { FunctionExpression greater = dsl.greater(DSL.ref(INT_TYPE_NULL_VALUE_FIELD, INTEGER), DSL.ref(INT_TYPE_MISSING_VALUE_FIELD, INTEGER)); assertEquals(BOOLEAN, greater.type()); assertEquals(LITERAL_MISSING, greater.valueOf(valueEnv())); greater = dsl.greater(DSL.ref(INT_TYPE_MISSING_VALUE_FIELD, INTEGER), DSL.ref(INT_TYPE_NULL_VALUE_FIELD, INTEGER)); assertEquals(BOOLEAN, greater.type()); assertEquals(LITERAL_MISSING, greater.valueOf(valueEnv())); }