You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2015/06/18 02:16:38 UTC
[1/3] phoenix git commit: PHOENIX-2014 WHERE search condition ignored
when also using row value constructor in view
Repository: phoenix
Updated Branches:
refs/heads/master 80600488f -> 2d70eff65
PHOENIX-2014 WHERE search condition ignored when also using row value constructor in view
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/14d11b13
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/14d11b13
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/14d11b13
Branch: refs/heads/master
Commit: 14d11b130ca0b3726e7724a1f4a9770bc1cb2453
Parents: 8060048
Author: James Taylor <ja...@apache.org>
Authored: Wed Jun 17 16:58:51 2015 -0700
Committer: James Taylor <ja...@apache.org>
Committed: Wed Jun 17 16:58:51 2015 -0700
----------------------------------------------------------------------
.../phoenix/end2end/RowValueConstructorIT.java | 28 ++++++++++++++++++++
.../apache/phoenix/compile/WhereOptimizer.java | 25 ++++++++++-------
.../phoenix/compile/WhereOptimizerTest.java | 20 ++++++++++++++
3 files changed, 64 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/14d11b13/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 3859785..e227eb0 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
@@ -1395,4 +1395,32 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
assertEquals(1, numRecords);
}
+ @Test
+ public void testRVCInView() throws Exception {
+ Connection conn = nextConnection(getUrl());
+ conn.createStatement().execute("CREATE TABLE TEST_TABLE.TEST1 (\n" +
+ "PK1 CHAR(3) NOT NULL, \n" +
+ "PK2 CHAR(3) NOT NULL,\n" +
+ "DATA1 CHAR(10)\n" +
+ "CONSTRAINT PK PRIMARY KEY (PK1, PK2))");
+ conn.close();
+ conn = nextConnection(getUrl());
+ conn.createStatement().execute("CREATE VIEW TEST_TABLE.FOO AS SELECT * FROM TEST_TABLE.TEST1 WHERE PK1 = 'FOO'");
+ conn.close();
+ conn = nextConnection(getUrl());
+ conn.createStatement().execute("UPSERT INTO TEST_TABLE.TEST1 VALUES('FOO','001','SOMEDATA')");
+ conn.createStatement().execute("UPSERT INTO TEST_TABLE.TEST1 VALUES('FOO','002','SOMEDATA')");
+ conn.createStatement().execute("UPSERT INTO TEST_TABLE.TEST1 VALUES('FOO','003','SOMEDATA')");
+ conn.createStatement().execute("UPSERT INTO TEST_TABLE.TEST1 VALUES('FOO','004','SOMEDATA')");
+ conn.createStatement().execute("UPSERT INTO TEST_TABLE.TEST1 VALUES('FOO','005','SOMEDATA')");
+ conn.commit();
+ conn.close();
+
+ conn = nextConnection(getUrl());
+ ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST_TABLE.FOO WHERE PK2 < '004' AND (PK1,PK2) > ('FOO','002') LIMIT 2");
+ assertTrue(rs.next());
+ assertEquals("003", rs.getString("PK2"));
+ assertFalse(rs.next());
+ conn.close();
+ }
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/14d11b13/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
index a5aef02..b7f04e0 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
@@ -647,23 +647,30 @@ public class WhereOptimizer {
if (childSlot == EMPTY_KEY_SLOTS) {
return EMPTY_KEY_SLOTS;
}
- // FIXME: get rid of this min/max range BS now that a key range can span multiple columns
+ // FIXME: get rid of this special-cased min/max range now that a key range can span multiple columns
if (childSlot.getMinMaxRange() != null) { // Only set if in initial pk position
- // TODO: potentially use KeySlot.intersect here. However, we can't intersect the key ranges in the slot
- // with our minMaxRange, since it spans columns and this would mess up our skip scan.
+ // TODO: fix intersectSlots so that it works with RVCs. We'd just need to fill in the leading parts
+ // of the key with the minMaxRange and then intersect the key parts that overlap.
minMaxRange = minMaxRange.intersect(childSlot.getMinMaxRange());
for (KeySlot slot : childSlot) {
if (slot != null) {
- minMaxExtractNodes.addAll(slot.getKeyPart().getExtractNodes());
+ // We can only definitely extract the expression nodes that start from the
+ // leading PK column. They may get extracted at the end if we end up having
+ // expressions matching the leading PK columns, but otherwise we'll be forced
+ // to execute the expression in a filter.
+ if (slot.getPKPosition() == initPosition) {
+ minMaxExtractNodes.addAll(slot.getKeyPart().getExtractNodes());
+ } else {
+ if (!intersectSlots(keySlot, slot)) {
+ return EMPTY_KEY_SLOTS;
+ }
+ }
}
}
} else {
for (KeySlot slot : childSlot) {
- // We have a nested AND with nothing for this slot, so continue
- if (slot == null) {
- continue;
- }
- if (!intersectSlots(keySlot, slot)) {
+ // The slot will be null if we have no condition for this slot
+ if (slot != null && !intersectSlots(keySlot, slot)) {
return EMPTY_KEY_SLOTS;
}
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/14d11b13/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java
index f40afc3..adbd9a2 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java
@@ -1780,6 +1780,26 @@ public class WhereOptimizerTest extends BaseConnectionlessQueryTest {
PChar.INSTANCE.toBytes(entityId2), 15)), k2.getLowerRange());
}
+
+ @Test
+ public void testRVCInView() throws Exception {
+ Connection conn = DriverManager.getConnection(getUrl());
+ conn.createStatement().execute("CREATE TABLE TEST_TABLE.TEST1 (\n" +
+ "PK1 CHAR(3) NOT NULL, \n" +
+ "PK2 CHAR(3) NOT NULL,\n" +
+ "DATA1 CHAR(10)\n" +
+ "CONSTRAINT PK PRIMARY KEY (PK1, PK2))");
+ conn.createStatement().execute("CREATE VIEW TEST_TABLE.FOO AS SELECT * FROM TEST_TABLE.TEST1 WHERE PK1 = 'FOO'");
+ String query = "SELECT * FROM TEST_TABLE.FOO WHERE PK2 < '004' AND (PK1,PK2) > ('FOO','002') LIMIT 2";
+ Scan scan = compileStatement(query, Collections.emptyList(), 2).getScan();
+ byte[] startRow = ByteUtil.nextKey(ByteUtil.concat(PChar.INSTANCE.toBytes("FOO"),
+ PVarchar.INSTANCE.toBytes("002")));
+ assertArrayEquals(startRow, scan.getStartRow());
+ byte[] stopRow = ByteUtil.concat(PChar.INSTANCE.toBytes("FOO"),
+ PChar.INSTANCE.toBytes("004"));
+ assertArrayEquals(stopRow, scan.getStopRow());
+ }
+
private static StatementContext compileStatementTenantSpecific(String tenantId, String query, List<Object> binds) throws Exception {
PhoenixConnection pconn = getTenantSpecificConnection("tenantId").unwrap(PhoenixConnection.class);
PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query);
[3/3] phoenix git commit: PHOENIX-2049 Change ArraysWithNullsIT to be
derived from BaseHBaseManagedTimeIT
Posted by ja...@apache.org.
PHOENIX-2049 Change ArraysWithNullsIT to be derived from BaseHBaseManagedTimeIT
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/2d70eff6
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/2d70eff6
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/2d70eff6
Branch: refs/heads/master
Commit: 2d70eff6594d0f46b10f2d9c4c8fa5d43d6ba5ab
Parents: fb44f35
Author: James Taylor <ja...@apache.org>
Authored: Wed Jun 17 17:09:33 2015 -0700
Committer: James Taylor <ja...@apache.org>
Committed: Wed Jun 17 17:13:31 2015 -0700
----------------------------------------------------------------------
.../src/it/java/org/apache/phoenix/end2end/ArraysWithNullsIT.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/2d70eff6/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArraysWithNullsIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArraysWithNullsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArraysWithNullsIT.java
index b034193..e95a386 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArraysWithNullsIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArraysWithNullsIT.java
@@ -26,7 +26,7 @@ import org.apache.phoenix.schema.types.PTimestamp;
import org.apache.phoenix.schema.types.PhoenixArray;
import org.junit.Test;
-public class ArraysWithNullsIT extends BaseClientManagedTimeIT {
+public class ArraysWithNullsIT extends BaseHBaseManagedTimeIT {
@Test
public void testArrayUpsertIntWithNulls() throws Exception {
[2/3] phoenix git commit: PHOENIX-2025 Phoenix-core's
hbase-default.xml prevents HBaseTestingUtility from starting up in client
apps (Geoffrey Jacoby)
Posted by ja...@apache.org.
PHOENIX-2025 Phoenix-core's hbase-default.xml prevents HBaseTestingUtility from starting up in client apps (Geoffrey Jacoby)
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/fb44f353
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/fb44f353
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/fb44f353
Branch: refs/heads/master
Commit: fb44f35300510670b037f597ee66f709cb4d8dbb
Parents: 14d11b1
Author: James Taylor <ja...@apache.org>
Authored: Wed Jun 17 17:01:34 2015 -0700
Committer: James Taylor <ja...@apache.org>
Committed: Wed Jun 17 17:13:25 2015 -0700
----------------------------------------------------------------------
phoenix-core/src/it/resources/hbase-default.xml | 36 --------------------
phoenix-core/src/it/resources/hbase-site.xml | 36 ++++++++++++++++++++
.../phoenix/compile/WhereCompilerTest.java | 10 ++++--
.../phoenix/query/ConnectionlessTest.java | 14 +-------
.../src/test/resources/hbase-default.xml | 36 --------------------
5 files changed, 45 insertions(+), 87 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/fb44f353/phoenix-core/src/it/resources/hbase-default.xml
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/resources/hbase-default.xml b/phoenix-core/src/it/resources/hbase-default.xml
deleted file mode 100644
index 691b702..0000000
--- a/phoenix-core/src/it/resources/hbase-default.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-<!--
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-<configuration>
- <property>
- <name>hbase.defaults.for.version.skip</name>
- <value>true</value>
- <description>
- Set to true to skip the 'hbase.defaults.for.version' check.
- Setting this to true can be useful in contexts other than
- the other side of a maven generation; i.e. running in an
- ide. You'll want to set this boolean to true to avoid
- seeing the RuntimException complaint: "hbase-default.xml file
- seems to be for and old version of HBase (@@@VERSION@@@), this
- version is X.X.X-SNAPSHOT"
- </description>
- </property>
-</configuration>
http://git-wip-us.apache.org/repos/asf/phoenix/blob/fb44f353/phoenix-core/src/it/resources/hbase-site.xml
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/resources/hbase-site.xml b/phoenix-core/src/it/resources/hbase-site.xml
new file mode 100644
index 0000000..691b702
--- /dev/null
+++ b/phoenix-core/src/it/resources/hbase-site.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<!--
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<configuration>
+ <property>
+ <name>hbase.defaults.for.version.skip</name>
+ <value>true</value>
+ <description>
+ Set to true to skip the 'hbase.defaults.for.version' check.
+ Setting this to true can be useful in contexts other than
+ the other side of a maven generation; i.e. running in an
+ ide. You'll want to set this boolean to true to avoid
+ seeing the RuntimException complaint: "hbase-default.xml file
+ seems to be for and old version of HBase (@@@VERSION@@@), this
+ version is X.X.X-SNAPSHOT"
+ </description>
+ </property>
+</configuration>
http://git-wip-us.apache.org/repos/asf/phoenix/blob/fb44f353/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java
index 3a012fb..6c040d2 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java
@@ -44,6 +44,9 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
import org.apache.hadoop.hbase.filter.Filter;
@@ -943,8 +946,11 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest {
PhoenixPreparedStatement pstmt = newPreparedStatement(pconn, query);
QueryPlan plan = pstmt.optimizeQuery();
Scan scan = plan.getContext().getScan();
- assertEquals(QueryServicesOptions.DEFAULT_SCAN_CACHE_SIZE, pstmt.getFetchSize());
- assertEquals(QueryServicesOptions.DEFAULT_SCAN_CACHE_SIZE, scan.getCaching());
+ Configuration config = HBaseConfiguration.create();
+ int defaultScannerCacheSize = config.getInt(HConstants.HBASE_CLIENT_SCANNER_CACHING,
+ HConstants.DEFAULT_HBASE_CLIENT_SCANNER_CACHING);
+ assertEquals(defaultScannerCacheSize, pstmt.getFetchSize());
+ assertEquals(defaultScannerCacheSize, scan.getCaching());
}
@Test
http://git-wip-us.apache.org/repos/asf/phoenix/blob/fb44f353/phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionlessTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionlessTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionlessTest.java
index 2b2841b..732563f 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionlessTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionlessTest.java
@@ -22,7 +22,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.sql.Connection;
import java.sql.Date;
@@ -36,14 +35,13 @@ import java.util.Properties;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
-import org.apache.phoenix.exception.SQLExceptionCode;
import org.apache.phoenix.jdbc.PhoenixConnection;
import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
import org.apache.phoenix.jdbc.PhoenixDriver;
+import org.apache.phoenix.schema.SaltingUtil;
import org.apache.phoenix.schema.types.PChar;
import org.apache.phoenix.schema.types.PDate;
import org.apache.phoenix.schema.types.PVarchar;
-import org.apache.phoenix.schema.SaltingUtil;
import org.apache.phoenix.util.ByteUtil;
import org.apache.phoenix.util.PhoenixRuntime;
import org.apache.phoenix.util.StringUtil;
@@ -172,16 +170,6 @@ public class ConnectionlessTest {
}
@Test
- public void testNoConnectionInfo() throws Exception {
- try {
- DriverManager.getConnection(PhoenixRuntime.JDBC_PROTOCOL);
- fail();
- } catch (SQLException e) {
- assertEquals(SQLExceptionCode.MALFORMED_CONNECTION_URL.getSQLState(),e.getSQLState());
- }
- }
-
- @Test
public void testMultipleConnectionQueryServices() throws Exception {
String url1 = getUrl();
String url2 = url1 + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + "LongRunningQueries";
http://git-wip-us.apache.org/repos/asf/phoenix/blob/fb44f353/phoenix-core/src/test/resources/hbase-default.xml
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/resources/hbase-default.xml b/phoenix-core/src/test/resources/hbase-default.xml
deleted file mode 100644
index 691b702..0000000
--- a/phoenix-core/src/test/resources/hbase-default.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-<!--
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-<configuration>
- <property>
- <name>hbase.defaults.for.version.skip</name>
- <value>true</value>
- <description>
- Set to true to skip the 'hbase.defaults.for.version' check.
- Setting this to true can be useful in contexts other than
- the other side of a maven generation; i.e. running in an
- ide. You'll want to set this boolean to true to avoid
- seeing the RuntimException complaint: "hbase-default.xml file
- seems to be for and old version of HBase (@@@VERSION@@@), this
- version is X.X.X-SNAPSHOT"
- </description>
- </property>
-</configuration>