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

James Taylor commented on PHOENIX-2475:
---------------------------------------

Tests look good. Thanks, [~ram_krish]. Couple minor nits:
- Would you mind adding TIME and TIMESTAMP subtraction tests like you've done 
for add?
- Would you mind increasing the readability of the Time tests by getting the 
millis for the original time value and comparing against that (instead of those 
hard coded long values)? Like this:
{code}
+      props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 
30));
+      conn = DriverManager.getConnection(getUrl(), props);
+      stmt = conn.prepareStatement("upsert into time_table values (?)");
+      Time time = new Time(1995 - 1900, 4, 2);
+      stmt.setTime(1, time);
+      stmt.execute();
+      conn.commit();
+      props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 
60));
+      conn = DriverManager.getConnection(getUrl(), props);
+      rs = conn.createStatement().executeQuery("SELECT ts FROM time_table");
+      assertTrue(rs.next());
+      assertEquals(time.getTime(),rs.getTimestamp(1).getTime());
+      props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 
70));
+      conn = DriverManager.getConnection(getUrl(), props);
+      rs = conn.createStatement().executeQuery("SELECT ts + 1 FROM 
time_table");
+      assertTrue(rs.next());
+      assertEquals(time.getTime() + 
TestUtil.MILLIS_IN_DAY,rs.getTimestamp(1).getTime());
{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
>            Assignee: ramkrishna.s.vasudevan
>            Priority: Minor
>              Labels: date, newbie, phoenix, timestamp
>             Fix For: 4.7.0
>
>         Attachments: PHOENIX-2475_1_master.patch, 
> PHOENIX-2475_2_master.patch, PHOENIX-2475_master.patch
>
>
> 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)

Reply via email to