Re: Datetime_Plus and TimestampAdd operators

2018-05-30 Thread Julian Hyde
There doesn’t seem to be a clear victor: TIMESTAMPADD is specified by ODBC, whereas interval “+” is specified by the SQL standard. TIMESTAMPADD TIMESTAMPADD with Calcite extensions can handle unusual intervals such as WEEK, whereas these cannot be directly expressed using interval “+” Interval

Re: Datetime_Plus and TimestampAdd operators

2018-05-30 Thread Julian Hyde
I have logged https://issues.apache.org/jira/browse/CALCITE-2339 to capture this discussion, and attached a PDF snapshot of the google doc. > On May 30, 2018, at 1:24 PM, James Duong wrote: > > Note that this is essentially an extension of

Re: Datetime_Plus and TimestampAdd operators

2018-05-30 Thread James Duong
Note that this is essentially an extension of the current way we expose these two operations. We expose a form that normalizes the two approaches but allows the adapter layer to get it into a form that it supports. Some databases support TIMESTAMPADD only such as SQL Server. While others support

Re: Datetime_Plus and TimestampAdd operators

2018-05-30 Thread James Duong
Thanks Michael. Here is a link to a Google Doc: https://docs.google.com/document/d/1j0wa0pZ2senQhAoy_3W_Ev2vHqIhm3ob19BGy4nBJkI/edit?usp=sharing On Wed, May 30, 2018 at 6:08 AM, Michael Mior wrote: > James, > > Just a note that the list doesn't support attachments. I'd suggest creating > a

Re: Datetime_Plus and TimestampAdd operators

2018-05-30 Thread Michael Mior
James, Just a note that the list doesn't support attachments. I'd suggest creating a Google Doc with the contents. -- Michael Mior mm...@uwaterloo.ca Le mer. 30 mai 2018 à 04:23, James Duong a écrit : > I've recorded my thoughts on this in the attached document > > A few notes: > -

Re: Datetime_Plus and TimestampAdd operators

2018-05-30 Thread James Duong
I've recorded my thoughts on this in the attached document A few notes: - TimestampAdd has very well-spec'd behavior as part of ODBC. For example the semantics for how to handle adding a second to a date value are clearly defined. I experimented with a few different databases for how this is

Re: Datetime_Plus and TimestampAdd operators

2018-05-28 Thread Julian Hyde
I think we should use the datetime_plus operator. It is standard, and sufficiently general. Its second argument needs to be an interval value, not necessarily an interval literal. On Mon, May 28, 2018 at 2:35 PM, James Duong wrote: > There are essentially two ways to add an interval to a

Datetime_Plus and TimestampAdd operators

2018-05-28 Thread James Duong
There are essentially two ways to add an interval to a datetime vaue in Calcite Call the timestampadd() function: select {fn timestampadd(year, 1, hire_date)}... Use datetime_plus interval arithmetic: select hire_date + interval '1' year Note that timestampadd's second argument does not need