Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5698

EXTRACT from INTERVAL partially does not follow the SQL standard

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      From SQL standard we can found:

      ISO/IEC 9075-2:1999 (E)
      6.17 <numeric value function>:
      
      If <extract field> is a <primary datetime field>, then the result is the value of the datetime
      field identified by that <primary datetime field> and has the same sign as the <extract
      source>.

      other data bases are follow this rule, i.e. :

      SELECT
        EXTRACT (MONTH FROM INTERVAL '-1' MONTH)
      FROM
        DUAL;

      returns: -1

      and  **  the other one:

      SELECT EXTRACT(MONTH FROM INTERVAL '-1 MONTHS')

      return the same result,

      while calcite:

      SELECT EXTRACT(MONTH FROM INTERVAL -1 MONTHS) AS extracted;
      < +---------+
      < |      -1 |
      < +---------+
      ---
      > +-----------+
      > |        11 |
      > +-----------+

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            zstan Evgeny Stanilovsky
            zstan Evgeny Stanilovsky
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment