[
https://issues.apache.org/jira/browse/OPTIQ-304?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14037000#comment-14037000
]
Vladimir Sitnikov edited comment on OPTIQ-304 at 6/19/14 5:57 AM:
------------------------------------------------------------------
In fact, {{DATE/INTERVAL}} implementation is very strange.
Can you explain why it is based on the adding apples and oranges?
Try using {{date '2014-06-19' + interval '1' year}} in
[testPlusIntervalOperator|https://github.com/julianhyde/optiq/blob/master/core/src/test/java/org/eigenbase/sql/test/SqlOperatorBaseTest.java#L2724]
and you'll get
{noformat}
java.lang.AssertionError:
Expected :[2015-06-19]
Actual :[2014-06-31]
{noformat}
{code:java}
/* 23 */ public Object current() {
/* 24 */ return $L4J$C$16240_12;
/* 25 */ }
/* 26 */
/* 27 */ static final int $L4J$C$16240_12 = 16240 + 12; // !!! interval '1'
year is converted to 12 months and 12 gets added to the number of days
{code}
Can you explain
[SqlOperatorBaseTest#testCastIntervalToNumeric|https://github.com/julianhyde/optiq/blob/master/core/src/test/java/org/eigenbase/sql/test/SqlOperatorBaseTest.java#L655]?
How useful is {{cast(INTERVAL '5' minute as decimal(2,1))==5}} and
{{cast(INTERVAL '5' hour as decimal(2,1))==5}}?
was (Author: vladimirsitnikov):
In fact, {{DATE/INTERVAL}} implementation is very strange.
Can you explain why it is based on the adding apples and oranges?
Try using {{date '2014-06-19' + interval '1' year}} in
[testPlusIntervalOperator|https://github.com/julianhyde/optiq/blob/master/core/src/test/java/org/eigenbase/sql/test/SqlOperatorBaseTest.java#L2724]
and you'll get
{noformat}
java.lang.AssertionError:
Expected :[2015-05-19]
Actual :[2014-05-31]
{noformat}
{code:java}
/* 23 */ public Object current() {
/* 24 */ return $L4J$C$16240_12;
/* 25 */ }
/* 26 */
/* 27 */ static final int $L4J$C$16240_12 = 16240 + 12; // !!! interval '1'
year is converted to 12 months and 12 gets added to the number of days
{code}
Can you explain
[SqlOperatorBaseTest#testCastIntervalToNumeric|https://github.com/julianhyde/optiq/blob/master/core/src/test/java/org/eigenbase/sql/test/SqlOperatorBaseTest.java#L655]?
How useful is {{cast(INTERVAL '5' minute as decimal(2,1))==5}} and
{{cast(INTERVAL '5' hour as decimal(2,1))==5}}?
> Support '<DATE> + <INTEGER>' operator
> -------------------------------------
>
> Key: OPTIQ-304
> URL: https://issues.apache.org/jira/browse/OPTIQ-304
> Project: optiq
> Issue Type: Bug
> Reporter: Julian Hyde
>
> We should support '<DATE> + <INTEGER>' operator. I'm not sure whether it is
> standard SQL, but it occurs in TPC-DS (query 72).
> Note that {{d + n}} is equivalent to {{d + interval n day}} if {{n}} is a
> constant.
--
This message was sent by Atlassian JIRA
(v6.2#6252)