[04/50] [abbrv] phoenix git commit: PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up
PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/72fa8749 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/72fa8749 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/72fa8749 Branch: refs/heads/4.14-HBase-1.3 Commit: 72fa8749eb443b6fb9cb6436b06891642eff0440 Parents: 5dc873d Author: Thomas D'Silva Authored: Thu May 10 16:30:36 2018 -0700 Committer: Thomas D'Silva Committed: Fri May 11 09:33:35 2018 -0700 -- .../phoenix/end2end/RowValueConstructorIT.java | 120 +++ .../org/apache/phoenix/compile/ScanRanges.java | 5 + 2 files changed, 125 insertions(+) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/72fa8749/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java index df7603a..fb04261 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java @@ -48,6 +48,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.util.List; import java.util.Properties; import org.apache.phoenix.util.DateUtil; @@ -57,6 +58,9 @@ import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; + public class RowValueConstructorIT extends ParallelStatsDisabledIT { @@ -1646,4 +1650,120 @@ public class RowValueConstructorIT extends ParallelStatsDisabledIT { assertEquals("value", rs.getString(3)); assertFalse(rs.next()); } + +@Test +/** + * Verifies that a query with a RVC expression lexographically higher than all values in an OR + * clause causes query works see PHOENIX-4734 + */ +public void testRVCWithAndClause() throws Exception { +final int numItemsInClause = 5; +Properties tenantProps = new Properties(); +tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); +String fullTableName = SchemaUtil.getTableName("S", "T_" + generateUniqueName()); +String fullViewName = SchemaUtil.getTableName("S", "V_" + generateUniqueName()); +try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { +tenantConn.setAutoCommit(false); +createBaseTableAndTenantView(tenantConn, fullTableName, fullViewName); +loadDataIntoTenantView(tenantConn, fullViewName); +List objectIdsList = +selectObjectIdsForInClause(tenantConn, fullViewName, numItemsInClause); +StringBuilder querySb = generateQueryToTest(numItemsInClause, fullViewName); +PreparedStatement ps = tenantConn.prepareStatement(querySb.toString()); +int numbBindVarsSet = 0; +String objectId = null; +for (int i = 0; i < numItemsInClause; i++) { +objectId = objectIdsList.get(i); +ps.setString((i + 1), objectId); +numbBindVarsSet++; +} +assertEquals(numItemsInClause, numbBindVarsSet); +assertEquals("v1000", objectId); +ps.setString(numItemsInClause + 1, "z00"); +ps.setString(numItemsInClause + 2, "v1000"); // This value must match or be + // lexographically higher than the highest + // value in the IN clause +// Query should execute and return 0 results +ResultSet rs = ps.executeQuery(); +assertFalse( +"Query should return no results as IN clause and RVC clause are disjoint sets", +rs.next()); +} +} + +private StringBuilder generateQueryToTest(int numItemsInClause, String fullViewName) { +StringBuilder querySb = +new StringBuilder("SELECT OBJECT_ID,OBJECT_DATA2,OBJECT_DATA FROM " + fullViewName); +querySb.append(" WHERE (("); +List orClauses = Lists.newArrayList(); +for (int i = 1; i < (numItemsInClause + 1); i++) { +orClauses.add("OBJECT_ID = ?"); +} +querySb.append(Joiner.on(" OR ").join(orClauses)); +querySb.append(") AND (KEY_PREFIX,OBJECT_ID) > (?,?)) ORDER BY
[11/22] phoenix git commit: PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up
PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/72fa8749 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/72fa8749 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/72fa8749 Branch: refs/heads/omid2 Commit: 72fa8749eb443b6fb9cb6436b06891642eff0440 Parents: 5dc873d Author: Thomas D'SilvaAuthored: Thu May 10 16:30:36 2018 -0700 Committer: Thomas D'Silva Committed: Fri May 11 09:33:35 2018 -0700 -- .../phoenix/end2end/RowValueConstructorIT.java | 120 +++ .../org/apache/phoenix/compile/ScanRanges.java | 5 + 2 files changed, 125 insertions(+) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/72fa8749/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java index df7603a..fb04261 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java @@ -48,6 +48,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.util.List; import java.util.Properties; import org.apache.phoenix.util.DateUtil; @@ -57,6 +58,9 @@ import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; + public class RowValueConstructorIT extends ParallelStatsDisabledIT { @@ -1646,4 +1650,120 @@ public class RowValueConstructorIT extends ParallelStatsDisabledIT { assertEquals("value", rs.getString(3)); assertFalse(rs.next()); } + +@Test +/** + * Verifies that a query with a RVC expression lexographically higher than all values in an OR + * clause causes query works see PHOENIX-4734 + */ +public void testRVCWithAndClause() throws Exception { +final int numItemsInClause = 5; +Properties tenantProps = new Properties(); +tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); +String fullTableName = SchemaUtil.getTableName("S", "T_" + generateUniqueName()); +String fullViewName = SchemaUtil.getTableName("S", "V_" + generateUniqueName()); +try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { +tenantConn.setAutoCommit(false); +createBaseTableAndTenantView(tenantConn, fullTableName, fullViewName); +loadDataIntoTenantView(tenantConn, fullViewName); +List objectIdsList = +selectObjectIdsForInClause(tenantConn, fullViewName, numItemsInClause); +StringBuilder querySb = generateQueryToTest(numItemsInClause, fullViewName); +PreparedStatement ps = tenantConn.prepareStatement(querySb.toString()); +int numbBindVarsSet = 0; +String objectId = null; +for (int i = 0; i < numItemsInClause; i++) { +objectId = objectIdsList.get(i); +ps.setString((i + 1), objectId); +numbBindVarsSet++; +} +assertEquals(numItemsInClause, numbBindVarsSet); +assertEquals("v1000", objectId); +ps.setString(numItemsInClause + 1, "z00"); +ps.setString(numItemsInClause + 2, "v1000"); // This value must match or be + // lexographically higher than the highest + // value in the IN clause +// Query should execute and return 0 results +ResultSet rs = ps.executeQuery(); +assertFalse( +"Query should return no results as IN clause and RVC clause are disjoint sets", +rs.next()); +} +} + +private StringBuilder generateQueryToTest(int numItemsInClause, String fullViewName) { +StringBuilder querySb = +new StringBuilder("SELECT OBJECT_ID,OBJECT_DATA2,OBJECT_DATA FROM " + fullViewName); +querySb.append(" WHERE (("); +List orClauses = Lists.newArrayList(); +for (int i = 1; i < (numItemsInClause + 1); i++) { +orClauses.add("OBJECT_ID = ?"); +} +querySb.append(Joiner.on(" OR ").join(orClauses)); +querySb.append(") AND
[3/5] phoenix git commit: PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up
PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/7856a001 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7856a001 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7856a001 Branch: refs/heads/4.x-cdh5.14 Commit: 7856a0017f5377ab02e882e964b32e93877d5456 Parents: 670e14f Author: Thomas D'SilvaAuthored: Fri May 11 00:30:36 2018 +0100 Committer: Pedro Boado Committed: Sun May 13 10:45:54 2018 +0100 -- .../phoenix/end2end/RowValueConstructorIT.java | 120 +++ .../org/apache/phoenix/compile/ScanRanges.java | 5 + 2 files changed, 125 insertions(+) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/7856a001/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java index df7603a..fb04261 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java @@ -48,6 +48,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.util.List; import java.util.Properties; import org.apache.phoenix.util.DateUtil; @@ -57,6 +58,9 @@ import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; + public class RowValueConstructorIT extends ParallelStatsDisabledIT { @@ -1646,4 +1650,120 @@ public class RowValueConstructorIT extends ParallelStatsDisabledIT { assertEquals("value", rs.getString(3)); assertFalse(rs.next()); } + +@Test +/** + * Verifies that a query with a RVC expression lexographically higher than all values in an OR + * clause causes query works see PHOENIX-4734 + */ +public void testRVCWithAndClause() throws Exception { +final int numItemsInClause = 5; +Properties tenantProps = new Properties(); +tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); +String fullTableName = SchemaUtil.getTableName("S", "T_" + generateUniqueName()); +String fullViewName = SchemaUtil.getTableName("S", "V_" + generateUniqueName()); +try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { +tenantConn.setAutoCommit(false); +createBaseTableAndTenantView(tenantConn, fullTableName, fullViewName); +loadDataIntoTenantView(tenantConn, fullViewName); +List objectIdsList = +selectObjectIdsForInClause(tenantConn, fullViewName, numItemsInClause); +StringBuilder querySb = generateQueryToTest(numItemsInClause, fullViewName); +PreparedStatement ps = tenantConn.prepareStatement(querySb.toString()); +int numbBindVarsSet = 0; +String objectId = null; +for (int i = 0; i < numItemsInClause; i++) { +objectId = objectIdsList.get(i); +ps.setString((i + 1), objectId); +numbBindVarsSet++; +} +assertEquals(numItemsInClause, numbBindVarsSet); +assertEquals("v1000", objectId); +ps.setString(numItemsInClause + 1, "z00"); +ps.setString(numItemsInClause + 2, "v1000"); // This value must match or be + // lexographically higher than the highest + // value in the IN clause +// Query should execute and return 0 results +ResultSet rs = ps.executeQuery(); +assertFalse( +"Query should return no results as IN clause and RVC clause are disjoint sets", +rs.next()); +} +} + +private StringBuilder generateQueryToTest(int numItemsInClause, String fullViewName) { +StringBuilder querySb = +new StringBuilder("SELECT OBJECT_ID,OBJECT_DATA2,OBJECT_DATA FROM " + fullViewName); +querySb.append(" WHERE (("); +List orClauses = Lists.newArrayList(); +for (int i = 1; i < (numItemsInClause + 1); i++) { +orClauses.add("OBJECT_ID = ?"); +} +querySb.append(Joiner.on(" OR ").join(orClauses)); +querySb.append(") AND
[3/5] phoenix git commit: PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up
PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/7856a001 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7856a001 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7856a001 Branch: refs/heads/4.x-cdh5.13 Commit: 7856a0017f5377ab02e882e964b32e93877d5456 Parents: 670e14f Author: Thomas D'SilvaAuthored: Fri May 11 00:30:36 2018 +0100 Committer: Pedro Boado Committed: Sun May 13 10:45:54 2018 +0100 -- .../phoenix/end2end/RowValueConstructorIT.java | 120 +++ .../org/apache/phoenix/compile/ScanRanges.java | 5 + 2 files changed, 125 insertions(+) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/7856a001/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java index df7603a..fb04261 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java @@ -48,6 +48,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.util.List; import java.util.Properties; import org.apache.phoenix.util.DateUtil; @@ -57,6 +58,9 @@ import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; + public class RowValueConstructorIT extends ParallelStatsDisabledIT { @@ -1646,4 +1650,120 @@ public class RowValueConstructorIT extends ParallelStatsDisabledIT { assertEquals("value", rs.getString(3)); assertFalse(rs.next()); } + +@Test +/** + * Verifies that a query with a RVC expression lexographically higher than all values in an OR + * clause causes query works see PHOENIX-4734 + */ +public void testRVCWithAndClause() throws Exception { +final int numItemsInClause = 5; +Properties tenantProps = new Properties(); +tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); +String fullTableName = SchemaUtil.getTableName("S", "T_" + generateUniqueName()); +String fullViewName = SchemaUtil.getTableName("S", "V_" + generateUniqueName()); +try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { +tenantConn.setAutoCommit(false); +createBaseTableAndTenantView(tenantConn, fullTableName, fullViewName); +loadDataIntoTenantView(tenantConn, fullViewName); +List objectIdsList = +selectObjectIdsForInClause(tenantConn, fullViewName, numItemsInClause); +StringBuilder querySb = generateQueryToTest(numItemsInClause, fullViewName); +PreparedStatement ps = tenantConn.prepareStatement(querySb.toString()); +int numbBindVarsSet = 0; +String objectId = null; +for (int i = 0; i < numItemsInClause; i++) { +objectId = objectIdsList.get(i); +ps.setString((i + 1), objectId); +numbBindVarsSet++; +} +assertEquals(numItemsInClause, numbBindVarsSet); +assertEquals("v1000", objectId); +ps.setString(numItemsInClause + 1, "z00"); +ps.setString(numItemsInClause + 2, "v1000"); // This value must match or be + // lexographically higher than the highest + // value in the IN clause +// Query should execute and return 0 results +ResultSet rs = ps.executeQuery(); +assertFalse( +"Query should return no results as IN clause and RVC clause are disjoint sets", +rs.next()); +} +} + +private StringBuilder generateQueryToTest(int numItemsInClause, String fullViewName) { +StringBuilder querySb = +new StringBuilder("SELECT OBJECT_ID,OBJECT_DATA2,OBJECT_DATA FROM " + fullViewName); +querySb.append(" WHERE (("); +List orClauses = Lists.newArrayList(); +for (int i = 1; i < (numItemsInClause + 1); i++) { +orClauses.add("OBJECT_ID = ?"); +} +querySb.append(Joiner.on(" OR ").join(orClauses)); +querySb.append(") AND
[3/5] phoenix git commit: PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up
PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/7856a001 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7856a001 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7856a001 Branch: refs/heads/4.x-cdh5.12 Commit: 7856a0017f5377ab02e882e964b32e93877d5456 Parents: 670e14f Author: Thomas D'SilvaAuthored: Fri May 11 00:30:36 2018 +0100 Committer: Pedro Boado Committed: Sun May 13 10:45:54 2018 +0100 -- .../phoenix/end2end/RowValueConstructorIT.java | 120 +++ .../org/apache/phoenix/compile/ScanRanges.java | 5 + 2 files changed, 125 insertions(+) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/7856a001/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java index df7603a..fb04261 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java @@ -48,6 +48,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.util.List; import java.util.Properties; import org.apache.phoenix.util.DateUtil; @@ -57,6 +58,9 @@ import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; + public class RowValueConstructorIT extends ParallelStatsDisabledIT { @@ -1646,4 +1650,120 @@ public class RowValueConstructorIT extends ParallelStatsDisabledIT { assertEquals("value", rs.getString(3)); assertFalse(rs.next()); } + +@Test +/** + * Verifies that a query with a RVC expression lexographically higher than all values in an OR + * clause causes query works see PHOENIX-4734 + */ +public void testRVCWithAndClause() throws Exception { +final int numItemsInClause = 5; +Properties tenantProps = new Properties(); +tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); +String fullTableName = SchemaUtil.getTableName("S", "T_" + generateUniqueName()); +String fullViewName = SchemaUtil.getTableName("S", "V_" + generateUniqueName()); +try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { +tenantConn.setAutoCommit(false); +createBaseTableAndTenantView(tenantConn, fullTableName, fullViewName); +loadDataIntoTenantView(tenantConn, fullViewName); +List objectIdsList = +selectObjectIdsForInClause(tenantConn, fullViewName, numItemsInClause); +StringBuilder querySb = generateQueryToTest(numItemsInClause, fullViewName); +PreparedStatement ps = tenantConn.prepareStatement(querySb.toString()); +int numbBindVarsSet = 0; +String objectId = null; +for (int i = 0; i < numItemsInClause; i++) { +objectId = objectIdsList.get(i); +ps.setString((i + 1), objectId); +numbBindVarsSet++; +} +assertEquals(numItemsInClause, numbBindVarsSet); +assertEquals("v1000", objectId); +ps.setString(numItemsInClause + 1, "z00"); +ps.setString(numItemsInClause + 2, "v1000"); // This value must match or be + // lexographically higher than the highest + // value in the IN clause +// Query should execute and return 0 results +ResultSet rs = ps.executeQuery(); +assertFalse( +"Query should return no results as IN clause and RVC clause are disjoint sets", +rs.next()); +} +} + +private StringBuilder generateQueryToTest(int numItemsInClause, String fullViewName) { +StringBuilder querySb = +new StringBuilder("SELECT OBJECT_ID,OBJECT_DATA2,OBJECT_DATA FROM " + fullViewName); +querySb.append(" WHERE (("); +List orClauses = Lists.newArrayList(); +for (int i = 1; i < (numItemsInClause + 1); i++) { +orClauses.add("OBJECT_ID = ?"); +} +querySb.append(Joiner.on(" OR ").join(orClauses)); +querySb.append(") AND
[2/3] phoenix git commit: PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up
PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/7856a001 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7856a001 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7856a001 Branch: refs/heads/4.x-cdh5.11 Commit: 7856a0017f5377ab02e882e964b32e93877d5456 Parents: 670e14f Author: Thomas D'SilvaAuthored: Fri May 11 00:30:36 2018 +0100 Committer: Pedro Boado Committed: Sun May 13 10:45:54 2018 +0100 -- .../phoenix/end2end/RowValueConstructorIT.java | 120 +++ .../org/apache/phoenix/compile/ScanRanges.java | 5 + 2 files changed, 125 insertions(+) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/7856a001/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java index df7603a..fb04261 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java @@ -48,6 +48,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.util.List; import java.util.Properties; import org.apache.phoenix.util.DateUtil; @@ -57,6 +58,9 @@ import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; + public class RowValueConstructorIT extends ParallelStatsDisabledIT { @@ -1646,4 +1650,120 @@ public class RowValueConstructorIT extends ParallelStatsDisabledIT { assertEquals("value", rs.getString(3)); assertFalse(rs.next()); } + +@Test +/** + * Verifies that a query with a RVC expression lexographically higher than all values in an OR + * clause causes query works see PHOENIX-4734 + */ +public void testRVCWithAndClause() throws Exception { +final int numItemsInClause = 5; +Properties tenantProps = new Properties(); +tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); +String fullTableName = SchemaUtil.getTableName("S", "T_" + generateUniqueName()); +String fullViewName = SchemaUtil.getTableName("S", "V_" + generateUniqueName()); +try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { +tenantConn.setAutoCommit(false); +createBaseTableAndTenantView(tenantConn, fullTableName, fullViewName); +loadDataIntoTenantView(tenantConn, fullViewName); +List objectIdsList = +selectObjectIdsForInClause(tenantConn, fullViewName, numItemsInClause); +StringBuilder querySb = generateQueryToTest(numItemsInClause, fullViewName); +PreparedStatement ps = tenantConn.prepareStatement(querySb.toString()); +int numbBindVarsSet = 0; +String objectId = null; +for (int i = 0; i < numItemsInClause; i++) { +objectId = objectIdsList.get(i); +ps.setString((i + 1), objectId); +numbBindVarsSet++; +} +assertEquals(numItemsInClause, numbBindVarsSet); +assertEquals("v1000", objectId); +ps.setString(numItemsInClause + 1, "z00"); +ps.setString(numItemsInClause + 2, "v1000"); // This value must match or be + // lexographically higher than the highest + // value in the IN clause +// Query should execute and return 0 results +ResultSet rs = ps.executeQuery(); +assertFalse( +"Query should return no results as IN clause and RVC clause are disjoint sets", +rs.next()); +} +} + +private StringBuilder generateQueryToTest(int numItemsInClause, String fullViewName) { +StringBuilder querySb = +new StringBuilder("SELECT OBJECT_ID,OBJECT_DATA2,OBJECT_DATA FROM " + fullViewName); +querySb.append(" WHERE (("); +List orClauses = Lists.newArrayList(); +for (int i = 1; i < (numItemsInClause + 1); i++) { +orClauses.add("OBJECT_ID = ?"); +} +querySb.append(Joiner.on(" OR ").join(orClauses)); +querySb.append(") AND
phoenix git commit: PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up
Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.3 5dc873dd2 -> 72fa8749e PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/72fa8749 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/72fa8749 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/72fa8749 Branch: refs/heads/4.x-HBase-1.3 Commit: 72fa8749eb443b6fb9cb6436b06891642eff0440 Parents: 5dc873d Author: Thomas D'SilvaAuthored: Thu May 10 16:30:36 2018 -0700 Committer: Thomas D'Silva Committed: Fri May 11 09:33:35 2018 -0700 -- .../phoenix/end2end/RowValueConstructorIT.java | 120 +++ .../org/apache/phoenix/compile/ScanRanges.java | 5 + 2 files changed, 125 insertions(+) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/72fa8749/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java index df7603a..fb04261 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java @@ -48,6 +48,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.util.List; import java.util.Properties; import org.apache.phoenix.util.DateUtil; @@ -57,6 +58,9 @@ import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; + public class RowValueConstructorIT extends ParallelStatsDisabledIT { @@ -1646,4 +1650,120 @@ public class RowValueConstructorIT extends ParallelStatsDisabledIT { assertEquals("value", rs.getString(3)); assertFalse(rs.next()); } + +@Test +/** + * Verifies that a query with a RVC expression lexographically higher than all values in an OR + * clause causes query works see PHOENIX-4734 + */ +public void testRVCWithAndClause() throws Exception { +final int numItemsInClause = 5; +Properties tenantProps = new Properties(); +tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); +String fullTableName = SchemaUtil.getTableName("S", "T_" + generateUniqueName()); +String fullViewName = SchemaUtil.getTableName("S", "V_" + generateUniqueName()); +try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { +tenantConn.setAutoCommit(false); +createBaseTableAndTenantView(tenantConn, fullTableName, fullViewName); +loadDataIntoTenantView(tenantConn, fullViewName); +List objectIdsList = +selectObjectIdsForInClause(tenantConn, fullViewName, numItemsInClause); +StringBuilder querySb = generateQueryToTest(numItemsInClause, fullViewName); +PreparedStatement ps = tenantConn.prepareStatement(querySb.toString()); +int numbBindVarsSet = 0; +String objectId = null; +for (int i = 0; i < numItemsInClause; i++) { +objectId = objectIdsList.get(i); +ps.setString((i + 1), objectId); +numbBindVarsSet++; +} +assertEquals(numItemsInClause, numbBindVarsSet); +assertEquals("v1000", objectId); +ps.setString(numItemsInClause + 1, "z00"); +ps.setString(numItemsInClause + 2, "v1000"); // This value must match or be + // lexographically higher than the highest + // value in the IN clause +// Query should execute and return 0 results +ResultSet rs = ps.executeQuery(); +assertFalse( +"Query should return no results as IN clause and RVC clause are disjoint sets", +rs.next()); +} +} + +private StringBuilder generateQueryToTest(int numItemsInClause, String fullViewName) { +StringBuilder querySb = +new StringBuilder("SELECT OBJECT_ID,OBJECT_DATA2,OBJECT_DATA FROM " + fullViewName); +querySb.append(" WHERE (("); +List orClauses = Lists.newArrayList(); +for (int i = 1; i < (numItemsInClause + 1); i++) { +orClauses.add("OBJECT_ID = ?"); +} +
phoenix git commit: PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up
Repository: phoenix Updated Branches: refs/heads/master ce25e4287 -> 0c8349e3c PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/0c8349e3 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/0c8349e3 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/0c8349e3 Branch: refs/heads/master Commit: 0c8349e3c01a9f1e18e2ebd565833bd448271d9e Parents: ce25e42 Author: Thomas D'SilvaAuthored: Thu May 10 16:30:36 2018 -0700 Committer: Thomas D'Silva Committed: Fri May 11 09:33:45 2018 -0700 -- .../phoenix/end2end/RowValueConstructorIT.java | 120 +++ .../org/apache/phoenix/compile/ScanRanges.java | 5 + 2 files changed, 125 insertions(+) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/0c8349e3/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java index df7603a..fb04261 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java @@ -48,6 +48,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.util.List; import java.util.Properties; import org.apache.phoenix.util.DateUtil; @@ -57,6 +58,9 @@ import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; + public class RowValueConstructorIT extends ParallelStatsDisabledIT { @@ -1646,4 +1650,120 @@ public class RowValueConstructorIT extends ParallelStatsDisabledIT { assertEquals("value", rs.getString(3)); assertFalse(rs.next()); } + +@Test +/** + * Verifies that a query with a RVC expression lexographically higher than all values in an OR + * clause causes query works see PHOENIX-4734 + */ +public void testRVCWithAndClause() throws Exception { +final int numItemsInClause = 5; +Properties tenantProps = new Properties(); +tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); +String fullTableName = SchemaUtil.getTableName("S", "T_" + generateUniqueName()); +String fullViewName = SchemaUtil.getTableName("S", "V_" + generateUniqueName()); +try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { +tenantConn.setAutoCommit(false); +createBaseTableAndTenantView(tenantConn, fullTableName, fullViewName); +loadDataIntoTenantView(tenantConn, fullViewName); +List objectIdsList = +selectObjectIdsForInClause(tenantConn, fullViewName, numItemsInClause); +StringBuilder querySb = generateQueryToTest(numItemsInClause, fullViewName); +PreparedStatement ps = tenantConn.prepareStatement(querySb.toString()); +int numbBindVarsSet = 0; +String objectId = null; +for (int i = 0; i < numItemsInClause; i++) { +objectId = objectIdsList.get(i); +ps.setString((i + 1), objectId); +numbBindVarsSet++; +} +assertEquals(numItemsInClause, numbBindVarsSet); +assertEquals("v1000", objectId); +ps.setString(numItemsInClause + 1, "z00"); +ps.setString(numItemsInClause + 2, "v1000"); // This value must match or be + // lexographically higher than the highest + // value in the IN clause +// Query should execute and return 0 results +ResultSet rs = ps.executeQuery(); +assertFalse( +"Query should return no results as IN clause and RVC clause are disjoint sets", +rs.next()); +} +} + +private StringBuilder generateQueryToTest(int numItemsInClause, String fullViewName) { +StringBuilder querySb = +new StringBuilder("SELECT OBJECT_ID,OBJECT_DATA2,OBJECT_DATA FROM " + fullViewName); +querySb.append(" WHERE (("); +List orClauses = Lists.newArrayList(); +for (int i = 1; i < (numItemsInClause + 1); i++) { +orClauses.add("OBJECT_ID = ?"); +} +
phoenix git commit: PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up
Repository: phoenix Updated Branches: refs/heads/5.x-HBase-2.0 b13b54363 -> ded15dc42 PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/ded15dc4 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ded15dc4 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ded15dc4 Branch: refs/heads/5.x-HBase-2.0 Commit: ded15dc4236f62defd666d84bfd2d15d999c9016 Parents: b13b543 Author: Thomas D'SilvaAuthored: Thu May 10 16:30:36 2018 -0700 Committer: Thomas D'Silva Committed: Fri May 11 09:34:00 2018 -0700 -- .../phoenix/end2end/RowValueConstructorIT.java | 120 +++ .../org/apache/phoenix/compile/ScanRanges.java | 5 + 2 files changed, 125 insertions(+) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/ded15dc4/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java index df7603a..fb04261 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java @@ -48,6 +48,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.util.List; import java.util.Properties; import org.apache.phoenix.util.DateUtil; @@ -57,6 +58,9 @@ import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; + public class RowValueConstructorIT extends ParallelStatsDisabledIT { @@ -1646,4 +1650,120 @@ public class RowValueConstructorIT extends ParallelStatsDisabledIT { assertEquals("value", rs.getString(3)); assertFalse(rs.next()); } + +@Test +/** + * Verifies that a query with a RVC expression lexographically higher than all values in an OR + * clause causes query works see PHOENIX-4734 + */ +public void testRVCWithAndClause() throws Exception { +final int numItemsInClause = 5; +Properties tenantProps = new Properties(); +tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); +String fullTableName = SchemaUtil.getTableName("S", "T_" + generateUniqueName()); +String fullViewName = SchemaUtil.getTableName("S", "V_" + generateUniqueName()); +try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { +tenantConn.setAutoCommit(false); +createBaseTableAndTenantView(tenantConn, fullTableName, fullViewName); +loadDataIntoTenantView(tenantConn, fullViewName); +List objectIdsList = +selectObjectIdsForInClause(tenantConn, fullViewName, numItemsInClause); +StringBuilder querySb = generateQueryToTest(numItemsInClause, fullViewName); +PreparedStatement ps = tenantConn.prepareStatement(querySb.toString()); +int numbBindVarsSet = 0; +String objectId = null; +for (int i = 0; i < numItemsInClause; i++) { +objectId = objectIdsList.get(i); +ps.setString((i + 1), objectId); +numbBindVarsSet++; +} +assertEquals(numItemsInClause, numbBindVarsSet); +assertEquals("v1000", objectId); +ps.setString(numItemsInClause + 1, "z00"); +ps.setString(numItemsInClause + 2, "v1000"); // This value must match or be + // lexographically higher than the highest + // value in the IN clause +// Query should execute and return 0 results +ResultSet rs = ps.executeQuery(); +assertFalse( +"Query should return no results as IN clause and RVC clause are disjoint sets", +rs.next()); +} +} + +private StringBuilder generateQueryToTest(int numItemsInClause, String fullViewName) { +StringBuilder querySb = +new StringBuilder("SELECT OBJECT_ID,OBJECT_DATA2,OBJECT_DATA FROM " + fullViewName); +querySb.append(" WHERE (("); +List orClauses = Lists.newArrayList(); +for (int i = 1; i < (numItemsInClause + 1); i++) { +orClauses.add("OBJECT_ID = ?"); +} +
phoenix git commit: PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up
Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.1 6fa49ee2f -> e6119229c PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/e6119229 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/e6119229 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/e6119229 Branch: refs/heads/4.x-HBase-1.1 Commit: e6119229c11134f4e8a751fc48a5b78f8e4270e4 Parents: 6fa49ee Author: Thomas D'SilvaAuthored: Thu May 10 16:30:36 2018 -0700 Committer: Thomas D'Silva Committed: Fri May 11 09:33:19 2018 -0700 -- .../phoenix/end2end/RowValueConstructorIT.java | 120 +++ .../org/apache/phoenix/compile/ScanRanges.java | 5 + 2 files changed, 125 insertions(+) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/e6119229/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java index df7603a..fb04261 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java @@ -48,6 +48,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.util.List; import java.util.Properties; import org.apache.phoenix.util.DateUtil; @@ -57,6 +58,9 @@ import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; + public class RowValueConstructorIT extends ParallelStatsDisabledIT { @@ -1646,4 +1650,120 @@ public class RowValueConstructorIT extends ParallelStatsDisabledIT { assertEquals("value", rs.getString(3)); assertFalse(rs.next()); } + +@Test +/** + * Verifies that a query with a RVC expression lexographically higher than all values in an OR + * clause causes query works see PHOENIX-4734 + */ +public void testRVCWithAndClause() throws Exception { +final int numItemsInClause = 5; +Properties tenantProps = new Properties(); +tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); +String fullTableName = SchemaUtil.getTableName("S", "T_" + generateUniqueName()); +String fullViewName = SchemaUtil.getTableName("S", "V_" + generateUniqueName()); +try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { +tenantConn.setAutoCommit(false); +createBaseTableAndTenantView(tenantConn, fullTableName, fullViewName); +loadDataIntoTenantView(tenantConn, fullViewName); +List objectIdsList = +selectObjectIdsForInClause(tenantConn, fullViewName, numItemsInClause); +StringBuilder querySb = generateQueryToTest(numItemsInClause, fullViewName); +PreparedStatement ps = tenantConn.prepareStatement(querySb.toString()); +int numbBindVarsSet = 0; +String objectId = null; +for (int i = 0; i < numItemsInClause; i++) { +objectId = objectIdsList.get(i); +ps.setString((i + 1), objectId); +numbBindVarsSet++; +} +assertEquals(numItemsInClause, numbBindVarsSet); +assertEquals("v1000", objectId); +ps.setString(numItemsInClause + 1, "z00"); +ps.setString(numItemsInClause + 2, "v1000"); // This value must match or be + // lexographically higher than the highest + // value in the IN clause +// Query should execute and return 0 results +ResultSet rs = ps.executeQuery(); +assertFalse( +"Query should return no results as IN clause and RVC clause are disjoint sets", +rs.next()); +} +} + +private StringBuilder generateQueryToTest(int numItemsInClause, String fullViewName) { +StringBuilder querySb = +new StringBuilder("SELECT OBJECT_ID,OBJECT_DATA2,OBJECT_DATA FROM " + fullViewName); +querySb.append(" WHERE (("); +List orClauses = Lists.newArrayList(); +for (int i = 1; i < (numItemsInClause + 1); i++) { +orClauses.add("OBJECT_ID = ?"); +} +
phoenix git commit: PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up
Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.2 4691d8fbd -> 141686ab5 PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/141686ab Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/141686ab Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/141686ab Branch: refs/heads/4.x-HBase-1.2 Commit: 141686ab5dcc4217c756891694b3b6acc2034ef8 Parents: 4691d8f Author: Thomas D'SilvaAuthored: Thu May 10 16:30:36 2018 -0700 Committer: Thomas D'Silva Committed: Fri May 11 09:33:29 2018 -0700 -- .../phoenix/end2end/RowValueConstructorIT.java | 120 +++ .../org/apache/phoenix/compile/ScanRanges.java | 5 + 2 files changed, 125 insertions(+) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/141686ab/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java index df7603a..fb04261 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java @@ -48,6 +48,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.util.List; import java.util.Properties; import org.apache.phoenix.util.DateUtil; @@ -57,6 +58,9 @@ import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; + public class RowValueConstructorIT extends ParallelStatsDisabledIT { @@ -1646,4 +1650,120 @@ public class RowValueConstructorIT extends ParallelStatsDisabledIT { assertEquals("value", rs.getString(3)); assertFalse(rs.next()); } + +@Test +/** + * Verifies that a query with a RVC expression lexographically higher than all values in an OR + * clause causes query works see PHOENIX-4734 + */ +public void testRVCWithAndClause() throws Exception { +final int numItemsInClause = 5; +Properties tenantProps = new Properties(); +tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); +String fullTableName = SchemaUtil.getTableName("S", "T_" + generateUniqueName()); +String fullViewName = SchemaUtil.getTableName("S", "V_" + generateUniqueName()); +try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { +tenantConn.setAutoCommit(false); +createBaseTableAndTenantView(tenantConn, fullTableName, fullViewName); +loadDataIntoTenantView(tenantConn, fullViewName); +List objectIdsList = +selectObjectIdsForInClause(tenantConn, fullViewName, numItemsInClause); +StringBuilder querySb = generateQueryToTest(numItemsInClause, fullViewName); +PreparedStatement ps = tenantConn.prepareStatement(querySb.toString()); +int numbBindVarsSet = 0; +String objectId = null; +for (int i = 0; i < numItemsInClause; i++) { +objectId = objectIdsList.get(i); +ps.setString((i + 1), objectId); +numbBindVarsSet++; +} +assertEquals(numItemsInClause, numbBindVarsSet); +assertEquals("v1000", objectId); +ps.setString(numItemsInClause + 1, "z00"); +ps.setString(numItemsInClause + 2, "v1000"); // This value must match or be + // lexographically higher than the highest + // value in the IN clause +// Query should execute and return 0 results +ResultSet rs = ps.executeQuery(); +assertFalse( +"Query should return no results as IN clause and RVC clause are disjoint sets", +rs.next()); +} +} + +private StringBuilder generateQueryToTest(int numItemsInClause, String fullViewName) { +StringBuilder querySb = +new StringBuilder("SELECT OBJECT_ID,OBJECT_DATA2,OBJECT_DATA FROM " + fullViewName); +querySb.append(" WHERE (("); +List orClauses = Lists.newArrayList(); +for (int i = 1; i < (numItemsInClause + 1); i++) { +orClauses.add("OBJECT_ID = ?"); +} +
phoenix git commit: PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up
Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 124ca6c39 -> faacf0469 PHOENIX-4734 SQL Query with an RVC expression lexographically higher than all values in an OR clause causes query to blow up Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/faacf046 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/faacf046 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/faacf046 Branch: refs/heads/4.x-HBase-0.98 Commit: faacf046998b89115a72c968ba4458820be91e64 Parents: 124ca6c Author: Thomas D'SilvaAuthored: Thu May 10 16:30:36 2018 -0700 Committer: Thomas D'Silva Committed: Fri May 11 09:32:53 2018 -0700 -- .../phoenix/end2end/RowValueConstructorIT.java | 120 +++ .../org/apache/phoenix/compile/ScanRanges.java | 5 + 2 files changed, 125 insertions(+) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/faacf046/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java index df7603a..fb04261 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java @@ -48,6 +48,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.util.List; import java.util.Properties; import org.apache.phoenix.util.DateUtil; @@ -57,6 +58,9 @@ import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; + public class RowValueConstructorIT extends ParallelStatsDisabledIT { @@ -1646,4 +1650,120 @@ public class RowValueConstructorIT extends ParallelStatsDisabledIT { assertEquals("value", rs.getString(3)); assertFalse(rs.next()); } + +@Test +/** + * Verifies that a query with a RVC expression lexographically higher than all values in an OR + * clause causes query works see PHOENIX-4734 + */ +public void testRVCWithAndClause() throws Exception { +final int numItemsInClause = 5; +Properties tenantProps = new Properties(); +tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); +String fullTableName = SchemaUtil.getTableName("S", "T_" + generateUniqueName()); +String fullViewName = SchemaUtil.getTableName("S", "V_" + generateUniqueName()); +try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { +tenantConn.setAutoCommit(false); +createBaseTableAndTenantView(tenantConn, fullTableName, fullViewName); +loadDataIntoTenantView(tenantConn, fullViewName); +List objectIdsList = +selectObjectIdsForInClause(tenantConn, fullViewName, numItemsInClause); +StringBuilder querySb = generateQueryToTest(numItemsInClause, fullViewName); +PreparedStatement ps = tenantConn.prepareStatement(querySb.toString()); +int numbBindVarsSet = 0; +String objectId = null; +for (int i = 0; i < numItemsInClause; i++) { +objectId = objectIdsList.get(i); +ps.setString((i + 1), objectId); +numbBindVarsSet++; +} +assertEquals(numItemsInClause, numbBindVarsSet); +assertEquals("v1000", objectId); +ps.setString(numItemsInClause + 1, "z00"); +ps.setString(numItemsInClause + 2, "v1000"); // This value must match or be + // lexographically higher than the highest + // value in the IN clause +// Query should execute and return 0 results +ResultSet rs = ps.executeQuery(); +assertFalse( +"Query should return no results as IN clause and RVC clause are disjoint sets", +rs.next()); +} +} + +private StringBuilder generateQueryToTest(int numItemsInClause, String fullViewName) { +StringBuilder querySb = +new StringBuilder("SELECT OBJECT_ID,OBJECT_DATA2,OBJECT_DATA FROM " + fullViewName); +querySb.append(" WHERE (("); +List orClauses = Lists.newArrayList(); +for (int i = 1; i < (numItemsInClause + 1); i++) { +orClauses.add("OBJECT_ID = ?"); +} +