Class MapFunctionHelper

java.lang.Object
dev.frostlake.functions.scalar.semistructured.MapFunctionHelper

public final class MapFunctionHelper extends Object
Types and shared reads for the MAP built-in family (MAP_KEYS, MAP_SIZE, MAP_CAT and the rest).
  • Field Details

    • MAP

      public static final MapType MAP
      The MAP type a MAP-returning built-in declares. Live derives the RESULT's key and value types from its arguments — SYSTEM$TYPEOF(MAP_CAT(<MAP(VARCHAR,INT)>, <MAP(VARCHAR,INT)>)) is MAP(VARCHAR, NUMBER(38,0)) — which the registry's one nominal declaration per function cannot express. What matters for the strict-argument rule is the FAMILY: it is a MAP, so MAP_KEYS(MAP_CAT(…)) and MAP_SIZE(MAP_CONSTRUCT('a',1)) pass, matching live, where a plain OBJECT declaration would have made every nested call an argument-type error.
    • KEY_ARRAY

      public static final StructuredArrayType KEY_ARRAY
      The array type MAP_KEYS and MAP_ENTRIES return — a STRUCTURED array, not a plain one. Live-verified: SYSTEM$TYPEOF(MAP_KEYS(m)) is ARRAY(VARCHAR(16777216) NOT NULL) and SYSTEM$TYPEOF(MAP_ENTRIES(m)) is ARRAY(OBJECT(key VARCHAR NOT NULL, value NUMBER(38,0))), and the difference is visible to callers — ARRAY_TO_STRING(MAP_KEYS(m), ',') is an argument-type error over that structured array while the same call over a plain ARRAY joins, and ARRAY_SIZE(MAP_KEYS(m)) works.
  • Method Details

    • body

      public static tools.jackson.databind.JsonNode body(Object value)
      The MAP argument's body, or null when it is SQL NULL. Every function in the family answers NULL for a NULL map (live: MAP_KEYS(NULL::MAP(VARCHAR,INT)), MAP_SIZE, MAP_ENTRIES, MAP_DELETE, MAP_INSERT, MAP_PICK and MAP_CONTAINS_KEY all return NULL), so they share this read.
    • sortedKeys

      public static List<String> sortedKeys(tools.jackson.databind.JsonNode body)
      A map body's keys in Snowflake's order. Live renders a MAP and returns MAP_KEYS / MAP_ENTRIES key-sorted by codepoint rather than by insertion — MAP_CONSTRUCT('Z','x','a','y','B','z') is {"B":"z","Z":"x","a":"y"} and its keys come back ["B","Z","a"] — which is exactly the ordering ArrayFunctionHelper.canonicalize(tools.jackson.databind.JsonNode) already imposes on every OBJECT.
    • keyName

      public static String keyName(Object value)
      A key argument as its member name, or null for SQL NULL. Frostlake stores a MAP as an OBJECT, so every key is a member NAME (text); a NUMBER-keyed map built by MAP_CONSTRUCT(1,'a') therefore reads back as the string key "1" where live keeps the NUMBER — see docs/functions.md.