phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeffr...@apache.org
Subject [47/50] [abbrv] git commit: Add test case MutableIndexTest.testIndexWithDecimalCol()
Date Wed, 05 Mar 2014 22:55:33 GMT
Add test case MutableIndexTest.testIndexWithDecimalCol()


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

Branch: refs/heads/4.0
Commit: 3df8a827510e51c04b54306ff344c3e4fb5c29e7
Parents: b36daea
Author: maryannxue <maryannxue@apache.org>
Authored: Wed Mar 5 00:49:27 2014 -0500
Committer: maryannxue <maryannxue@apache.org>
Committed: Wed Mar 5 00:49:27 2014 -0500

----------------------------------------------------------------------
 .../end2end/index/BaseMutableIndexTest.java     | 18 +++++-----
 .../phoenix/end2end/index/MutableIndexTest.java | 38 ++++++++++++++++++++
 2 files changed, 47 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/3df8a827/phoenix-core/src/test/java/org/apache/phoenix/end2end/index/BaseMutableIndexTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/end2end/index/BaseMutableIndexTest.java
b/phoenix-core/src/test/java/org/apache/phoenix/end2end/index/BaseMutableIndexTest.java
index afbf804..05da4a1 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/end2end/index/BaseMutableIndexTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/end2end/index/BaseMutableIndexTest.java
@@ -74,17 +74,17 @@ public class BaseMutableIndexTest extends BaseIndexTest {
             stmt.setString(2, "char1");
             stmt.setInt(3, 1);
             stmt.setLong(4, 1L);
-            stmt.setBigDecimal(5, new BigDecimal(1.0));
+            stmt.setBigDecimal(5, new BigDecimal("1.1"));
             stmt.setString(6, "varchar_a");
             stmt.setString(7, "chara");
             stmt.setInt(8, 2);
             stmt.setLong(9, 2L);
-            stmt.setBigDecimal(10, new BigDecimal(2.0));
+            stmt.setBigDecimal(10, new BigDecimal("2.1"));
             stmt.setString(11, "varchar_b");
             stmt.setString(12, "charb");
             stmt.setInt(13, 3);
             stmt.setLong(14, 3L);
-            stmt.setBigDecimal(15, new BigDecimal(3.0));
+            stmt.setBigDecimal(15, new BigDecimal("3.1"));
             stmt.setDate(16, date == null ? null : new Date(date.getTime() + TestUtil.MILLIS_IN_DAY));
             stmt.executeUpdate();
             
@@ -92,17 +92,17 @@ public class BaseMutableIndexTest extends BaseIndexTest {
             stmt.setString(2, "char2");
             stmt.setInt(3, 2);
             stmt.setLong(4, 2L);
-            stmt.setBigDecimal(5, new BigDecimal(2.0));
+            stmt.setBigDecimal(5, new BigDecimal("2.2"));
             stmt.setString(6, "varchar_a");
             stmt.setString(7, "chara");
             stmt.setInt(8, 3);
             stmt.setLong(9, 3L);
-            stmt.setBigDecimal(10, new BigDecimal(3.0));
+            stmt.setBigDecimal(10, new BigDecimal("3.2"));
             stmt.setString(11, "varchar_b");
             stmt.setString(12, "charb");
             stmt.setInt(13, 4);
             stmt.setLong(14, 4L);
-            stmt.setBigDecimal(15, new BigDecimal(4.0));
+            stmt.setBigDecimal(15, new BigDecimal("4.2"));
             stmt.setDate(16, date);
             stmt.executeUpdate();
             
@@ -110,17 +110,17 @@ public class BaseMutableIndexTest extends BaseIndexTest {
             stmt.setString(2, "char3");
             stmt.setInt(3, 3);
             stmt.setLong(4, 3L);
-            stmt.setBigDecimal(5, new BigDecimal(3.0));
+            stmt.setBigDecimal(5, new BigDecimal("3.3"));
             stmt.setString(6, "varchar_a");
             stmt.setString(7, "chara");
             stmt.setInt(8, 4);
             stmt.setLong(9, 4L);
-            stmt.setBigDecimal(10, new BigDecimal(4.0));
+            stmt.setBigDecimal(10, new BigDecimal("4.3"));
             stmt.setString(11, "varchar_b");
             stmt.setString(12, "charb");
             stmt.setInt(13, 5);
             stmt.setLong(14, 5L);
-            stmt.setBigDecimal(15, new BigDecimal(5.0));
+            stmt.setBigDecimal(15, new BigDecimal("5.3"));
             stmt.setDate(16, date == null ? null : new Date(date.getTime() + 2 * TestUtil.MILLIS_IN_DAY));
             stmt.executeUpdate();
             

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/3df8a827/phoenix-core/src/test/java/org/apache/phoenix/end2end/index/MutableIndexTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/end2end/index/MutableIndexTest.java
b/phoenix-core/src/test/java/org/apache/phoenix/end2end/index/MutableIndexTest.java
index 00056c9..613fb63 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/end2end/index/MutableIndexTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/end2end/index/MutableIndexTest.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import java.math.BigDecimal;
 import java.sql.Connection;
 import java.sql.Date;
 import java.sql.DriverManager;
@@ -782,4 +783,41 @@ public class MutableIndexTest extends BaseMutableIndexTest {
             conn.close();
         }
     }
+
+    @Test
+    public void testIndexWithDecimalCol() throws Exception {
+        Properties props = new Properties(TEST_PROPERTIES);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        conn.setAutoCommit(false);
+        try {
+            Date date = new Date(System.currentTimeMillis());
+            
+            createTestTable();
+            populateTestTable(date);
+            String ddl = "CREATE INDEX " + INDEX_TABLE_NAME + " ON " + DATA_TABLE_FULL_NAME
+ " (decimal_pk) INCLUDE (decimal_col1, decimal_col2)";
+            PreparedStatement stmt = conn.prepareStatement(ddl);
+            stmt.execute();
+            
+            String query = "SELECT decimal_pk, decimal_col1, decimal_col2 from " + DATA_TABLE_FULL_NAME
;
+            ResultSet rs = conn.createStatement().executeQuery("EXPLAIN " + query);
+            assertEquals("CLIENT PARALLEL 1-WAY FULL SCAN OVER " + INDEX_TABLE_FULL_NAME,
QueryUtil.getExplainPlan(rs));
+            
+            rs = conn.createStatement().executeQuery(query);
+            assertTrue(rs.next());
+            assertEquals(new BigDecimal("1.1"), rs.getBigDecimal(1));
+            assertEquals(new BigDecimal("2.1"), rs.getBigDecimal(2));
+            assertEquals(new BigDecimal("3.1"), rs.getBigDecimal(3));
+            assertTrue(rs.next());
+            assertEquals(new BigDecimal("2.2"), rs.getBigDecimal(1));
+            assertEquals(new BigDecimal("3.2"), rs.getBigDecimal(2));
+            assertEquals(new BigDecimal("4.2"), rs.getBigDecimal(3));
+            assertTrue(rs.next());
+            assertEquals(new BigDecimal("3.3"), rs.getBigDecimal(1));
+            assertEquals(new BigDecimal("4.3"), rs.getBigDecimal(2));
+            assertEquals(new BigDecimal("5.3"), rs.getBigDecimal(3));
+            assertFalse(rs.next());
+        } finally {
+            conn.close();
+        }
+    }
 }


Mime
View raw message