trinodb/trino

Support cast from varchar to day-time interval type

Open

#4,697 opened on Aug 5, 2020

View on GitHub
 (4 comments) (0 reactions) (0 assignees)Java (2,678 forks)batch import
enhancementgood first issue

Repository metrics

Stars
 (9,113 stars)
PR merge metrics
 (Avg merge 5d 9h) (306 merged PRs in 30d)

Description

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.

Contributor guide