You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ma...@apache.org on 2017/04/06 00:31:43 UTC

phoenix git commit: PHOENIX-3768 Fix 'Phoenix schema not found' error

Repository: phoenix
Updated Branches:
  refs/heads/calcite 9ac3aa83e -> d1678c713


PHOENIX-3768 Fix 'Phoenix schema not found' error


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

Branch: refs/heads/calcite
Commit: d1678c7134848742aa3ae11df24d0a335bdae467
Parents: 9ac3aa8
Author: maryannxue <ma...@gmail.com>
Authored: Wed Apr 5 17:31:34 2017 -0700
Committer: maryannxue <ma...@gmail.com>
Committed: Wed Apr 5 17:31:34 2017 -0700

----------------------------------------------------------------------
 .../phoenix/calcite/PhoenixPrepareImpl.java     | 23 +++++++++++++++++-
 .../phoenix/calcite/rel/PhoenixValues.java      | 25 ++------------------
 2 files changed, 24 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/d1678c71/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixPrepareImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixPrepareImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixPrepareImpl.java
index c07bd6f..b6d0035 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixPrepareImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixPrepareImpl.java
@@ -1,6 +1,12 @@
 package org.apache.phoenix.calcite;
 
+import static org.apache.phoenix.util.PhoenixRuntime.CONNECTIONLESS;
+import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL;
+import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR;
+
 import java.lang.reflect.Type;
+import java.sql.Connection;
+import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -115,6 +121,21 @@ import com.google.common.collect.Lists;
 public class PhoenixPrepareImpl extends CalcitePrepareImpl {
     public static final ThreadLocal<String> THREAD_SQL_STRING =
         new ThreadLocal<>();
+    
+    public static final PhoenixConnection CONNECTIONLESS_PHOENIX_CONNECTION;
+    static {
+        try {
+            Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
+            final Connection connection =
+                DriverManager.getConnection(JDBC_PROTOCOL + JDBC_PROTOCOL_SEPARATOR + CONNECTIONLESS);
+            CONNECTIONLESS_PHOENIX_CONNECTION =
+                connection.unwrap(PhoenixConnection.class);
+        } catch (ClassNotFoundException e) {
+            throw new RuntimeException(e);
+        } catch (SQLException e) {
+            throw new RuntimeException(e);
+        }
+    }
 
     protected final RelOptRule[] defaultConverterRules;
 
@@ -718,6 +739,6 @@ public class PhoenixPrepareImpl extends CalcitePrepareImpl {
             } catch (ClassCastException e) {
             }
         }
-        throw new RuntimeException("Phoenix schema not found.");
+        return CONNECTIONLESS_PHOENIX_CONNECTION;
     }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d1678c71/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixValues.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixValues.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixValues.java
index 886e861..c979da1 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixValues.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixValues.java
@@ -1,11 +1,5 @@
 package org.apache.phoenix.calcite.rel;
 
-import static org.apache.phoenix.util.PhoenixRuntime.CONNECTIONLESS;
-import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL;
-import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.Iterator;
 import java.util.List;
@@ -28,6 +22,7 @@ import org.apache.calcite.rex.RexLiteral;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.phoenix.calcite.CalciteUtils;
+import org.apache.phoenix.calcite.PhoenixPrepareImpl;
 import org.apache.phoenix.calcite.TableMapping;
 import org.apache.phoenix.compile.OrderByCompiler.OrderBy;
 import org.apache.phoenix.compile.ColumnResolver;
@@ -39,7 +34,6 @@ import org.apache.phoenix.compile.StatementContext;
 import org.apache.phoenix.execute.LiteralResultIterationPlan;
 import org.apache.phoenix.execute.TupleProjector;
 import org.apache.phoenix.expression.Expression;
-import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.jdbc.PhoenixStatement;
 import org.apache.phoenix.parse.SelectStatement;
 import org.apache.phoenix.schema.PTable;
@@ -57,21 +51,6 @@ import com.google.common.collect.Lists;
  */
 public class PhoenixValues extends Values implements PhoenixQueryRel {
     
-    private static final PhoenixConnection phoenixConnection;
-    static {
-        try {
-            Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
-            final Connection connection =
-                DriverManager.getConnection(JDBC_PROTOCOL + JDBC_PROTOCOL_SEPARATOR + CONNECTIONLESS);
-            phoenixConnection =
-                connection.unwrap(PhoenixConnection.class);
-        } catch (ClassNotFoundException e) {
-            throw new RuntimeException(e);
-        } catch (SQLException e) {
-            throw new RuntimeException(e);
-        }
-    }
-    
     public static PhoenixValues create(RelOptCluster cluster, final RelDataType rowType, final ImmutableList<ImmutableList<RexLiteral>> tuples) {
         final RelMetadataQuery mq = RelMetadataQuery.instance();
         final RelTraitSet traits =
@@ -125,7 +104,7 @@ public class PhoenixValues extends Values implements PhoenixQueryRel {
         implementor.setTableMapping(tableMapping);
         
         try {
-            PhoenixStatement stmt = new PhoenixStatement(phoenixConnection);
+            PhoenixStatement stmt = new PhoenixStatement(PhoenixPrepareImpl.CONNECTIONLESS_PHOENIX_CONNECTION);
             ColumnResolver resolver = FromCompiler.getResolver(tableMapping.getTableRef());
             StatementContext context = new StatementContext(stmt, resolver, new Scan(), new SequenceManager(stmt));
             return new LiteralResultIterationPlan(literalResult, context, SelectStatement.SELECT_ONE, TableRef.EMPTY_TABLE_REF, RowProjector.EMPTY_PROJECTOR, null, null, OrderBy.EMPTY_ORDER_BY, null);