You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Tanner Clary <ta...@google.com.INVALID> on 2022/11/21 17:19:12 UTC

BigQuery Timestamp_Add Implementation Question

Hello,

Apologies if this is not the correct medium for this question, I am a new
contributor to Calcite. I am currently working on
https://issues.apache.org/jira/browse/CALCITE-5360 and am running into some
issues getting the function to accept time units outside of second, minute,
hour, day, month, and year. I believe this is due to the way the call is
parsed, as the newly implemented TimeUnitOrName() which covers a wider
array of time units including custom timeframes, is not invoked in the
generic function call. One solution I was attempting involved creating a
custom function call for BQ's timestamp_add that did utilize the
TimeUnitOrName() but I was thinking there may be a better solution
(potentially modifying the generic function call) in case this issue arises
in the future for other function implementations. I suppose my question is
asking if there are any glaring issues with either of these approaches or
if there is another better alternative. Apologies again if this is the
wrong forum. Thank you!

Best,
Tanner Clary

Re: BigQuery Timestamp_Add Implementation Question

Posted by Julian Hyde <jh...@gmail.com>.
Tanner,

I made a comment in the Jira case that I hoped that TIMESTAMP_ADD would map onto the TIMESTAMPADD function (basically just be a synonym for it) as the DATEADD function already does. TIMESTAMPADD already handles custom time frames [1]. Did you try that strategy?

It’s a bit confusing that Calcite’s existing TIMESTAMPADD function maps to the field TIMESTAMP_ADD (with an underscore) in SqlStdOperatorTable. But I think it’s unavoidable.

Julian

[1] https://github.com/apache/calcite/blob/dc56fcc912261a09021a74f13de35b426f3d0d8b/core/src/main/java/org/apache/calcite/sql/fun/SqlTimestampAddFunction.java#L116


> On Nov 21, 2022, at 9:19 AM, Tanner Clary <ta...@google.com.INVALID> wrote:
> 
> Hello,
> 
> Apologies if this is not the correct medium for this question, I am a new
> contributor to Calcite. I am currently working on
> https://issues.apache.org/jira/browse/CALCITE-5360 and am running into some
> issues getting the function to accept time units outside of second, minute,
> hour, day, month, and year. I believe this is due to the way the call is
> parsed, as the newly implemented TimeUnitOrName() which covers a wider
> array of time units including custom timeframes, is not invoked in the
> generic function call. One solution I was attempting involved creating a
> custom function call for BQ's timestamp_add that did utilize the
> TimeUnitOrName() but I was thinking there may be a better solution
> (potentially modifying the generic function call) in case this issue arises
> in the future for other function implementations. I suppose my question is
> asking if there are any glaring issues with either of these approaches or
> if there is another better alternative. Apologies again if this is the
> wrong forum. Thank you!
> 
> Best,
> Tanner Clary