Repository: phoenix
Updated Branches:
  refs/heads/calcite 4075d76e5 -> d2b995c83


PHOENIX-3341 Schema update is not visible to following statements of the same 
connection due to CalciteSchema caching.


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

Branch: refs/heads/calcite
Commit: d2b995c838e03699f58e33e4d91cbd19bfe62bc8
Parents: 4075d76
Author: maryannxue <maryann....@gmail.com>
Authored: Wed May 24 21:35:26 2017 +0800
Committer: maryannxue <maryann....@gmail.com>
Committed: Wed May 24 21:35:26 2017 +0800

----------------------------------------------------------------------
 .../phoenix/calcite/PhoenixPrepareImpl.java     | 20 --------------------
 .../apache/phoenix/calcite/PhoenixSchema.java   | 11 ++++-------
 .../phoenix/calcite/ToExpressionTest.java       |  5 +++++
 3 files changed, 9 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/d2b995c8/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 91b0cb6..1ee84f0 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
@@ -23,19 +23,14 @@ import org.apache.calcite.plan.RelOptCostFactory;
 import org.apache.calcite.plan.RelOptPlanner;
 import org.apache.calcite.plan.RelOptRule;
 import org.apache.calcite.prepare.CalcitePrepareImpl;
-import org.apache.calcite.prepare.Prepare.PreparedResult;
 import org.apache.calcite.rel.RelNode;
-import org.apache.calcite.rel.RelRoot;
 import org.apache.calcite.rel.convert.ConverterRule;
-import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rex.RexBuilder;
 import org.apache.calcite.runtime.Hook;
 import org.apache.calcite.runtime.Hook.Closeable;
 import org.apache.calcite.schema.SchemaPlus;
 import org.apache.calcite.sql.SqlColumnDefInPkConstraintNode;
 import org.apache.calcite.sql.SqlColumnDefNode;
-import org.apache.calcite.sql.SqlExplainFormat;
-import org.apache.calcite.sql.SqlExplainLevel;
 import org.apache.calcite.sql.SqlFunctionArguementNode;
 import org.apache.calcite.sql.SqlIdentifier;
 import org.apache.calcite.sql.SqlIndexExpressionNode;
@@ -248,21 +243,6 @@ public class PhoenixPrepareImpl extends CalcitePrepareImpl 
{
             boolean materializationEnabled, final boolean forceDecorrelate) {
         final List<Closeable> hooks = Lists.newArrayList();
 
-        hooks.add(Hook.PARSE_TREE.add(new Function<Object[], Object>() {
-            @Override
-            public Object apply(Object[] input) {
-                for (CalciteSchema schema : 
rootSchema.getSubSchemaMap().values()) {
-                    if (schema.schema instanceof PhoenixSchema) {
-                        ((PhoenixSchema) schema.schema).clear();
-                        for (CalciteSchema subSchema : 
schema.getSubSchemaMap().values()) {
-                            ((PhoenixSchema) subSchema.schema).clear();
-                        }
-                    }
-                }
-                return null;
-            }
-        }));
-
         hooks.add(Hook.TRIMMED.add(new Function<RelNode, Object>() {
             @Override
             public Object apply(RelNode root) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d2b995c8/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixSchema.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixSchema.java 
b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixSchema.java
index 315556a..6d9afdf 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixSchema.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixSchema.java
@@ -13,7 +13,6 @@ import org.apache.calcite.materialize.MaterializationService;
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeFactory;
 import org.apache.calcite.schema.*;
-import org.apache.calcite.schema.Table;
 import org.apache.calcite.schema.impl.TableFunctionImpl;
 import org.apache.calcite.schema.impl.ViewTable;
 import org.apache.calcite.sql.ListJarsTable;
@@ -438,12 +437,10 @@ public class PhoenixSchema implements Schema {
     public boolean contentsHaveChangedSince(long lastCheck, long now) {
         return lastCheck != now;
     }
-    
-    public void clear() {
-        tables.clear();
-        views.clear();
-        this.views.put("ListJars", listJarsFunction);
-        viewTables.clear();
+
+    @Override
+    public Schema snapshot(long now) {
+        return new PhoenixSchema(name, schemaName, parentSchema, pc, 
typeFactory);
     }
     
     public void defineIndexesAsMaterializations() {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d2b995c8/phoenix-core/src/test/java/org/apache/phoenix/calcite/ToExpressionTest.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/calcite/ToExpressionTest.java 
b/phoenix-core/src/test/java/org/apache/phoenix/calcite/ToExpressionTest.java
index e1afa84..5bfc77b 100644
--- 
a/phoenix-core/src/test/java/org/apache/phoenix/calcite/ToExpressionTest.java
+++ 
b/phoenix-core/src/test/java/org/apache/phoenix/calcite/ToExpressionTest.java
@@ -223,6 +223,11 @@ public class ToExpressionTest extends 
BaseConnectionlessQueryTest {
         public boolean contentsHaveChangedSince(long lastCheck, long now) {
             return false;
         }
+
+        @Override
+        public Schema snapshot(long now) {
+            return this;
+        }
            
        }
 }

Reply via email to