Class ObjectConstruct

java.lang.Object
dev.frostlake.functions.BuiltInFunction
dev.frostlake.functions.scalar.semistructured.ObjectConstruct
Direct Known Subclasses:
ObjectConstructKeepNull

public class ObjectConstruct extends BuiltInFunction
OBJECT_CONSTRUCT(k1, v1, k2, v2, ...) — builds an object from key-value pairs. Also supports OBJECT_CONSTRUCT(*) which is handled as no-args → empty object.
  • Constructor Details

    • ObjectConstruct

      public ObjectConstruct()
    • ObjectConstruct

      protected ObjectConstruct(String name)
  • Method Details

    • structuredRejection

      public SemiStructuredRejection structuredRejection(int position)
      A STRUCTURED value is refused in either half of the alternating argument list, but with a different sentence in each. Live, OBJECT_CONSTRUCT('a', so) and OBJECT_CONSTRUCT('a', 1, 'b', so) are "Function OBJECT_CONSTRUCT does not support OBJECT(x VARCHAR(16777216)) argument type" (vendor code 2016) while OBJECT_CONSTRUCT(so, 1) — the same value used as a KEY — appends " for keys" and carries vendor code 2270 instead. The plain types are accepted in the value half (OBJECT_CONSTRUCT('a', o) nests the object), so this is a divergence and not a general semi-structured rule.

      Inherited by OBJECT_CONSTRUCT_KEEP_NULL, which subclasses this and was measured to behave identically.

      Overrides:
      structuredRejection in class BuiltInFunction
      Parameters:
      position - the zero-based argument position being asked about
      Returns:
      the extra refusal this position gives a structured value, or NONE when undeclared
    • fileRejection

      public SemiStructuredRejection fileRejection(int position)
      A FILE splits the two halves differently again: it NESTS as a value and is refused as a KEY. Live, OBJECT_CONSTRUCT('a', f) returns {"a":{"CONTENT_TYPE":…}} while OBJECT_CONSTRUCT(f, 1) is "Function OBJECT_CONSTRUCT does not support FILE argument type for keys" — the key sentence a structured value gets, with the value half left alone.
      Overrides:
      fileRejection in class BuiltInFunction
      Parameters:
      position - the zero-based argument position being asked about
      Returns:
      the refusal this position gives a FILE value; by default, the semi-structured answer
    • evaluate

      public Object evaluate(List<Object> args)
      Description copied from class: BuiltInFunction
      Computes the function's result over its already-evaluated argument values. A SQL NULL argument arrives as Java null, and returning null makes the SQL result NULL.
      Specified by:
      evaluate in class BuiltInFunction
      Parameters:
      args - the argument values, in call order
      Returns:
      the function's value for these arguments, or null for SQL NULL
    • build

      protected static Object build(List<Object> args, boolean keepNull)
    • getMinArgCount

      public int getMinArgCount()
      Description copied from class: BuiltInFunction
      The fewest arguments a call to this function may pass; fewer is an argument-count error.
      Specified by:
      getMinArgCount in class BuiltInFunction
      Returns:
      the minimum accepted argument count
    • getMaxArgCount

      public int getMaxArgCount()
      Description copied from class: BuiltInFunction
      The most arguments a call to this function may pass; Integer.MAX_VALUE marks a variadic function (see BuiltInFunction.isVariadic()).
      Specified by:
      getMaxArgCount in class BuiltInFunction
      Returns:
      the maximum accepted argument count