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

James Duong commented on CALCITE-2339:
--------------------------------------

* missing MINUTE from the switch
 * >>> done


 * I don't think the visitor can throw FoundOne
 * >>> the DateTimePlusToTsAddVisitor can throw a FoundOne() by design - if it 
runs into a multi-field interval since we can't transform that to timestampAdd 
([https://github.com/jduo/calcite/blob/16e9e46c0db8e46a5e14beed208ca486f24bf09a/core/src/main/java/org/apache/calcite/rex/RexUtil.java#L2711|https://github.com/jduo/calcite/blob/16e9e46c0db8e46a5e14beed208ca486f24bf09a/core/src/main/java/org/apache/calcite/rex/RexUtil.java#L2711)]
 )


 * only call the method if the condition is not null, do not check for nulls in 
the method, and assume the method returns not-null
 * >>> assuming this is in reference to the convertDatetimePlusToTimestampAdd() 
method. I would like to have the semantics to return either the transformation 
is not possible, or the completed transformation. Would a Java8 optional be 
more appropriate?


 * indentation is off in a couple of places
 * >>> I'll check this out.


 * need some unit tests
 * >>> Will do.
 * rather than trying to do constant reduction to convert interval to integer, 
could you just use "cast(<interval expression> AS INTEGER)"? less code to 
maintain
 * >>> I thought about this, but realized that if we ever need to invoke this 
transformation to timestampadd, it means the backend probably doesn't support 
intervals so you can't use CAST(<interval expression>). What might work is to 
create the Cast node, then use RexSimplify to see if it can be constant-reduced 
to just an integer literal. I'll look into this.

> JDBC adapter should transform timestamp arithmetic for target database 
> -----------------------------------------------------------------------
>
>                 Key: CALCITE-2339
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2339
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Assignee: Julian Hyde
>            Priority: Major
>         Attachments: Datetime Addition - Calcite.pdf
>
>
> JDBC adapter should transform timestamp arithmetic for target database.
> There are two ways in Calcite to add intervals to timestamps: the 
> TIMESTAMP_ADD function and the "<timestamp> + <interval>" operator.
> The attached document (authored by James Doung) describes their pros and cons.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to