Class BooleanAggregate
- Direct Known Subclasses:
BoolAndAgg,BoolOrAgg,BoolXorAgg
TO_BOOLEAN(x), so an argument that conversion refuses is
refused while the statement compiles, in the conversion's words and with no position — a FLOAT, a
DATE / TIME / TIMESTAMP, a BINARY, an OBJECT or an ARRAY: invalid type [TO_BOOLEAN(AW.F)] for
parameter 'TO_BOOLEAN'. An exact NUMBER reads as x <> 0, a BOOLEAN as itself, and a VARCHAR
or a VARIANT is read at row time — a text that is no TO_BOOLEAN form is Boolean value 'x' is
not recognized, a VARIANT member that is not a boolean Failed to cast variant value 1 to
BOOLEAN (all live-verified).-
Nested Class Summary
Nested classes/interfaces inherited from class dev.frostlake.functions.AggregateFunction
AggregateFunction.Accumulator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapproximateRejection(int position) How the function treats an APPROXIMATE numeric argument atposition.binaryRejection(int position) The refusal a position gives a statically BINARY-typed value.structuredRejection(int position) The EXTRA refusal argumentpositionreserves for a STRUCTURED value —OBJECT(x VARCHAR),ARRAY(INT),MAP(VARCHAR, INT)— where the plain semi-structured OBJECT or ARRAY is ACCEPTED.temporalRejection(int position) The refusal this position gives a declared DATE / TIME / TIMESTAMP argument.Methods inherited from class dev.frostlake.functions.AggregateFunction
createAccumulatorMethods inherited from class dev.frostlake.functions.BuiltInFunction
booleanRejection, evaluate, evaluate, fileRejection, geoRejection, getMaxArgCount, getMinArgCount, getName, getReturnType, isVariadic, refusesMissingArgumentsByType, semiStructuredRejection, temporalRejection, temporalRejection, textRejection, uuidRejection, vectorRejection
-
Constructor Details
-
BooleanAggregate
-
-
Method Details
-
approximateRejection
Description copied from class:BuiltInFunctionHow the function treats an APPROXIMATE numeric argument atposition.- Overrides:
approximateRejectionin classBuiltInFunction
-
temporalRejection
Description copied from class:BuiltInFunctionThe refusal this position gives a declared DATE / TIME / TIMESTAMP argument. Declared per function: the numeric family refuses every temporal flavour at compile time, each named with its own parameters — (DATE), (TIME(9)), (TIMESTAMP_NTZ(9)) and the LTZ/TZ twins — where the datetime functions read them happily.- Overrides:
temporalRejectionin classBuiltInFunction- Parameters:
position- the zero-based argument position being asked about- Returns:
- the refusal this position gives a temporal value; by default none
-
binaryRejection
Description copied from class:BuiltInFunctionThe refusal a position gives a statically BINARY-typed value.A fifth question rather than a reuse of any of the four above, because BINARY sits on the opposite side of them: it is a scalar a text function is happy to be handed almost everywhere — live answers
LENGTH(bn),SUBSTR(bn, 1, 1),CONCAT(bn, bn)— where an OBJECT is refused. Only the functions that read their argument AS TEXT and would have to decode it refuse one, and they say so themselves:VALIDATE_UTF8(bn)andTRY_VALIDATE_UTF8(bn)are "Invalid argument types for function 'TRY_VALIDATE_UTF8': (BINARY(5))" while the same call over a VARCHAR, and even over a NUMBER, returns a value.The default is
NONE: undeclared means unconstrained, as for the other four.- Overrides:
binaryRejectionin classBuiltInFunction- Parameters:
position- the zero-based argument position being asked about- Returns:
- the refusal this position gives a BINARY value; by default none
-
structuredRejection
Description copied from class:BuiltInFunctionThe EXTRA refusal argumentpositionreserves for a STRUCTURED value —OBJECT(x VARCHAR),ARRAY(INT),MAP(VARCHAR, INT)— where the plain semi-structured OBJECT or ARRAY is ACCEPTED. Consulted only whenBuiltInFunction.semiStructuredRejection(int)declares nothing for the position, so a function that refuses every semi-structured value keeps saying so in one place.The two are separate because Snowflake genuinely treats
OBJECTandOBJECT(x VARCHAR)as different types, and they DIVERGE — measured over populated columns of both:ARRAY_AGG(o)returns the array whileARRAY_AGG(so)is an argument-type error,TO_JSON(o)returns the JSON text whileTO_JSON(so)is refused, andTYPEOF,IS_OBJECT,AS_VARCHAR,ARRAY_TO_STRINGand the constructors all split the same way. A single rule keyed on "is this semi-structured?" gets both cases wrong in opposite directions, which is why the answer is asked twice.What a structured type does NOT get is a rejection anywhere the plain types are accepted as KEYS: live,
GROUP BY so,ORDER BY so,SELECT DISTINCT so,PARTITION BY so, the set operators,JOIN … ON so = soandCOUNT(DISTINCT so)all work over each of the three structured kinds — that was measured rather than inferred from the plain behaviour.The default is
NONEfor the same reason as above: undeclared means unconstrained.- Overrides:
structuredRejectionin classBuiltInFunction- Parameters:
position- the zero-based argument position being asked about- Returns:
- the extra refusal this position gives a structured value, or
NONEwhen undeclared
-