phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ramkrishna.s.vasudevan (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PHOENIX-2475) Date arithmetic broken for time and timestamp
Date Wed, 23 Dec 2015 06:22:46 GMT

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

ramkrishna.s.vasudevan commented on PHOENIX-2475:
-------------------------------------------------

With the above select stmt I get
{code}
java.lang.IllegalArgumentException: nanos > 999999999 or < 0
	at org.apache.phoenix.util.DateUtil.getTimestamp(DateUtil.java:187)
	at org.apache.phoenix.util.DateUtil.getTimestamp(DateUtil.java:206)
	at org.apache.phoenix.expression.TimestampAddExpression.evaluate(TimestampAddExpression.java:78)
	at org.apache.phoenix.compile.ExpressionProjector.getValue(ExpressionProjector.java:69)
	at org.apache.phoenix.jdbc.PhoenixResultSet.getTimestamp(PhoenixResultSet.java:660)
	at org.apache.phoenix.end2end.MultiCfQueryExecIT.testAddTimeStamp(MultiCfQueryExecIT.java:362)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
{code}
in the latest trunk. In TimeStampAddExpression, the expression ts + 1 evaluates with 2 children
- one is the actual 'ts' which is the timestamp that is upserted and '1' is of type INTEGER.
So we try to convert 1 to BigDecimal 
{code}
 } else if (type.isCoercibleTo(PDecimal.INSTANCE)) {
                value = (((BigDecimal) PDecimal.INSTANCE.toObject(ptr, sortOrder)).multiply(QueryConstants.BD_MILLIS_IN_DAY)).setScale(6,
RoundingMode.HALF_UP);
            }
{code}
This evaluates 1 to a very large exponential number and hence timestamp is not getting evaluated.
This is the select query
{code}
     rs = conn.createStatement().executeQuery("SELECT ts + 1 FROM timestamp_table");
{code}

> Date arithmetic broken for time and timestamp
> ---------------------------------------------
>
>                 Key: PHOENIX-2475
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2475
>             Project: Phoenix
>          Issue Type: New Feature
>    Affects Versions: 4.6.0
>            Reporter: Kevin Liew
>            Priority: Minor
>              Labels: date, newbie, phoenix, timestamp
>             Fix For: 4.7.0
>
>
> Create a timestamp table and insert a timestamp
> {noformat}create table timestamp_table (ts timestamp primary key)upsert into timestamp_table
values ('1995-05-02 01:01:01'){noformat}
> Example test case
> {noformat}select ts + 1 from timestamp_table{noformat}
> Expected result:
> The timestamp with one day added to it
> {noformat}1995-05-03 01:01:01{noformat}
> Actual result:
> the unmodified timestamp



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message