Repository: kylin
Updated Branches:
  refs/heads/KYLIN-1971 c1e6ff680 -> 8974b99af


ITQuery pass


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

Branch: refs/heads/KYLIN-1971
Commit: 8974b99afb4b1f18f33ea8b533925a9e73a736ca
Parents: c1e6ff6
Author: Yang Li <liy...@apache.org>
Authored: Wed Oct 26 21:58:02 2016 +0800
Committer: Yang Li <liy...@apache.org>
Committed: Wed Oct 26 21:58:02 2016 +0800

----------------------------------------------------------------------
 .../relnode/OLAPToEnumerableConverter.java      | 41 ++++++++------------
 1 file changed, 17 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/8974b99a/query/src/main/java/org/apache/kylin/query/relnode/OLAPToEnumerableConverter.java
----------------------------------------------------------------------
diff --git 
a/query/src/main/java/org/apache/kylin/query/relnode/OLAPToEnumerableConverter.java
 
b/query/src/main/java/org/apache/kylin/query/relnode/OLAPToEnumerableConverter.java
index 24fc430..1233422 100644
--- 
a/query/src/main/java/org/apache/kylin/query/relnode/OLAPToEnumerableConverter.java
+++ 
b/query/src/main/java/org/apache/kylin/query/relnode/OLAPToEnumerableConverter.java
@@ -48,7 +48,6 @@ import 
org.apache.kylin.metadata.filter.TupleFilter.FilterOperatorEnum;
 import org.apache.kylin.metadata.model.TblColRef;
 import org.apache.kylin.metadata.realization.IRealization;
 import org.apache.kylin.query.routing.ModelChooser;
-import org.apache.kylin.query.routing.NoRealizationFoundException;
 import org.apache.kylin.query.routing.QueryRouter;
 import org.apache.kylin.query.schema.OLAPTable;
 
@@ -79,30 +78,23 @@ public class OLAPToEnumerableConverter extends 
ConverterImpl implements Enumerab
         OLAPRel.OLAPImplementor olapImplementor = new 
OLAPRel.OLAPImplementor();
         olapImplementor.visitChild(getInput(), this);
 
-        // find cube from olap context and apply cell level security
-        try {
-            for (OLAPContext context : OLAPContext.getThreadLocalContexts()) {
-                // Context has no table scan is created by OLAPJoinRel which 
looks like
-                //     (sub-query) as A join (sub-query) as B
-                // No realization needed for such context.
-                if (context.firstTableScan == null) {
-                    continue;
-                }
-
-                Set<IRealization> candidates = 
ModelChooser.selectModel(context);
-                IRealization realization = 
QueryRouter.selectRealization(context, candidates);
-                context.realization = realization;
-
-                doAccessControl(context);
-            }
-        } catch (NoRealizationFoundException e) {
-            OLAPContext ctx0 = (OLAPContext) 
OLAPContext.getThreadLocalContexts().toArray()[0];
-            if (ctx0 != null && ctx0.olapSchema.hasStarSchemaUrl()) {
-                // generate hive result
-                return buildHiveResult(enumImplementor, pref, ctx0);
-            } else {
-                throw e;
+        // identify cube from olap context
+        int contextCount = OLAPContext.getThreadLocalContexts().size();
+        for (int i = contextCount - 1; i >= 0; i--) {
+            OLAPContext context = OLAPContext.getThreadLocalContextById(i);
+            
+            // Context has no table scan is created by OLAPJoinRel which looks 
like
+            //     (sub-query) as A join (sub-query) as B
+            // No realization needed for such context.
+            if (context.firstTableScan == null) {
+                continue;
             }
+
+            Set<IRealization> candidates = ModelChooser.selectModel(context);
+            IRealization realization = QueryRouter.selectRealization(context, 
candidates);
+            context.realization = realization;
+
+            doAccessControl(context);
         }
 
         // rewrite query if necessary
@@ -176,6 +168,7 @@ public class OLAPToEnumerableConverter extends 
ConverterImpl implements Enumerab
         }
     }
 
+    @SuppressWarnings("unused")
     private Result buildHiveResult(EnumerableRelImplementor enumImplementor, 
Prefer pref, OLAPContext context) {
         RelDataType hiveRowType = getRowType();
 

Reply via email to