[ 
https://issues.apache.org/jira/browse/CALCITE-3218?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16897619#comment-16897619
 ] 

Julian Hyde commented on CALCITE-3218:
--------------------------------------

[~lindseycat] wrote:{quote} Is the babel parser different from the one we were 
looking at yesterday?{quote}
Yes, kind of. It's an extension to the core parser. You "extend" it by adding 
definitions to text files read by the templating system. See what I did to add 
the "DATE()" function in 
[f1cad57|https://github.com/apache/calcite/commit/f1cad57035db0f94190433aa6db2352228a641e0].

That said, you should start by getting it working in the core parser, and add 
tests. Then create a PR. Then it's straightforward to move the code from 
{{Parser.jj}} to {{parserImpls.ftl}} and {{config.fmpp}}.

> Syntax error while parsing DATEADD function (which is valid on Redshift)
> ------------------------------------------------------------------------
>
>                 Key: CALCITE-3218
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3218
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Lindsey Meyer
>            Assignee: Julian Hyde
>            Priority: Major
>
> Syntax error while parsing the {{DATEADD}} function:
> {code:java}
> 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{code}
> throws 
> {noformat}
> `Column 'year' not found in any table`
> `DATEADD(year,1,...`
> {noformat}
> 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.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to