Class TextArgumentFunction
- Direct Known Subclasses:
Ascii,BitLength,Char,CharIndex,Chr,Concat,ConcatWs,Contains,EditDistance,EndsWith,InitCap,Insert,JarowinklerSimilarity,Left,Len,Length,Lower,LPad,LTrim,NormalizeFn,OctetLength,ParseIp,ParseUrl,Position,RandStr,RegexpCount,RegexpInstr,RegexpLike,RegexpReplace,RegexpSubstr,RegexpSubstrAll,Repeat,Replace,Reverse,Right,RPad,RTrim,RtrimmedLength,Soundex,Space,Split,SplitPart,StartsWith,Strtok,StrtokToArray,Substring,Translate,Trim,TryParseIp,TryValidateUtf8,Unicode,Upper,ValidateUtf8
Every position, not merely the string-shaped ones — that was measured rather than assumed.
Live over an OBJECT column, all three of SPLIT_PART(o, ',', 1),
SPLIT_PART(s, o, 1) and SPLIT_PART(s, ',', o) are argument-type errors, and so are
LPAD(o, 20, '.'), LPAD(s, o, '.') (which live reports through SPACE) and
LPAD(s, 20, o). A semi-structured value coerces to neither the VARCHAR nor the NUMBER these
functions want, so the whole signature refuses it and the per-position distinction collapses.
Membership is by measurement, so two neighbours in the same package deliberately stay out:
SEARCH ACCEPTS semi-structured data (SEARCH(o, 'k') returned TRUE live), and
INSTR / CHAR_LENGTH / CHARACTER_LENGTH are names Snowflake does not know at
all ("Unknown function"), so there is no live behaviour to copy. Extending this class is what
declares the rule; nothing infers it from the package.
VARIANT is never refused, even when it holds an object — UPPER(vo) returned
{"X":1} live — and neither is an explicit conversion: UPPER(o::VARCHAR),
UPPER(TO_VARCHAR(o)) and UPPER(TO_JSON(o)) all work. The rule reads the DECLARED
type, so UPPER(v::OBJECT) — the same value, cast — IS refused.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsemiStructuredRejection(int position) How argumentpositionrefuses a statically OBJECT- or ARRAY-typed value, orSemiStructuredRejection.NONEwhen it does not.vectorRejection(int position) A VECTOR is no text either, and is refused in every position (live-verified).Methods inherited from class dev.frostlake.functions.BuiltInFunction
approximateRejection, binaryRejection, booleanRejection, evaluate, evaluate, fileRejection, geoRejection, getMaxArgCount, getMinArgCount, getName, getReturnType, isVariadic, refusesMissingArgumentsByType, structuredRejection, temporalRejection, temporalRejection, temporalRejection, textRejection, uuidRejection
-
Constructor Details
-
TextArgumentFunction
-
-
Method Details
-
semiStructuredRejection
Description copied from class:BuiltInFunctionHow argumentpositionrefuses a statically OBJECT- or ARRAY-typed value, orSemiStructuredRejection.NONEwhen it does not. Snowflake never implicitly coerces a semi-structured value to the VARCHAR (or NUMBER) a text or numeric function reads, so such an argument is an argument-type error at COMPILE time rather than a stringification or a fabricated zero: live,UPPER(o)over an OBJECT column is "Invalid argument types for function 'UPPER': (OBJECT)",SUM(o)is the same sentence for 'SUM', andSPLIT_PART(s, o, 1)names the position it was given. VARIANT is never refused, even when it holds an object.Declared HERE, on the function, rather than in a name-keyed table beside the rule: the registry is already the authority on a function's types (
BuiltInFunction.getReturnType()), a declaration on the instance covers the function's ALIASES for free (SUBSTR and SUBSTRING are one object, and so are VARIANCE_POP and VAR_POP), and a per-position answer is the only shape that fits —ARRAY_TO_STRING(a, ',')takes an ARRAY in position 0 and refuses one in position 1.The answer is an ENUM rather than a boolean because Snowflake phrases the refusal three different ways, with three different SQLSTATEs — see
SemiStructuredRejection.The default is
NONE, meaning UNDECLARED rather than "accepts": a function that has not been measured against live Snowflake constrains nothing. Answering for every position is whatTextArgumentFunctionandNumericArgumentFunctionexist for.- Overrides:
semiStructuredRejectionin classBuiltInFunction- Parameters:
position- the zero-based argument position being asked about- Returns:
- the refusal this position gives a semi-structured value, or
NONEwhen undeclared
-
vectorRejection
A VECTOR is no text either, and is refused in every position (live-verified).- Overrides:
vectorRejectionin classBuiltInFunction- Parameters:
position- the zero-based argument position being asked about- Returns:
- the refusal this position gives a VECTOR value; by default none
-