LucidDB / luciddb

DEFUNCT: See README
https://github.com/LucidDB/luciddb
Apache License 2.0
53 stars 24 forks source link

[FRG-200] CAST for intervals is incomplete #672

Open dynamobi-build opened 12 years ago

dynamobi-build commented 12 years ago

[reporter="angel", created="Mon, 11 Sep 2006 22:44:22 -0500 (GMT-05:00)"] CAST for intervals need to be implemented.

  1. Cast to/from strings. There is some basic casting from interval to string in the java calc. It doesn't fully match the SQL spec and precision is not taken into account. There is no support in the fennel calc at all.
  2. Cast to/from exact numerics need to be reviewed and finished (something happens now, but not necessarily the correct thing).
  3. Cast between compatible interval types is not working. Should be allows to cast from datetime interval to datetime interval, and from year-month interval to year-month interval.

    Cast specification for interval to string:
    From SQL:2003, 6.12 :

        d) If
        SD is a datetime data type or an interval data type, then let Y be the shortest character string that

        conforms to the definition of in
        Subclause 5.3, "", and such that the interpreted value

        of
        Y is SV and the interpreted precision of Y is the precision of SD. If SV is an interval, then

        shall be specified within in the literal
        Y.

        Case:

        i) If
        Y contains any that is not in the character repertoire of TD, then

        an exception condition is raised:
        data exception — invalid character value for cast.

        ii) If the length in characters
        LY of Y is equal to LTD, then TV is Y.

        iii) If the length in characters
        LY of Y is less than LTD, then TV is Y extended on the right by LTD-LY

        s.

        iv) Otherwise, an exception condition is raised:
        data exception — string data, right truncation.