phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject [1/4] phoenix git commit: PHOENIX-4185 Rewrite tests to disable DDL and DML for PercentileIT.java and ProductMetricsIT.java (Ethan Wang)
Date Wed, 13 Sep 2017 00:04:59 GMT
Repository: phoenix
Updated Branches:
  refs/heads/master d9ac3f109 -> 586cdab9f


http://git-wip-us.apache.org/repos/asf/phoenix/blob/586cdab9/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
index 87b7af6..969b585 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
@@ -48,13 +48,15 @@ import org.apache.phoenix.util.DateUtil;
 import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.After;
 import org.junit.Test;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Ordering;
 
 
-public class ProductMetricsIT extends BaseClientManagedTimeIT {
+public class ProductMetricsIT extends ParallelStatsDisabledIT {
     private static final String PRODUCT_METRICS_NAME = "PRODUCT_METRICS";
     private static final String PRODUCT_METRICS_SCHEMA_NAME = "";
     private static final String DS1 = "1970-01-01 00:58:00";
@@ -76,57 +78,55 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
     private static final String F3 = "C";
     private static final String R1 = "R1";
     private static final String R2 = "R2";
-    
+
     private static byte[][] getSplits(String tenantId) {
-        return new byte[][] { 
-            ByteUtil.concat(Bytes.toBytes(tenantId), PDate.INSTANCE.toBytes(D3)),
-            ByteUtil.concat(Bytes.toBytes(tenantId), PDate.INSTANCE.toBytes(D5)),
-            };
+        return new byte[][] {
+                ByteUtil.concat(Bytes.toBytes(tenantId), PDate.INSTANCE.toBytes(D3)),
+                ByteUtil.concat(Bytes.toBytes(tenantId), PDate.INSTANCE.toBytes(D5)),
+        };
     }
-    
+
     private static Date toDate(String dateString) {
         return DateUtil.parseDate(dateString);
     }
-    
-    private static void initTable(byte[][] splits, long ts) throws Exception {
-        ensureTableCreated(getUrl(), PRODUCT_METRICS_NAME, PRODUCT_METRICS_NAME,splits, ts-2, null);
+
+    private static void initTable(String tablename, byte[][] splits) throws Exception {
+        ensureTableCreated(getUrl(), tablename, PRODUCT_METRICS_NAME, splits, null, null);
     }
 
-    private static void assertNoRows(Connection conn) throws SQLException {
+    private static void assertNoRows(String tablename,Connection conn) throws SQLException {
         Statement stmt = conn.createStatement();
-        ResultSet rs = stmt.executeQuery("select 1 from PRODUCT_METRICS");
+        ResultSet rs = stmt.executeQuery("select 1 from "+tablename);
         assertFalse(rs.next());
     }
-    
-    private static void initTableValues(String tenantId, byte[][] splits, long ts) throws Exception {
-        initTable(splits, ts);
 
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + ts; // Run query at timestamp 5
+    private static void initTableValues(String tablename, String tenantId, byte[][] splits) throws Exception {
+        initTable(tablename, splits);
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            assertNoRows(conn);
-            initTableValues(conn, tenantId);
+            assertNoRows(tablename, conn);
+            initTableValues(tablename, conn, tenantId);
             conn.commit();
         } finally {
             conn.close();
         }
     }
-    
-    protected static void initTableValues(Connection conn, String tenantId) throws Exception {
+
+    protected static void initTableValues(String tablename, Connection conn, String tenantId) throws Exception {
         PreparedStatement stmt = conn.prepareStatement(
-            "upsert into " +
-            "PRODUCT_METRICS(" +
-            "    ORGANIZATION_ID, " +
-            "    \"DATE\", " +
-            "    FEATURE, " +
-            "    UNIQUE_USERS, " +
-            "    TRANSACTIONS, " +
-            "    CPU_UTILIZATION, " +
-            "    DB_UTILIZATION, " +
-            "    REGION, " +
-            "    IO_TIME)" +
-            "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
+                "upsert into " + tablename +
+                        " (" +
+                        "    ORGANIZATION_ID, " +
+                        "    \"DATE\", " +
+                        "    FEATURE, " +
+                        "    UNIQUE_USERS, " +
+                        "    TRANSACTIONS, " +
+                        "    CPU_UTILIZATION, " +
+                        "    DB_UTILIZATION, " +
+                        "    REGION, " +
+                        "    IO_TIME)" +
+                        "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
         stmt.setString(1, tenantId);
         stmt.setDate(2, D1);
         stmt.setString(3, F1);
@@ -137,7 +137,7 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
         stmt.setString(8, R2);
         stmt.setNull(9, Types.BIGINT);
         stmt.execute();
-        
+
         stmt.setString(1, tenantId);
         stmt.setDate(2, D2);
         stmt.setString(3, F1);
@@ -148,7 +148,7 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
         stmt.setString(8, null);
         stmt.setLong(9, 2000);
         stmt.execute();
-        
+
         stmt.setString(1, tenantId);
         stmt.setDate(2, D3);
         stmt.setString(3, F1);
@@ -159,7 +159,7 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
         stmt.setString(8, R1);
         stmt.setNull(9, Types.BIGINT);
         stmt.execute();
-        
+
         stmt.setString(1, tenantId);
         stmt.setDate(2, D4);
         stmt.setString(3, F2);
@@ -170,7 +170,7 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
         stmt.setString(8, R1);
         stmt.setLong(9, 4000);
         stmt.execute();
-        
+
         stmt.setString(1, tenantId);
         stmt.setDate(2, D5);
         stmt.setString(3, F3);
@@ -181,7 +181,7 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
         stmt.setString(8, R2);
         stmt.setLong(9, 5000);
         stmt.execute();
-        
+
         stmt.setString(1, tenantId);
         stmt.setDate(2, D6);
         stmt.setString(3, F1);
@@ -193,40 +193,39 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
         stmt.setNull(9, Types.BIGINT);
         stmt.execute();
     }
-        
-    private static void initDateTableValues(String tenantId, byte[][] splits, long ts, Date startDate) throws Exception {
-        initDateTableValues(tenantId, splits, ts, startDate, 2.0);
+
+    private static void initDateTableValues(String tablename, String tenantId, byte[][] splits, Date startDate) throws Exception {
+        initDateTableValues(tablename, tenantId, splits, startDate, 2.0);
     }
-    
-    private static void initDateTableValues(String tenantId, byte[][] splits, long ts, Date startDate, double dateIncrement) throws Exception {
-        initTable(splits, ts);
 
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + ts; // Run query at timestamp 5
+    private static void initDateTableValues(String tablename, String tenantId, byte[][] splits, Date startDate, double dateIncrement) throws Exception {
+         initTable(tablename, splits);
+
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            assertNoRows(conn);
-            initDateTableValues(conn, tenantId, startDate, dateIncrement);
+            assertNoRows(tablename, conn);
+            initDateTableValues(tablename, conn, tenantId, startDate, dateIncrement);
             conn.commit();
         } finally {
             conn.close();
         }
     }
-    
-    private static void initDateTableValues(Connection conn, String tenantId, Date startDate, double dateIncrement) throws Exception {
+
+    private static void initDateTableValues(String tablename, Connection conn, String tenantId, Date startDate, double dateIncrement) throws Exception {
         PreparedStatement stmt = conn.prepareStatement(
-            "upsert into " +
-            "PRODUCT_METRICS(" +
-            "    ORGANIZATION_ID, " +
-            "    \"DATE\", " +
-            "    FEATURE, " +
-            "    UNIQUE_USERS, " +
-            "    TRANSACTIONS, " +
-            "    CPU_UTILIZATION, " +
-            "    DB_UTILIZATION, " +
-            "    REGION, " +
-            "    IO_TIME)" +
-            "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
+                "upsert into " +tablename+
+                        "(" +
+                        "    ORGANIZATION_ID, " +
+                        "    \"DATE\", " +
+                        "    FEATURE, " +
+                        "    UNIQUE_USERS, " +
+                        "    TRANSACTIONS, " +
+                        "    CPU_UTILIZATION, " +
+                        "    DB_UTILIZATION, " +
+                        "    REGION, " +
+                        "    IO_TIME)" +
+                        "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
         stmt.setString(1, tenantId);
         stmt.setDate(2, startDate);
         stmt.setString(3, "A");
@@ -237,7 +236,7 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
         stmt.setString(8, R2);
         stmt.setNull(9, Types.BIGINT);
         stmt.execute();
-        
+
         startDate = new Date(startDate.getTime() + (long)(QueryConstants.MILLIS_IN_DAY * dateIncrement));
         stmt.setString(1, tenantId);
         stmt.setDate(2, startDate);
@@ -249,7 +248,7 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
         stmt.setString(8, null);
         stmt.setLong(9, 2000);
         stmt.execute();
-        
+
         startDate = new Date(startDate.getTime() + (long)(QueryConstants.MILLIS_IN_DAY * dateIncrement));
         stmt.setString(1, tenantId);
         stmt.setDate(2, startDate);
@@ -261,7 +260,7 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
         stmt.setString(8, R1);
         stmt.setNull(9, Types.BIGINT);
         stmt.execute();
-        
+
         startDate = new Date(startDate.getTime() + (long)(QueryConstants.MILLIS_IN_DAY * dateIncrement));
         stmt.setString(1, tenantId);
         stmt.setDate(2, startDate);
@@ -273,7 +272,7 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
         stmt.setString(8, R1);
         stmt.setLong(9, 4000);
         stmt.execute();
-        
+
         startDate = new Date(startDate.getTime() + (long)(QueryConstants.MILLIS_IN_DAY * dateIncrement));
         stmt.setString(1, tenantId);
         stmt.setDate(2, startDate);
@@ -285,7 +284,7 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
         stmt.setString(8, R2);
         stmt.setLong(9, 5000);
         stmt.execute();
-        
+
         startDate = new Date(startDate.getTime() + (long)(QueryConstants.MILLIS_IN_DAY * dateIncrement));
         stmt.setString(1, tenantId);
         stmt.setDate(2, startDate);
@@ -298,18 +297,21 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
         stmt.setNull(9, Types.BIGINT);
         stmt.execute();
     }
-    
+
+
+
+
     @Test
     public void testDateRangeAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT count(1), feature f FROM PRODUCT_METRICS WHERE organization_id=? AND \"DATE\" >= to_date(?) AND \"DATE\" <= to_date(?) GROUP BY f";
+        String query = "SELECT count(1), feature f FROM "+tablename+" WHERE organization_id=? AND \"DATE\" >= to_date(?) AND \"DATE\" <= to_date(?) GROUP BY f";
         //String query = "SELECT count(1), feature FROM PRODUCT_METRICS GROUP BY feature";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setString(2, DS2);
@@ -326,17 +328,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testTableAliasSameAsTableName() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT sum(PRODUCT_METRICS.transactions) FROM PRODUCT_METRICS PRODUCT_METRICS";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT sum("+tablename+".transactions) FROM "+tablename+" PRODUCT_METRICS";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             ResultSet rs = statement.executeQuery();
             assertTrue(rs.next());
@@ -346,17 +347,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testPartiallyEvaluableAnd() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT \"DATE\" FROM PRODUCT_METRICS WHERE organization_id=? AND unique_users >= 30 AND transactions >= 300 AND cpu_utilization > 2 AND db_utilization > 0.5 AND io_time = 4000";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT \"DATE\" FROM "+tablename+" WHERE organization_id=? AND unique_users >= 30 AND transactions >= 300 AND cpu_utilization > 2 AND db_utilization > 0.5 AND io_time = 4000";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
@@ -367,17 +367,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testPartiallyEvaluableOr() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT \"DATE\" FROM PRODUCT_METRICS WHERE organization_id=? AND (transactions = 10000 OR unset_column = 5 OR io_time = 4000)";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT \"DATE\" FROM "+tablename+" WHERE organization_id=? AND (transactions = 10000 OR unset_column = 5 OR io_time = 4000)";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
@@ -388,17 +387,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testConstantTrueHaving() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT count(1), feature FROM PRODUCT_METRICS WHERE organization_id=? AND \"DATE\" >= to_date(?) AND \"DATE\" <= to_date(?) GROUP BY feature HAVING 1=1";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT count(1), feature FROM "+tablename+" WHERE organization_id=? AND \"DATE\" >= to_date(?) AND \"DATE\" <= to_date(?) GROUP BY feature HAVING 1=1";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setString(2, DS2);
@@ -415,17 +413,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testConstantFalseHaving() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT count(1), feature FROM PRODUCT_METRICS WHERE organization_id=? AND \"DATE\" >= to_date(?) AND \"DATE\" <= to_date(?) GROUP BY feature HAVING 1=1 and 0=1";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT count(1), feature FROM "+tablename+" WHERE organization_id=? AND \"DATE\" >= to_date(?) AND \"DATE\" <= to_date(?) GROUP BY feature HAVING 1=1 and 0=1";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setString(2, DS2);
@@ -436,17 +433,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testDateRangeHavingAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT count(1), feature FROM PRODUCT_METRICS WHERE organization_id=? AND \"DATE\" >= to_date(?) AND \"DATE\" <= to_date(?) GROUP BY feature HAVING count(1) >= 2";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT count(1), feature FROM "+tablename+" WHERE organization_id=? AND \"DATE\" >= to_date(?) AND \"DATE\" <= to_date(?) GROUP BY feature HAVING count(1) >= 2";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setString(2, DS2);
@@ -460,17 +456,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testDateRangeSumLongAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT sum(transactions), feature FROM PRODUCT_METRICS WHERE organization_id=? AND \"DATE\" >= to_date(?) AND \"DATE\" <= to_date(?) GROUP BY feature";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT sum(transactions), feature FROM "+tablename+" WHERE organization_id=? AND \"DATE\" >= to_date(?) AND \"DATE\" <= to_date(?) GROUP BY feature";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setString(2, DS2);
@@ -487,70 +482,68 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testRoundAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT round(\"DATE\",'hour',1) r,count(1) FROM PRODUCT_METRICS WHERE organization_id=? GROUP BY r";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT round(\"DATE\",'hour',1) r,count(1) FROM "+tablename+" WHERE organization_id=? GROUP BY r";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             Date d;
             int c;
             ResultSet rs = statement.executeQuery();
-            
+
             assertTrue(rs.next());
             d = rs.getDate(1);
             c = rs.getInt(2);
             assertEquals(1 * 60 * 60 * 1000, d.getTime()); // Date bucketed into 1 hr
             assertEquals(2, c);
-            
+
             assertTrue(rs.next());
             d = rs.getDate(1);
             c = rs.getInt(2);
             assertEquals(2 * 60 * 60 * 1000, d.getTime()); // Date bucketed into 2 hr
             assertEquals(3, c);
-            
+
             assertTrue(rs.next());
             d = rs.getDate(1);
             c = rs.getInt(2);
             assertEquals(4 * 60 * 60 * 1000, d.getTime()); // Date bucketed into 4 hr
             assertEquals(1, c);
-            
+
             assertFalse(rs.next());
         } finally {
             conn.close();
         }
     }
-    
+
     @Test
     public void testRoundScan() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT round(\"DATE\",'hour') FROM PRODUCT_METRICS WHERE organization_id=?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT round(\"DATE\",'hour') FROM "+tablename+" WHERE organization_id=?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             Date d;
             long t;
             ResultSet rs = statement.executeQuery();
-            
+
             assertTrue(rs.next());
             d = rs.getDate(1);
             t = 1 * 60 * 60 * 1000;
             assertEquals(t, d.getTime()); // Date bucketed into 1 hr
             assertTrue(rs.next());
             assertEquals(t, d.getTime()); // Date bucketed into 1 hr
-            
+
             assertTrue(rs.next());
             d = rs.getDate(1);
             t = 2 * 60 * 60 * 1000;
@@ -559,52 +552,51 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             assertEquals(t, d.getTime()); // Date bucketed into 2 hr
             assertTrue(rs.next());
             assertEquals(t, d.getTime()); // Date bucketed into 2 hr
-            
+
             assertTrue(rs.next());
             d = rs.getDate(1);
             t = 4 * 60 * 60 * 1000;
             assertEquals(t, d.getTime()); // Date bucketed into 4 hr
-            
+
             assertFalse(rs.next());
         } finally {
             conn.close();
         }
     }
-    
+
     @Test
     public void testTruncAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT trunc(\"DATE\",'hour'),count(1) FROM PRODUCT_METRICS WHERE organization_id=? GROUP BY trunc(\"DATE\",'hour')";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT trunc(\"DATE\",'hour'),count(1) FROM "+tablename+" WHERE organization_id=? GROUP BY trunc(\"DATE\",'hour')";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             Date d;
             int c;
             ResultSet rs = statement.executeQuery();
-            
+
             assertTrue(rs.next());
             d = rs.getDate(1);
             c = rs.getInt(2);
             assertEquals(0, d.getTime()); // Date bucketed into 0 hr
             assertEquals(1, c);
-            
+
             assertTrue(rs.next());
             d = rs.getDate(1);
             c = rs.getInt(2);
             assertEquals(1 * 60 * 60 * 1000, d.getTime()); // Date bucketed into 1 hr
             assertEquals(3, c);
-            
+
             assertTrue(rs.next());
             d = rs.getDate(1);
             c = rs.getInt(2);
             assertEquals(2 * 60 * 60 * 1000, d.getTime()); // Date bucketed into 2 hr
             assertEquals(1, c);
-            
+
             assertTrue(rs.next());
             d = rs.getDate(1);
             c = rs.getInt(2);
@@ -616,17 +608,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT feature,sum(unique_users) FROM PRODUCT_METRICS WHERE organization_id=? AND transactions > 0 GROUP BY feature";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT feature,sum(unique_users) FROM "+tablename+" WHERE organization_id=? AND transactions > 0 GROUP BY feature";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
@@ -638,17 +629,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testHavingAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT feature,sum(unique_users) FROM PRODUCT_METRICS WHERE organization_id=? AND transactions > 0 GROUP BY feature HAVING feature=?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT feature,sum(unique_users) FROM "+tablename+" WHERE organization_id=? AND transactions > 0 GROUP BY feature HAVING feature=?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setString(2, F1);
@@ -659,17 +649,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testConstantSumAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT sum(1),sum(unique_users) FROM PRODUCT_METRICS WHERE organization_id=?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT sum(1),sum(unique_users) FROM "+tablename+" WHERE organization_id=?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
@@ -681,21 +670,20 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testMultiDimAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT feature,region,sum(unique_users) FROM PRODUCT_METRICS WHERE organization_id=? GROUP BY feature,region";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT feature,region,sum(unique_users) FROM "+tablename+" WHERE organization_id=? GROUP BY feature,region";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
-            
+
             assertTrue(rs.next());
             assertEquals(F1,rs.getString(1));
             assertEquals(null,rs.getString(2));
@@ -713,32 +701,31 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             assertEquals(F2,rs.getString(1));
             assertEquals(R1,rs.getString(2));
             assertEquals(40,rs.getInt(3));
-            
+
             assertTrue(rs.next());
             assertEquals(F3,rs.getString(1));
             assertEquals(R2,rs.getString(2));
             assertEquals(50,rs.getInt(3));
-            
+
             assertFalse(rs.next());
         } finally {
             conn.close();
         }
     }
-    
+
     @Test
     public void testMultiDimRoundAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT round(\"DATE\",'hour',1),feature,sum(unique_users) FROM PRODUCT_METRICS WHERE organization_id=? GROUP BY round(\"DATE\",'hour',1),feature";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT round(\"DATE\",'hour',1),feature,sum(unique_users) FROM "+tablename+" WHERE organization_id=? GROUP BY round(\"DATE\",'hour',1),feature";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
-            
+
             Date bucket1 = new Date(1 * 60 * 60 * 1000);
             Date bucket2 = new Date(2 * 60 * 60 * 1000);
             Date bucket3 = new Date(4 * 60 * 60 * 1000);
@@ -747,45 +734,44 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             assertEquals(bucket1, rs.getDate(1));
             assertEquals(F1,rs.getString(2));
             assertEquals(30,rs.getInt(3));
-            
-            
+
+
             assertTrue(rs.next());
             assertEquals(bucket2, rs.getDate(1));
             assertEquals(F1,rs.getString(2));
             assertEquals(30,rs.getInt(3));
-            
+
             assertTrue(rs.next());
             assertEquals(bucket2.getTime(), rs.getDate(1).getTime());
             assertEquals(F2,rs.getString(2));
             assertEquals(40,rs.getInt(3));
-            
+
             assertTrue(rs.next());
             assertEquals(bucket2, rs.getDate(1));
             assertEquals(F3,rs.getString(2));
             assertEquals(50,rs.getInt(3));
-            
-            
+
+
             assertTrue(rs.next());
             assertEquals(bucket3, rs.getDate(1));
             assertEquals(F1,rs.getString(2));
             assertEquals(60,rs.getInt(3));
-            
+
             assertFalse(rs.next());
         } finally {
             conn.close();
         }
     }
-    
+
     @Test
     public void testDateRangeSumNumberUngroupedAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT sum(cpu_utilization) FROM PRODUCT_METRICS WHERE organization_id=? AND \"DATE\" >= to_date(?) AND \"DATE\" <= to_date(?)";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT sum(cpu_utilization) FROM "+tablename+" WHERE organization_id=? AND \"DATE\" >= to_date(?) AND \"DATE\" <= to_date(?)";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setString(2, DS2);
@@ -801,14 +787,13 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
 
     @Test
     public void testSumUngroupedAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT sum(unique_users),sum(cpu_utilization),sum(transactions),sum(db_utilization),sum(response_time) FROM PRODUCT_METRICS WHERE organization_id=?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT sum(unique_users),sum(cpu_utilization),sum(transactions),sum(db_utilization),sum(response_time) FROM "+tablename+" WHERE organization_id=?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
@@ -824,29 +809,27 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testResetColumnInSameTxn() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT sum(transactions) FROM PRODUCT_METRICS WHERE organization_id=?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT sum(transactions) FROM "+tablename+" WHERE organization_id=?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
-        String upsertUrl = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + ts; // Run updates at timestamp 0
-        Connection upsertConn = DriverManager.getConnection(upsertUrl, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        Connection upsertConn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTable(getSplits(tenantId), ts);
-            initTableValues(upsertConn, tenantId);
+            initTable(tablename,getSplits(tenantId));
+            initTableValues(tablename, upsertConn, tenantId);
             PreparedStatement stmt = upsertConn.prepareStatement(
-                    "upsert into " +
-                    "PRODUCT_METRICS(" +
-                    "    ORGANIZATION_ID, " +
-                    "    \"DATE\", " +
-                    "    FEATURE, " +
-                    "    UNIQUE_USERS," +
-                    "    TRANSACTIONS) " +
-                    "VALUES (?, ?, ?, ?, ?)");
+                    "upsert into " + tablename+
+                            "(" +
+                            "    ORGANIZATION_ID, " +
+                            "    \"DATE\", " +
+                            "    FEATURE, " +
+                            "    UNIQUE_USERS," +
+                            "    TRANSACTIONS) " +
+                            "VALUES (?, ?, ?, ?, ?)");
             stmt.setString(1, tenantId);
             stmt.setDate(2, D1);
             stmt.setString(3, F1);
@@ -865,17 +848,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testSumUngroupedHavingAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT sum(unique_users),sum(cpu_utilization),sum(transactions),sum(db_utilization),sum(response_time) FROM PRODUCT_METRICS WHERE organization_id=? HAVING sum(unique_users) > 200 AND sum(db_utilization) > 4.5";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT sum(unique_users),sum(cpu_utilization),sum(transactions),sum(db_utilization),sum(response_time) FROM "+tablename+" WHERE organization_id=? HAVING sum(unique_users) > 200 AND sum(db_utilization) > 4.5";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
@@ -891,17 +873,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testSumUngroupedHavingAggregation2() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT sum(unique_users),sum(cpu_utilization),sum(transactions),sum(db_utilization),sum(response_time) FROM PRODUCT_METRICS WHERE organization_id=? HAVING sum(unique_users) > 200 AND sum(db_utilization) > 5";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT sum(unique_users),sum(cpu_utilization),sum(transactions),sum(db_utilization),sum(response_time) FROM "+tablename+" WHERE organization_id=? HAVING sum(unique_users) > 200 AND sum(db_utilization) > 5";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
@@ -910,17 +891,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testMinUngroupedAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT min(unique_users),min(cpu_utilization),min(transactions),min(db_utilization),min('X'),min(response_time) FROM PRODUCT_METRICS WHERE organization_id=?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT min(unique_users),min(cpu_utilization),min(transactions),min(db_utilization),min('X'),min(response_time) FROM "+tablename+" WHERE organization_id=?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
@@ -929,7 +909,7 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             assertEquals(BigDecimal.valueOf(0.5), rs.getBigDecimal(2));
             assertEquals(100L, rs.getLong(3));
             assertEquals(BigDecimal.valueOf(0.2), rs.getBigDecimal(4));
-            assertEquals("X", rs.getString(5));            
+            assertEquals("X", rs.getString(5));
             assertEquals(0, rs.getLong(6));
             assertEquals(true, rs.wasNull());
             assertFalse(rs.next());
@@ -940,14 +920,13 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
 
     @Test
     public void testMinUngroupedAggregation1() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT min(cpu_utilization) FROM PRODUCT_METRICS WHERE organization_id=?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT min(cpu_utilization) FROM "+tablename+" WHERE organization_id=?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
@@ -961,14 +940,13 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
 
     @Test
     public void testMaxUngroupedAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT max(unique_users),max(cpu_utilization),max(transactions),max(db_utilization),max('X'),max(response_time) FROM PRODUCT_METRICS WHERE organization_id=?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT max(unique_users),max(cpu_utilization),max(transactions),max(db_utilization),max('X'),max(response_time) FROM "+tablename+" WHERE organization_id=?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
@@ -977,7 +955,7 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             assertEquals(BigDecimal.valueOf(4), rs.getBigDecimal(2));
             assertEquals(600L, rs.getLong(3));
             assertEquals(BigDecimal.valueOf(1.4), rs.getBigDecimal(4));
-            assertEquals("X", rs.getString(5));            
+            assertEquals("X", rs.getString(5));
             assertEquals(0, rs.getLong(6));
             assertEquals(true, rs.wasNull());
             assertFalse(rs.next());
@@ -988,14 +966,13 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
 
     @Test
     public void testMaxGroupedAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT feature,max(transactions) FROM PRODUCT_METRICS WHERE organization_id=? GROUP BY feature";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT feature,max(transactions) FROM "+tablename+" WHERE organization_id=? GROUP BY feature";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
@@ -1016,14 +993,13 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
 
     @Test
     public void testCountUngroupedAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT count(1) FROM PRODUCT_METRICS";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT count(1) FROM "+tablename;
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             ResultSet rs = statement.executeQuery();
             assertTrue(rs.next());
@@ -1036,21 +1012,20 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
 
     @Test
     public void testCountColumnUngroupedAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT count(io_time),sum(io_time),avg(io_time) FROM PRODUCT_METRICS WHERE organization_id=?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT count(io_time),sum(io_time),avg(io_time) FROM "+tablename+" WHERE organization_id=?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
             assertTrue(rs.next());
             assertEquals(3, rs.getLong(1));
             assertEquals(11000, rs.getLong(2));
-            // Scale is automatically capped at 4 if no scale is specified. 
+            // Scale is automatically capped at 4 if no scale is specified.
             assertEquals(new BigDecimal("3666.6666"), rs.getBigDecimal(3));
             assertFalse(rs.next());
         } finally {
@@ -1060,14 +1035,13 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
 
     @Test
     public void testNoRowsUngroupedAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT count(io_time),sum(io_time),avg(io_time),count(1) FROM PRODUCT_METRICS WHERE organization_id=? AND feature > ?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT count(io_time),sum(io_time),avg(io_time),count(1) FROM "+tablename+" WHERE organization_id=? AND feature > ?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setString(2,F3);
@@ -1088,14 +1062,13 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
 
     @Test
     public void testAvgUngroupedAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT avg(unique_users) FROM PRODUCT_METRICS WHERE organization_id=?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT avg(unique_users) FROM "+tablename+" WHERE organization_id=?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
@@ -1106,17 +1079,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testAvgUngroupedAggregationOnValueField() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT AVG(DB_UTILIZATION) FROM PRODUCT_METRICS WHERE organization_id=?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT AVG(DB_UTILIZATION) FROM "+tablename+" WHERE organization_id=?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
 
@@ -1129,23 +1101,22 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     /**
      * Test aggregate query with rownum limit that does not explicity contain a count(1) as a select expression
      * @throws Exception
      */
     @Test
     public void testLimitSumUngroupedAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
         // No count(1) aggregation, so it will get added automatically
         // LIMIT has no effect, since it's applied at the end and we'll always have a single row for ungrouped aggregation
-        String query = "SELECT sum(unique_users),sum(cpu_utilization),sum(transactions),sum(db_utilization),sum(response_time) feature FROM PRODUCT_METRICS WHERE organization_id=? LIMIT 3";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT sum(unique_users),sum(cpu_utilization),sum(transactions),sum(db_utilization),sum(response_time) feature FROM "+tablename+" WHERE organization_id=? LIMIT 3";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
@@ -1168,14 +1139,13 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
      */
     @Test
     public void testSumGroupedAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT feature,sum(unique_users),sum(cpu_utilization),sum(transactions),sum(db_utilization),sum(response_time),count(1) c FROM PRODUCT_METRICS WHERE organization_id=? AND feature < ? GROUP BY feature";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT feature,sum(unique_users),sum(cpu_utilization),sum(transactions),sum(db_utilization),sum(response_time),count(1) c FROM "+tablename+" WHERE organization_id=? AND feature < ? GROUP BY feature";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setString(2, F3);
@@ -1206,14 +1176,13 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
 
     @Test
     public void testDegenerateAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT count(1), feature FROM PRODUCT_METRICS WHERE organization_id=? AND \"DATE\" >= to_date(?) AND \"DATE\" <= to_date(?) GROUP BY feature";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT count(1), feature FROM "+tablename+" WHERE organization_id=? AND \"DATE\" >= to_date(?) AND \"DATE\" <= to_date(?) GROUP BY feature";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             // Start date larger than end date
@@ -1225,21 +1194,20 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     /**
      * Query with multiple > expressions on continquous PK columns
      * @throws Exception
      */
     @Test
     public void testFeatureDateRangeAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT feature,unique_users FROM PRODUCT_METRICS WHERE organization_id=? AND \"DATE\" >= to_date(?) AND feature > ?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT feature,unique_users FROM "+tablename+" WHERE organization_id=? AND \"DATE\" >= to_date(?) AND feature > ?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setString(2, DS2);
@@ -1253,21 +1221,20 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     /**
      * Query with non contiguous PK column expressions (i.e. no expresion for DATE)
      * @throws Exception
      */
     @Test
     public void testFeatureGTAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT feature,unique_users FROM PRODUCT_METRICS WHERE organization_id=? AND feature > ?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT feature,unique_users FROM "+tablename+" WHERE organization_id=? AND feature > ?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setString(2, F2);
@@ -1280,17 +1247,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testFeatureGTEAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT feature,unique_users FROM PRODUCT_METRICS WHERE organization_id=? AND feature >= ?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT feature,unique_users FROM "+tablename+" WHERE organization_id=? AND feature >= ?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setString(2, F2);
@@ -1306,17 +1272,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testFeatureEQAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT feature,unique_users FROM PRODUCT_METRICS WHERE organization_id=? AND feature = ?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT feature,unique_users FROM "+tablename+" WHERE organization_id=? AND feature = ?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setString(2, F2);
@@ -1330,17 +1295,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
         }
     }
 
-    
+
     @Test
     public void testFeatureLTAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT feature,unique_users FROM PRODUCT_METRICS WHERE organization_id=? AND feature < ?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT feature,unique_users FROM "+tablename+" WHERE organization_id=? AND feature < ?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setString(2, F2);
@@ -1365,14 +1329,13 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
 
     @Test
     public void testFeatureLTEAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT feature,unique_users FROM PRODUCT_METRICS WHERE organization_id=? AND feature <= ?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT feature,unique_users FROM "+tablename+" WHERE organization_id=? AND feature <= ?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setString(2, F2);
@@ -1399,14 +1362,13 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
     }
     @Test
     public void testOrderByNonAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        initTableValues(tenantId, getSplits(tenantId), ts);
-        String query = "SELECT \"DATE\", transactions t FROM PRODUCT_METRICS WHERE organization_id=? AND unique_users <= 30 ORDER BY t DESC LIMIT 2";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        initTableValues(tablename, tenantId, getSplits(tenantId));
+        String query = "SELECT \"DATE\", transactions t FROM "+tablename+" WHERE organization_id=? AND unique_users <= 30 ORDER BY t DESC LIMIT 2";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
 
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
@@ -1423,18 +1385,17 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
 
     @Test
     public void testOrderByUngroupedAggregation() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
         String query = "SELECT sum(unique_users) sumUsers,count(feature) " +
-                       "FROM PRODUCT_METRICS " + 
-                       "WHERE organization_id=? " +
-                       "ORDER BY 100000-sumUsers";
+                "FROM " + tablename+
+                " WHERE organization_id=? " +
+                "ORDER BY 100000-sumUsers";
 
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
@@ -1446,26 +1407,25 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
-    public void testOrderByGroupedAggregation() throws Exception {        
-        long ts = nextTimestamp();
+    public void testOrderByGroupedAggregation() throws Exception {
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
         String query = "SELECT feature,sum(unique_users) s,count(feature),round(\"DATE\",'hour',1) r " +
-                       "FROM PRODUCT_METRICS " + 
-                       "WHERE organization_id=? " +
-                       "GROUP BY feature, r " +
-                       "ORDER BY 1 desc,feature desc,r,feature,s";
+                "FROM "+tablename+
+                " WHERE organization_id=? " +
+                "GROUP BY feature, r " +
+                "ORDER BY 1 desc,feature desc,r,feature,s";
 
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
-            
+
             Object[][] expected = {
                     {F3, 50, 1},
                     {F2, 40, 1},
@@ -1487,24 +1447,23 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
     }
 
     @Test
-    public void testOrderByUnprojected() throws Exception {        
-        long ts = nextTimestamp();
+    public void testOrderByUnprojected() throws Exception {
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
         String query = "SELECT sum(unique_users), count(feature) c " +
-                       "FROM PRODUCT_METRICS " + 
-                       "WHERE organization_id=? " +
-                       "GROUP BY feature " +
-                       "ORDER BY 100-c,feature";
+                "FROM " + tablename+
+                " WHERE organization_id=? " +
+                "GROUP BY feature " +
+                "ORDER BY 100-c,feature";
 
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
-            
+
             int[] expected = {120, 40, 50};
             for (int i = 0; i < expected.length; i++) {
                 assertTrue(rs.next());
@@ -1515,40 +1474,39 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testOrderByNullColumns__nullsFirst() throws Exception {
         helpTestOrderByNullColumns(true);
     }
-    
+
     @Test
     public void testOrderByNullColumns__nullsLast() throws Exception {
         helpTestOrderByNullColumns(false);
     }
-    
+
     private void helpTestOrderByNullColumns(boolean nullsFirst) throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
         String query = "SELECT region " +
-                       "FROM PRODUCT_METRICS " + 
-                       "WHERE organization_id=? " +
-                       "GROUP BY region " +
-                       "ORDER BY region nulls " + (nullsFirst ? "first" : "last");
+                "FROM " +tablename+
+                " WHERE organization_id=? " +
+                "GROUP BY region " +
+                "ORDER BY region nulls " + (nullsFirst ? "first" : "last");
 
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
-            
+
             List<String> expected = Lists.newArrayList(null, R1, R2);
             Ordering<String> regionOrdering = Ordering.natural();
             regionOrdering = nullsFirst ? regionOrdering.nullsFirst() : regionOrdering.nullsLast();
             Collections.sort(expected, regionOrdering);
-            
+
             for (String region : expected) {
                 assertTrue(rs.next());
                 assertEquals(region, rs.getString(1));
@@ -1566,18 +1524,17 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
      */
     @Test
     public void testFilterOnTrailingKeyColumn() throws Exception {
-    	long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+1));
         Connection conn = DriverManager.getConnection(getUrl(), props);
 
         HBaseAdmin admin = null;
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin();
-            admin.flush(SchemaUtil.getTableNameAsBytes(PRODUCT_METRICS_SCHEMA_NAME,PRODUCT_METRICS_NAME));
-            String query = "SELECT SUM(TRANSACTIONS) FROM " + PRODUCT_METRICS_NAME + " WHERE FEATURE=?";
+            admin.flush(SchemaUtil.getTableNameAsBytes(PRODUCT_METRICS_SCHEMA_NAME,tablename));
+            String query = "SELECT SUM(TRANSACTIONS) FROM " + tablename + " WHERE FEATURE=?";
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, F1);
             ResultSet rs = statement.executeQuery();
@@ -1586,19 +1543,18 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
         } finally {
             if (admin != null) admin.close();
             conn.close();
-        }	
+        }
     }
-    
+
     @Test
     public void testFilterOnTrailingKeyColumn2() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT organization_id, \"DATE\", feature FROM PRODUCT_METRICS WHERE substr(organization_id,1,3)=? AND \"DATE\" > to_date(?)";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT organization_id, \"DATE\", feature FROM "+tablename+" WHERE substr(organization_id,1,3)=? AND \"DATE\" > to_date(?)";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId.substring(0,3));
             statement.setString(2, DS4);
@@ -1616,17 +1572,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testSubstringNotEqual() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT organization_id, \"DATE\", feature FROM PRODUCT_METRICS WHERE organization_id=? AND \"DATE\" > to_date(?)";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT organization_id, \"DATE\", feature FROM "+tablename+" WHERE organization_id=? AND \"DATE\" > to_date(?)";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId.substring(0,3));
             statement.setString(2, DS4);
@@ -1636,17 +1591,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testKeyOrderedAggregation1() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT \"DATE\", sum(UNIQUE_USERS) FROM PRODUCT_METRICS WHERE \"DATE\" > to_date(?) GROUP BY organization_id, \"DATE\"";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT \"DATE\", sum(UNIQUE_USERS) FROM "+tablename+" WHERE \"DATE\" > to_date(?) GROUP BY organization_id, \"DATE\"";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, DS4);
             ResultSet rs = statement.executeQuery();
@@ -1661,17 +1615,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testKeyOrderedAggregation2() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT \"DATE\", sum(UNIQUE_USERS) FROM PRODUCT_METRICS WHERE \"DATE\" < to_date(?) GROUP BY organization_id, \"DATE\"";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT \"DATE\", sum(UNIQUE_USERS) FROM "+tablename+" WHERE \"DATE\" < to_date(?) GROUP BY organization_id, \"DATE\"";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, DS4);
             ResultSet rs = statement.executeQuery();
@@ -1689,17 +1642,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testKeyOrderedRoundAggregation1() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT round(\"DATE\",'HOUR'), sum(UNIQUE_USERS) FROM PRODUCT_METRICS WHERE \"DATE\" < to_date(?) GROUP BY organization_id, round(\"DATE\",'HOUR')";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT round(\"DATE\",'HOUR'), sum(UNIQUE_USERS) FROM "+tablename+" WHERE \"DATE\" < to_date(?) GROUP BY organization_id, round(\"DATE\",'HOUR')";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, DS4);
             ResultSet rs = statement.executeQuery();
@@ -1714,17 +1666,16 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testKeyOrderedRoundAggregation2() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT round(\"DATE\",'HOUR'), sum(UNIQUE_USERS) FROM PRODUCT_METRICS WHERE \"DATE\" <= to_date(?) GROUP BY organization_id, round(\"DATE\",'HOUR')";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT round(\"DATE\",'HOUR'), sum(UNIQUE_USERS) FROM "+tablename+" WHERE \"DATE\" <= to_date(?) GROUP BY organization_id, round(\"DATE\",'HOUR')";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
-            initTableValues(tenantId, getSplits(tenantId), ts);
+            initTableValues(tablename, tenantId, getSplits(tenantId));
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, DS4);
             ResultSet rs = statement.executeQuery();
@@ -1739,19 +1690,18 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testEqualsRound() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT feature FROM PRODUCT_METRICS WHERE organization_id = ? and trunc(\"DATE\",'DAY')=?";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT feature FROM "+tablename+" WHERE organization_id = ? and trunc(\"DATE\",'DAY')=?";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
             Date startDate = new Date(System.currentTimeMillis());
             Date equalDate = new Date((startDate.getTime() + 2 * QueryConstants.MILLIS_IN_DAY)/ QueryConstants.MILLIS_IN_DAY*QueryConstants.MILLIS_IN_DAY);
-            initDateTableValues(tenantId, getSplits(tenantId), ts, startDate, 1.0);
+            initDateTableValues(tablename, tenantId, getSplits(tenantId), startDate, 1.0);
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setDate(2, equalDate);
@@ -1763,19 +1713,18 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testDateSubtractionCompareNumber() throws Exception {
-        long ts = nextTimestamp();
+        String tablename=generateUniqueName();
         String tenantId = getOrganizationId();
-        String query = "SELECT feature FROM PRODUCT_METRICS WHERE organization_id = ? and ? - \"DATE\" > 3";
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+        String query = "SELECT feature FROM "+tablename+" WHERE organization_id = ? and ? - \"DATE\" > 3";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
             Date startDate = new Date(System.currentTimeMillis());
             Date endDate = new Date(startDate.getTime() + 6 * QueryConstants.MILLIS_IN_DAY);
-            initDateTableValues(tenantId, getSplits(tenantId), ts, startDate);
+            initDateTableValues(tablename, tenantId, getSplits(tenantId), startDate);
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             statement.setDate(2, endDate);
@@ -1789,19 +1738,18 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
             conn.close();
         }
     }
-    
+
     @Test
     public void testDateSubtractionLongToDecimalCompareNumber() throws Exception {
-        long ts = nextTimestamp();
+        String tablenam

<TRUNCATED>

Mime
View raw message