Apache-Phoenix | Master | Build Successful
Master branch build status Successful Source repository https://git-wip-us.apache.org/repos/asf?p=phoenix.git;a=shortlog;h=refs/heads/master Last Successful Compiled Artifacts https://builds.apache.org/job/Phoenix-master/lastSuccessfulBuild/artifact/ Last Complete Test Report https://builds.apache.org/job/Phoenix-master/lastCompletedBuild/testReport/ Changes [jtaylor] PHOENIX-2681 Avoid usage of HashSet in guideposts selection [jtaylor] PHOENIX-2658 When using QueryRunner API UNION ALL queries fail with NPE Build times for last couple of runsLatest build time is the right most | Legend blue: normal, red: test failure, gray: timeout
Apache-Phoenix | 4.x-HBase-0.98 | Build Successful
4.x-HBase-0.98 branch build status Successful Source repository https://git-wip-us.apache.org/repos/asf?p=phoenix.git;a=shortlog;h=refs/heads/4.x-HBase-0.98 Compiled Artifacts https://builds.apache.org/job/Phoenix-4.x-HBase-0.98/lastSuccessfulBuild/artifact/ Test Report https://builds.apache.org/job/Phoenix-4.x-HBase-0.98/lastCompletedBuild/testReport/ Changes [jtaylor] PHOENIX-2681 Avoid usage of HashSet in guideposts selection [jtaylor] PHOENIX-2658 When using QueryRunner API UNION ALL queries fail with NPE Build times for last couple of runsLatest build time is the right most | Legend blue: normal, red: test failure, gray: timeout
Apache-Phoenix | 4.x-HBase-1.0 | Build Successful
4.x-HBase-1.0 branch build status Successful Source repository https://git-wip-us.apache.org/repos/asf?p=phoenix.git;a=shortlog;h=refs/heads/4.x-HBase-1.0 Compiled Artifacts https://builds.apache.org/job/Phoenix-4.x-HBase-1.0/lastSuccessfulBuild/artifact/ Test Report https://builds.apache.org/job/Phoenix-4.x-HBase-1.0/lastCompletedBuild/testReport/ Changes [jtaylor] PHOENIX-2681 Avoid usage of HashSet in guideposts selection [jtaylor] PHOENIX-2658 When using QueryRunner API UNION ALL queries fail with NPE Build times for last couple of runsLatest build time is the right most | Legend blue: normal, red: test failure, gray: timeout
[1/2] phoenix git commit: PHOENIX-2658 When using QueryRunner API UNION ALL queries fail with NPE (Alicia Ying Shu)
Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.0 98f3f12be -> 421ad309b PHOENIX-2658 When using QueryRunner API UNION ALL queries fail with NPE (Alicia Ying Shu) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/421ad309 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/421ad309 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/421ad309 Branch: refs/heads/4.x-HBase-1.0 Commit: 421ad309bfba84d7d6c0bc6c1ebafe7c7a583e33 Parents: 6967543 Author: James Taylor Authored: Thu Feb 11 20:10:23 2016 -0800 Committer: James Taylor Committed: Thu Feb 11 20:22:18 2016 -0800 -- .../org/apache/phoenix/end2end/UnionAllIT.java | 49 +++- .../apache/phoenix/compile/QueryCompiler.java | 3 +- 2 files changed, 50 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/421ad309/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java index 6531129..b391dcc 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java @@ -40,7 +40,6 @@ import org.apache.phoenix.util.ReadOnlyProps; import org.junit.BeforeClass; import org.junit.Test; - public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT { @BeforeClass @@ -679,4 +678,52 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT { conn.close(); } } + +@Test +public void testParameterMetaDataNotNull() throws Exception { +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +Connection conn = DriverManager.getConnection(getUrl(), props); + +String ddl = "CREATE TABLE test_table " + +" (a_string varchar not null, col1 integer" + +" CONSTRAINT pk PRIMARY KEY (a_string))\n"; +createTestTable(getUrl(), ddl); +String dml = "UPSERT INTO test_table VALUES(?, ?)"; +PreparedStatement stmt = conn.prepareStatement(dml); +stmt.setString(1, "a"); +stmt.setInt(2, 10); +stmt.execute(); +conn.commit(); + +ddl = "CREATE TABLE b_table " + +" (a_string varchar not null, col1 integer" + +" CONSTRAINT pk PRIMARY KEY (a_string))\n"; +createTestTable(getUrl(), ddl); +dml = "UPSERT INTO b_table VALUES(?, ?)"; +stmt = conn.prepareStatement(dml); +stmt.setString(1, "b"); +stmt.setInt(2, 20); +stmt.execute(); +conn.commit(); + +String query = "select * from test_table union all select * from b_table"; + +try{ +PreparedStatement pstmt = conn.prepareStatement(query); +assertTrue(pstmt.getParameterMetaData() != null); +ResultSet rs = pstmt.executeQuery(); +assertTrue(rs.next()); +assertEquals("a",rs.getString(1)); +assertEquals(10,rs.getInt(2)); +assertTrue(rs.next()); +assertEquals("b",rs.getString(1)); +assertEquals(20,rs.getInt(2)); +assertFalse(rs.next()); +} catch (Exception ex) { +ex.printStackTrace(); +} finally { +conn.close(); +} +} + } http://git-wip-us.apache.org/repos/asf/phoenix/blob/421ad309/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java index 70bb815..9e756c8 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java @@ -182,7 +182,8 @@ public class QueryCompiler { StatementContext context = new StatementContext(statement, resolver, scan, sequenceManager); QueryPlan plan = compileSingleFlatQuery(context, select, statement.getParameters(), false, false, null, null, false); -plan = new UnionPlan(context, select, tableRef, plan.getProjector(), plan.getLimit(), plan.getOrderBy(), GroupBy.EMPTY_GROUP_BY, plans, null); +plan = new UnionPlan(context, select, tableRef, plan.getProjector(), plan.getLimit(), plan.getOrderBy(), GroupBy.EMPTY_GROUP_BY, +plans, context.getBindManager().getParameterMetaData()); return plan; }
[2/2] phoenix git commit: PHOENIX-2681 Avoid usage of HashSet in guideposts selection
PHOENIX-2681 Avoid usage of HashSet in guideposts selection Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/69675431 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/69675431 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/69675431 Branch: refs/heads/4.x-HBase-1.0 Commit: 6967543162fa1fe9447958864c622397c89438f5 Parents: 98f3f12 Author: James Taylor Authored: Thu Feb 11 20:09:16 2016 -0800 Committer: James Taylor Committed: Thu Feb 11 20:22:18 2016 -0800 -- .../phoenix/end2end/MultiCfQueryExecIT.java | 51 .../phoenix/iterate/BaseResultIterators.java| 35 ++ 2 files changed, 66 insertions(+), 20 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/69675431/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 f5566ce..2b14fe9 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 @@ -52,6 +52,7 @@ public class MultiCfQueryExecIT extends BaseOwnClusterClientManagedTimeIT { Map props = Maps.newHashMapWithExpectedSize(3); // Must update config before starting server props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20)); +props.put(QueryServices.QUEUE_SIZE_ATTRIB, Long.toString(200)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } @@ -184,6 +185,56 @@ public class MultiCfQueryExecIT extends BaseOwnClusterClientManagedTimeIT { } @Test +public void testGuidePostsForMultiCFsOverUnevenDistrib() throws Exception { +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); + +conn.createStatement().execute("CREATE TABLE T_6CF (K1 CHAR(1) NOT NULL, " ++ "K2 VARCHAR NOT NULL, " ++ "CF1.A INTEGER, " ++ "CF2.B INTEGER, " ++ "CF3.C INTEGER, " ++ "CF4.D INTEGER, " ++ "CF5.E INTEGER, " ++ "CF6.F INTEGER " ++ "CONSTRAINT PK PRIMARY KEY (K1,K2)) SPLIT ON ('B','C','D')"); + +conn.close(); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 20)); +conn = DriverManager.getConnection(getUrl(), props); +for (int i = 0; i < 100; i++) { +String upsert = "UPSERT INTO T_6CF(K1,K2,A) VALUES('" + Character.toString((char)('A'+i%10)) + "','" + (i*10) + "'," + i + ")"; +conn.createStatement().execute(upsert); +if (i % 10 == 0) { +conn.createStatement().execute("UPSERT INTO T_6CF(K1,K2,F) VALUES('" + Character.toString((char)('A'+i%10)) + "','" + (i*10) + "'," + (i * 10) + ")"); +} +} +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn = DriverManager.getConnection(getUrl(), props); +try { +analyzeTable(getUrl(), ts + 30, "T_6CF"); +PreparedStatement statement = conn.prepareStatement("select count(*) from T_6CF where f < 400"); +ResultSet rs = statement.executeQuery(); +assertTrue(rs.next()); +assertEquals(4, rs.getLong(1)); +assertFalse(rs.next()); +List splits = getAllSplits(conn, "T_6CF", "f < 400", "COUNT(*)"); +// Uses less populated column f +assertEquals(14, splits.size()); +// Uses more populated column a +splits = getAllSplits(conn, "T_6CF", "a < 80", "COUNT(*)"); +assertEquals(104, splits.size()); +} finally { +conn.close(); +} +} + +@Test public void testGuidePostsRetrievedForMultiCF() throws Exception { Connection conn; PreparedStatement stmt; http://git-wip-us.apache.org/repos/asf/phoenix/blob/69675431/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java index 3a3d1f2..2352e94 100644 --- a
[2/2] phoenix git commit: PHOENIX-2658 When using QueryRunner API UNION ALL queries fail with NPE (Alicia Ying Shu)
PHOENIX-2658 When using QueryRunner API UNION ALL queries fail with NPE (Alicia Ying Shu) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/cb5e3013 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/cb5e3013 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/cb5e3013 Branch: refs/heads/4.x-HBase-0.98 Commit: cb5e30139251188f14525b6fb45509f6b771b661 Parents: e8a972f Author: James Taylor Authored: Thu Feb 11 20:10:23 2016 -0800 Committer: James Taylor Committed: Thu Feb 11 20:16:07 2016 -0800 -- .../org/apache/phoenix/end2end/UnionAllIT.java | 49 +++- .../apache/phoenix/compile/QueryCompiler.java | 3 +- 2 files changed, 50 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/cb5e3013/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java index 6531129..b391dcc 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java @@ -40,7 +40,6 @@ import org.apache.phoenix.util.ReadOnlyProps; import org.junit.BeforeClass; import org.junit.Test; - public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT { @BeforeClass @@ -679,4 +678,52 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT { conn.close(); } } + +@Test +public void testParameterMetaDataNotNull() throws Exception { +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +Connection conn = DriverManager.getConnection(getUrl(), props); + +String ddl = "CREATE TABLE test_table " + +" (a_string varchar not null, col1 integer" + +" CONSTRAINT pk PRIMARY KEY (a_string))\n"; +createTestTable(getUrl(), ddl); +String dml = "UPSERT INTO test_table VALUES(?, ?)"; +PreparedStatement stmt = conn.prepareStatement(dml); +stmt.setString(1, "a"); +stmt.setInt(2, 10); +stmt.execute(); +conn.commit(); + +ddl = "CREATE TABLE b_table " + +" (a_string varchar not null, col1 integer" + +" CONSTRAINT pk PRIMARY KEY (a_string))\n"; +createTestTable(getUrl(), ddl); +dml = "UPSERT INTO b_table VALUES(?, ?)"; +stmt = conn.prepareStatement(dml); +stmt.setString(1, "b"); +stmt.setInt(2, 20); +stmt.execute(); +conn.commit(); + +String query = "select * from test_table union all select * from b_table"; + +try{ +PreparedStatement pstmt = conn.prepareStatement(query); +assertTrue(pstmt.getParameterMetaData() != null); +ResultSet rs = pstmt.executeQuery(); +assertTrue(rs.next()); +assertEquals("a",rs.getString(1)); +assertEquals(10,rs.getInt(2)); +assertTrue(rs.next()); +assertEquals("b",rs.getString(1)); +assertEquals(20,rs.getInt(2)); +assertFalse(rs.next()); +} catch (Exception ex) { +ex.printStackTrace(); +} finally { +conn.close(); +} +} + } http://git-wip-us.apache.org/repos/asf/phoenix/blob/cb5e3013/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java index 33b5c6e..936ec5f 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java @@ -182,7 +182,8 @@ public class QueryCompiler { StatementContext context = new StatementContext(statement, resolver, scan, sequenceManager); QueryPlan plan = compileSingleFlatQuery(context, select, statement.getParameters(), false, false, null, null, false); -plan = new UnionPlan(context, select, tableRef, plan.getProjector(), plan.getLimit(), plan.getOrderBy(), GroupBy.EMPTY_GROUP_BY, plans, null); +plan = new UnionPlan(context, select, tableRef, plan.getProjector(), plan.getLimit(), plan.getOrderBy(), GroupBy.EMPTY_GROUP_BY, +plans, context.getBindManager().getParameterMetaData()); return plan; }
[1/2] phoenix git commit: PHOENIX-2681 Avoid usage of HashSet in guideposts selection
Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 bcacdc128 -> cb5e30139 PHOENIX-2681 Avoid usage of HashSet in guideposts selection Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/e8a972f5 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/e8a972f5 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/e8a972f5 Branch: refs/heads/4.x-HBase-0.98 Commit: e8a972f55fba8d24e2e6ea3466822ce812221a9e Parents: bcacdc1 Author: James Taylor Authored: Thu Feb 11 20:09:16 2016 -0800 Committer: James Taylor Committed: Thu Feb 11 20:15:48 2016 -0800 -- .../phoenix/end2end/MultiCfQueryExecIT.java | 51 .../phoenix/iterate/BaseResultIterators.java| 35 ++ 2 files changed, 66 insertions(+), 20 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/e8a972f5/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 f5566ce..2b14fe9 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 @@ -52,6 +52,7 @@ public class MultiCfQueryExecIT extends BaseOwnClusterClientManagedTimeIT { Map props = Maps.newHashMapWithExpectedSize(3); // Must update config before starting server props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20)); +props.put(QueryServices.QUEUE_SIZE_ATTRIB, Long.toString(200)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } @@ -184,6 +185,56 @@ public class MultiCfQueryExecIT extends BaseOwnClusterClientManagedTimeIT { } @Test +public void testGuidePostsForMultiCFsOverUnevenDistrib() throws Exception { +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); + +conn.createStatement().execute("CREATE TABLE T_6CF (K1 CHAR(1) NOT NULL, " ++ "K2 VARCHAR NOT NULL, " ++ "CF1.A INTEGER, " ++ "CF2.B INTEGER, " ++ "CF3.C INTEGER, " ++ "CF4.D INTEGER, " ++ "CF5.E INTEGER, " ++ "CF6.F INTEGER " ++ "CONSTRAINT PK PRIMARY KEY (K1,K2)) SPLIT ON ('B','C','D')"); + +conn.close(); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 20)); +conn = DriverManager.getConnection(getUrl(), props); +for (int i = 0; i < 100; i++) { +String upsert = "UPSERT INTO T_6CF(K1,K2,A) VALUES('" + Character.toString((char)('A'+i%10)) + "','" + (i*10) + "'," + i + ")"; +conn.createStatement().execute(upsert); +if (i % 10 == 0) { +conn.createStatement().execute("UPSERT INTO T_6CF(K1,K2,F) VALUES('" + Character.toString((char)('A'+i%10)) + "','" + (i*10) + "'," + (i * 10) + ")"); +} +} +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn = DriverManager.getConnection(getUrl(), props); +try { +analyzeTable(getUrl(), ts + 30, "T_6CF"); +PreparedStatement statement = conn.prepareStatement("select count(*) from T_6CF where f < 400"); +ResultSet rs = statement.executeQuery(); +assertTrue(rs.next()); +assertEquals(4, rs.getLong(1)); +assertFalse(rs.next()); +List splits = getAllSplits(conn, "T_6CF", "f < 400", "COUNT(*)"); +// Uses less populated column f +assertEquals(14, splits.size()); +// Uses more populated column a +splits = getAllSplits(conn, "T_6CF", "a < 80", "COUNT(*)"); +assertEquals(104, splits.size()); +} finally { +conn.close(); +} +} + +@Test public void testGuidePostsRetrievedForMultiCF() throws Exception { Connection conn; PreparedStatement stmt; http://git-wip-us.apache.org/repos/asf/phoenix/blob/e8a972f5/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java b/phoenix-core/src/main/j
[1/2] phoenix git commit: PHOENIX-2681 Avoid usage of HashSet in guideposts selection
Repository: phoenix Updated Branches: refs/heads/master decbfe306 -> 0c21539cc PHOENIX-2681 Avoid usage of HashSet in guideposts selection Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/18f7a694 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/18f7a694 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/18f7a694 Branch: refs/heads/master Commit: 18f7a69452eec7fd5fde38953510600c4a060151 Parents: decbfe3 Author: James Taylor Authored: Thu Feb 11 20:09:16 2016 -0800 Committer: James Taylor Committed: Thu Feb 11 20:14:31 2016 -0800 -- .../phoenix/end2end/MultiCfQueryExecIT.java | 51 .../phoenix/iterate/BaseResultIterators.java| 35 ++ 2 files changed, 66 insertions(+), 20 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/18f7a694/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 f5566ce..2b14fe9 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 @@ -52,6 +52,7 @@ public class MultiCfQueryExecIT extends BaseOwnClusterClientManagedTimeIT { Map props = Maps.newHashMapWithExpectedSize(3); // Must update config before starting server props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20)); +props.put(QueryServices.QUEUE_SIZE_ATTRIB, Long.toString(200)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } @@ -184,6 +185,56 @@ public class MultiCfQueryExecIT extends BaseOwnClusterClientManagedTimeIT { } @Test +public void testGuidePostsForMultiCFsOverUnevenDistrib() throws Exception { +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); + +conn.createStatement().execute("CREATE TABLE T_6CF (K1 CHAR(1) NOT NULL, " ++ "K2 VARCHAR NOT NULL, " ++ "CF1.A INTEGER, " ++ "CF2.B INTEGER, " ++ "CF3.C INTEGER, " ++ "CF4.D INTEGER, " ++ "CF5.E INTEGER, " ++ "CF6.F INTEGER " ++ "CONSTRAINT PK PRIMARY KEY (K1,K2)) SPLIT ON ('B','C','D')"); + +conn.close(); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 20)); +conn = DriverManager.getConnection(getUrl(), props); +for (int i = 0; i < 100; i++) { +String upsert = "UPSERT INTO T_6CF(K1,K2,A) VALUES('" + Character.toString((char)('A'+i%10)) + "','" + (i*10) + "'," + i + ")"; +conn.createStatement().execute(upsert); +if (i % 10 == 0) { +conn.createStatement().execute("UPSERT INTO T_6CF(K1,K2,F) VALUES('" + Character.toString((char)('A'+i%10)) + "','" + (i*10) + "'," + (i * 10) + ")"); +} +} +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn = DriverManager.getConnection(getUrl(), props); +try { +analyzeTable(getUrl(), ts + 30, "T_6CF"); +PreparedStatement statement = conn.prepareStatement("select count(*) from T_6CF where f < 400"); +ResultSet rs = statement.executeQuery(); +assertTrue(rs.next()); +assertEquals(4, rs.getLong(1)); +assertFalse(rs.next()); +List splits = getAllSplits(conn, "T_6CF", "f < 400", "COUNT(*)"); +// Uses less populated column f +assertEquals(14, splits.size()); +// Uses more populated column a +splits = getAllSplits(conn, "T_6CF", "a < 80", "COUNT(*)"); +assertEquals(104, splits.size()); +} finally { +conn.close(); +} +} + +@Test public void testGuidePostsRetrievedForMultiCF() throws Exception { Connection conn; PreparedStatement stmt; http://git-wip-us.apache.org/repos/asf/phoenix/blob/18f7a694/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java b/phoenix-core/src/main/java/org/apache/p
[2/2] phoenix git commit: PHOENIX-2658 When using QueryRunner API UNION ALL queries fail with NPE (Alicia Ying Shu)
PHOENIX-2658 When using QueryRunner API UNION ALL queries fail with NPE (Alicia Ying Shu) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/0c21539c Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/0c21539c Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/0c21539c Branch: refs/heads/master Commit: 0c21539cc331b8d6ca144604cf899068ad74fb25 Parents: 18f7a69 Author: James Taylor Authored: Thu Feb 11 20:10:23 2016 -0800 Committer: James Taylor Committed: Thu Feb 11 20:14:32 2016 -0800 -- .../org/apache/phoenix/end2end/UnionAllIT.java | 49 +++- .../apache/phoenix/compile/QueryCompiler.java | 3 +- 2 files changed, 50 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/0c21539c/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java index 6531129..b391dcc 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java @@ -40,7 +40,6 @@ import org.apache.phoenix.util.ReadOnlyProps; import org.junit.BeforeClass; import org.junit.Test; - public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT { @BeforeClass @@ -679,4 +678,52 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT { conn.close(); } } + +@Test +public void testParameterMetaDataNotNull() throws Exception { +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +Connection conn = DriverManager.getConnection(getUrl(), props); + +String ddl = "CREATE TABLE test_table " + +" (a_string varchar not null, col1 integer" + +" CONSTRAINT pk PRIMARY KEY (a_string))\n"; +createTestTable(getUrl(), ddl); +String dml = "UPSERT INTO test_table VALUES(?, ?)"; +PreparedStatement stmt = conn.prepareStatement(dml); +stmt.setString(1, "a"); +stmt.setInt(2, 10); +stmt.execute(); +conn.commit(); + +ddl = "CREATE TABLE b_table " + +" (a_string varchar not null, col1 integer" + +" CONSTRAINT pk PRIMARY KEY (a_string))\n"; +createTestTable(getUrl(), ddl); +dml = "UPSERT INTO b_table VALUES(?, ?)"; +stmt = conn.prepareStatement(dml); +stmt.setString(1, "b"); +stmt.setInt(2, 20); +stmt.execute(); +conn.commit(); + +String query = "select * from test_table union all select * from b_table"; + +try{ +PreparedStatement pstmt = conn.prepareStatement(query); +assertTrue(pstmt.getParameterMetaData() != null); +ResultSet rs = pstmt.executeQuery(); +assertTrue(rs.next()); +assertEquals("a",rs.getString(1)); +assertEquals(10,rs.getInt(2)); +assertTrue(rs.next()); +assertEquals("b",rs.getString(1)); +assertEquals(20,rs.getInt(2)); +assertFalse(rs.next()); +} catch (Exception ex) { +ex.printStackTrace(); +} finally { +conn.close(); +} +} + } http://git-wip-us.apache.org/repos/asf/phoenix/blob/0c21539c/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java index 70bb815..9e756c8 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java @@ -182,7 +182,8 @@ public class QueryCompiler { StatementContext context = new StatementContext(statement, resolver, scan, sequenceManager); QueryPlan plan = compileSingleFlatQuery(context, select, statement.getParameters(), false, false, null, null, false); -plan = new UnionPlan(context, select, tableRef, plan.getProjector(), plan.getLimit(), plan.getOrderBy(), GroupBy.EMPTY_GROUP_BY, plans, null); +plan = new UnionPlan(context, select, tableRef, plan.getProjector(), plan.getLimit(), plan.getOrderBy(), GroupBy.EMPTY_GROUP_BY, +plans, context.getBindManager().getParameterMetaData()); return plan; }