LENS-1453: Method metrics names duplicate for segmentation inner rewrite

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

Branch: refs/heads/master
Commit: 65ca04b598bd29201a6670b7a51679f9ccb9ccc6
Parents: 6dca446
Author: Rajat Khandelwal <pro...@apache.org>
Authored: Thu Jul 20 16:09:58 2017 +0530
Committer: Rajat Khandelwal <rajatgupt...@gmail.com>
Committed: Thu Jul 20 16:13:07 2017 +0530

----------------------------------------------------------------------
 .../org/apache/lens/cube/parse/SegmentationCandidate.java   | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lens/blob/65ca04b5/lens-cube/src/main/java/org/apache/lens/cube/parse/SegmentationCandidate.java
----------------------------------------------------------------------
diff --git 
a/lens-cube/src/main/java/org/apache/lens/cube/parse/SegmentationCandidate.java 
b/lens-cube/src/main/java/org/apache/lens/cube/parse/SegmentationCandidate.java
index a2bd485..35638f3 100644
--- 
a/lens-cube/src/main/java/org/apache/lens/cube/parse/SegmentationCandidate.java
+++ 
b/lens-cube/src/main/java/org/apache/lens/cube/parse/SegmentationCandidate.java
@@ -52,6 +52,7 @@ import org.apache.lens.cube.metadata.MetastoreUtil;
 import org.apache.lens.cube.metadata.Segment;
 import org.apache.lens.cube.metadata.Segmentation;
 import org.apache.lens.cube.metadata.TimeRange;
+import org.apache.lens.server.api.LensConfConstants;
 import org.apache.lens.server.api.error.LensException;
 
 import org.apache.commons.lang3.tuple.Pair;
@@ -141,7 +142,13 @@ public class SegmentationCandidate implements Candidate {
         });
       addCubeNameAndAlias(ast, innerCube);
       trimHavingAndOrderby(ast, innerCube);
-      CubeQueryRewriter rewriter = new CubeQueryRewriter(conf, hconf);
+      Configuration innerConf = conf;
+      if (conf.get(LensConfConstants.QUERY_METRIC_UNIQUE_ID_CONF_KEY) != null) 
{
+        innerConf = new Configuration(conf);
+        innerConf.set(LensConfConstants.QUERY_METRIC_UNIQUE_ID_CONF_KEY,
+          conf.get(LensConfConstants.QUERY_METRIC_UNIQUE_ID_CONF_KEY) + "-" + 
segment.getName());
+      }
+      CubeQueryRewriter rewriter = new CubeQueryRewriter(innerConf, hconf);
       CubeQueryContext ctx = rewriter.rewrite(ast);
       cubeQueryContextMap.put(segment.getName(), ctx);
       if (!ctx.getCandidates().isEmpty()) {

Reply via email to