Class NullIf
java.lang.Object
dev.frostlake.functions.BuiltInFunction
dev.frostlake.functions.scalar.conditional.NullIf
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionNULLIF(a, b)isCASE WHEN a = b THEN NULL ELSE a END, so it decides equality the way the=operator does — by VALUE, across the type families.evaluate(List<Object> args, CollationSpec collation) Under a collation the two are compared by its rules, so a case-blind pair answers NULL.geoRejection(int position) NULLIFcompares its two arguments, and a GEOSPATIAL value does not compare: liveNULLIF(g, g)is "Invalid argument types for function 'NULLIF': (GEOGRAPHY, GEOGRAPHY)" (SQLSTATE 42P13), whileCOALESCE(g, NULL)— which chooses without comparing — returns the geo value.intThe most arguments a call to this function may pass;Integer.MAX_VALUEmarks a variadic function (seeBuiltInFunction.isVariadic()).intThe fewest arguments a call to this function may pass; fewer is an argument-count error.Methods inherited from class dev.frostlake.functions.BuiltInFunction
approximateRejection, binaryRejection, booleanRejection, fileRejection, getName, getReturnType, isVariadic, refusesMissingArgumentsByType, semiStructuredRejection, structuredRejection, temporalRejection, temporalRejection, temporalRejection, textRejection, uuidRejection, vectorRejection
-
Constructor Details
-
NullIf
public NullIf()
-
-
Method Details
-
geoRejection
NULLIFcompares its two arguments, and a GEOSPATIAL value does not compare: liveNULLIF(g, g)is "Invalid argument types for function 'NULLIF': (GEOGRAPHY, GEOGRAPHY)" (SQLSTATE 42P13), whileCOALESCE(g, NULL)— which chooses without comparing — returns the geo value.- Overrides:
geoRejectionin classBuiltInFunction- Parameters:
position- the zero-based argument position being asked about- Returns:
- the refusal this position gives a GEOGRAPHY or GEOMETRY value; by default, the union of the two semi-structured answers
-
evaluate
NULLIF(a, b)isCASE WHEN a = b THEN NULL ELSE a END, so it decides equality the way the=operator does — by VALUE, across the type families. Deciding it withObject.equals(java.lang.Object)instead made the answer depend on a runtime class the SQL cannot see:NULLIF(1.00, 1)handed back 1.00 because a BigDecimal is not a Long, and the same split hid every mixed-family pair — a boolean beside a number, a numeric string beside a number, a DATE beside a TIMESTAMP at the same instant. A NULL on either side is never compared: SQL NULL is not equal to anything, so the first argument stands.- Specified by:
evaluatein classBuiltInFunction- Parameters:
args- the argument values, in call order- Returns:
- the function's value for these arguments, or
nullfor SQL NULL
-
evaluate
Under a collation the two are compared by its rules, so a case-blind pair answers NULL.- Overrides:
evaluatein classBuiltInFunction- Parameters:
args- the argument values, in call ordercollation- the collation the call settled on, or null when it carries none- Returns:
- the function's value for these arguments, or
nullfor SQL NULL
-
getMinArgCount
public int getMinArgCount()Description copied from class:BuiltInFunctionThe fewest arguments a call to this function may pass; fewer is an argument-count error.- Specified by:
getMinArgCountin classBuiltInFunction- Returns:
- the minimum accepted argument count
-
getMaxArgCount
public int getMaxArgCount()Description copied from class:BuiltInFunctionThe most arguments a call to this function may pass;Integer.MAX_VALUEmarks a variadic function (seeBuiltInFunction.isVariadic()).- Specified by:
getMaxArgCountin classBuiltInFunction- Returns:
- the maximum accepted argument count
-