Yes, please create a JIRA and pull request. We’ll need to review but I’m pretty sure these functions would fit into Calcite.
> On Mar 3, 2016, at 12:57 PM, Arina Yelchiyeva <[email protected]> > wrote: > > I've made my changes based on calcite master (link above in mailing > thread). If they comply with community vision, I'd like to contribe them. > > If approach is acceptable, I can create jira and make pull request. > > On Thu, Mar 3, 2016, 20:51 Julian Hyde <[email protected]> wrote: > >> Interval types (e.g. SECOND) are key words, not an expressions, so calls >> to these functions are not ordinary function call syntax. You will need to >> modify the parser. We could add these functions to Calcite in a mysql >> compatibility mode. >> >> There are some other functions that use interval types, e.g. >> FLOOR(expression TO SECOND). You could use those as examples when modifying >> the parser. >> >> You may need to add MICROSECOND, QUARTER to enum TimeUnit. >> >> Julian >> >> >>> On Mar 3, 2016, at 7:17 AM, Arina Yelchiyeva <[email protected]> >> wrote: >>> >>> Hi all! >>> >>> I've been implementing timestampadd / timestampdiff functions for Drill >> and >>> noticed that these functions parsing is not fully implemented in Calcite. >>> First parameter in these functions is timestamp interval which can be on >>> one the following: >>> MICROSECOND (MICROSECONDS, FRAC_SECOND (deprecated)), (SQL_TSI_)SECOND, >>> (SQL_TSI_)MINUTE, (SQL_TSI_)HOUR, (SQL_TSI_)DAY, >>> (SQL_TSI_)WEEK,(SQL_TSI_)MONTH, (SQL_TSI_)QUARTER, (SQL_TSI_)YEAR >>> >>> Whenever I call timestampadd / timestampdiff with first parameter one of >>> above >>> (ex: timestampadd(second, 1, current_datetime). Calcite throws an error: >>> >>> Caused by: org.apache.calcite.sql.parser.SqlParseException: Encountered >> "( >>> SECOND" at line 1, column 25. >>> Was expecting one of: >>> "(" "*" ... >>> "(" ")" ... >>> "(" "WITH" ... >>> and so on. >>> >>> I have tried to implement parsing for timestamp[add|diff] in Calcite. >>> I have registered all timestamp intervals as tokens to convert them to >>> literals whenever they come inside timestamp[add|diff] structure. Also >> have >>> added them into SqlStdOperatorTable. >>> >>> But I am not sure if this is correct approach. Is there anybody who can >>> take a look at diff? >>> Link - >>> >> https://github.com/arina-ielchiieva/calcite/commit/723898d6b1cf222b44edc9c5f6c51072d2ccfe92 >>> >>> >>> Thank you in advance! >>> >>> Kind regards >>> Arina >> >>
