Repository: phoenix Updated Branches: refs/heads/master 6c3bcb6a9 -> b2153ef52
PHOENIX-4213 Modify ExtendedQueryExecIT and FunkyNamesIT to not use currentSCN Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/b2153ef5 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/b2153ef5 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/b2153ef5 Branch: refs/heads/master Commit: b2153ef52a8de60501fad964062b7f7f9b86654a Parents: 6c3bcb6 Author: Mujtaba <mujt...@apache.org> Authored: Fri Sep 15 10:38:53 2017 -0700 Committer: Mujtaba <mujt...@apache.org> Committed: Fri Sep 15 10:38:53 2017 -0700 ---------------------------------------------------------------------- .../phoenix/end2end/ExtendedQueryExecIT.java | 30 +++++-------- .../apache/phoenix/end2end/FunkyNamesIT.java | 47 +++++++++----------- 2 files changed, 30 insertions(+), 47 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/b2153ef5/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExtendedQueryExecIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExtendedQueryExecIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExtendedQueryExecIT.java index f46b3e4..f894725 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExtendedQueryExecIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExtendedQueryExecIT.java @@ -22,7 +22,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.apache.phoenix.util.TestUtil.ATABLE_NAME; import java.sql.Connection; import java.sql.Date; @@ -32,33 +31,28 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Properties; -import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; - - /** * * Extended tests for Phoenix JDBC implementation * */ -public class ExtendedQueryExecIT extends BaseClientManagedTimeIT { +public class ExtendedQueryExecIT extends ParallelStatsDisabledIT { @Test public void testToDateFunctionBind() throws Exception { - long ts = nextTimestamp(); Date date = new Date(1); String tenantId = getOrganizationId(); - initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId),date, ts, getUrl(), null); + String tableName = initATableValues(null, tenantId, getDefaultSplits(tenantId),date, null, getUrl(), null); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+1)); Connection conn = DriverManager.getConnection(getUrl(), props); try { - String query = "SELECT a_date FROM atable WHERE organization_id='" + tenantId + "' and a_date < TO_DATE(?)"; + String query = "SELECT a_date FROM " + tableName + " WHERE organization_id='" + tenantId + "' and a_date < TO_DATE(?)"; PreparedStatement statement = conn.prepareStatement(query); statement.setString(1, "1970-1-1 12:00:00"); ResultSet rs = statement.executeQuery(); @@ -73,14 +67,13 @@ public class ExtendedQueryExecIT extends BaseClientManagedTimeIT { justification="Test code.") @Test public void testTypeMismatchToDateFunctionBind() throws Exception { - long ts = nextTimestamp(); String tenantId = getOrganizationId(); - initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId),null, ts, getUrl(), null); + String tableName = initATableValues(null, tenantId, getDefaultSplits(tenantId),null, null, getUrl(), null); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); try { - String query = "SELECT a_date FROM atable WHERE organization_id='" + tenantId + "' and a_date < TO_DATE(?)"; + String query = "SELECT a_date FROM " + tableName + " WHERE organization_id='" + tenantId + "' and a_date < TO_DATE(?)"; PreparedStatement statement = conn.prepareStatement(query); statement.setDate(1, new Date(2)); statement.executeQuery(); @@ -99,17 +92,15 @@ public class ExtendedQueryExecIT extends BaseClientManagedTimeIT { */ @Test public void testDateFunctions() throws Exception { - long ts = nextTimestamp(); Date date = new Date(1); String tenantId = getOrganizationId(); - initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId),date, ts, getUrl(), null); + String tableName = initATableValues(null, tenantId, getDefaultSplits(tenantId),date, null, getUrl(), null); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+1)); Connection conn = DriverManager.getConnection(getUrl(), props); try { ResultSet rs; - String queryPrefix = "SELECT a_date FROM atable WHERE organization_id='" + tenantId + "' and "; + String queryPrefix = "SELECT a_date FROM " + tableName + " WHERE organization_id='" + tenantId + "' and "; String queryDateArg = "a_date < TO_DATE('1970-1-1 12:00:00')"; rs = getResultSet(conn, queryPrefix + queryDateArg); @@ -144,17 +135,16 @@ public class ExtendedQueryExecIT extends BaseClientManagedTimeIT { */ @Test public void testDateGroupBy() throws Exception { - long ts = nextTimestamp(); + Date date = new Date(1); String tenantId = getOrganizationId(); - initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId),date, ts, getUrl(), null); + String tableName = initATableValues(null, tenantId, getDefaultSplits(tenantId),date, null, getUrl(), null); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+1)); Connection conn = DriverManager.getConnection(getUrl(), props); try { ResultSet rs; - String query = "SELECT a_date, count(1) FROM atable WHERE organization_id='" + tenantId + "' group by a_date"; + String query = "SELECT a_date, count(1) FROM " + tableName + " WHERE organization_id='" + tenantId + "' group by a_date"; rs = getResultSet(conn, query); /* 3 rows in expected result: http://git-wip-us.apache.org/repos/asf/phoenix/blob/b2153ef5/phoenix-core/src/it/java/org/apache/phoenix/end2end/FunkyNamesIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/FunkyNamesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/FunkyNamesIT.java index 131e146..20b0ae0 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/FunkyNamesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/FunkyNamesIT.java @@ -31,24 +31,22 @@ import java.sql.ResultSet; import java.util.Properties; import org.apache.phoenix.schema.ColumnNotFoundException; -import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; -public class FunkyNamesIT extends BaseClientManagedTimeIT { +public class FunkyNamesIT extends ParallelStatsDisabledIT { - protected static void initTableValues(byte[][] splits, long ts) throws Exception { - ensureTableCreated(getUrl(), FUNKY_NAME, FUNKY_NAME,splits, ts-2, null); - - String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + ts; + protected static String initTableValues(byte[][] splits) throws Exception { + String tableName = generateUniqueName(); + ensureTableCreated(getUrl(), tableName, FUNKY_NAME,splits, null, null); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(url, props); + Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(true); - // Insert all rows at ts PreparedStatement stmt = conn.prepareStatement( "upsert into " + - "FUNKY_NAMES(" + + tableName + + "(" + " \"foo!\", " + " \"#@$\", " + " \"foo.bar-bas\", " + @@ -66,18 +64,17 @@ public class FunkyNamesIT extends BaseClientManagedTimeIT { stmt.setInt(7, 3); stmt.executeUpdate(); conn.close(); + return tableName; } @Test public void testUnaliasedFunkyNames() throws Exception { - long ts = nextTimestamp(); - String query = "SELECT \"foo!\",\"#@$\",\"foo.bar-bas\",\"_blah^\" FROM FUNKY_NAMES"; - String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5 + String query = "SELECT \"foo!\",\"#@$\",\"foo.bar-bas\",\"_blah^\" FROM %s"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(url, props); + Connection conn = DriverManager.getConnection(getUrl(), props); try { - initTableValues(null, ts); - PreparedStatement statement = conn.prepareStatement(query); + String tableName = initTableValues(null); + PreparedStatement statement = conn.prepareStatement(String.format(query, tableName)); ResultSet rs = statement.executeQuery(); assertTrue(rs.next()); assertEquals("a", rs.getString(1)); @@ -97,14 +94,12 @@ public class FunkyNamesIT extends BaseClientManagedTimeIT { @Test public void testCaseSensitive() throws Exception { - long ts = nextTimestamp(); - String query = "SELECT \"Value\",\"VALUE\",\"value\" FROM FUNKY_NAMES"; - String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5 + String query = "SELECT \"Value\",\"VALUE\",\"value\" FROM %s"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(url, props); + Connection conn = DriverManager.getConnection(getUrl(), props); try { - initTableValues(null, ts); - PreparedStatement statement = conn.prepareStatement(query); + String tableName = initTableValues(null); + PreparedStatement statement = conn.prepareStatement(String.format(query, tableName)); ResultSet rs = statement.executeQuery(); assertTrue(rs.next()); assertEquals(1, rs.getInt(1)); @@ -127,14 +122,12 @@ public class FunkyNamesIT extends BaseClientManagedTimeIT { @Test public void testAliasedFunkyNames() throws Exception { - long ts = nextTimestamp(); - String query = "SELECT \"1-3.4$\".\"foo!\" as \"1-2\",\"#@$\" as \"[3]\",\"foo.bar-bas\" as \"$$$\",\"_blah^\" \"0\" FROM FUNKY_NAMES \"1-3.4$\""; - String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5 + String query = "SELECT \"1-3.4$\".\"foo!\" as \"1-2\",\"#@$\" as \"[3]\",\"foo.bar-bas\" as \"$$$\",\"_blah^\" \"0\" FROM %s \"1-3.4$\""; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(url, props); + Connection conn = DriverManager.getConnection(getUrl(), props); try { - initTableValues(null, ts); - PreparedStatement statement = conn.prepareStatement(query); + String tableName = initTableValues(null); + PreparedStatement statement = conn.prepareStatement(String.format(query, tableName)); ResultSet rs = statement.executeQuery(); assertTrue(rs.next()); assertEquals("a", rs.getString("1-2"));