PHOENIX-2822 Tests that extend BaseHBaseManagedTimeIT are very slow(Rahul Gidwani)
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/ecc5ff2d Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ecc5ff2d Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ecc5ff2d Branch: refs/heads/4.x-HBase-0.98 Commit: ecc5ff2d5d2b675591c4071c45b8577545269d70 Parents: caea1a5 Author: Samarth <[email protected]> Authored: Fri Apr 8 15:09:16 2016 -0700 Committer: Samarth <[email protected]> Committed: Fri Apr 8 15:09:16 2016 -0700 ---------------------------------------------------------------------- .../phoenix/end2end/AbsFunctionEnd2EndIT.java | 12 +- .../phoenix/end2end/ArithmeticQueryIT.java | 296 ++++++++++------- .../phoenix/end2end/ArrayFillFunctionIT.java | 175 ++++++---- .../end2end/ArrayToStringFunctionIT.java | 326 +++++++++---------- .../phoenix/end2end/ArraysWithNullsIT.java | 152 ++++++--- .../apache/phoenix/end2end/AutoCommitIT.java | 21 +- .../phoenix/end2end/BaseHBaseManagedTimeIT.java | 5 +- .../BaseHBaseManagedTimeTableReuseIT.java | 56 ++++ .../phoenix/end2end/CbrtFunctionEnd2EndIT.java | 35 +- .../end2end/ConvertTimezoneFunctionIT.java | 71 ++-- .../phoenix/end2end/DecodeFunctionIT.java | 49 ++- .../apache/phoenix/end2end/DynamicFamilyIT.java | 31 +- .../phoenix/end2end/FirstValueFunctionIT.java | 144 +++++--- .../end2end/GetSetByteBitFunctionEnd2EndIT.java | 26 +- .../phoenix/end2end/LikeExpressionIT.java | 34 +- .../apache/phoenix/end2end/MD5FunctionIT.java | 30 +- .../phoenix/end2end/MappingTableDataTypeIT.java | 15 +- .../end2end/MinMaxAggregateFunctionIT.java | 24 +- .../phoenix/end2end/NthValueFunctionIT.java | 252 +++++++++----- .../end2end/OctetLengthFunctionEnd2EndIT.java | 13 +- .../phoenix/end2end/PowerFunctionEnd2EndIT.java | 21 +- .../apache/phoenix/end2end/PrimitiveTypeIT.java | 63 ++-- .../org/apache/phoenix/end2end/QueryMoreIT.java | 31 +- .../apache/phoenix/end2end/RTrimFunctionIT.java | 24 +- .../org/apache/phoenix/end2end/ReadOnlyIT.java | 17 +- .../phoenix/end2end/RegexpSplitFunctionIT.java | 52 +-- .../phoenix/end2end/ReverseFunctionIT.java | 42 +-- .../RoundFloorCeilFunctionsEnd2EndIT.java | 101 ++++-- .../phoenix/end2end/ServerExceptionIT.java | 9 +- .../phoenix/end2end/SignFunctionEnd2EndIT.java | 35 +- .../org/apache/phoenix/end2end/SortOrderIT.java | 303 ++++++++++------- .../phoenix/end2end/StatementHintsIT.java | 12 +- .../apache/phoenix/end2end/StoreNullsIT.java | 51 +-- .../end2end/StringToArrayFunctionIT.java | 164 ++++++---- .../end2end/TimezoneOffsetFunctionIT.java | 63 ++-- .../end2end/UpsertSelectAutoCommitIT.java | 50 ++- .../phoenix/end2end/index/DropViewIT.java | 1 + .../salted/SaltedTableUpsertSelectIT.java | 86 +++-- .../salted/SaltedTableVarLengthRowKeyIT.java | 11 +- .../phoenix/iterate/PhoenixQueryTimeoutIT.java | 23 +- .../phoenix/memory/GlobalMemoryManager.java | 29 +- .../phoenix/memory/MemoryManagerTest.java | 87 +++-- .../java/org/apache/phoenix/query/BaseTest.java | 8 + 43 files changed, 1875 insertions(+), 1175 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/ecc5ff2d/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java index 0c6204c..2aba334 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java @@ -34,8 +34,9 @@ import org.junit.Test; /** * End to end tests for {@link AbsFunction} */ -public class AbsFunctionEnd2EndIT extends BaseHBaseManagedTimeIT { +public class AbsFunctionEnd2EndIT extends BaseHBaseManagedTimeTableReuseIT { + private static final String TABLE_NAME = generateRandomString(); private static final String KEY = "key"; @Before @@ -43,9 +44,10 @@ public class AbsFunctionEnd2EndIT extends BaseHBaseManagedTimeIT { Connection conn = null; PreparedStatement stmt = null; try { + System.out.println("TABLE_NAME = " + TABLE_NAME); conn = DriverManager.getConnection(getUrl()); String ddl; - ddl = "CREATE TABLE testSigned (k VARCHAR NOT NULL PRIMARY KEY, dec DECIMAL, doub DOUBLE, fl FLOAT, inte INTEGER, lon BIGINT, smalli SMALLINT, tinyi TINYINT)"; + ddl = "CREATE TABLE " + TABLE_NAME + " (k VARCHAR NOT NULL PRIMARY KEY, dec DECIMAL, doub DOUBLE, fl FLOAT, inte INTEGER, lon BIGINT, smalli SMALLINT, tinyi TINYINT)"; conn.createStatement().execute(ddl); conn.commit(); } finally { @@ -54,7 +56,7 @@ public class AbsFunctionEnd2EndIT extends BaseHBaseManagedTimeIT { } private void updateSignedTable(Connection conn, double data) throws Exception { - PreparedStatement stmt = conn.prepareStatement("UPSERT INTO testSigned VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); + PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); stmt.setString(1, KEY); Double d = Double.valueOf(data); stmt.setBigDecimal(2, BigDecimal.valueOf(data)); @@ -70,7 +72,7 @@ public class AbsFunctionEnd2EndIT extends BaseHBaseManagedTimeIT { private void testSignedNumberSpec(Connection conn, double data) throws Exception { updateSignedTable(conn, data); - ResultSet rs = conn.createStatement() .executeQuery("SELECT ABS(dec),ABS(doub),ABS(fl),ABS(inte),ABS(lon),ABS(smalli),ABS(tinyi) FROM testSigned"); + ResultSet rs = conn.createStatement() .executeQuery("SELECT ABS(dec),ABS(doub),ABS(fl),ABS(inte),ABS(lon),ABS(smalli),ABS(tinyi) FROM " + TABLE_NAME); assertTrue(rs.next()); Double d = Double.valueOf(data); assertEquals(rs.getBigDecimal(1).compareTo(BigDecimal.valueOf(data).abs()), 0); @@ -82,7 +84,7 @@ public class AbsFunctionEnd2EndIT extends BaseHBaseManagedTimeIT { assertEquals(rs.getByte(7), Math.abs(d.byteValue())); assertTrue(!rs.next()); - PreparedStatement stmt = conn.prepareStatement("SELECT k FROM testSigned WHERE ABS(dec)=? AND ABS(doub)=? AND ABS(fl)=? AND ABS(inte)=? AND ABS(lon)=? AND ABS(smalli)=? AND ABS(tinyi)=?"); + PreparedStatement stmt = conn.prepareStatement("SELECT k FROM " + TABLE_NAME + " WHERE ABS(dec)=? AND ABS(doub)=? AND ABS(fl)=? AND ABS(inte)=? AND ABS(lon)=? AND ABS(smalli)=? AND ABS(tinyi)=?"); stmt.setBigDecimal(1, BigDecimal.valueOf(data).abs()); stmt.setDouble(2, Math.abs(d.doubleValue())); stmt.setFloat(3, Math.abs(d.floatValue())); http://git-wip-us.apache.org/repos/asf/phoenix/blob/ecc5ff2d/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java index f56c965..4dba393 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java @@ -40,7 +40,7 @@ import com.google.common.primitives.Doubles; import com.google.common.primitives.Floats; -public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { +public class ArithmeticQueryIT extends BaseHBaseManagedTimeTableReuseIT { @Test public void testDecimalUpsertValue() throws Exception { @@ -48,13 +48,15 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(false); try { - String ddl = "CREATE TABLE testDecimalArithmetic" + + String testDecimalArithmetic = generateRandomString(); + String ddl = "CREATE TABLE " + testDecimalArithmetic + " (pk VARCHAR NOT NULL PRIMARY KEY, " + "col1 DECIMAL(31,0), col2 DECIMAL(5), col3 DECIMAL(5,2), col4 DECIMAL)"; createTestTable(getUrl(), ddl); // Test upsert correct values - String query = "UPSERT INTO testDecimalArithmetic(pk, col1, col2, col3, col4) VALUES(?,?,?,?,?)"; + String query = "UPSERT INTO " + testDecimalArithmetic + + "(pk, col1, col2, col3, col4) VALUES(?,?,?,?,?)"; PreparedStatement stmt = conn.prepareStatement(query); stmt.setString(1, "valueOne"); stmt.setBigDecimal(2, new BigDecimal("123456789123456789")); @@ -64,7 +66,8 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { stmt.execute(); conn.commit(); - query = "SELECT col1, col2, col3, col4 FROM testDecimalArithmetic WHERE pk = 'valueOne'"; + query = "SELECT col1, col2, col3, col4 FROM " + testDecimalArithmetic + + " WHERE pk = 'valueOne'"; stmt = conn.prepareStatement(query); ResultSet rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -74,7 +77,8 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { assertEquals(new BigDecimal("12345.6789"), rs.getBigDecimal(4)); assertFalse(rs.next()); - query = "UPSERT INTO testDecimalArithmetic(pk, col1, col2, col3) VALUES(?,?,?,?)"; + query = + "UPSERT INTO " + testDecimalArithmetic + "(pk, col1, col2, col3) VALUES(?,?,?,?)"; stmt = conn.prepareStatement(query); stmt.setString(1, "valueTwo"); stmt.setBigDecimal(2, new BigDecimal("1234567890123456789012345678901.12345")); @@ -83,7 +87,8 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { stmt.execute(); conn.commit(); - query = "SELECT col1, col2, col3 FROM testDecimalArithmetic WHERE pk = 'valueTwo'"; + query = + "SELECT col1, col2, col3 FROM " + testDecimalArithmetic + " WHERE pk = 'valueTwo'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -94,7 +99,8 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { // Test upsert incorrect values and confirm exceptions would be thrown. try { - query = "UPSERT INTO testDecimalArithmetic(pk, col1, col2, col3) VALUES(?,?,?,?)"; + query = "UPSERT INTO " + testDecimalArithmetic + + "(pk, col1, col2, col3) VALUES(?,?,?,?)"; stmt = conn.prepareStatement(query); stmt.setString(1, "badValues"); // one more than max_precision @@ -108,7 +114,8 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { assertEquals(SQLExceptionCode.DATA_EXCEEDS_MAX_CAPACITY.getErrorCode(),e.getErrorCode()); } try { - query = "UPSERT INTO testDecimalArithmetic(pk, col1, col2, col3) VALUES(?,?,?,?)"; + query = "UPSERT INTO " + testDecimalArithmetic + + "(pk, col1, col2, col3) VALUES(?,?,?,?)"; stmt = conn.prepareStatement(query); stmt.setString(1, "badValues"); stmt.setBigDecimal(2, new BigDecimal("123456")); @@ -132,14 +139,16 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(false); try { - String ddl = "CREATE TABLE source" + + String source = generateRandomString(); + String ddl = "CREATE TABLE " + source + " (pk VARCHAR NOT NULL PRIMARY KEY, col1 DECIMAL(5,2), col2 DECIMAL(5,1), col3 DECIMAL(5,2), col4 DECIMAL(4,4))"; createTestTable(getUrl(), ddl); - ddl = "CREATE TABLE target" + + String target = generateRandomString(); + ddl = "CREATE TABLE " + target + " (pk VARCHAR NOT NULL PRIMARY KEY, col1 DECIMAL(5,1), col2 DECIMAL(5,2), col3 DECIMAL(4,4))"; createTestTable(getUrl(), ddl); - String query = "UPSERT INTO source(pk, col1) VALUES(?,?)"; + String query = "UPSERT INTO " + source + "(pk, col1) VALUES(?,?)"; PreparedStatement stmt = conn.prepareStatement(query); stmt.setString(1, "1"); stmt.setBigDecimal(2, new BigDecimal("100.12")); @@ -152,11 +161,11 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { // Evaluated on client side. // source and target in different tables, values scheme compatible. - query = "UPSERT INTO target(pk, col2) SELECT pk, col1 from source"; + query = "UPSERT INTO " + target + "(pk, col2) SELECT pk, col1 from " + source; stmt = conn.prepareStatement(query); stmt.execute(); conn.commit(); - query = "SELECT col2 FROM target"; + query = "SELECT col2 FROM " + target; stmt = conn.prepareStatement(query); ResultSet rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -165,11 +174,11 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { assertEquals(new BigDecimal("100.34"), rs.getBigDecimal(1)); assertFalse(rs.next()); // source and target in different tables, values requires scale chopping. - query = "UPSERT INTO target(pk, col1) SELECT pk, col1 from source"; + query = "UPSERT INTO " + target + "(pk, col1) SELECT pk, col1 from " + source; stmt = conn.prepareStatement(query); stmt.execute(); conn.commit(); - query = "SELECT col1 FROM target"; + query = "SELECT col1 FROM " + target; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -179,7 +188,7 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { assertFalse(rs.next()); // source and target in different tables, values scheme incompatible. try { - query = "UPSERT INTO target(pk, col3) SELECT pk, col1 from source"; + query = "UPSERT INTO " + target + "(pk, col3) SELECT pk, col1 from " + source; stmt = conn.prepareStatement(query); stmt.execute(); conn.commit(); @@ -191,11 +200,11 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { // Evaluate on server side. conn.setAutoCommit(true); // source and target in same table, values scheme compatible. - query = "UPSERT INTO source(pk, col3) SELECT pk, col1 from source"; + query = "UPSERT INTO " + source + "(pk, col3) SELECT pk, col1 from " + source; stmt = conn.prepareStatement(query); stmt.execute(); conn.commit(); - query = "SELECT col3 FROM source"; + query = "SELECT col3 FROM " + source; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -204,11 +213,11 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { assertEquals(new BigDecimal("100.34"), rs.getBigDecimal(1)); assertFalse(rs.next()); // source and target in same table, values requires scale chopping. - query = "UPSERT INTO source(pk, col2) SELECT pk, col1 from source"; + query = "UPSERT INTO " + source + "(pk, col2) SELECT pk, col1 from " + source; stmt = conn.prepareStatement(query); stmt.execute(); conn.commit(); - query = "SELECT col2 FROM source"; + query = "SELECT col2 FROM " + source; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -217,11 +226,11 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { assertEquals(new BigDecimal("100.3"), rs.getBigDecimal(1)); assertFalse(rs.next()); // source and target in same table, values scheme incompatible. - query = "UPSERT INTO source(pk, col4) SELECT pk, col1 from source"; + query = "UPSERT INTO " + source + "(pk, col4) SELECT pk, col1 from " + source; stmt = conn.prepareStatement(query); stmt.execute(); conn.commit(); - query = "SELECT col4 FROM source"; + query = "SELECT col4 FROM " + source; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -240,11 +249,13 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(false); try { - String ddl = "CREATE TABLE testDecimalArithmetic" + + String testDecimalArithmetic = generateRandomString(); + String ddl = "CREATE TABLE " + testDecimalArithmetic + " (pk VARCHAR NOT NULL PRIMARY KEY, col1 DECIMAL(31, 11), col2 DECIMAL(31,1), col3 DECIMAL(38,1))"; createTestTable(getUrl(), ddl); - String query = "UPSERT INTO testDecimalArithmetic(pk, col1, col2, col3) VALUES(?,?,?,?)"; + String query = + "UPSERT INTO " + testDecimalArithmetic + "(pk, col1, col2, col3) VALUES(?,?,?,?)"; PreparedStatement stmt = conn.prepareStatement(query); stmt.setString(1, "1"); stmt.setBigDecimal(2, new BigDecimal("99999999999999999999.1")); @@ -268,14 +279,14 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { // Averaging // result scale should be: max(max(ls, rs), 4). // We are not imposing restriction on precisioin. - query = "SELECT avg(col1) FROM testDecimalArithmetic"; + query = "SELECT avg(col1) FROM " + testDecimalArithmetic; stmt = conn.prepareStatement(query); ResultSet rs = stmt.executeQuery(); assertTrue(rs.next()); BigDecimal result = rs.getBigDecimal(1); assertEquals(new BigDecimal("33333333333333333333.03333333333"), result); - query = "SELECT avg(col2) FROM testDecimalArithmetic"; + query = "SELECT avg(col2) FROM " + testDecimalArithmetic; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -283,7 +294,7 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { assertEquals(new BigDecimal("33333333333333333333.0333"), result); // We cap our decimal to a precision of 38. - query = "SELECT avg(col3) FROM testDecimalArithmetic"; + query = "SELECT avg(col3) FROM " + testDecimalArithmetic; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -300,14 +311,17 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(false); try { - String ddl = "CREATE TABLE testRandomFunction (pk VARCHAR NOT NULL PRIMARY KEY)"; + String testRandomFunction = generateRandomString(); + String ddl = + "CREATE TABLE " + testRandomFunction + " (pk VARCHAR NOT NULL PRIMARY KEY)"; createTestTable(getUrl(), ddl); - conn.createStatement().execute("upsert into testRandomFunction values ('x')"); - conn.createStatement().execute("upsert into testRandomFunction values ('y')"); - conn.createStatement().execute("upsert into testRandomFunction values ('z')"); + conn.createStatement().execute("upsert into " + testRandomFunction + " values ('x')"); + conn.createStatement().execute("upsert into " + testRandomFunction + " values ('y')"); + conn.createStatement().execute("upsert into " + testRandomFunction + " values ('z')"); conn.commit(); - ResultSet rs = conn.createStatement().executeQuery("select rand(), rand(), rand(1), rand(2), rand(1) from testRandomFunction"); + ResultSet rs = conn.createStatement().executeQuery( + "select rand(), rand(), rand(1), rand(2), rand(1) from " + testRandomFunction); assertTrue(rs.next()); double rand0 = rs.getDouble(1); double rand1 = rs.getDouble(3); @@ -337,7 +351,8 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { assertTrue(rs.getDouble(4) != rs.getDouble(5)); double rand12 = rs.getDouble(3); - rs = conn.createStatement().executeQuery("select rand(), rand(), rand(1), rand(2), rand(1) from testRandomFunction"); + rs = conn.createStatement().executeQuery( + "select rand(), rand(), rand(1), rand(2), rand(1) from " + testRandomFunction); assertTrue(rs.next()); assertTrue(rs.getDouble(1) != rs.getDouble(2)); assertTrue(rs.getDouble(2) != rs.getDouble(3)); @@ -353,40 +368,52 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { assertTrue(rs.next()); assertTrue(rand12 == rs.getDouble(3)); - ddl = "CREATE TABLE testRandomFunction1 (pk VARCHAR NOT NULL PRIMARY KEY, v1 UNSIGNED_DOUBLE)"; + String testRandomFunction1 = generateRandomString(); + ddl = "CREATE TABLE " + testRandomFunction1 + + " (pk VARCHAR NOT NULL PRIMARY KEY, v1 UNSIGNED_DOUBLE)"; createTestTable(getUrl(), ddl); - conn.createStatement().execute("upsert into testRandomFunction1 select pk, rand(1) from testRandomFunction"); + conn.createStatement().execute( + "upsert into " + testRandomFunction1 + " select pk, rand(1) from " + testRandomFunction); conn.commit(); - rs = conn.createStatement().executeQuery("select count(*) from testRandomFunction1 where v1 = rand(1)"); + rs = conn.createStatement().executeQuery( + "select count(*) from " + testRandomFunction1 + " where v1 = rand(1)"); assertTrue(rs.next()); assertEquals(3, rs.getInt(1)); - rs = conn.createStatement().executeQuery("select count(*) from testRandomFunction1 where v1 = rand(2)"); + rs = conn.createStatement().executeQuery( + "select count(*) from " + testRandomFunction1 + " where v1 = rand(2)"); assertTrue(rs.next()); assertEquals(0, rs.getInt(1)); - conn.createStatement().execute("delete from testRandomFunction1 where v1 = rand(2)"); + conn.createStatement().execute( + "delete from " + testRandomFunction1 + " where v1 = rand(2)"); conn.commit(); - rs = conn.createStatement().executeQuery("select count(*) from testRandomFunction1 where v1 = rand(1)"); + rs = conn.createStatement().executeQuery( + "select count(*) from " + testRandomFunction1 + " where v1 = rand(1)"); assertTrue(rs.next()); assertEquals(3, rs.getInt(1)); conn.setAutoCommit(true); - conn.createStatement().execute("upsert into testRandomFunction1 select pk, rand(2) from testRandomFunction1"); + conn.createStatement().execute("upsert into " + testRandomFunction1 + + " select pk, rand(2) from " + testRandomFunction1); - rs = conn.createStatement().executeQuery("select count(*) from testRandomFunction1 where v1 = rand(1)"); + rs = conn.createStatement().executeQuery( + "select count(*) from " + testRandomFunction1 + " where v1 = rand(1)"); assertTrue(rs.next()); assertEquals(0, rs.getInt(1)); - rs = conn.createStatement().executeQuery("select count(*) from testRandomFunction1 where v1 = rand(2)"); + rs = conn.createStatement().executeQuery( + "select count(*) from " + testRandomFunction1 + " where v1 = rand(2)"); assertTrue(rs.next()); assertEquals(3, rs.getInt(1)); - conn.createStatement().execute("delete from testRandomFunction1 where v1 = rand(2)"); + conn.createStatement().execute( + "delete from " + testRandomFunction1 + " where v1 = rand(2)"); - rs = conn.createStatement().executeQuery("select count(*) from testRandomFunction1 where v1 = rand(2)"); + rs = conn.createStatement().executeQuery( + "select count(*) from " + testRandomFunction1 + " where v1 = rand(2)"); assertTrue(rs.next()); assertEquals(0, rs.getInt(1)); } finally { @@ -400,12 +427,14 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(false); try { - String ddl = "CREATE TABLE testDecimalArithmetic" + + String testDecimalArithmetic = generateRandomString(); + String ddl = "CREATE TABLE " + testDecimalArithmetic + " (pk VARCHAR NOT NULL PRIMARY KEY, " + "col1 DECIMAL(38,0), col2 DECIMAL(5, 2), col3 INTEGER, col4 BIGINT, col5 DECIMAL)"; createTestTable(getUrl(), ddl); - String query = "UPSERT INTO testDecimalArithmetic(pk, col1, col2, col3, col4, col5) VALUES(?,?,?,?,?,?)"; + String query = "UPSERT INTO " + testDecimalArithmetic + + "(pk, col1, col2, col3, col4, col5) VALUES(?,?,?,?,?,?)"; PreparedStatement stmt = conn.prepareStatement(query); stmt.setString(1, "testValueOne"); stmt.setBigDecimal(2, new BigDecimal("1234567890123456789012345678901")); @@ -427,105 +456,105 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { // INT has a default precision and scale of (10, 0) // LONG has a default precision and scale of (19, 0) - query = "SELECT col1 + col3 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col1 + col3 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); ResultSet rs = stmt.executeQuery(); assertTrue(rs.next()); BigDecimal result = rs.getBigDecimal(1); assertEquals(new BigDecimal("1234567890123456789012345678911"), result); - query = "SELECT col1 + col4 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col1 + col4 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("1234567890123456789012345678911"), result); - query = "SELECT col2 + col3 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col2 + col3 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("133.45"), result); - query = "SELECT col2 + col4 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col2 + col4 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("133.45"), result); - query = "SELECT col5 + col3 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col5 + col3 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("121.111"), result); - query = "SELECT col5 + col4 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col5 + col4 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("121.111"), result); - query = "SELECT col1 - col3 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col1 - col3 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("1234567890123456789012345678891"), result); - query = "SELECT col1 - col4 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col1 - col4 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("1234567890123456789012345678891"), result); - query = "SELECT col2 - col3 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col2 - col3 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("113.45"), result); - query = "SELECT col2 - col4 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col2 - col4 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("113.45"), result); - query = "SELECT col5 - col3 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col5 - col3 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("101.111"), result); - query = "SELECT col5 - col4 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col5 - col4 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("101.111"), result); - query = "SELECT col1 * col3 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col1 * col3 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("1.234567890123456789012345678901E+31"), result); - query = "SELECT col1 * col4 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col1 * col4 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("1.234567890123456789012345678901E+31"), result); - query = "SELECT col1 * col3 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col1 * col3 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -533,7 +562,8 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { assertEquals(new BigDecimal("1.234567890123456789012345678901E+31"), result); try { - query = "SELECT col1 * col3 FROM testDecimalArithmetic WHERE pk='testValueTwo'"; + query = + "SELECT col1 * col3 FROM " + testDecimalArithmetic + " WHERE pk='testValueTwo'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -544,7 +574,8 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { } try { - query = "SELECT col1 * col4 FROM testDecimalArithmetic WHERE pk='testValueTwo'"; + query = + "SELECT col1 * col4 FROM " + testDecimalArithmetic + " WHERE pk='testValueTwo'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -554,21 +585,21 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { assertEquals(SQLExceptionCode.DATA_EXCEEDS_MAX_CAPACITY.getErrorCode(),e.getErrorCode()); } - query = "SELECT col4 * col5 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col4 * col5 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(0, result.compareTo(new BigDecimal("1111.11"))); - query = "SELECT col3 * col5 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col3 * col5 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(0, result.compareTo(new BigDecimal("1111.11"))); - query = "SELECT col2 * col4 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col2 * col4 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -576,14 +607,14 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { assertEquals(new BigDecimal("1234.5"), result); // Result scale has value of 0 - query = "SELECT col1 / col3 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col1 / col3 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("1.2345678901234567890123456789E+29"), result); - query = "SELECT col1 / col4 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col1 / col4 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -591,14 +622,14 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { assertEquals(new BigDecimal("1.2345678901234567890123456789E+29"), result); // Result scale is 2. - query = "SELECT col2 / col3 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col2 / col3 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("12.34"), result); - query = "SELECT col2 / col4 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col2 / col4 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -606,14 +637,14 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { assertEquals(new BigDecimal("12.34"), result); // col5 has NO_SCALE, so the result's scale is not expected to be truncated to col5 value's scale of 4 - query = "SELECT col5 / col3 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col5 / col3 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); result = rs.getBigDecimal(1); assertEquals(new BigDecimal("11.1111"), result); - query = "SELECT col5 / col4 FROM testDecimalArithmetic WHERE pk='testValueOne'"; + query = "SELECT col5 / col4 FROM " + testDecimalArithmetic + " WHERE pk='testValueOne'"; stmt = conn.prepareStatement(query); rs = stmt.executeQuery(); assertTrue(rs.next()); @@ -691,24 +722,27 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { } } - private void initIntegerTable(Connection conn) throws SQLException { - String ddl = "CREATE TABLE ARITHMETIC_TEST (six INTEGER PRIMARY KEY, four INTEGER, three INTEGER)"; + private String initIntegerTable(Connection conn) throws SQLException { + String arithmetic_test = generateRandomString(); + String ddl = "CREATE TABLE " + arithmetic_test + + " (six INTEGER PRIMARY KEY, four INTEGER, three INTEGER)"; conn.createStatement().execute(ddl); - String dml = "UPSERT INTO ARITHMETIC_TEST VALUES(6, 4, 3)"; + String dml = "UPSERT INTO " + arithmetic_test + " VALUES(6, 4, 3)"; conn.createStatement().execute(dml); - conn.commit(); + conn.commit(); + return arithmetic_test; } @Test public void testOrderOfOperationsAdditionSubtraction() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initIntegerTable(conn); + String tableName = initIntegerTable(conn); ResultSet rs; // 6 + 4 - 3 // 10 - 3 // 7 - rs = conn.createStatement().executeQuery("SELECT six + four - three FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT six + four - three FROM " + tableName); assertTrue(rs.next()); assertEquals(7, rs.getLong(1)); assertFalse(rs.next()); @@ -716,7 +750,7 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { // 4 - 3 + 6 // 1 + 6 // 7 - rs = conn.createStatement().executeQuery("SELECT four - three + six FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT four - three + six FROM " + tableName); assertTrue(rs.next()); assertEquals(7, rs.getLong(1)); assertFalse(rs.next()); @@ -725,13 +759,13 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { @Test public void testOrderOfOperationsAdditionMultiplication() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initIntegerTable(conn); + String tableName = initIntegerTable(conn); ResultSet rs; // 6 + 4 * 3 // 6 + 12 // 18 - rs = conn.createStatement().executeQuery("SELECT six + four * three FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT six + four * three FROM " + tableName); assertTrue(rs.next()); assertEquals(18, rs.getLong(1)); assertFalse(rs.next()); @@ -739,7 +773,7 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { // 4 * 3 + 6 // 12 * 6 // 18 - rs = conn.createStatement().executeQuery("SELECT four * three + six FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT four * three + six FROM " + tableName); assertTrue(rs.next()); assertEquals(18, rs.getLong(1)); assertFalse(rs.next()); @@ -748,13 +782,13 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { @Test public void testOrderOfOperationsAdditionDivision() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initIntegerTable(conn); + String tableName = initIntegerTable(conn); ResultSet rs; // 6 + 4 / 3 // 6 + 1 // 7 - rs = conn.createStatement().executeQuery("SELECT six + four / three FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT six + four / three FROM " + tableName); assertTrue(rs.next()); assertEquals(7, rs.getLong(1)); assertFalse(rs.next()); @@ -762,7 +796,7 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { // 4 / 3 + 6 // 1 + 6 // 7 - rs = conn.createStatement().executeQuery("SELECT four / three + six FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT four / three + six FROM " + tableName); assertTrue(rs.next()); assertEquals(7, rs.getLong(1)); assertFalse(rs.next()); @@ -771,13 +805,13 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { @Test public void testOrderOfOperationsAdditionModulus() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initIntegerTable(conn); + String tableName = initIntegerTable(conn); ResultSet rs; // 6 + 4 % 3 // 6 + 1 // 7 - rs = conn.createStatement().executeQuery("SELECT six + four % three FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT six + four % three FROM " + tableName); assertTrue(rs.next()); assertEquals(7, rs.getLong(1)); assertFalse(rs.next()); @@ -785,7 +819,7 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { // 4 % 3 + 6 // 1 + 6 // 7 - rs = conn.createStatement().executeQuery("SELECT four % three + six FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT four % three + six FROM " + tableName); assertTrue(rs.next()); assertEquals(7, rs.getLong(1)); assertFalse(rs.next()); @@ -794,13 +828,13 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { @Test public void testOrderOfOperationsSubtrationMultiplication() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initIntegerTable(conn); + String tableName = initIntegerTable(conn); ResultSet rs; // 6 - 4 * 3 // 6 - 12 // -6 - rs = conn.createStatement().executeQuery("SELECT six - four * three FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT six - four * three FROM " + tableName); assertTrue(rs.next()); assertEquals(-6, rs.getLong(1)); assertFalse(rs.next()); @@ -808,7 +842,7 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { // 4 * 3 - 6 // 12 - 6 // 6 - rs = conn.createStatement().executeQuery("SELECT four * three - six FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT four * three - six FROM " + tableName); assertTrue(rs.next()); assertEquals(6, rs.getLong(1)); assertFalse(rs.next()); @@ -817,13 +851,13 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { @Test public void testOrderOfOperationsSubtractionDivision() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initIntegerTable(conn); + String tableName = initIntegerTable(conn); ResultSet rs; // 6 - 4 / 3 // 6 - 1 (integer division) // 5 - rs = conn.createStatement().executeQuery("SELECT six - four / three FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT six - four / three FROM " + tableName); assertTrue(rs.next()); assertEquals(5, rs.getLong(1)); assertFalse(rs.next()); @@ -831,7 +865,7 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { // 4 / 3 - 6 // 1 - 6 (integer division) // -5 - rs = conn.createStatement().executeQuery("SELECT four / three - six FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT four / three - six FROM " + tableName); assertTrue(rs.next()); assertEquals(-5, rs.getLong(1)); assertFalse(rs.next()); @@ -840,13 +874,13 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { @Test public void testOrderOfOperationsSubtractionModulus() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initIntegerTable(conn); + String tableName = initIntegerTable(conn); ResultSet rs; // 6 - 4 % 3 // 6 - 1 // 5 - rs = conn.createStatement().executeQuery("SELECT six - four % three FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT six - four % three FROM " + tableName); assertTrue(rs.next()); assertEquals(5, rs.getLong(1)); assertFalse(rs.next()); @@ -854,7 +888,7 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { // 4 % 3 - 6 // 1 - 6 // -5 - rs = conn.createStatement().executeQuery("SELECT four % three - six FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT four % three - six FROM " + tableName); assertTrue(rs.next()); assertEquals(-5, rs.getLong(1)); assertFalse(rs.next()); @@ -863,13 +897,13 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { @Test public void testOrderOfOperationsMultiplicationDivision() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initIntegerTable(conn); + String tableName = initIntegerTable(conn); ResultSet rs; // 6 * 4 / 3 // 24 / 3 // 8 - rs = conn.createStatement().executeQuery("SELECT six * four / three FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT six * four / three FROM " + tableName); assertTrue(rs.next()); assertEquals(8, rs.getLong(1)); assertFalse(rs.next()); @@ -877,7 +911,7 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { // 4 / 3 * 6 // 1 * 6 (integer division) // 6 - rs = conn.createStatement().executeQuery("SELECT four / three * six FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT four / three * six FROM " + tableName); assertTrue(rs.next()); assertEquals(6, rs.getLong(1)); assertFalse(rs.next()); @@ -886,13 +920,13 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { @Test public void testOrderOfOperationsMultiplicationModulus() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initIntegerTable(conn); + String tableName = initIntegerTable(conn); ResultSet rs; // 6 * 4 % 3 // 24 % 3 // 0 - rs = conn.createStatement().executeQuery("SELECT six * four % three FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT six * four % three FROM " + tableName); assertTrue(rs.next()); assertEquals(0, rs.getLong(1)); assertFalse(rs.next()); @@ -900,7 +934,7 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { // 4 % 3 * 6 // 1 * 6 // 6 - rs = conn.createStatement().executeQuery("SELECT four % three * six FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT four % three * six FROM " + tableName); assertTrue(rs.next()); assertEquals(6, rs.getLong(1)); assertFalse(rs.next()); @@ -909,13 +943,13 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { @Test public void testOrderOfOperationsDivisionModulus() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initIntegerTable(conn); + String tableName = initIntegerTable(conn); ResultSet rs; // 6 / 4 % 3 // 1 % 3 (integer division) // 1 - rs = conn.createStatement().executeQuery("SELECT six / four % three FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT six / four % three FROM " + tableName); assertTrue(rs.next()); assertEquals(1, rs.getLong(1)); assertFalse(rs.next()); @@ -923,7 +957,7 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { // 4 % 3 / 6 // 1 / 6 // 0 (integer division) - rs = conn.createStatement().executeQuery("SELECT four % three / six FROM ARITHMETIC_TEST"); + rs = conn.createStatement().executeQuery("SELECT four % three / six FROM " + tableName); assertTrue(rs.next()); assertEquals(0, rs.getLong(1)); assertFalse(rs.next()); @@ -932,13 +966,16 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { @Test public void testCastingOnConstantAddInArithmeticEvaluation() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - String ddl = "CREATE TABLE IF NOT EXISTS test_table (k1 INTEGER NOT NULL, v1 INTEGER CONSTRAINT pk PRIMARY KEY (k1))"; + String testTable = generateRandomString(); + String ddl = "CREATE TABLE IF NOT EXISTS " + testTable + + " (k1 INTEGER NOT NULL, v1 INTEGER CONSTRAINT pk PRIMARY KEY (k1))"; conn.createStatement().execute(ddl); - String dml = "UPSERT INTO test_table (k1, v1) VALUES (2, 2)"; + String dml = "UPSERT INTO " + testTable + " (k1, v1) VALUES (2, 2)"; conn.createStatement().execute(dml); conn.commit(); - ResultSet rs = conn.createStatement().executeQuery("SELECT k1 / (v1 + 0.5) FROM test_table"); + ResultSet rs = conn.createStatement().executeQuery( + "SELECT k1 / (v1 + 0.5) FROM " + testTable); assertTrue(rs.next()); double d = rs.getDouble(1); assertEquals(0.8, d, 0.01); @@ -947,13 +984,16 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { @Test public void testCastingOnConstantSubInArithmeticEvaluation() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - String ddl = "CREATE TABLE IF NOT EXISTS test_table (k1 INTEGER NOT NULL, v1 INTEGER CONSTRAINT pk PRIMARY KEY (k1))"; + String testTable = generateRandomString(); + String ddl = "CREATE TABLE IF NOT EXISTS " + testTable + + " (k1 INTEGER NOT NULL, v1 INTEGER CONSTRAINT pk PRIMARY KEY (k1))"; conn.createStatement().execute(ddl); - String dml = "UPSERT INTO test_table (k1, v1) VALUES (2, 2)"; + String dml = "UPSERT INTO " + testTable + " (k1, v1) VALUES (2, 2)"; conn.createStatement().execute(dml); conn.commit(); - ResultSet rs = conn.createStatement().executeQuery("SELECT k1 / (v1 - 0.5) FROM test_table"); + ResultSet rs = conn.createStatement().executeQuery( + "SELECT k1 / (v1 - 0.5) FROM " + testTable); assertTrue(rs.next()); assertEquals(1.333333333, rs.getDouble(1), 0.001); } @@ -961,13 +1001,15 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { @Test public void testFloatingPointUpsert() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - String ddl = "CREATE TABLE test (id VARCHAR not null primary key, name VARCHAR, lat FLOAT)"; + String test = generateRandomString(); + String ddl = + "CREATE TABLE " + test + " (id VARCHAR not null primary key, name VARCHAR, lat FLOAT)"; conn.createStatement().execute(ddl); - String dml = "UPSERT INTO test(id,name,lat) VALUES ('testid', 'testname', -1.00)"; + String dml = "UPSERT INTO " + test + "(id,name,lat) VALUES ('testid', 'testname', -1.00)"; conn.createStatement().execute(dml); conn.commit(); - ResultSet rs = conn.createStatement().executeQuery("SELECT lat FROM test"); + ResultSet rs = conn.createStatement().executeQuery("SELECT lat FROM " + test); assertTrue(rs.next()); assertEquals(-1.0f, rs.getFloat(1), 0.001); } @@ -975,13 +1017,16 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { @Test public void testFloatingPointMultiplicationUpsert() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - String ddl = "CREATE TABLE test (id VARCHAR not null primary key, name VARCHAR, lat FLOAT)"; + String test = generateRandomString(); + String ddl = + "CREATE TABLE " + test + " (id VARCHAR not null primary key, name VARCHAR, lat FLOAT)"; conn.createStatement().execute(ddl); - String dml = "UPSERT INTO test(id,name,lat) VALUES ('testid', 'testname', -1.00 * 1)"; + String dml = + "UPSERT INTO " + test + "(id,name,lat) VALUES ('testid', 'testname', -1.00 * 1)"; conn.createStatement().execute(dml); conn.commit(); - ResultSet rs = conn.createStatement().executeQuery("SELECT lat FROM test"); + ResultSet rs = conn.createStatement().executeQuery("SELECT lat FROM " + test); assertTrue(rs.next()); assertEquals(-1.0f, rs.getFloat(1), 0.001); } @@ -989,9 +1034,10 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { @Test public void testSystemTableHasDoubleForExponentialNumber() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - String ddl = "CREATE TABLE test (id VARCHAR not null primary key, num FLOAT)"; + String test = generateRandomString(); + String ddl = "CREATE TABLE " + test + " (id VARCHAR not null primary key, num FLOAT)"; conn.createStatement().execute(ddl); - String dml = "UPSERT INTO test(id,num) VALUES ('testid', 1.2E3)"; + String dml = "UPSERT INTO " + test + "(id,num) VALUES ('testid', 1.2E3)"; conn.createStatement().execute(dml); conn.commit(); @@ -1022,8 +1068,10 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { private ResultSet createTableWithValues(String[] values, String valueType) throws SQLException { Connection conn = DriverManager.getConnection(getUrl()); - StringBuilder ddl = new StringBuilder("CREATE TABLE test (id VARCHAR not null primary key"); - StringBuilder dmll = new StringBuilder("UPSERT INTO test(id,"); + String test = generateRandomString(); + StringBuilder ddl = new StringBuilder( + "CREATE TABLE " + test + " (id VARCHAR not null primary key"); + StringBuilder dmll = new StringBuilder("UPSERT INTO " + test + "(id,"); StringBuilder dmlr = new StringBuilder(") VALUES ('testid'"); StringBuilder select = new StringBuilder("SELECT"); for(int i = 0; i < values.length; i++) { @@ -1036,7 +1084,7 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { dmlr.append(")"); dmll.deleteCharAt(dmll.length()-1); select.deleteCharAt(select.length()-1); - select.append(" FROM test"); + select.append(" FROM " + test); conn.createStatement().execute(ddl.toString()); conn.createStatement().execute(dmll.toString() + dmlr.toString()); conn.commit(); @@ -1045,4 +1093,4 @@ public class ArithmeticQueryIT extends BaseHBaseManagedTimeIT { rs.next(); return rs; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/ecc5ff2d/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java index f9ce88d..dd9a64a 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java @@ -25,14 +25,22 @@ import static org.junit.Assert.assertTrue; import java.math.BigDecimal; import java.sql.*; +import org.junit.BeforeClass; import org.junit.Test; -public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { +public class ArrayFillFunctionIT extends BaseHBaseManagedTimeTableReuseIT { - private void initTables(Connection conn) throws Exception { - String ddl = "CREATE TABLE regions (region_name VARCHAR PRIMARY KEY,length1 INTEGER, length2 INTEGER,date DATE,time TIME,timestamp TIMESTAMP,varchar VARCHAR,integer INTEGER,double DOUBLE,bigint BIGINT,char CHAR(15),double1 DOUBLE,char1 CHAR(17),nullcheck INTEGER,chars2 CHAR(15)[], varchars2 VARCHAR[])"; + private static final String REGIONS = generateRandomString(); + + @BeforeClass + public static void initTables() throws Exception { + Connection conn = DriverManager.getConnection(getUrl()); + String ddl = "CREATE TABLE " + REGIONS + + " (region_name VARCHAR PRIMARY KEY,length1 INTEGER, length2 INTEGER,date DATE,time TIME,timestamp TIMESTAMP,varchar VARCHAR,integer INTEGER,double DOUBLE,bigint BIGINT,char CHAR(15),double1 DOUBLE,char1 CHAR(17),nullcheck INTEGER,chars2 CHAR(15)[], varchars2 VARCHAR[])"; conn.createStatement().execute(ddl); - String dml = "UPSERT INTO regions(region_name,length1,length2,date,time,timestamp,varchar,integer,double,bigint,char,double1,char1,nullcheck,chars2,varchars2) VALUES('SF Bay Area'," + + String dml = "UPSERT INTO " + REGIONS + + "(region_name,length1,length2,date,time,timestamp,varchar,integer,double,bigint,char,double1,char1,nullcheck,chars2,varchars2) VALUES('SF Bay Area'," + + "0," + "-3," + "to_date('2015-05-20 06:12:14.184')," + @@ -57,10 +65,10 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionVarchar() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT ARRAY_FILL(varchar,5) FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT ARRAY_FILL(varchar,5) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); String[] strings = new String[]{"foo", "foo", "foo", "foo", "foo"}; @@ -74,10 +82,10 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionInteger() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT ARRAY_FILL(integer,4) FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT ARRAY_FILL(integer,4) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{34, 34, 34, 34}; @@ -91,10 +99,11 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionDouble() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT ARRAY_FILL(double,4) FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT ARRAY_FILL(double,4) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{23.45, 23.45, 23.45, 23.45}; @@ -108,10 +117,11 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionBigint() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT ARRAY_FILL(bigint,4) FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT ARRAY_FILL(bigint,4) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{34567l, 34567l, 34567l, 34567l}; @@ -125,10 +135,11 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionChar() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT ARRAY_FILL(char,4) FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT ARRAY_FILL(char,4) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{"foo", "foo", "foo", "foo"}; @@ -141,10 +152,11 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionVarChar() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT ARRAY_FILL(varchar,4) FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT ARRAY_FILL(varchar,4) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{"foo", "foo", "foo", "foo"}; @@ -157,10 +169,11 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionDate() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT ARRAY_FILL(date,3) FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT ARRAY_FILL(date,3) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{new Date(1432102334184l), new Date(1432102334184l), new Date(1432102334184l)}; @@ -173,10 +186,11 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionTime() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT ARRAY_FILL(time,3) FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT ARRAY_FILL(time,3) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{new Time(1432102334184l), new Time(1432102334184l), new Time(1432102334184l)}; @@ -189,10 +203,11 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionTimestamp() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT ARRAY_FILL(timestamp,3) FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT ARRAY_FILL(timestamp,3) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{new Timestamp(1432102334184l), new Timestamp(1432102334184l), new Timestamp(1432102334184l)}; @@ -205,10 +220,12 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test(expected = IllegalArgumentException.class) public void testArrayFillFunctionInvalidLength1() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT ARRAY_FILL(timestamp,length2) FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT ARRAY_FILL(timestamp,length2) FROM " + REGIONS + + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{new Timestamp(1432102334184l), new Timestamp(1432102334184l), new Timestamp(1432102334184l)}; @@ -221,10 +238,12 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test(expected = IllegalArgumentException.class) public void testArrayFillFunctionInvalidLength2() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT ARRAY_FILL(timestamp,length1) FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT ARRAY_FILL(timestamp,length1) FROM " + REGIONS + + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{new Timestamp(1432102334184l), new Timestamp(1432102334184l), new Timestamp(1432102334184l)}; @@ -237,10 +256,12 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionWithNestedFunctions1() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT ARRAY_FILL(ARRAY_ELEM(ARRAY[23,45],1),3) FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT ARRAY_FILL(ARRAY_ELEM(ARRAY[23,45],1),3) FROM " + REGIONS + + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Integer[] integers = new Integer[]{23, 23, 23}; @@ -254,10 +275,12 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionWithNestedFunctions2() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT ARRAY_FILL('hello', ARRAY_LENGTH(ARRAY[34, 45])) FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT ARRAY_FILL('hello', ARRAY_LENGTH(ARRAY[34, 45])) FROM " + REGIONS + + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{"hello", "hello"}; @@ -271,10 +294,12 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionWithNestedFunctions3() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT ARRAY_FILL(3.4, ARRAY_LENGTH(ARRAY[34, 45])) FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT ARRAY_FILL(3.4, ARRAY_LENGTH(ARRAY[34, 45])) FROM " + REGIONS + + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{BigDecimal.valueOf(3.4), BigDecimal.valueOf(3.4)}; @@ -289,15 +314,19 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { public void testArrayFillFunctionWithUpsert1() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - String ddl = "CREATE TABLE regions (region_name VARCHAR PRIMARY KEY,varchars VARCHAR[])"; + String regions = generateRandomString(); + String ddl = + "CREATE TABLE " + regions + " (region_name VARCHAR PRIMARY KEY,varchars VARCHAR[])"; conn.createStatement().execute(ddl); - String dml = "UPSERT INTO regions(region_name,varchars) VALUES('SF Bay Area',ARRAY_FILL('hello',3))"; + String dml = "UPSERT INTO " + regions + + "(region_name,varchars) VALUES('SF Bay Area',ARRAY_FILL('hello',3))"; conn.createStatement().execute(dml); conn.commit(); ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT varchars FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT varchars FROM " + regions + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); String[] strings = new String[]{"hello", "hello", "hello"}; @@ -312,15 +341,19 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { public void testArrayFillFunctionWithUpsert2() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - String ddl = "CREATE TABLE regions (region_name VARCHAR PRIMARY KEY,integers INTEGER[])"; + String regions = generateRandomString(); + String ddl = + "CREATE TABLE " + regions + " (region_name VARCHAR PRIMARY KEY,integers INTEGER[])"; conn.createStatement().execute(ddl); - String dml = "UPSERT INTO regions(region_name,integers) VALUES('SF Bay Area',ARRAY_FILL(3456,3))"; + String dml = "UPSERT INTO " + regions + + "(region_name,integers) VALUES('SF Bay Area',ARRAY_FILL(3456,3))"; conn.createStatement().execute(dml); conn.commit(); ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT integers FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT integers FROM " + regions + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Integer[] integers = new Integer[]{3456, 3456, 3456}; @@ -335,15 +368,19 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { public void testArrayFillFunctionWithUpsert3() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - String ddl = "CREATE TABLE regions (region_name VARCHAR PRIMARY KEY,doubles DOUBLE[])"; + String regions = generateRandomString(); + String ddl = + "CREATE TABLE " + regions + " (region_name VARCHAR PRIMARY KEY,doubles DOUBLE[])"; conn.createStatement().execute(ddl); - String dml = "UPSERT INTO regions(region_name,doubles) VALUES('SF Bay Area',ARRAY_FILL(2.5,3))"; + String dml = "UPSERT INTO " + regions + + "(region_name,doubles) VALUES('SF Bay Area',ARRAY_FILL(2.5,3))"; conn.createStatement().execute(dml); conn.commit(); ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT doubles FROM regions WHERE region_name = 'SF Bay Area'"); + rs = conn.createStatement().executeQuery( + "SELECT doubles FROM " + regions + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Double[] doubles = new Double[]{2.5, 2.5, 2.5}; @@ -400,25 +437,34 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { public void testArrayFillFunctionWithUpsertSelect2() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - String ddl = "CREATE TABLE source (region_name VARCHAR PRIMARY KEY,varchars VARCHAR[])"; + String source = generateRandomString(); + String ddl = + "CREATE TABLE " + source + " (region_name VARCHAR PRIMARY KEY,varchars VARCHAR[])"; conn.createStatement().execute(ddl); - ddl = "CREATE TABLE target (region_name VARCHAR PRIMARY KEY,varchars VARCHAR[],varchars2 VARCHAR[])"; + String target = generateRandomString(); + ddl = "CREATE TABLE " + target + + " (region_name VARCHAR PRIMARY KEY,varchars VARCHAR[],varchars2 VARCHAR[])"; conn.createStatement().execute(ddl); - String dml = "UPSERT INTO source(region_name,varchars) VALUES('SF Bay Area',ARRAY_FILL('foo',3))"; + String dml = "UPSERT INTO " + source + + "(region_name,varchars) VALUES('SF Bay Area',ARRAY_FILL('foo',3))"; conn.createStatement().execute(dml); - dml = "UPSERT INTO source(region_name,varchars) VALUES('SF Bay Area2',ARRAY_FILL('hello',3))"; + dml = "UPSERT INTO " + source + + "(region_name,varchars) VALUES('SF Bay Area2',ARRAY_FILL('hello',3))"; conn.createStatement().execute(dml); conn.commit(); - dml = "UPSERT INTO target(region_name, varchars, varchars2) SELECT region_name, varchars,ARRAY_FILL(':-)',5) FROM source"; + dml = + "UPSERT INTO " + target + + "(region_name, varchars, varchars2) SELECT region_name, varchars,ARRAY_FILL(':-)',5) FROM " + + source; conn.createStatement().execute(dml); conn.commit(); ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT varchars, varchars2 FROM target"); + rs = conn.createStatement().executeQuery("SELECT varchars, varchars2 FROM " + target); assertTrue(rs.next()); String[] strings = new String[]{"foo", "foo", "foo"}; @@ -441,10 +487,11 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionInWhere1() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT region_name FROM regions WHERE ARRAY[12, 12, 12, 12]=ARRAY_FILL(12,4)"); + rs = conn.createStatement().executeQuery( + "SELECT region_name FROM " + REGIONS + " WHERE ARRAY[12, 12, 12, 12]=ARRAY_FILL(12,4)"); assertTrue(rs.next()); assertEquals("SF Bay Area", rs.getString(1)); @@ -454,10 +501,11 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionInWhere2() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT region_name FROM regions WHERE varchar=ANY(ARRAY_FILL('foo',3))"); + rs = conn.createStatement().executeQuery( + "SELECT region_name FROM " + REGIONS + " WHERE varchar=ANY(ARRAY_FILL('foo',3))"); assertTrue(rs.next()); assertEquals("SF Bay Area", rs.getString(1)); @@ -467,10 +515,11 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionInWhere3() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT region_name FROM regions WHERE ARRAY['2345', '2345', '2345', '2345']=ARRAY_FILL('2345', 4)"); + rs = conn.createStatement().executeQuery("SELECT region_name FROM " + REGIONS + + " WHERE ARRAY['2345', '2345', '2345', '2345']=ARRAY_FILL('2345', 4)"); assertTrue(rs.next()); assertEquals("SF Bay Area", rs.getString(1)); @@ -480,10 +529,11 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionInWhere4() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT region_name FROM regions WHERE ARRAY[23.45, 23.45, 23.45]=ARRAY_FILL(23.45, 3)"); + rs = conn.createStatement().executeQuery("SELECT region_name FROM " + REGIONS + + " WHERE ARRAY[23.45, 23.45, 23.45]=ARRAY_FILL(23.45, 3)"); assertTrue(rs.next()); assertEquals("SF Bay Area", rs.getString(1)); @@ -493,10 +543,11 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionInWhere5() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT region_name FROM regions WHERE ARRAY['foo','foo','foo','foo','foo']=ARRAY_FILL(varchar,5)"); + rs = conn.createStatement().executeQuery("SELECT region_name FROM " + REGIONS + + " WHERE ARRAY['foo','foo','foo','foo','foo']=ARRAY_FILL(varchar,5)"); assertTrue(rs.next()); assertEquals("SF Bay Area", rs.getString(1)); @@ -506,10 +557,11 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionInWhere6() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT region_name FROM regions WHERE varchars2=ARRAY_FILL('hello',3)"); + rs = conn.createStatement().executeQuery( + "SELECT region_name FROM " + REGIONS + " WHERE varchars2=ARRAY_FILL('hello',3)"); assertTrue(rs.next()); assertEquals("SF Bay Area", rs.getString(1)); @@ -519,10 +571,11 @@ public class ArrayFillFunctionIT extends BaseHBaseManagedTimeIT { @Test public void testArrayFillFunctionInWhere7() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); - initTables(conn); + ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT region_name FROM regions WHERE ARRAY[2,2,2,2]=ARRAY_FILL(2,4)"); + rs = conn.createStatement().executeQuery( + "SELECT region_name FROM " + REGIONS + " WHERE ARRAY[2,2,2,2]=ARRAY_FILL(2,4)"); assertTrue(rs.next()); assertEquals("SF Bay Area", rs.getString(1));
