phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maryann...@apache.org
Subject phoenix git commit: PHOENIX-1917 Correlated subquery fails if the inner query contains JOIN
Date Fri, 24 Apr 2015 20:05:13 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 269e86ab6 -> 43a7aba9b


PHOENIX-1917 Correlated subquery fails if the inner query contains JOIN


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/43a7aba9
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/43a7aba9
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/43a7aba9

Branch: refs/heads/4.x-HBase-0.98
Commit: 43a7aba9b5ddd6cc3fc285a7a4a35554740b6a96
Parents: 269e86a
Author: maryannxue <wei.xue@intel.com>
Authored: Fri Apr 24 16:04:38 2015 -0400
Committer: maryannxue <wei.xue@intel.com>
Committed: Fri Apr 24 16:04:38 2015 -0400

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/SubqueryIT.java    | 18 ++++++++++++++++++
 .../apache/phoenix/compile/SubqueryRewriter.java  |  2 ++
 2 files changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/43a7aba9/phoenix-core/src/it/java/org/apache/phoenix/end2end/SubqueryIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SubqueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SubqueryIT.java
index 13354da..794c4f5 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SubqueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SubqueryIT.java
@@ -648,6 +648,24 @@ public class SubqueryIT extends BaseHBaseManagedTimeIT {
 
             assertFalse(rs.next());
 
+            query = "SELECT \"order_id\", name FROM " + JOIN_ORDER_TABLE_FULL_NAME + " o
JOIN " + JOIN_ITEM_TABLE_FULL_NAME + " i ON o.\"item_id\" = i.\"item_id\" WHERE quantity =
(SELECT max(quantity) FROM " + JOIN_ITEM_TABLE_FULL_NAME + " i2 JOIN " + JOIN_ORDER_TABLE_FULL_NAME
+ " q ON i2.\"item_id\" = q.\"item_id\" WHERE o.\"item_id\" = i2.\"item_id\")";
+            statement = conn.prepareStatement(query);
+            rs = statement.executeQuery();
+            assertTrue (rs.next());
+            assertEquals(rs.getString(1), "000000000000001");
+            assertEquals(rs.getString(2), "T1");
+            assertTrue (rs.next());
+            assertEquals(rs.getString(1), "000000000000003");
+            assertEquals(rs.getString(2), "T2");
+            assertTrue (rs.next());
+            assertEquals(rs.getString(1), "000000000000004");
+            assertEquals(rs.getString(2), "T6");
+            assertTrue (rs.next());
+            assertEquals(rs.getString(1), "000000000000005");
+            assertEquals(rs.getString(2), "T3");
+
+            assertFalse(rs.next());
+
             query = "SELECT name from " + JOIN_CUSTOMER_TABLE_FULL_NAME + " WHERE \"customer_id\"
IN (SELECT \"customer_id\" FROM " + JOIN_ITEM_TABLE_FULL_NAME + " i JOIN " + JOIN_ORDER_TABLE_FULL_NAME
+ " o ON o.\"item_id\" = i.\"item_id\" WHERE i.name = 'T2' OR quantity > (SELECT avg(quantity)
FROM " + JOIN_ORDER_TABLE_FULL_NAME + " q WHERE o.\"item_id\" = q.\"item_id\"))";
             statement = conn.prepareStatement(query);
             rs = statement.executeQuery();

http://git-wip-us.apache.org/repos/asf/phoenix/blob/43a7aba9/phoenix-core/src/main/java/org/apache/phoenix/compile/SubqueryRewriter.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/SubqueryRewriter.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/SubqueryRewriter.java
index 8e887a8..1746d8a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/SubqueryRewriter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/SubqueryRewriter.java
@@ -52,6 +52,7 @@ import org.apache.phoenix.parse.TableName;
 import org.apache.phoenix.parse.TableNode;
 import org.apache.phoenix.schema.ColumnFamilyNotFoundException;
 import org.apache.phoenix.schema.ColumnNotFoundException;
+import org.apache.phoenix.schema.TableNotFoundException;
 
 import com.google.common.collect.Lists;
 
@@ -557,6 +558,7 @@ public class SubqueryRewriter extends ParseNodeRewriter {
                 localResolver.resolveColumn(node.getSchemaName(), node.getTableName(), node.getName());
                 addType(true);
                 return null;
+            } catch (TableNotFoundException e) {
             } catch (ColumnNotFoundException e) { 
             } catch (ColumnFamilyNotFoundException e) {
             }


Mime
View raw message