Class TimeFunction


public class TimeFunction extends ToTime
TIME(<expr>) — the TIME synonym, which is not TO_TIME. The account resolves it among one-argument overloads — a text, a VARIANT, a timestamp — so it reads a text exactly as TO_TIME does and everything else its own way (all live-verified):
   TIME('10:00:00')              10:00:00
   TIME(TRUE)                    Time 'true' is not recognized            a BOOLEAN reads as its text
   TIME(123), TIME(n)            Failed to cast variant value 123 to TIME   a NUMBER goes by a VARIANT
   TIME(d)                       00:00:00                                 a DATE is its midnight
   TIME(ts), TIME(ltz), TIME(tz) the wall clock
   TIME(o), TIME(a)              Failed to cast variant value {"a":1} to TIME
   TIME(PARSE_JSON('"10:00"'))   10:00:00                                 a VARIANT's text, or its TIME
   TIME(PARSE_JSON('"abc"'))     Failed to cast variant value "abc" to TIME
   TIME(tm)                      incompatible types: [TIME(9)] and [TIMESTAMP_LTZ(9)]
   TIME(bn)                      Invalid argument types for function 'TIME': (BINARY(8388608))
   TIME('10:00', 'HH24:MI')      too many arguments for function [...] expected 1, got 2
   TIME()                        Invalid argument types for function 'TIME': ()
 
  • Constructor Details

    • TimeFunction

      public TimeFunction()
  • Method Details

    • evaluate

      public Object evaluate(List<Object> args)
      Description copied from class: BuiltInFunction
      Computes the function's result over its already-evaluated argument values. A SQL NULL argument arrives as Java null, and returning null makes the SQL result NULL.
      Overrides:
      evaluate in class ToTime
      Parameters:
      args - the argument values, in call order
      Returns:
      the function's value for these arguments, or null for SQL NULL
    • getMaxArgCount

      public int getMaxArgCount()
      Description copied from class: BuiltInFunction
      The most arguments a call to this function may pass; Integer.MAX_VALUE marks a variadic function (see BuiltInFunction.isVariadic()).
      Overrides:
      getMaxArgCount in class ToTime
      Returns:
      the maximum accepted argument count
    • refusesMissingArgumentsByType

      public boolean refusesMissingArgumentsByType()
      Description copied from class: BuiltInFunction
      Whether a call with fewer arguments than BuiltInFunction.getMinArgCount() is refused by its argument types rather than by its count. A function the account resolves among overloads has no single count to report: live, TIME() is "Invalid argument types for function 'TIME': ()" where LOG(10) is "not enough arguments for function [LOG(10)], expected 2, got 1".
      Overrides:
      refusesMissingArgumentsByType in class BuiltInFunction
      Returns:
      true when the refusal lists the argument types; false by default
    • binaryRejection

      public SemiStructuredRejection binaryRejection(int position)
      A BINARY matches no overload: "Invalid argument types for function 'TIME': (BINARY(1))".
      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
    • temporalRejection

      public SemiStructuredRejection temporalRejection(int position, int argumentCount, DataType temporal)
      A TIME is refused on its way to the TIMESTAMP_LTZ overload; a DATE and a timestamp are read.
      Overrides:
      temporalRejection in class BuiltInFunction
      Parameters:
      position - the zero-based argument position being asked about
      argumentCount - how many arguments the call carries
      temporal - the argument's declared temporal type
      Returns:
      the refusal this position gives that temporal value