lens-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pro...@apache.org
Subject [11/12] lens git commit: LENS-1451: Enforcing valid fact tables doesn't filter out segmentations
Date Thu, 13 Jul 2017 09:14:04 GMT
LENS-1451: Enforcing valid fact tables doesn't filter out segmentations


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

Branch: refs/heads/current-release-line
Commit: 3769ef0e8987caf26c931bf2735e3658e30f3ac4
Parents: 41051ea
Author: Rajat Khandelwal <prongs@apache.org>
Authored: Thu Jul 6 19:35:15 2017 +0530
Committer: Rajat Khandelwal <rajatgupta59@gmail.com>
Committed: Thu Jul 13 14:43:00 2017 +0530

----------------------------------------------------------------------
 .../lens/cube/parse/CandidateTableResolver.java | 26 ++++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lens/blob/3769ef0e/lens-cube/src/main/java/org/apache/lens/cube/parse/CandidateTableResolver.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/CandidateTableResolver.java
b/lens-cube/src/main/java/org/apache/lens/cube/parse/CandidateTableResolver.java
index be3b474..86209bd 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/CandidateTableResolver.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/CandidateTableResolver.java
@@ -104,6 +104,9 @@ class CandidateTableResolver implements ContextRewriter {
 
   private void populateCandidateTables(CubeQueryContext cubeql) throws LensException {
     if (cubeql.getCube() != null) {
+      String str = cubeql.getConf().get(CubeQueryConfUtil.getValidFactTablesKey(cubeql.getCube().getName()));
+      List<String> validFactTables =
+        StringUtils.isBlank(str) ? null : Arrays.asList(StringUtils.split(str.toLowerCase(),
","));
       List<FactTable> factTables = cubeql.getMetastoreClient().getAllFacts(cubeql.getCube());
       if (factTables.isEmpty()) {
         throw new LensException(LensCubeErrorCode.NO_CANDIDATE_FACT_AVAILABLE.getLensErrorInfo(),
@@ -112,11 +115,15 @@ class CandidateTableResolver implements ContextRewriter {
       for (FactTable fact : factTables) {
         if (fact.getUpdatePeriods().isEmpty()) {
           log.info("Not considering fact: {} as it has no update periods", fact.getName());
+        } else if (validFactTables != null && !validFactTables.contains(fact.getName()))
{
+          log.info("Not considering fact: {} as it's not valid as per user configuration.",
fact.getName());
         } else {
           for (String s : fact.getStorages()) {
             StorageCandidate sc = new StorageCandidate(cubeql.getCube(), fact, s, cubeql);
             if (isStorageSupportedOnDriver(sc.getStorageName())) {
               cubeql.getCandidates().add(sc);
+            } else {
+              log.info("Not considering {} since storage is not supported on driver.", sc.getName());
             }
           }
         }
@@ -125,7 +132,12 @@ class CandidateTableResolver implements ContextRewriter {
       log.info("Populated storage candidates: {}", cubeql.getCandidates());
       List<SegmentationCandidate> segmentationCandidates = Lists.newArrayList();
       for (Segmentation segmentation : cubeql.getMetastoreClient().getAllSegmentations(cubeql.getCube()))
{
-        segmentationCandidates.add(new SegmentationCandidate(cubeql, segmentation));
+        if (validFactTables != null && !validFactTables.contains(segmentation.getName()))
{
+          log.info("Not considering segmentation: {} as it's not valid as per user configuration.",
+            segmentation.getName());
+        } else {
+          segmentationCandidates.add(new SegmentationCandidate(cubeql, segmentation));
+        }
       }
       cubeql.getCandidates().addAll(segmentationCandidates);
     }
@@ -261,9 +273,6 @@ class CandidateTableResolver implements ContextRewriter {
 
   private void resolveCandidateFactTables(CubeQueryContext cubeql) throws LensException {
     if (cubeql.getCube() != null) {
-      String str = cubeql.getConf().get(CubeQueryConfUtil.getValidFactTablesKey(cubeql.getCube().getName()));
-      List<String> validFactTables =
-          StringUtils.isBlank(str) ? null : Arrays.asList(StringUtils.split(str.toLowerCase(),
","));
 
       Set<QueriedPhraseContext> queriedMsrs = new HashSet<>();
       Set<QueriedPhraseContext> dimExprs = new HashSet<>();
@@ -279,15 +288,6 @@ class CandidateTableResolver implements ContextRewriter {
         Candidate cand = i.next();
         if (cand instanceof StorageCandidate) {
           StorageCandidate sc = (StorageCandidate) cand;
-          if (validFactTables != null) {
-            if (!validFactTables.contains(sc.getFact().getName().toLowerCase())) {
-              log.info("Not considering storage candidate:{} as it is not a valid candidate",
sc);
-              cubeql.addStoragePruningMsg(sc, new CandidateTablePruneCause(CandidateTablePruneCode.INVALID));
-              i.remove();
-              continue;
-            }
-          }
-
           // update expression evaluability for this fact
           for (String expr : cubeql.getQueriedExprs()) {
             cubeql.getExprCtx().updateEvaluables(expr, sc);


Mime
View raw message