You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by sa...@apache.org on 2016/08/26 00:17:21 UTC
[08/14] phoenix git commit: PHOENIX-3036 Modify phoenix IT tests to
extend BaseHBaseManagedTimeTableReuseIT (Prakul Agarwal, Samarth Jain)
http://git-wip-us.apache.org/repos/asf/phoenix/blob/03df8ab5/phoenix-core/src/it/java/org/apache/phoenix/end2end/InstrFunctionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InstrFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InstrFunctionIT.java
index b869ff4..0adcc10 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InstrFunctionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InstrFunctionIT.java
@@ -28,11 +28,11 @@ import java.sql.ResultSet;
import org.junit.Test;
-public class InstrFunctionIT extends BaseHBaseManagedTimeIT {
- private void initTable(Connection conn, String sortOrder, String s, String subStr) throws Exception {
- String ddl = "CREATE TABLE SAMPLE (name VARCHAR NOT NULL PRIMARY KEY " + sortOrder + ", substr VARCHAR)";
+public class InstrFunctionIT extends BaseHBaseManagedTimeTableReuseIT {
+ private void initTable(Connection conn, String tableName, String sortOrder, String s, String subStr) throws Exception {
+ String ddl = "CREATE TABLE " + tableName + " (name VARCHAR NOT NULL PRIMARY KEY " + sortOrder + ", substr VARCHAR)";
conn.createStatement().execute(ddl);
- String dml = "UPSERT INTO SAMPLE VALUES(?,?)";
+ String dml = "UPSERT INTO " + tableName + " VALUES(?,?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, s);
stmt.setString(2, subStr);
@@ -61,56 +61,63 @@ public class InstrFunctionIT extends BaseHBaseManagedTimeIT {
@Test
public void testSingleByteInstrAscending() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
- initTable(conn, "ASC", "abcdefghijkl","fgh");
- String queryToExecute = "SELECT INSTR(name, 'fgh') FROM SAMPLE";
+ String tableName = generateRandomString();
+ initTable(conn, tableName, "ASC", "abcdefghijkl","fgh");
+ String queryToExecute = "SELECT INSTR(name, 'fgh') FROM " + tableName;
testInstr(conn, queryToExecute, 6);
}
@Test
public void testSingleByteInstrDescending() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
- initTable(conn, "DESC", "abcdefghijkl","fgh");
- String queryToExecute = "SELECT INSTR(name, 'fgh') FROM SAMPLE";
+ String tableName = generateRandomString();
+ initTable(conn, tableName, "DESC", "abcdefghijkl","fgh");
+ String queryToExecute = "SELECT INSTR(name, 'fgh') FROM " + tableName;
testInstr(conn, queryToExecute, 6);
}
@Test
public void testSingleByteInstrAscendingNoString() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
- initTable(conn, "ASC", "abcde fghijkl","lmn");
- String queryToExecute = "SELECT INSTR(name, 'lmn') FROM SAMPLE";
+ String tableName = generateRandomString();
+ initTable(conn, tableName, "ASC", "abcde fghijkl","lmn");
+ String queryToExecute = "SELECT INSTR(name, 'lmn') FROM " + tableName;
testInstr(conn, queryToExecute, 0);
}
@Test
public void testSingleByteInstrDescendingNoString() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
- initTable(conn, "DESC", "abcde fghijkl","lmn");
- String queryToExecute = "SELECT INSTR(name, 'lmn') FROM SAMPLE";
+ String tableName = generateRandomString();
+ initTable(conn, tableName, "DESC", "abcde fghijkl","lmn");
+ String queryToExecute = "SELECT INSTR(name, 'lmn') FROM " + tableName;
testInstr(conn, queryToExecute, 0);
}
@Test
public void testMultiByteInstrAscending() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
- initTable(conn, "ASC", "A\u025a\u0266FGH","\u025a\u0266");
- String queryToExecute = "SELECT INSTR(name, '\u025a\u0266') FROM SAMPLE";
+ String tableName = generateRandomString();
+ initTable(conn, tableName, "ASC", "A\u025a\u0266FGH","\u025a\u0266");
+ String queryToExecute = "SELECT INSTR(name, '\u025a\u0266') FROM " + tableName;
testInstr(conn, queryToExecute, 2);
}
@Test
public void testMultiByteInstrDecending() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
- initTable(conn, "DESC", "A\u025a\u0266FGH","\u025a\u0266");
- String queryToExecute = "SELECT INSTR(name, '\u025a\u0266') FROM SAMPLE";
+ String tableName = generateRandomString();
+ initTable(conn, tableName, "DESC", "A\u025a\u0266FGH","\u025a\u0266");
+ String queryToExecute = "SELECT INSTR(name, '\u025a\u0266') FROM " + tableName;
testInstr(conn, queryToExecute, 2);
}
@Test
public void testByteInstrAscendingFilter() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
- initTable(conn, "ASC", "abcdefghijkl","fgh");
- String queryToExecute = "select NAME from sample where instr(name, 'fgh') > 0";
+ String tableName = generateRandomString();
+ initTable(conn, tableName, "ASC", "abcdefghijkl","fgh");
+ String queryToExecute = "select NAME from " + tableName + " where instr(name, 'fgh') > 0";
testInstrFilter(conn, queryToExecute,"abcdefghijkl");
}
@@ -118,8 +125,9 @@ public class InstrFunctionIT extends BaseHBaseManagedTimeIT {
@Test
public void testByteInstrDecendingFilter() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
- initTable(conn, "DESC", "abcdefghijkl","fgh");
- String queryToExecute = "select NAME from sample where instr(name, 'fgh') > 0";
+ String tableName = generateRandomString();
+ initTable(conn, tableName, "DESC", "abcdefghijkl","fgh");
+ String queryToExecute = "select NAME from " + tableName + " where instr(name, 'fgh') > 0";
testInstrFilter(conn, queryToExecute,"abcdefghijkl");
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/03df8ab5/phoenix-core/src/it/java/org/apache/phoenix/end2end/IsNullIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IsNullIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IsNullIT.java
index fb49378..504b18c 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IsNullIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IsNullIT.java
@@ -30,29 +30,30 @@ import java.sql.ResultSet;
import org.junit.Test;
-public class IsNullIT extends BaseHBaseManagedTimeIT {
+public class IsNullIT extends BaseHBaseManagedTimeTableReuseIT {
@Test
public void testIsNullInPk() throws Exception {
- ensureTableCreated(getUrl(),"IntIntKeyTest");
+ String tableName = generateRandomString();
+ ensureTableCreated(getUrl(), tableName, "IntIntKeyTest");
Connection conn = DriverManager.getConnection(getUrl());
- String upsert = "UPSERT INTO IntIntKeyTest VALUES(4,2)";
+ String upsert = "UPSERT INTO " + tableName + " VALUES(4,2)";
PreparedStatement upsertStmt = conn.prepareStatement(upsert);
int rowsInserted = upsertStmt.executeUpdate();
assertEquals(1, rowsInserted);
- upsert = "UPSERT INTO IntIntKeyTest VALUES(6)";
+ upsert = "UPSERT INTO " + tableName + " VALUES(6)";
upsertStmt = conn.prepareStatement(upsert);
rowsInserted = upsertStmt.executeUpdate();
assertEquals(1, rowsInserted);
conn.commit();
- String select = "SELECT i/j FROM IntIntKeyTest WHERE j IS NULL";
+ String select = "SELECT i/j FROM " + tableName + " WHERE j IS NULL";
ResultSet rs;
rs = conn.createStatement().executeQuery(select);
assertTrue(rs.next());
assertEquals(0,rs.getInt(1));
assertTrue(rs.wasNull());
assertFalse(rs.next());
- select = "SELECT i/j FROM IntIntKeyTest WHERE j IS NOT NULL";
+ select = "SELECT i/j FROM " + tableName + " WHERE j IS NOT NULL";
rs = conn.createStatement().executeQuery(select);
assertTrue(rs.next());
assertEquals(2,rs.getInt(1));
@@ -61,15 +62,16 @@ public class IsNullIT extends BaseHBaseManagedTimeIT {
@Test
public void testIsNullWithLastPKColDesc() throws Exception {
+ String tableName = generateRandomString();
Connection conn = DriverManager.getConnection(getUrl());
- conn.createStatement().execute("CREATE TABLE T(k1 VARCHAR NOT NULL, k2 VARCHAR, k3 VARCHAR, CONSTRAINT pk PRIMARY KEY (k1, k2, k3 DESC))");
- conn.createStatement().execute("UPSERT INTO T VALUES ('a')");
- conn.createStatement().execute("UPSERT INTO T VALUES ('b')");
- conn.createStatement().execute("UPSERT INTO T VALUES ('b',null,'c')");
- conn.createStatement().execute("UPSERT INTO T VALUES ('ba', null, 'd')");
+ conn.createStatement().execute("CREATE TABLE " + tableName + "(k1 VARCHAR NOT NULL, k2 VARCHAR, k3 VARCHAR, CONSTRAINT pk PRIMARY KEY (k1, k2, k3 DESC))");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES ('a')");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES ('b')");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES ('b',null,'c')");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES ('ba', null, 'd')");
conn.commit();
- ResultSet rs = conn.createStatement().executeQuery("SELECT k1,k2,k3 FROM T WHERE k1='b' AND k2 IS NULL");
+ ResultSet rs = conn.createStatement().executeQuery("SELECT k1,k2,k3 FROM " + tableName + " WHERE k1='b' AND k2 IS NULL");
assertTrue(rs.next());
assertEquals("b",rs.getString(1));
assertNull(rs.getString(2));
@@ -87,15 +89,16 @@ public class IsNullIT extends BaseHBaseManagedTimeIT {
@Test
public void testIsNullInCompositeKey() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
- conn.createStatement().execute("CREATE TABLE T(k1 VARCHAR, k2 VARCHAR, CONSTRAINT pk PRIMARY KEY (k1,k2))");
- conn.createStatement().execute("UPSERT INTO T VALUES (null,'a')");
- conn.createStatement().execute("UPSERT INTO T VALUES ('a','a')");
+ String tableName = generateRandomString();
+ conn.createStatement().execute("CREATE TABLE " + tableName + "(k1 VARCHAR, k2 VARCHAR, CONSTRAINT pk PRIMARY KEY (k1,k2))");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES (null,'a')");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES ('a','a')");
conn.commit();
- ResultSet rs = conn.createStatement().executeQuery("SELECT count(*) FROM T");
+ ResultSet rs = conn.createStatement().executeQuery("SELECT count(*) FROM " + tableName);
assertTrue(rs.next());
assertEquals(2,rs.getInt(1));
- rs = conn.createStatement().executeQuery("SELECT count(*) FROM T WHERE k1 = 'a' or k1 is null");
+ rs = conn.createStatement().executeQuery("SELECT count(*) FROM " + tableName + " WHERE k1 = 'a' or k1 is null");
assertTrue(rs.next());
assertEquals(2,rs.getInt(1));
conn.close();
http://git-wip-us.apache.org/repos/asf/phoenix/blob/03df8ab5/phoenix-core/src/it/java/org/apache/phoenix/end2end/KeyOnlyIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/KeyOnlyIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/KeyOnlyIT.java
index dca57b4..4497c49 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/KeyOnlyIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/KeyOnlyIT.java
@@ -60,7 +60,7 @@ public class KeyOnlyIT extends BaseOwnClusterClientManagedTimeIT {
@Test
public void testKeyOnly() throws Exception {
long ts = nextTimestamp();
- ensureTableCreated(getUrl(),KEYONLY_NAME,null, ts);
+ ensureTableCreated(getUrl(),KEYONLY_NAME,KEYONLY_NAME,null, ts);
initTableValues(ts+1);
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+30));
@@ -139,7 +139,7 @@ public class KeyOnlyIT extends BaseOwnClusterClientManagedTimeIT {
@Test
public void testOr() throws Exception {
long ts = nextTimestamp();
- ensureTableCreated(getUrl(),KEYONLY_NAME,null, ts);
+ ensureTableCreated(getUrl(),KEYONLY_NAME,KEYONLY_NAME,null, ts);
initTableValues(ts+1);
Properties props = new Properties();
@@ -164,7 +164,7 @@ public class KeyOnlyIT extends BaseOwnClusterClientManagedTimeIT {
@Test
public void testQueryWithLimitAndStats() throws Exception {
long ts = nextTimestamp();
- ensureTableCreated(getUrl(),KEYONLY_NAME,null, ts);
+ ensureTableCreated(getUrl(),KEYONLY_NAME,KEYONLY_NAME,null, ts);
initTableValues(ts+1, 100);
TestUtil.analyzeTable(getUrl(), ts+10, KEYONLY_NAME);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/03df8ab5/phoenix-core/src/it/java/org/apache/phoenix/end2end/LastValueFunctionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LastValueFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LastValueFunctionIT.java
index cbadc35..f8d2d32 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LastValueFunctionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LastValueFunctionIT.java
@@ -28,33 +28,33 @@ import java.sql.ResultSet;
import org.junit.Test;
-public class LastValueFunctionIT extends BaseHBaseManagedTimeIT {
+public class LastValueFunctionIT extends BaseHBaseManagedTimeTableReuseIT {
@Test
public void unsignedLong() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
-
- String ddl = "CREATE TABLE IF NOT EXISTS last_value_table "
+ String tableName = generateRandomString();
+ String ddl = "CREATE TABLE IF NOT EXISTS " + tableName
+ "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG,"
+ " date DATE, \"value\" UNSIGNED_LONG)";
conn.createStatement().execute(ddl);
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") "
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") "
+ "VALUES (1, 8, TO_DATE('2013-01-01 00:00:00'), 300)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") "
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") "
+ "VALUES (2, 8, TO_DATE('2013-01-01 00:01:00'), 7)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") "
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") "
+ "VALUES (3, 8, TO_DATE('2013-01-01 00:02:00'), 9)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") "
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") "
+ "VALUES (4, 8, TO_DATE('2013-01-01 00:03:00'), 4)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") "
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") "
+ "VALUES (5, 8, TO_DATE('2013-01-01 00:04:00'), 2)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") "
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") "
+ "VALUES (6, 8, TO_DATE('2013-01-01 00:05:00'), 150)");
conn.commit();
ResultSet rs = conn.createStatement().executeQuery(
- "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM last_value_table GROUP BY page_id");
+ "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM " + tableName + " GROUP BY page_id");
assertTrue(rs.next());
assertEquals(rs.getLong(1), 150);
@@ -65,20 +65,21 @@ public class LastValueFunctionIT extends BaseHBaseManagedTimeIT {
@Test
public void signedInteger() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
+ String tableName = generateRandomString();
- String ddl = "CREATE TABLE IF NOT EXISTS last_test_table "
+ String ddl = "CREATE TABLE IF NOT EXISTS " + tableName
+ "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG, date INTEGER, \"value\" INTEGER)";
conn.createStatement().execute(ddl);
- conn.createStatement().execute("UPSERT INTO last_test_table (id, page_id, date, \"value\") VALUES (5, 8, 5, -255)");
- conn.createStatement().execute("UPSERT INTO last_test_table (id, page_id, date, \"value\") VALUES (1, 8, 1, 3)");
- conn.createStatement().execute("UPSERT INTO last_test_table (id, page_id, date, \"value\") VALUES (2, 8, 2, 7)");
- conn.createStatement().execute("UPSERT INTO last_test_table (id, page_id, date, \"value\") VALUES (3, 8, 3, 9)");
- conn.createStatement().execute("UPSERT INTO last_test_table (id, page_id, date, \"value\") VALUES (4, 8, 4, 4)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (5, 8, 5, -255)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (1, 8, 1, 3)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (2, 8, 2, 7)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (3, 8, 3, 9)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (4, 8, 4, 4)");
conn.commit();
ResultSet rs = conn.createStatement().executeQuery(
- "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM last_test_table GROUP BY page_id"
+ "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM " + tableName + " GROUP BY page_id"
);
assertTrue(rs.next());
@@ -89,21 +90,22 @@ public class LastValueFunctionIT extends BaseHBaseManagedTimeIT {
@Test
public void unsignedInteger() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
+ String tableName = generateRandomString();
- String ddl = "CREATE TABLE IF NOT EXISTS last_test_table "
+ String ddl = "CREATE TABLE IF NOT EXISTS " + tableName
+ "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG,"
+ " date UNSIGNED_INT, \"value\" UNSIGNED_INT)";
conn.createStatement().execute(ddl);
- conn.createStatement().execute("UPSERT INTO last_test_table (id, page_id, date, \"value\") VALUES (1, 8, 1, 3)");
- conn.createStatement().execute("UPSERT INTO last_test_table (id, page_id, date, \"value\") VALUES (2, 8, 2, 7)");
- conn.createStatement().execute("UPSERT INTO last_test_table (id, page_id, date, \"value\") VALUES (3, 8, 3, 9)");
- conn.createStatement().execute("UPSERT INTO last_test_table (id, page_id, date, \"value\") VALUES (5, 8, 4, 2)");
- conn.createStatement().execute("UPSERT INTO last_test_table (id, page_id, date, \"value\") VALUES (4, 8, 5, 4)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (1, 8, 1, 3)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (2, 8, 2, 7)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (3, 8, 3, 9)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (5, 8, 4, 2)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (4, 8, 5, 4)");
conn.commit();
ResultSet rs = conn.createStatement().executeQuery(
- "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM last_test_table GROUP BY page_id"
+ "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM " + tableName + " GROUP BY page_id"
);
assertTrue(rs.next());
assertEquals(rs.getInt(1), 4);
@@ -113,22 +115,23 @@ public class LastValueFunctionIT extends BaseHBaseManagedTimeIT {
@Test
public void simpleTestDescOrder() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
+ String tableName = generateRandomString();
- String ddl = "CREATE TABLE IF NOT EXISTS last_value_table "
+ String ddl = "CREATE TABLE IF NOT EXISTS " + tableName
+ "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG,"
+ " dates INTEGER, val INTEGER)";
conn.createStatement().execute(ddl);
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, dates, val) VALUES (1, 8, 0, 300)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, dates, val) VALUES (2, 8, 1, 7)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, dates, val) VALUES (3, 8, 2, 9)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, dates, val) VALUES (4, 8, 3, 4)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, dates, val) VALUES (5, 8, 4, 2)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, dates, val) VALUES (6, 8, 5, 150)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, dates, val) VALUES (1, 8, 0, 300)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, dates, val) VALUES (2, 8, 1, 7)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, dates, val) VALUES (3, 8, 2, 9)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, dates, val) VALUES (4, 8, 3, 4)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, dates, val) VALUES (5, 8, 4, 2)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, dates, val) VALUES (6, 8, 5, 150)");
conn.commit();
ResultSet rs = conn.createStatement().executeQuery(
- "SELECT LAST_VALUE(val) WITHIN GROUP (ORDER BY dates DESC) FROM last_value_table GROUP BY page_id");
+ "SELECT LAST_VALUE(val) WITHIN GROUP (ORDER BY dates DESC) FROM " + tableName + " GROUP BY page_id");
assertTrue(rs.next());
assertEquals(rs.getInt(1), 300);
@@ -138,22 +141,23 @@ public class LastValueFunctionIT extends BaseHBaseManagedTimeIT {
@Test
public void simpleTestAscOrder() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
+ String tableName = generateRandomString();
- String ddl = "CREATE TABLE IF NOT EXISTS last_value_table "
+ String ddl = "CREATE TABLE IF NOT EXISTS " + tableName
+ "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG,"
+ " dates INTEGER, val INTEGER)";
conn.createStatement().execute(ddl);
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, dates, val) VALUES (1, 8, 0, 300)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, dates, val) VALUES (2, 8, 1, 7)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, dates, val) VALUES (3, 8, 2, 9)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, dates, val) VALUES (4, 8, 3, 4)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, dates, val) VALUES (5, 8, 4, 2)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, dates, val) VALUES (6, 8, 5, 150)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, dates, val) VALUES (1, 8, 0, 300)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, dates, val) VALUES (2, 8, 1, 7)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, dates, val) VALUES (3, 8, 2, 9)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, dates, val) VALUES (4, 8, 3, 4)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, dates, val) VALUES (5, 8, 4, 2)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, dates, val) VALUES (6, 8, 5, 150)");
conn.commit();
ResultSet rs = conn.createStatement().executeQuery(
- "SELECT LAST_VALUE(val) WITHIN GROUP (ORDER BY dates ASC) FROM last_value_table GROUP BY page_id");
+ "SELECT LAST_VALUE(val) WITHIN GROUP (ORDER BY dates ASC) FROM " + tableName + " GROUP BY page_id");
assertTrue(rs.next());
assertEquals(rs.getInt(1), 150);
@@ -163,21 +167,22 @@ public class LastValueFunctionIT extends BaseHBaseManagedTimeIT {
@Test
public void charDatatype() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
+ String tableName = generateRandomString();
- String ddl = "CREATE TABLE IF NOT EXISTS last_value_table "
+ String ddl = "CREATE TABLE IF NOT EXISTS " + tableName
+ "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG, "
+ "date CHAR(3), \"value\" CHAR(3))";
conn.createStatement().execute(ddl);
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (1, 8, '1', '300')");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (2, 8, '2', '7')");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (3, 8, '3', '9')");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (5, 8, '4', '2')");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (4, 8, '5', '400')");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (1, 8, '1', '300')");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (2, 8, '2', '7')");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (3, 8, '3', '9')");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (5, 8, '4', '2')");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (4, 8, '5', '400')");
conn.commit();
ResultSet rs = conn.createStatement().executeQuery(
- "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM last_value_table GROUP BY page_id");
+ "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM " + tableName + " GROUP BY page_id");
assertTrue(rs.next());
assertEquals(rs.getString(1), "400");
@@ -187,21 +192,22 @@ public class LastValueFunctionIT extends BaseHBaseManagedTimeIT {
@Test
public void varcharVariableLenghtDatatype() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
+ String tableName = generateRandomString();
- String ddl = "CREATE TABLE IF NOT EXISTS last_value_table "
+ String ddl = "CREATE TABLE IF NOT EXISTS " + tableName
+ "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG,"
+ " date VARCHAR, \"value\" VARCHAR)";
conn.createStatement().execute(ddl);
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (1, 8, '1', '3')");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (2, 8, '2', '7')");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (3, 8, '3', '9')");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (5, 8, '4', '2')");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (4, 8, '5', '4')");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (1, 8, '1', '3')");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (2, 8, '2', '7')");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (3, 8, '3', '9')");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (5, 8, '4', '2')");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (4, 8, '5', '4')");
conn.commit();
ResultSet rs = conn.createStatement().executeQuery(
- "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM last_value_table GROUP BY page_id");
+ "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM " + tableName + " GROUP BY page_id");
assertTrue(rs.next());
assertEquals(rs.getString(1), "4");
@@ -211,30 +217,31 @@ public class LastValueFunctionIT extends BaseHBaseManagedTimeIT {
@Test
public void groupMultipleValues() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
+ String tableName = generateRandomString();
- String ddl = "CREATE TABLE IF NOT EXISTS last_value_table "
+ String ddl = "CREATE TABLE IF NOT EXISTS " + tableName
+ "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG,"
+ " date UNSIGNED_INT, \"value\" UNSIGNED_INT)";
conn.createStatement().execute(ddl);
//first page_id
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (1, 8, 1, 3)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (2, 8, 2, 7)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (3, 8, 3, 9)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (5, 8, 4, 2)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (4, 8, 5, 4)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (1, 8, 1, 3)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (2, 8, 2, 7)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (3, 8, 3, 9)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (5, 8, 4, 2)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (4, 8, 5, 4)");
//second page_id
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (11, 9, 1, 3)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (12, 9, 2, 7)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (13, 9, 3, 9)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (15, 9, 4, 2)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (14, 9, 5, 40)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (11, 9, 1, 3)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (12, 9, 2, 7)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (13, 9, 3, 9)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (15, 9, 4, 2)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (14, 9, 5, 40)");
conn.commit();
ResultSet rs = conn.createStatement().executeQuery(
- "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM last_value_table GROUP BY page_id");
+ "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM " + tableName + " GROUP BY page_id");
assertTrue(rs.next());
assertEquals(rs.getInt(1), 4);
@@ -247,21 +254,22 @@ public class LastValueFunctionIT extends BaseHBaseManagedTimeIT {
@Test
public void nullValuesInAggregatingColumns() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
+ String tableName = generateRandomString();
- String ddl = "CREATE TABLE IF NOT EXISTS last_value_table "
+ String ddl = "CREATE TABLE IF NOT EXISTS " + tableName
+ "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG,"
+ " date UNSIGNED_INT, \"value\" UNSIGNED_INT)";
conn.createStatement().execute(ddl);
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date) VALUES (1, 8, 1)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date) VALUES (2, 8, 2)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date) VALUES (3, 8, 3)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date) VALUES (5, 8, 4)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date) VALUES (4, 8, 5)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date) VALUES (1, 8, 1)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date) VALUES (2, 8, 2)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date) VALUES (3, 8, 3)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date) VALUES (5, 8, 4)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date) VALUES (4, 8, 5)");
conn.commit();
ResultSet rs = conn.createStatement().executeQuery(
- "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM last_value_table GROUP BY page_id");
+ "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM " + tableName + " GROUP BY page_id");
assertTrue(rs.next());
byte[] nothing = rs.getBytes(1);
@@ -271,22 +279,23 @@ public class LastValueFunctionIT extends BaseHBaseManagedTimeIT {
@Test
public void nullValuesInAggregatingColumnsSecond() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
+ String tableName = generateRandomString();
- String ddl = "CREATE TABLE IF NOT EXISTS last_value_table "
+ String ddl = "CREATE TABLE IF NOT EXISTS " + tableName
+ "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG,"
+ " date UNSIGNED_INT, \"value\" UNSIGNED_INT)";
conn.createStatement().execute(ddl);
//first page_id
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date) VALUES (1, 8, 1)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date) VALUES (2, 8, 2)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date) VALUES (3, 8, 3)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date) VALUES (5, 8, 4)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date) VALUES (4, 8, 5)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date) VALUES (1, 8, 1)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date) VALUES (2, 8, 2)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date) VALUES (3, 8, 3)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date) VALUES (5, 8, 4)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date) VALUES (4, 8, 5)");
conn.commit();
ResultSet rs = conn.createStatement().executeQuery(
- "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM last_value_table GROUP BY page_id");
+ "SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) FROM " + tableName + " GROUP BY page_id");
assertTrue(rs.next());
byte[] nothing = rs.getBytes(1);
@@ -296,31 +305,32 @@ public class LastValueFunctionIT extends BaseHBaseManagedTimeIT {
@Test
public void inOrderByClausule() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
+ String tableName = generateRandomString();
- String ddl = "CREATE TABLE IF NOT EXISTS last_value_table "
+ String ddl = "CREATE TABLE IF NOT EXISTS " + tableName
+ "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_INT,"
+ " date UNSIGNED_INT, \"value\" UNSIGNED_INT)";
conn.createStatement().execute(ddl);
//first page
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (1, 8, 1, 3)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (2, 8, 2, 7)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (3, 8, 3, 9)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (5, 8, 4, 2)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (4, 8, 5, 5)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (1, 8, 1, 3)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (2, 8, 2, 7)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (3, 8, 3, 9)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (5, 8, 4, 2)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (4, 8, 5, 5)");
//second page
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (5, 2, 1, 3)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (6, 2, 2, 7)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (7, 2, 3, 9)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (8, 2, 4, 2)");
- conn.createStatement().execute("UPSERT INTO last_value_table (id, page_id, date, \"value\") VALUES (9, 2, 5, 4)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (5, 2, 1, 3)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (6, 2, 2, 7)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (7, 2, 3, 9)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (8, 2, 4, 2)");
+ conn.createStatement().execute("UPSERT INTO " + tableName + " (id, page_id, date, \"value\") VALUES (9, 2, 5, 4)");
conn.commit();
ResultSet rs = conn.createStatement().executeQuery(
"SELECT LAST_VALUE(\"value\") WITHIN GROUP (ORDER BY date ASC) AS val "
- + "FROM last_value_table GROUP BY page_id ORDER BY val DESC");
+ + "FROM " + tableName + " GROUP BY page_id ORDER BY val DESC");
assertTrue(rs.next());
assertEquals(rs.getInt(1), 5);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/03df8ab5/phoenix-core/src/it/java/org/apache/phoenix/end2end/LnLogFunctionEnd2EndIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LnLogFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LnLogFunctionEnd2EndIT.java
index e2c72ca..466e71d 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LnLogFunctionEnd2EndIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LnLogFunctionEnd2EndIT.java
@@ -33,10 +33,12 @@ import org.junit.Test;
/**
* End to end tests for {@link LnFunction} and {@link LogFunction}
*/
-public class LnLogFunctionEnd2EndIT extends BaseHBaseManagedTimeIT {
+public class LnLogFunctionEnd2EndIT extends BaseHBaseManagedTimeTableReuseIT {
private static final String KEY = "key";
private static final double ZERO = 1e-9;
+ private String signedTableName;
+ private String unsignedTableName;
private static boolean twoDoubleEquals(double a, double b) {
if (Double.isNaN(a) ^ Double.isNaN(b)) return false;
@@ -57,14 +59,17 @@ public class LnLogFunctionEnd2EndIT extends BaseHBaseManagedTimeIT {
public void initTable() throws Exception {
Connection conn = null;
PreparedStatement stmt = null;
+ signedTableName = generateRandomString();
+ unsignedTableName = generateRandomString();
+
try {
conn = DriverManager.getConnection(getUrl());
String ddl;
ddl =
- "CREATE TABLE testSigned (k VARCHAR NOT NULL PRIMARY KEY, doub DOUBLE, fl FLOAT, inte INTEGER, lon BIGINT, smalli SMALLINT, tinyi TINYINT)";
+ "CREATE TABLE " + signedTableName + " (k VARCHAR NOT NULL PRIMARY KEY, doub DOUBLE, fl FLOAT, inte INTEGER, lon BIGINT, smalli SMALLINT, tinyi TINYINT)";
conn.createStatement().execute(ddl);
ddl =
- "CREATE TABLE testUnsigned (k VARCHAR NOT NULL PRIMARY KEY, doub UNSIGNED_DOUBLE, fl UNSIGNED_FLOAT, inte UNSIGNED_INT, lon UNSIGNED_LONG, smalli UNSIGNED_SMALLINT, tinyi UNSIGNED_TINYINT)";
+ "CREATE TABLE " + unsignedTableName + " (k VARCHAR NOT NULL PRIMARY KEY, doub UNSIGNED_DOUBLE, fl UNSIGNED_FLOAT, inte UNSIGNED_INT, lon UNSIGNED_LONG, smalli UNSIGNED_SMALLINT, tinyi UNSIGNED_TINYINT)";
conn.createStatement().execute(ddl);
conn.commit();
} finally {
@@ -136,8 +141,8 @@ public class LnLogFunctionEnd2EndIT extends BaseHBaseManagedTimeIT {
public void test() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
for (double d : new double[] { 0.0, 1.0, -1.0, 123.1234, -123.1234 }) {
- testNumberSpec(conn, d, "testSigned");
- if (d >= 0) testNumberSpec(conn, d, "testUnsigned");
+ testNumberSpec(conn, d, signedTableName );
+ if (d >= 0) testNumberSpec(conn, d, unsignedTableName );
}
}
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/03df8ab5/phoenix-core/src/it/java/org/apache/phoenix/end2end/MapReduceIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MapReduceIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MapReduceIT.java
index f030701..275d524 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MapReduceIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MapReduceIT.java
@@ -41,56 +41,63 @@ import static org.junit.Assert.*;
/**
* Test that our MapReduce basic tools work as expected
*/
-public class MapReduceIT extends BaseHBaseManagedTimeIT {
+public class MapReduceIT extends BaseHBaseManagedTimeTableReuseIT {
- private static final String STOCK_TABLE_NAME = "stock";
- private static final String STOCK_STATS_TABLE_NAME = "stock_stats";
private static final String STOCK_NAME = "STOCK_NAME";
private static final String RECORDING_YEAR = "RECORDING_YEAR";
private static final String RECORDINGS_QUARTER = "RECORDINGS_QUARTER";
- private static final String CREATE_STOCK_TABLE = "CREATE TABLE IF NOT EXISTS " + STOCK_TABLE_NAME + " ( " +
- STOCK_NAME + " VARCHAR NOT NULL ," + RECORDING_YEAR + " INTEGER NOT NULL, " + RECORDINGS_QUARTER +
- " DOUBLE array[] CONSTRAINT pk PRIMARY KEY (" + STOCK_NAME + " , " + RECORDING_YEAR + "))";
+ private String CREATE_STOCK_TABLE = "CREATE TABLE IF NOT EXISTS %s ( " +
+ " STOCK_NAME VARCHAR NOT NULL , RECORDING_YEAR INTEGER NOT NULL, RECORDINGS_QUARTER " +
+ " DOUBLE array[] CONSTRAINT pk PRIMARY KEY ( STOCK_NAME, RECORDING_YEAR ))";
private static final String MAX_RECORDING = "MAX_RECORDING";
- private static final String CREATE_STOCK_STATS_TABLE =
- "CREATE TABLE IF NOT EXISTS " + STOCK_STATS_TABLE_NAME + "(" + STOCK_NAME + " VARCHAR NOT NULL , "
- + MAX_RECORDING + " DOUBLE CONSTRAINT pk PRIMARY KEY (" + STOCK_NAME + "))";
- private static final String UPSERT = "UPSERT into " + STOCK_TABLE_NAME + " values (?, ?, ?)";
+ private String CREATE_STOCK_STATS_TABLE =
+ "CREATE TABLE IF NOT EXISTS %s(STOCK_NAME VARCHAR NOT NULL , "
+ + " MAX_RECORDING DOUBLE CONSTRAINT pk PRIMARY KEY (STOCK_NAME ))";
+ private String UPSERT = "UPSERT into %s values (?, ?, ?)";
@Before
public void setupTables() throws Exception {
- Connection conn = DriverManager.getConnection(getUrl());
- conn.createStatement().execute(CREATE_STOCK_TABLE);
- conn.createStatement().execute(CREATE_STOCK_STATS_TABLE);
- conn.commit();
+
}
@Test
public void testNoConditionsOnSelect() throws Exception {
+ Connection conn = DriverManager.getConnection(getUrl());
+ String stockTableName = generateRandomString();
+ String stockStatsTableName = generateRandomString();
+ conn.createStatement().execute(String.format(CREATE_STOCK_TABLE, stockTableName));
+ conn.createStatement().execute(String.format(CREATE_STOCK_STATS_TABLE, stockStatsTableName));
+ conn.commit();
final Configuration conf = getUtility().getConfiguration();
Job job = Job.getInstance(conf);
- PhoenixMapReduceUtil.setInput(job, StockWritable.class, STOCK_TABLE_NAME, null,
+ PhoenixMapReduceUtil.setInput(job, StockWritable.class, stockTableName, null,
STOCK_NAME, RECORDING_YEAR, "0." + RECORDINGS_QUARTER);
- testJob(job, 91.04);
+ testJob(job, stockTableName, stockStatsTableName, 91.04);
}
@Test
public void testConditionsOnSelect() throws Exception {
+ Connection conn = DriverManager.getConnection(getUrl());
+ String stockTableName = generateRandomString();
+ String stockStatsTableName = generateRandomString();
+ conn.createStatement().execute(String.format(CREATE_STOCK_TABLE, stockTableName));
+ conn.createStatement().execute(String.format(CREATE_STOCK_STATS_TABLE, stockStatsTableName));
+ conn.commit();
final Configuration conf = getUtility().getConfiguration();
Job job = Job.getInstance(conf);
- PhoenixMapReduceUtil.setInput(job, StockWritable.class, STOCK_TABLE_NAME, RECORDING_YEAR+" < 2009",
+ PhoenixMapReduceUtil.setInput(job, StockWritable.class, stockTableName, RECORDING_YEAR+" < 2009",
STOCK_NAME, RECORDING_YEAR, "0." + RECORDINGS_QUARTER);
- testJob(job, 81.04);
+ testJob(job, stockTableName, stockStatsTableName, 81.04);
}
- private void testJob(Job job, double expectedMax)
+ private void testJob(Job job, String stockTableName, String stockStatsTableName, double expectedMax)
throws SQLException, InterruptedException, IOException, ClassNotFoundException {
- upsertData();
+ upsertData(stockTableName);
// only run locally, rather than having to spin up a MiniMapReduce cluster and lets us use breakpoints
job.getConfiguration().set("mapreduce.framework.name", "local");
- setOutput(job);
+ setOutput(job, stockStatsTableName);
job.setMapperClass(StockMapper.class);
job.setReducerClass(StockReducer.class);
@@ -106,7 +113,7 @@ public class MapReduceIT extends BaseHBaseManagedTimeIT {
// verify
ResultSet stats = DriverManager.getConnection(getUrl()).createStatement()
- .executeQuery("SELECT * FROM " + STOCK_STATS_TABLE_NAME);
+ .executeQuery("SELECT * FROM " + stockStatsTableName);
assertTrue("No data stored in stats table!", stats.next());
String name = stats.getString(1);
double max = stats.getDouble(2);
@@ -120,17 +127,17 @@ public class MapReduceIT extends BaseHBaseManagedTimeIT {
*
* @param job to update
*/
- private void setOutput(Job job) {
+ private void setOutput(Job job, String stockStatsTableName) {
final Configuration configuration = job.getConfiguration();
- PhoenixConfigurationUtil.setOutputTableName(configuration, STOCK_STATS_TABLE_NAME);
- configuration.set(PhoenixConfigurationUtil.UPSERT_STATEMENT, "UPSERT into " + STOCK_STATS_TABLE_NAME +
+ PhoenixConfigurationUtil.setOutputTableName(configuration, stockStatsTableName);
+ configuration.set(PhoenixConfigurationUtil.UPSERT_STATEMENT, "UPSERT into " + stockStatsTableName +
" (" + STOCK_NAME + ", " + MAX_RECORDING + ") values (?,?)");
job.setOutputFormatClass(PhoenixOutputFormat.class);
}
- private void upsertData() throws SQLException {
+ private void upsertData(String stockTableName) throws SQLException {
Connection conn = DriverManager.getConnection(getUrl());
- PreparedStatement stmt = conn.prepareStatement(UPSERT);
+ PreparedStatement stmt = conn.prepareStatement(String.format(UPSERT, stockTableName));
upsertData(stmt, "AAPL", 2009, new Double[]{85.88, 91.04, 88.5, 90.3});
upsertData(stmt, "AAPL", 2008, new Double[]{75.88, 81.04, 78.5, 80.3});
conn.commit();
http://git-wip-us.apache.org/repos/asf/phoenix/blob/03df8ab5/phoenix-core/src/it/java/org/apache/phoenix/end2end/MappingTableDataTypeIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MappingTableDataTypeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MappingTableDataTypeIT.java
index 6c51ebd..3ae33fb 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MappingTableDataTypeIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MappingTableDataTypeIT.java
@@ -49,7 +49,7 @@ import org.apache.phoenix.util.PropertiesUtil;
import org.junit.Test;
-public class MappingTableDataTypeIT extends BaseHBaseManagedTimeIT {
+public class MappingTableDataTypeIT extends BaseHBaseManagedTimeTableReuseIT {
@Test
public void testMappingHbaseTableToPhoenixTable() throws Exception {
String mtest = generateRandomString();
http://git-wip-us.apache.org/repos/asf/phoenix/blob/03df8ab5/phoenix-core/src/it/java/org/apache/phoenix/end2end/ModulusExpressionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ModulusExpressionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ModulusExpressionIT.java
index 7de85ea..8cb061f 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ModulusExpressionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ModulusExpressionIT.java
@@ -32,7 +32,7 @@ import java.sql.SQLException;
import org.junit.Test;
-public class ModulusExpressionIT extends BaseHBaseManagedTimeIT {
+public class ModulusExpressionIT extends BaseHBaseManagedTimeTableReuseIT {
private static final long SMALL_VALUE = 31L;
private static final long LARGE_VALUE = 0x5dec6f3847021a9bL;
@@ -40,10 +40,11 @@ public class ModulusExpressionIT extends BaseHBaseManagedTimeIT {
private static final long[] DIVIDENDS = {Long.MAX_VALUE, LARGE_VALUE, SMALL_VALUE, 0, -SMALL_VALUE, -LARGE_VALUE, Long.MIN_VALUE};
private static final long[] DIVISORS = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 31, 127, 1024};
- private void initTable(Connection conn, long value) throws SQLException {
- String ddl = "CREATE TABLE MODULUS_TEST (pk BIGINT NOT NULL PRIMARY KEY, kv BIGINT)";
+ private void initTable(Connection conn, long value, String tableName) throws SQLException {
+
+ String ddl = "CREATE TABLE " + tableName + " (pk BIGINT NOT NULL PRIMARY KEY, kv BIGINT)";
conn.createStatement().execute(ddl);
- String dml = "UPSERT INTO MODULUS_TEST VALUES(?)";
+ String dml = "UPSERT INTO " + tableName + " VALUES(?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setLong(1, value);
stmt.execute();
@@ -52,11 +53,12 @@ public class ModulusExpressionIT extends BaseHBaseManagedTimeIT {
private void testDividend(long dividend) throws SQLException {
Connection conn = DriverManager.getConnection(getUrl());
- initTable(conn, dividend);
-
+ String tableName = generateRandomString();
+ initTable(conn, dividend, tableName);
+
for(long divisor : DIVISORS) {
long remainder = dividend % divisor;
- String sql = "SELECT pk % " + divisor + " FROM MODULUS_TEST";
+ String sql = "SELECT pk % " + divisor + " FROM " + tableName;
ResultSet rs = conn.createStatement().executeQuery(sql);
assertTrue(rs.next());
@@ -103,16 +105,17 @@ public class ModulusExpressionIT extends BaseHBaseManagedTimeIT {
@Test
public void testZeroDivisor() throws SQLException {
Connection conn = DriverManager.getConnection(getUrl());
- initTable(conn, 0);
+ String tableName = generateRandomString();
+ initTable(conn, 0, tableName);
for(long dividend : DIVIDENDS) {
try {
- String sql = "SELECT " + dividend + " % pk FROM MODULUS_TEST";
+ String sql = "SELECT " + dividend + " % pk FROM " + tableName;
// workaround for parser not being able to parse Long.MIN_VALUE
// see: https://issues.apache.org/jira/browse/PHOENIX-1061
if(dividend == Long.MIN_VALUE) {
- sql = "SELECT (" + (dividend + 1) + " + -1) % pk FROM MODULUS_TEST";
+ sql = "SELECT (" + (dividend + 1) + " + -1) % pk FROM " + tableName;
}
ResultSet rs = conn.createStatement().executeQuery(sql);
@@ -129,10 +132,11 @@ public class ModulusExpressionIT extends BaseHBaseManagedTimeIT {
@Test
public void testNullDividend() throws SQLException {
Connection conn = DriverManager.getConnection(getUrl());
- initTable(conn, SMALL_VALUE);
+ String tableName = generateRandomString();
+ initTable(conn, SMALL_VALUE, tableName);
for(long divisor : DIVISORS) {
- String sql = "SELECT kv % " + divisor + " FROM MODULUS_TEST";
+ String sql = "SELECT kv % " + divisor + " FROM " + tableName;
ResultSet rs = conn.createStatement().executeQuery(sql);
assertTrue(rs.next());
@@ -144,15 +148,16 @@ public class ModulusExpressionIT extends BaseHBaseManagedTimeIT {
@Test
public void testNullDivisor() throws SQLException {
Connection conn = DriverManager.getConnection(getUrl());
- initTable(conn, SMALL_VALUE);
+ String tableName = generateRandomString();
+ initTable(conn, SMALL_VALUE, tableName);
for(long dividend : DIVIDENDS) {
- String sql = "SELECT " + dividend + " % kv FROM MODULUS_TEST";
+ String sql = "SELECT " + dividend + " % kv FROM " + tableName;
// workaround for parser not being able to parse Long.MIN_VALUE
// see: https://issues.apache.org/jira/browse/PHOENIX-1061
if(dividend == Long.MIN_VALUE) {
- sql = "SELECT (" + (dividend + 1) + " + -1) % kv FROM MODULUS_TEST";
+ sql = "SELECT (" + (dividend + 1) + " + -1) % kv FROM " + tableName;
}
ResultSet rs = conn.createStatement().executeQuery(sql);
@@ -165,21 +170,23 @@ public class ModulusExpressionIT extends BaseHBaseManagedTimeIT {
@Test
public void testNullEverything() throws SQLException {
Connection conn = DriverManager.getConnection(getUrl());
- initTable(conn, SMALL_VALUE);
+ String tableName = generateRandomString();
+ initTable(conn, SMALL_VALUE, tableName);
- String sql = "SELECT null % kv FROM MODULUS_TEST";
+ String sql = "SELECT null % kv FROM " + tableName;
ResultSet rs = conn.createStatement().executeQuery(sql);
assertTrue(rs.next());
assertNull(rs.getObject(1));
assertFalse(rs.next());
- sql = "SELECT kv % null FROM MODULUS_TEST";
+ sql = "SELECT kv % null FROM " + tableName;
rs = conn.createStatement().executeQuery(sql);
assertTrue(rs.next());
assertNull(rs.getObject(1));
assertFalse(rs.next());
}
-
+
+
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/03df8ab5/phoenix-core/src/it/java/org/apache/phoenix/end2end/MultiCfQueryExecIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MultiCfQueryExecIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MultiCfQueryExecIT.java
index 2b14fe9..15fc01d 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MultiCfQueryExecIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MultiCfQueryExecIT.java
@@ -57,7 +57,7 @@ public class MultiCfQueryExecIT extends BaseOwnClusterClientManagedTimeIT {
}
protected static void initTableValues(long ts) throws Exception {
- ensureTableCreated(getUrl(),MULTI_CF,null, ts-2);
+ ensureTableCreated(getUrl(),MULTI_CF,MULTI_CF,null, ts-2);
String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + ts;
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/03df8ab5/phoenix-core/src/it/java/org/apache/phoenix/end2end/NamespaceSchemaMappingIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NamespaceSchemaMappingIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NamespaceSchemaMappingIT.java
index 43b62dd..0f91978 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NamespaceSchemaMappingIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NamespaceSchemaMappingIT.java
@@ -44,7 +44,7 @@ import org.junit.Test;
/*
* since 4.8
*/
-public class NamespaceSchemaMappingIT extends BaseHBaseManagedTimeIT {
+public class NamespaceSchemaMappingIT extends BaseHBaseManagedTimeTableReuseIT {
/**
* Tests that when: There is a table created with older version of phoenix and a table created with newer version
* having {@code QueryServices#IS_NAMESPACE_MAPPING_ENABLED} true, then there is only a flag
@@ -57,7 +57,7 @@ public class NamespaceSchemaMappingIT extends BaseHBaseManagedTimeIT {
String namespace = "TEST_SCHEMA";
String schemaName = namespace;
- String tableName = "TEST";
+ String tableName = generateRandomString();
String phoenixFullTableName = schemaName + "." + tableName;
String hbaseFullTableName = schemaName + ":" + tableName;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/03df8ab5/phoenix-core/src/it/java/org/apache/phoenix/end2end/NativeHBaseTypesIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NativeHBaseTypesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NativeHBaseTypesIT.java
index 2c5de02..3d0fa2c 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NativeHBaseTypesIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NativeHBaseTypesIT.java
@@ -151,7 +151,7 @@ public class NativeHBaseTypesIT extends BaseClientManagedTimeIT {
}
// Create Phoenix table after HBase table was created through the native APIs
// The timestamp of the table creation must be later than the timestamp of the data
- ensureTableCreated(getUrl(),HBASE_NATIVE,null, ts+1);
+ ensureTableCreated(getUrl(),HBASE_NATIVE,HBASE_NATIVE,null, ts+1);
}
@Test
http://git-wip-us.apache.org/repos/asf/phoenix/blob/03df8ab5/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByIT.java
index 2c880e7..dcb2a0d 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByIT.java
@@ -43,13 +43,13 @@ import org.apache.phoenix.util.PropertiesUtil;
import org.junit.Test;
-public class OrderByIT extends BaseHBaseManagedTimeIT {
+public class OrderByIT extends BaseHBaseManagedTimeTableReuseIT {
@Test
public void testMultiOrderByExpr() throws Exception {
String tenantId = getOrganizationId();
- initATableValues(tenantId, getDefaultSplits(tenantId), getUrl());
- String query = "SELECT entity_id FROM aTable ORDER BY b_string, entity_id";
+ String tableName = initATableValues(tenantId, getDefaultSplits(tenantId), getUrl());
+ String query = "SELECT entity_id FROM " + tableName + " ORDER BY b_string, entity_id";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
@@ -84,8 +84,8 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
@Test
public void testDescMultiOrderByExpr() throws Exception {
String tenantId = getOrganizationId();
- initATableValues(tenantId, getDefaultSplits(tenantId), getUrl());
- String query = "SELECT entity_id FROM aTable ORDER BY b_string || entity_id desc";
+ String tableName = initATableValues(tenantId, getDefaultSplits(tenantId), getUrl());
+ String query = "SELECT entity_id FROM " + tableName + " ORDER BY b_string || entity_id desc";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
@@ -123,12 +123,13 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE t_table " +
+ String tableName = generateRandomString();
+ String ddl = "CREATE TABLE " + tableName +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- String dml = "UPSERT INTO t_table VALUES(?, ?)";
+ String dml = "UPSERT INTO " + tableName + " VALUES(?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 40);
@@ -141,7 +142,7 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- String query = "select count(*), col1 from t_table group by col1 order by 2";
+ String query = "select count(*), col1 from " + tableName + " group by col1 order by 2";
ResultSet rs = conn.createStatement().executeQuery(query);
assertTrue(rs.next());
assertEquals(1,rs.getInt(1));
@@ -151,7 +152,7 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
assertEquals(1,rs.getInt(1));
assertFalse(rs.next());
- query = "select a_string x, col1 y from t_table order by x";
+ query = "select a_string x, col1 y from " + tableName + " order by x";
rs = conn.createStatement().executeQuery(query);
assertTrue(rs.next());
assertEquals("a",rs.getString(1));
@@ -164,7 +165,7 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
assertEquals(30,rs.getInt(2));
assertFalse(rs.next());
- query = "select * from t_table order by 2";
+ query = "select * from " + tableName + " order by 2";
rs = conn.createStatement().executeQuery(query);
assertTrue(rs.next());
assertEquals("b",rs.getString(1));
@@ -189,11 +190,12 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE x_table " +
+ String tableName = generateRandomString();
+ String ddl = "CREATE TABLE " + tableName +
" (a_string varchar not null, cf1.a integer, cf1.b varchar, col1 integer, cf2.c varchar, cf2.d integer, col2 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- String dml = "UPSERT INTO x_table VALUES(?,?,?,?,?,?,?)";
+ String dml = "UPSERT INTO " + tableName + " VALUES(?,?,?,?,?,?,?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 40);
@@ -221,7 +223,7 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- String query = "select * from x_table order by 2, 5";
+ String query = "select * from " + tableName + " order by 2, 5";
ResultSet rs = conn.createStatement().executeQuery(query);
assertTrue(rs.next());
assertEquals("c",rs.getString(1));
@@ -249,7 +251,7 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
assertEquals(1,rs.getInt(7));
assertFalse(rs.next());
- query = "select * from x_table order by 7";
+ query = "select * from " + tableName + " order by 7";
rs = conn.createStatement().executeQuery(query);
assertTrue(rs.next());
assertEquals("a",rs.getString(1));
@@ -288,11 +290,12 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE s_table " +
+ String tableName1 = generateRandomString();
+ String ddl = "CREATE TABLE " + tableName1 +
" (a_string varchar not null, cf1.a integer, cf1.b varchar, col1 integer, cf2.c varchar, cf2.d integer " +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- String dml = "UPSERT INTO s_table VALUES(?,?,?,?,?,?)";
+ String dml = "UPSERT INTO " + tableName1 + " VALUES(?,?,?,?,?,?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 40);
@@ -317,12 +320,13 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- ddl = "CREATE TABLE t_table " +
+ String tableName2 = generateRandomString();
+ ddl = "CREATE TABLE " + tableName2 +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- dml = "UPSERT INTO t_table VALUES(?, ?)";
+ dml = "UPSERT INTO " + tableName2 + " VALUES(?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 40);
@@ -335,7 +339,7 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- String query = "select t1.* from s_table t1 join t_table t2 on t1.a_string = t2.a_string order by 3";
+ String query = "select t1.* from " + tableName1 + " t1 join " + tableName2 + " t2 on t1.a_string = t2.a_string order by 3";
ResultSet rs = conn.createStatement().executeQuery(query);
assertTrue(rs.next());
assertEquals("a",rs.getString(1));
@@ -360,7 +364,7 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
assertEquals(60,rs.getInt(6));
assertFalse(rs.next());
- query = "select t1.a_string, t2.col1 from s_table t1 join t_table t2 on t1.a_string = t2.a_string order by 2";
+ query = "select t1.a_string, t2.col1 from " + tableName1 + " t1 join " + tableName2 + " t2 on t1.a_string = t2.a_string order by 2";
rs = conn.createStatement().executeQuery(query);
assertTrue(rs.next());
assertEquals("b",rs.getString(1));
@@ -385,11 +389,12 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE x_table " +
+ String tableName1 = generateRandomString();
+ String ddl = "CREATE TABLE " + tableName1 +
" (a_string varchar not null, cf1.a integer, cf1.b varchar, col1 integer, cf2.c varchar, cf2.d integer " +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- String dml = "UPSERT INTO x_table VALUES(?,?,?,?,?,?)";
+ String dml = "UPSERT INTO " + tableName1 + " VALUES(?,?,?,?,?,?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 40);
@@ -414,12 +419,13 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- ddl = "CREATE TABLE y_table " +
+ String tableName2 = generateRandomString();
+ ddl = "CREATE TABLE " + tableName2 +
" (a_string varchar not null, col1 integer" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
- dml = "UPSERT INTO y_table VALUES(?, ?)";
+ dml = "UPSERT INTO " + tableName2 + " VALUES(?, ?)";
stmt = conn.prepareStatement(dml);
stmt.setString(1, "aa");
stmt.setInt(2, 40);
@@ -432,7 +438,7 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- String query = "select a_string, cf2.d from x_table union all select * from y_table order by 2";
+ String query = "select a_string, cf2.d from " + tableName1 + " union all select * from " + tableName2 + " order by 2";
ResultSet rs = conn.createStatement().executeQuery(query);
assertTrue(rs.next());
assertEquals("bb",rs.getString(1));
@@ -465,13 +471,14 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
conn.setAutoCommit(false);
try {
- String ddl = "CREATE TABLE e_table " +
+ String tableName = generateRandomString();
+ String ddl = "CREATE TABLE " + tableName +
" (a_string varchar not null, col1 integer, col2 integer, col3 timestamp, col4 varchar" +
" CONSTRAINT pk PRIMARY KEY (a_string))\n";
createTestTable(getUrl(), ddl);
Date date = new Date(System.currentTimeMillis());
- String dml = "UPSERT INTO e_table VALUES(?, ?, ?, ?, ?)";
+ String dml = "UPSERT INTO " + tableName + " VALUES(?, ?, ?, ?, ?)";
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setString(1, "a");
stmt.setInt(2, 40);
@@ -493,7 +500,7 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
stmt.execute();
conn.commit();
- String query = "SELECT col1+col2, col4, a_string FROM e_table ORDER BY 1, 2";
+ String query = "SELECT col1+col2, col4, a_string FROM " + tableName + " ORDER BY 1, 2";
ResultSet rs = conn.createStatement().executeQuery(query);
assertTrue(rs.next());
assertEquals("a", rs.getString(3));
@@ -512,19 +519,20 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
public void testOrderByRVC() throws Exception {
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
- String ddl = "create table test1 (testpk varchar not null primary key, l_quantity decimal(15,2), l_discount decimal(15,2))";
+ String tableName = generateRandomString();
+ String ddl = "create table " + tableName + " (testpk varchar not null primary key, l_quantity decimal(15,2), l_discount decimal(15,2))";
conn.createStatement().execute(ddl);
- PreparedStatement stmt = conn.prepareStatement("upsert into test1 values ('a',0.1,0.9)");
+ PreparedStatement stmt = conn.prepareStatement("upsert into " + tableName + " values ('a',0.1,0.9)");
stmt.execute();
- stmt = conn.prepareStatement(" upsert into test1 values ('b',0.5,0.5)");
+ stmt = conn.prepareStatement(" upsert into " + tableName + " values ('b',0.5,0.5)");
stmt.execute();
- stmt = conn.prepareStatement(" upsert into test1 values ('c',0.9,0.1)");
+ stmt = conn.prepareStatement(" upsert into " + tableName + " values ('c',0.9,0.1)");
stmt.execute();
conn.commit();
ResultSet rs;
- stmt = conn.prepareStatement("select l_discount,testpk from test1 order by (l_discount,l_quantity)");
+ stmt = conn.prepareStatement("select l_discount,testpk from " + tableName + " order by (l_discount,l_quantity)");
rs = stmt.executeQuery();
assertTrue(rs.next());
assertEquals(0.1, rs.getDouble(1), 0.01);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/03df8ab5/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelIteratorsIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelIteratorsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelIteratorsIT.java
index e86cf27..4e1e983 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelIteratorsIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelIteratorsIT.java
@@ -116,7 +116,7 @@ public class ParallelIteratorsIT extends BaseOwnClusterHBaseManagedTimeIT {
public void testServerNameOnScan() throws Exception {
Connection conn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES);
byte[][] splits = new byte[][] { K3, K9, KR };
- ensureTableCreated(getUrl(), STABLE_NAME, splits);
+ ensureTableCreated(getUrl(), STABLE_NAME, STABLE_NAME, splits);
PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class);
ResultSet rs = stmt.executeQuery("SELECT * FROM " + STABLE_NAME + " LIMIT 1");
@@ -138,7 +138,7 @@ public class ParallelIteratorsIT extends BaseOwnClusterHBaseManagedTimeIT {
public void testGuidePostsLifeCycle() throws Exception {
Connection conn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES);
byte[][] splits = new byte[][] { K3, K9, KR };
- ensureTableCreated(getUrl(), STABLE_NAME, splits);
+ ensureTableCreated(getUrl(), STABLE_NAME, STABLE_NAME, splits);
// create index
conn.createStatement().execute("CREATE INDEX " + STABLE_INDEX + " ON " + STABLE_NAME + "( \"value\")");
// before upserting
@@ -206,7 +206,7 @@ public class ParallelIteratorsIT extends BaseOwnClusterHBaseManagedTimeIT {
private static void initTableValues(Connection conn) throws Exception {
byte[][] splits = new byte[][] {K3,K4,K9,K11};
- ensureTableCreated(getUrl(),STABLE_NAME,splits);
+ ensureTableCreated(getUrl(),STABLE_NAME, STABLE_NAME, splits);
PreparedStatement stmt = conn.prepareStatement("upsert into " + STABLE_NAME + " VALUES (?, ?)");
stmt.setString(1, new String(KMIN));
stmt.setInt(2, 1);