phoenix-dev mailing list archives

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


ramkrishna.s.vasudevan commented on PHOENIX-2475:

With the above select stmt I get
java.lang.IllegalArgumentException: nanos > 999999999 or < 0
	at org.apache.phoenix.util.DateUtil.getTimestamp(
	at org.apache.phoenix.util.DateUtil.getTimestamp(
	at org.apache.phoenix.expression.TimestampAddExpression.evaluate(
	at org.apache.phoenix.compile.ExpressionProjector.getValue(
	at org.apache.phoenix.jdbc.PhoenixResultSet.getTimestamp(
	at org.apache.phoenix.end2end.MultiCfQueryExecIT.testAddTimeStamp(
	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(
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(
	at org.junit.internal.runners.statements.RunAfters.evaluate(
	at org.junit.runners.ParentRunner.runLeaf(
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(
	at org.junit.runners.ParentRunner$
	at org.junit.runners.ParentRunner$1.schedule(
	at org.junit.runners.ParentRunner.runChildren(
	at org.junit.runners.ParentRunner.access$000(
	at org.junit.runners.ParentRunner$2.evaluate(
	at org.junit.internal.runners.statements.RunBefores.evaluate(
	at org.junit.internal.runners.statements.RunAfters.evaluate(
	at org.junit.rules.ExternalResource$1.evaluate(
	at org.junit.rules.RunRules.evaluate(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
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 
 } else if (type.isCoercibleTo(PDecimal.INSTANCE)) {
                value = (((BigDecimal) PDecimal.INSTANCE.toObject(ptr, sortOrder)).multiply(QueryConstants.BD_MILLIS_IN_DAY)).setScale(6,
This evaluates 1 to a very large exponential number and hence timestamp is not getting evaluated.
This is the select query
     rs = conn.createStatement().executeQuery("SELECT ts + 1 FROM timestamp_table");

> Date arithmetic broken for time and timestamp
> ---------------------------------------------
>                 Key: PHOENIX-2475
>                 URL:
>             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

View raw message