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

Syntax error while parsing DATEADD function (which is valid on Redshift)

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.21.0
    • None

    Description

      Syntax error while parsing the DATEADD function:

      SELECT 
      	DATE(CONVERT_TIMEZONE('UTC', 'America/Los_Angeles', events.event_date )) AS "events.event_date",
      	COALESCE(SUM(events.daily_user_count ), 0) AS "events.daily_active_users",
      	COALESCE(SUM(events.monthly_user_count ), 0) AS "events.monthly_active_users"
      FROM public.events_proto  AS events
      
      WHERE 
      	(((events.event_date ) >= ((CONVERT_TIMEZONE('America/Los_Angeles', 'UTC', DATEADD(day,-364, DATE_TRUNC('day',CONVERT_TIMEZONE('UTC', 'America/Los_Angeles', GETDATE())) )))) AND (events.event_date ) < ((CONVERT_TIMEZONE('America/Los_Angeles', 'UTC', DATEADD(day,365, DATEADD(day,-364, DATE_TRUNC('day',CONVERT_TIMEZONE('UTC', 'America/Los_Angeles', GETDATE())) ) ))))))
      GROUP BY 1
      HAVING 
      	NOT (COALESCE(SUM(events.monthly_user_count ), 0) = 0)
      ORDER BY 1 DESC
      LIMIT 500

      throws 

      `Column 'year' not found in any table`
      `DATEADD(year,1,...`
      

      This query is valid on Redshift. Redshift's parser understands that the first argument (DAY) is intended to be a time unit, not an identifier.

      Attachments

        Issue Links

        Activity

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

          People

            julianhyde Julian Hyde
            lindseycat Lindsey Meyer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m

                Slack

                  Issue deployment