Class BooleanAggregate

Direct Known Subclasses:
BoolAndAgg, BoolOrAgg, BoolXorAgg

public abstract class BooleanAggregate extends AggregateFunction
The three boolean aggregates' shared argument rule. The account plans BOOLOR_AGG, BOOLAND_AGG and BOOLXOR_AGG as MAX / MIN over 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).
  • Constructor Details

    • BooleanAggregate

      protected BooleanAggregate(String name, DataType returnType)
  • Method Details

    • approximateRejection

      public SemiStructuredRejection approximateRejection(int position)
      Description copied from class: BuiltInFunction
      How the function treats an APPROXIMATE numeric argument at position.
      Overrides:
      approximateRejection in class BuiltInFunction
    • temporalRejection

      public SemiStructuredRejection temporalRejection(int position)
      Description copied from class: BuiltInFunction
      The 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:
      temporalRejection in class BuiltInFunction
      Parameters:
      position - the zero-based argument position being asked about
      Returns:
      the refusal this position gives a temporal value; by default none
    • binaryRejection

      public SemiStructuredRejection binaryRejection(int position)
      Description copied from class: BuiltInFunction
      The 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) and TRY_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:
      binaryRejection in class BuiltInFunction
      Parameters:
      position - the zero-based argument position being asked about
      Returns:
      the refusal this position gives a BINARY value; by default none
    • structuredRejection

      public SemiStructuredRejection structuredRejection(int position)
      Description copied from class: BuiltInFunction
      The EXTRA refusal argument position reserves for a STRUCTURED value — OBJECT(x VARCHAR), ARRAY(INT), MAP(VARCHAR, INT) — where the plain semi-structured OBJECT or ARRAY is ACCEPTED. Consulted only when BuiltInFunction.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 OBJECT and OBJECT(x VARCHAR) as different types, and they DIVERGE — measured over populated columns of both: ARRAY_AGG(o) returns the array while ARRAY_AGG(so) is an argument-type error, TO_JSON(o) returns the JSON text while TO_JSON(so) is refused, and TYPEOF, IS_OBJECT, AS_VARCHAR, ARRAY_TO_STRING and 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 = so and COUNT(DISTINCT so) all work over each of the three structured kinds — that was measured rather than inferred from the plain behaviour.

      The default is NONE for the same reason as above: undeclared means unconstrained.

      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