You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by st...@apache.org on 2021/08/05 15:48:20 UTC
[phoenix-connectors] branch master updated: PHOENIX-6524 Hive
Connector returns emtpy AND expression when all children are pushed down
This is an automated email from the ASF dual-hosted git repository.
stoty pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix-connectors.git
The following commit(s) were added to refs/heads/master by this push:
new 349a2b2 PHOENIX-6524 Hive Connector returns emtpy AND expression when all children are pushed down
349a2b2 is described below
commit 349a2b2d7d5c4be78e99f7a94e20d47b22b68e6d
Author: Istvan Toth <st...@apache.org>
AuthorDate: Wed Aug 4 10:43:06 2021 +0200
PHOENIX-6524 Hive Connector returns emtpy AND expression when all children are pushed down
also fix incorrect phoenix.hbase.table.name property in some tests
---
.../apache/phoenix/hive/HivePhoenixStoreIT.java | 54 +++++++++++++++++++---
.../hive/ql/index/IndexPredicateAnalyzer.java | 5 ++
2 files changed, 52 insertions(+), 7 deletions(-)
diff --git a/phoenix-hive-base/src/it/java/org/apache/phoenix/hive/HivePhoenixStoreIT.java b/phoenix-hive-base/src/it/java/org/apache/phoenix/hive/HivePhoenixStoreIT.java
index bdd10e5..461ab99 100644
--- a/phoenix-hive-base/src/it/java/org/apache/phoenix/hive/HivePhoenixStoreIT.java
+++ b/phoenix-hive-base/src/it/java/org/apache/phoenix/hive/HivePhoenixStoreIT.java
@@ -139,7 +139,7 @@ public abstract class HivePhoenixStoreIT extends BaseHivePhoenixStoreIT {
"DOUBLE,fl FLOAT, us INT)" + HiveTestUtil.CRLF +
" STORED BY \"org.apache.phoenix.hive.PhoenixStorageHandler\"" + HiveTestUtil
.CRLF + " TBLPROPERTIES(" + HiveTestUtil.CRLF +
- " 'phoenix.hbase.table.name'='phoenix_datatype'," + HiveTestUtil.CRLF +
+ " 'phoenix.table.name'='phoenix_datatype'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.znode.parent'='/hbase'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.quorum'='localhost'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.client.port'='" +
@@ -185,7 +185,7 @@ public abstract class HivePhoenixStoreIT extends BaseHivePhoenixStoreIT {
" STORED BY \"org.apache.phoenix.hive.PhoenixStorageHandler\"" + HiveTestUtil
.CRLF +
" TBLPROPERTIES(" + HiveTestUtil.CRLF +
- " 'phoenix.hbase.table.name'='phoenix_MultiKey'," + HiveTestUtil.CRLF +
+ " 'phoenix.table.name'='phoenix_MultiKey'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.znode.parent'='/hbase'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.quorum'='localhost'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.client.port'='" +
@@ -233,7 +233,7 @@ public abstract class HivePhoenixStoreIT extends BaseHivePhoenixStoreIT {
" STORED BY \"org.apache.phoenix.hive.PhoenixStorageHandler\"" + HiveTestUtil
.CRLF +
" TBLPROPERTIES(" + HiveTestUtil.CRLF +
- " 'phoenix.hbase.table.name'='joinTable1'," + HiveTestUtil.CRLF +
+ " 'phoenix.table.name'='joinTable1'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.znode.parent'='/hbase'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.quorum'='localhost'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.client.port'='" +
@@ -244,7 +244,7 @@ public abstract class HivePhoenixStoreIT extends BaseHivePhoenixStoreIT {
" STORED BY \"org.apache.phoenix.hive.PhoenixStorageHandler\"" + HiveTestUtil
.CRLF +
" TBLPROPERTIES(" + HiveTestUtil.CRLF +
- " 'phoenix.hbase.table.name'='joinTable2'," + HiveTestUtil.CRLF +
+ " 'phoenix.table.name'='joinTable2'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.znode.parent'='/hbase'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.quorum'='localhost'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.client.port'='" +
@@ -283,7 +283,7 @@ public abstract class HivePhoenixStoreIT extends BaseHivePhoenixStoreIT {
" STORED BY \"org.apache.phoenix.hive.PhoenixStorageHandler\"" + HiveTestUtil
.CRLF +
" TBLPROPERTIES(" + HiveTestUtil.CRLF +
- " 'phoenix.hbase.table.name'='joinTable3'," + HiveTestUtil.CRLF +
+ " 'phoenix.table.name'='joinTable3'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.znode.parent'='/hbase'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.quorum'='localhost'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.client.port'='" +
@@ -295,7 +295,7 @@ public abstract class HivePhoenixStoreIT extends BaseHivePhoenixStoreIT {
" STORED BY \"org.apache.phoenix.hive.PhoenixStorageHandler\"" + HiveTestUtil
.CRLF +
" TBLPROPERTIES(" + HiveTestUtil.CRLF +
- " 'phoenix.hbase.table.name'='joinTable4'," + HiveTestUtil.CRLF +
+ " 'phoenix.table.name'='joinTable4'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.znode.parent'='/hbase'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.quorum'='localhost'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.client.port'='" +
@@ -344,7 +344,7 @@ public abstract class HivePhoenixStoreIT extends BaseHivePhoenixStoreIT {
" STORED BY \"org.apache.phoenix.hive.PhoenixStorageHandler\"" + HiveTestUtil
.CRLF +
" TBLPROPERTIES(" + HiveTestUtil.CRLF +
- " 'phoenix.hbase.table.name'='TIMESTAMPTABLE'," + HiveTestUtil.CRLF +
+ " 'phoenix.table.name'='TIMESTAMPTABLE'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.znode.parent'='/hbase'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.quorum'='localhost'," + HiveTestUtil.CRLF +
" 'phoenix.zookeeper.client.port'='" +
@@ -362,4 +362,44 @@ public abstract class HivePhoenixStoreIT extends BaseHivePhoenixStoreIT {
createFile(sb.toString(), fullPath);
runTest(testName, fullPath);
}
+
+ @Test
+ //For some reason, this test only fails on Mapreduce, and not on Tez
+ public void testCompletelyEliminateAnd() throws Exception {
+ String testName = "testCompletelyEliminateAnd";
+ utility.getTestFileSystem().createNewFile(new Path(hiveLogDir, testName + ".out"));
+ createFile("1\t1\tc_h\td_h\te_h\t2020-01-30 15:10:10\t2020-01-30\n", new Path(hiveOutputDir, testName + ".out").toString());
+ createFile(StringUtil.EMPTY_STRING, new Path(hiveLogDir, testName + ".out").toString());
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("CREATE EXTERNAL TABLE TEST_PHX (\n"
+ + "a_h string,\n"
+ + "b_h string,\n"
+ + "c_h string,\n"
+ + "d_h string,\n"
+ + "e_h string,\n"
+ + "f_h string,\n"
+ + "g_h string)\n"
+ + "ROW FORMAT SERDE\n"
+ + " 'org.apache.phoenix.hive.PhoenixSerDe'\n"
+ + "STORED BY\n"
+ + " 'org.apache.phoenix.hive.PhoenixStorageHandler'\n"
+ + "WITH SERDEPROPERTIES (\n"
+ + " 'serialization.format'='1')\n"
+ + "TBLPROPERTIES (\n"
+ + " 'bucketing_version'='2',\n"
+ + "'phoenix.rowkeys'='a_h, b_h, c_h, d_h, e_h, f_h' ,"
+ + "'phoenix.table.name'='TEST',\n"
+ + "'phoenix.zookeeper.client.port'='"+ utility.getZkCluster().getClientPort() + "',"
+ + "'phoenix.zookeeper.quorum'='localhost',\n"
+ + "'phoenix.zookeeper.znode.parent'='/hbase');" + HiveTestUtil.CRLF);
+
+ sb.append("INSERT into TEST_PHX values ('1', '1', 'c_h', 'd_h', 'e_h', '2020-01-30 15:10:10', '2020-01-30');\n" + HiveTestUtil.CRLF);
+
+ sb.append("SELECT * from TEST_PHX where f_h >=\"2020-01-30\" and b_h=\"1\";" + HiveTestUtil.CRLF);
+
+ String fullPath = new Path(utility.getDataTestDir(), testName).toString();
+ createFile(sb.toString(), fullPath);
+ runTest(testName, fullPath);
+ }
}
diff --git a/phoenix-hive-base/src/main/java/org/apache/phoenix/hive/ql/index/IndexPredicateAnalyzer.java b/phoenix-hive-base/src/main/java/org/apache/phoenix/hive/ql/index/IndexPredicateAnalyzer.java
index e4082bb..d9079da 100644
--- a/phoenix-hive-base/src/main/java/org/apache/phoenix/hive/ql/index/IndexPredicateAnalyzer.java
+++ b/phoenix-hive-base/src/main/java/org/apache/phoenix/hive/ql/index/IndexPredicateAnalyzer.java
@@ -360,7 +360,12 @@ public class IndexPredicateAnalyzer {
residuals.add((ExprNodeDesc) nodeOutput);
}
}
+ if (residuals.size() == 0) {
+ //All children were pushed down
+ return null;
+ }
if (residuals.size() == 1) {
+ //A single child remains
return residuals.get(0);
}
return new ExprNodeGenericFuncDesc(TypeInfoFactory.booleanTypeInfo, FunctionRegistry