Class MapFunctionHelper
java.lang.Object
dev.frostlake.functions.scalar.semistructured.MapFunctionHelper
Types and shared reads for the MAP built-in family (MAP_KEYS, MAP_SIZE, MAP_CAT and the rest).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StructuredArrayTypeThe array typeMAP_KEYSandMAP_ENTRIESreturn — a STRUCTURED array, not a plain one.static final MapTypeThe MAP type a MAP-returning built-in declares. -
Method Summary
Modifier and TypeMethodDescriptionstatic tools.jackson.databind.JsonNodeThe MAP argument's body, or null when it is SQL NULL.static StringA key argument as its member name, or null for SQL NULL.sortedKeys(tools.jackson.databind.JsonNode body) A map body's keys in Snowflake's order.
-
Field Details
-
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)>))isMAP(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, soMAP_KEYS(MAP_CAT(…))andMAP_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
The array typeMAP_KEYSandMAP_ENTRIESreturn — a STRUCTURED array, not a plain one. Live-verified:SYSTEM$TYPEOF(MAP_KEYS(m))isARRAY(VARCHAR(16777216) NOT NULL)andSYSTEM$TYPEOF(MAP_ENTRIES(m))isARRAY(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, andARRAY_SIZE(MAP_KEYS(m))works.
-
-
Method Details
-
body
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_PICKandMAP_CONTAINS_KEYall return NULL), so they share this read. -
sortedKeys
A map body's keys in Snowflake's order. Live renders a MAP and returnsMAP_KEYS/MAP_ENTRIESkey-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 orderingArrayFunctionHelper.canonicalize(tools.jackson.databind.JsonNode)already imposes on every OBJECT. -
keyName
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 byMAP_CONSTRUCT(1,'a')therefore reads back as the string key"1"where live keeps the NUMBER — seedocs/functions.md.
-