trinodb/trino

Support cast from varchar to day-time interval type

Aperta

#4697 aperta il 5 ago 2020

 (4 commenti) (0 reazioni) (0 assegnatari)Java (2678 fork)batch import
enhancementgood first issue

Metriche repository

Star
 (9113 stelle)
Metriche merge PR
 (Merge medio 5g 9h) (306 PR mergiate in 30 g)

Descrizione

From the SQL spec:

20) If TD is interval, then
    [...]
    b) If SD is character string, then SV is replaced by

        TRIM ( BOTH ' ' FROM VE )

    Case:
        i) If the rules for <literal> or for <unquoted interval string> in Subclause 5.3, “<literal>”, can be applied to SV to 
           determine a valid value of the data type TD, then let TV be that value.
        ii) Otherwise, an exception condition is raised: data exception — invalid interval format.

and

<unquoted interval string> ::= [ <sign> ] { <year-month literal> | <day-time literal> }

<day-time literal> ::= 
    <day-time interval>
  | <time interval>

<day-time interval> ::=
   <days value> [ <space> <hours value> [ <colon> <minutes value>  [ <colon> <seconds value> ] ] ]

<time interval> ::=
    <hours value> [ <colon> <minutes value> [ <colon> <seconds value> ] ]
  | <minutes value> [ <colon> <seconds value> ]
  | <seconds value>

(only the <day-time literal> part of <unquoted interval string> applies to day-time intervals.

Guida contributor