phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramkris...@apache.org
Subject phoenix git commit: PHOENIX-2039 ROUND over numeric in GROUP BY always returns null (testcase only)-Ram
Date Tue, 05 Jan 2016 16:43:53 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 29435eef2 -> b76c076c0


PHOENIX-2039 ROUND over numeric in GROUP BY always returns null (testcase
only)-Ram


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/b76c076c
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/b76c076c
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/b76c076c

Branch: refs/heads/4.x-HBase-0.98
Commit: b76c076c0d9b5a349b8300dbb8a84ab0529cbc6d
Parents: 29435ee
Author: ramkrishna <ramkrishna.s.vasudevan@gmail.com>
Authored: Tue Jan 5 17:48:06 2016 +0530
Committer: ramkrishna <ramkrishna.s.vasudevan@gmail.com>
Committed: Tue Jan 5 22:13:36 2016 +0530

----------------------------------------------------------------------
 .../RoundFloorCeilFunctionsEnd2EndIT.java       | 38 ++++++++++++++++++++
 1 file changed, 38 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/b76c076c/phoenix-core/src/it/java/org/apache/phoenix/end2end/RoundFloorCeilFunctionsEnd2EndIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RoundFloorCeilFunctionsEnd2EndIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RoundFloorCeilFunctionsEnd2EndIT.java
index 42635c6..cd00354 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RoundFloorCeilFunctionsEnd2EndIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RoundFloorCeilFunctionsEnd2EndIT.java
@@ -17,6 +17,7 @@
  */
 package org.apache.phoenix.end2end;
 
+import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
 import static org.apache.phoenix.util.TestUtil.closeStmtAndConn;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -27,6 +28,7 @@ import java.sql.Date;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
+import java.sql.SQLException;
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.util.Properties;
@@ -36,6 +38,8 @@ import org.apache.phoenix.expression.function.FloorFunction;
 import org.apache.phoenix.expression.function.RoundFunction;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.util.DateUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.PropertiesUtil;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -554,4 +558,38 @@ public class RoundFloorCeilFunctionsEnd2EndIT extends BaseHBaseManagedTimeIT
{
 		}
 	}
 
+  @Test
+  public void testRoundOffFunction() throws SQLException {
+    long ts = nextTimestamp();
+    Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10));
+    Connection conn = DriverManager.getConnection(getUrl(), props);
+    String ddl = "create table round_test(k bigint primary key)";
+    conn.createStatement().execute(ddl);
+    conn.close();
+    
+    props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30));
+    conn = DriverManager.getConnection(getUrl(), props);
+    PreparedStatement stmt = conn.prepareStatement("upsert into round_test values(1380603308885)");
+    stmt.execute();
+    conn.commit();
+    conn.close();
+    
+
+    props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40));
+    conn = DriverManager.getConnection(getUrl(), props);
+    ResultSet rs;
+    stmt = conn.prepareStatement("select round(k/1000000,0) from round_test");
+    rs = stmt.executeQuery();
+    assertTrue(rs.next());
+    assertEquals(1380603, rs.getLong(1));
+    
+    props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40));
+    conn = DriverManager.getConnection(getUrl(), props);
+    stmt = conn.prepareStatement("select round(k/1000000,0) x from round_test group by x");
+    rs = stmt.executeQuery();
+    assertTrue(rs.next());
+    assertEquals(1380603, rs.getLong(1));
+  }
+
 }


Mime
View raw message