Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Clarification of ANY and arbitrary

...

    input = @DataTypeHint("ANY"takeArbitraryInput = YES),

    isVarArgs = YES,

    output = @DataTypeHint("STRING"))

...

Parameter

Description

version

Logic version for future backwards compatibility. Current version by default.

allowAnyGlobally

General flag that defines whether ANY data type should be used for classes that cannot be mapped to any SQL-like type or cause an error. Set to false by default, which means that an exception is thrown for unmapped types. For example, `java.math.BigDecimal` cannot be mapped because the SQL standard defines that decimals have a fixed precision and scale.

allowAnyPattern

Patterns that enable the usage of an ANY type. A pattern is a prefix or a fully qualified name of `Class#getName()` excluding arrays. The general `allowAnyGlobally` flag must not be enabled for patterns.

forceAnyPattern

Patterns that force the usage of an ANY type. A pattern is a prefix or a fully qualified name of `Class#getName()` excluding arrays. `allowAnyGlobally` must not be enabled for forcing ANY types.

defaultDecimalPrecision

Sets a default precision for all decimals that occur. By default, decimals are not extracted.

defaultDecimalScale

Sets a default scale for all decimals that occur. By default, decimals are not extracted.

defaultYearPrecision

Sets a default year precision for year-month intervals. If set to 0, a month interval is assumed.

defaultSecondPrecision

Sets a default second fraction for timestamps and intervals that occur. E.g. because some planners don't support nano seconds yet.

takeArbitraryInputDetermines whether arbitrary input should be allowed. If set to true, this has similar behavior as an always passing input type validator. The bridging class must be Object.


Side note: If the community decides for renaming the ANY type, we can rename `takeArbitraryInput` to `takeAnyInput`.


Some examples:


public class ScalarFunction {

...

    public void eval(String prefix, @DataTypeHint("ANY"takeArbitraryInput = YES) Object obj) {

        //...

...

→ Takes a string and an arbitrary input parameter and returns a STRING.Note to the last exampleThe ANY type is a special logical type as it bridges the Java class hierarchy world and the SQL type world. An ANY type is always connected to a class. In the example above, the ANY type is interpreted as `ANY<java.lang.Object>`. When translating an ANY type to an input validation, the validation happens class-based. Only the ANY type uses class-based validation with the class given in the input data type only. So eval(java.lang.Object) will accept any data type (including primitives) according to the JVM specification.

Manual Definition

If the (possibly annotated) extraction cannot solve a certain use case, for example, because literal values of a function call need to be analyzed or the return type is dependent on the input type. More advanced users can overwrite the `getTypeInference()` method.

...