phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sama...@apache.org
Subject phoenix git commit: NullPointerException when parsing a query with hints in UNION ALL (Alicia Ying Shu)
Date Thu, 15 Oct 2015 18:26:36 GMT
Repository: phoenix
Updated Branches:
  refs/heads/master d8333e838 -> d2a2d72b4


NullPointerException when parsing a query with hints in UNION ALL (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/d2a2d72b
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/d2a2d72b
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/d2a2d72b

Branch: refs/heads/master
Commit: d2a2d72b42612fd7df72d4fe08f432d4dc8816b4
Parents: d8333e8
Author: Samarth <samarth@apache.org>
Authored: Thu Oct 15 11:26:27 2015 -0700
Committer: Samarth <samarth@apache.org>
Committed: Thu Oct 15 11:26:27 2015 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/UnionAllIT.java  | 34 ++++++++++++++++++++
 .../apache/phoenix/execute/AggregatePlan.java   | 10 ++++--
 .../org/apache/phoenix/execute/ScanPlan.java    | 11 +++++--
 .../phoenix/iterate/BaseResultIterators.java    | 10 ++++--
 .../phoenix/iterate/UnionResultIterators.java   | 11 +++++--
 5 files changed, 68 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/d2a2d72b/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 1d4055a..6531129 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
@@ -645,4 +645,38 @@ public class UnionAllIT extends BaseOwnClusterHBaseManagedTimeIT {
             conn.close();
         }
     } 
+
+    @Test
+    public void testBug2295() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        conn.setAutoCommit(false);
+
+        try {
+            String ddl = "CREATE TABLE table1(" +
+                    "id BIGINT, col1 VARCHAR, col2 integer, CONSTRAINT pk PRIMARY KEY (id))
IMMUTABLE_ROWS=true";
+            createTestTable(getUrl(), ddl);
+
+            ddl = "CREATE TABLE table2(" +
+                    "id BIGINT, col1 VARCHAR, col2 integer, CONSTRAINT pk PRIMARY KEY (id))
IMMUTABLE_ROWS=true";
+            createTestTable(getUrl(), ddl);
+
+            ddl = "CREATE index idx_table1_col1 on table1(col1)";
+            createTestTable(getUrl(), ddl);
+
+            ddl = "CREATE index idx_table2_col1 on table2(col1)";
+            createTestTable(getUrl(), ddl);
+
+            ddl = "Explain SELECT /*+ INDEX(table1 idx_table1_col1) */ col1, col2 from table1
where col1='123' " +
+                    "union all SELECT /*+ INDEX(table2 idx_table2_col1) */ col1, col2 from
table2 where col1='123'"; 
+            ResultSet rs = conn.createStatement().executeQuery(ddl);
+            assertTrue(rs.next());
+        } finally {
+            String ddl = "drop table table1";
+            conn.createStatement().execute(ddl);
+            ddl = "drop table table2";
+            conn.createStatement().execute(ddl);
+            conn.close();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d2a2d72b/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java
index 9a415b9..e4f0fbe 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java
@@ -95,12 +95,18 @@ public class AggregatePlan extends BaseQueryPlan {
     
     @Override
     public List<KeyRange> getSplits() {
-        return splits;
+        if (splits == null)
+            return Collections.emptyList();
+        else
+            return splits;
     }
 
     @Override
     public List<List<Scan>> getScans() {
-        return scans;
+        if (scans == null)
+            return Collections.emptyList();
+        else
+            return scans;
     }
 
     private static class OrderingResultIteratorFactory implements ParallelIteratorFactory
{

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d2a2d72b/phoenix-core/src/main/java/org/apache/phoenix/execute/ScanPlan.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/ScanPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/ScanPlan.java
index 9f7e482..3098980 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/ScanPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/ScanPlan.java
@@ -19,6 +19,7 @@ package org.apache.phoenix.execute;
 
 
 import java.sql.SQLException;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.hadoop.hbase.HTableDescriptor;
@@ -156,12 +157,18 @@ public class ScanPlan extends BaseQueryPlan {
 
     @Override
     public List<KeyRange> getSplits() {
-        return splits;
+        if (splits == null)
+            return Collections.emptyList();
+        else
+            return splits;
     }
 
     @Override
     public List<List<Scan>> getScans() {
-        return scans;
+        if (scans == null)
+            return Collections.emptyList();
+        else
+            return scans;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d2a2d72b/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 341bd57..ec961d5 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
@@ -305,12 +305,18 @@ public abstract class BaseResultIterators extends ExplainTable implements
Result
 
     @Override
     public List<KeyRange> getSplits() {
-        return splits;
+        if (splits == null)
+            return Collections.emptyList();
+        else
+            return splits;
     }
 
     @Override
     public List<List<Scan>> getScans() {
-        return scans;
+        if (scans == null)
+            return Collections.emptyList();
+        else
+            return scans;
     }
 
     private static List<byte[]> toBoundaries(List<HRegionLocation> regionLocations)
{

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d2a2d72b/phoenix-core/src/main/java/org/apache/phoenix/iterate/UnionResultIterators.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/UnionResultIterators.java
b/phoenix-core/src/main/java/org/apache/phoenix/iterate/UnionResultIterators.java
index 2296982..5018dad 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/UnionResultIterators.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/UnionResultIterators.java
@@ -18,6 +18,7 @@
 package org.apache.phoenix.iterate;
 
 import java.sql.SQLException;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.hadoop.hbase.client.Scan;
@@ -66,7 +67,10 @@ public class UnionResultIterators implements ResultIterators {
 
     @Override
     public List<KeyRange> getSplits() {
-        return splits;
+        if (splits == null)
+            return Collections.emptyList();
+        else
+            return splits;
     }
 
     @Override
@@ -113,7 +117,10 @@ public class UnionResultIterators implements ResultIterators {
     
     @Override
     public List<List<Scan>> getScans() {
-        return scans;
+        if (scans == null)
+            return Collections.emptyList();
+        else
+            return scans;
     }
 
     @Override


Mime
View raw message