http://git-wip-us.apache.org/repos/asf/lens/blob/ae83caae/lens-cube/src/test/java/org/apache/lens/cube/parse/TestUnionQueries.java
----------------------------------------------------------------------
diff --git 
a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestUnionQueries.java 
b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestUnionQueries.java
index d5bc81c..bed1e7a 100644
--- a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestUnionQueries.java
+++ b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestUnionQueries.java
@@ -28,13 +28,13 @@ import static org.apache.lens.cube.parse.TestCubeRewriter.*;
 import static org.testng.Assert.*;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
-import org.apache.lens.cube.error.LensCubeErrorCode;
+import org.apache.lens.cube.error.NoCandidateFactAvailableException;
 import org.apache.lens.server.api.LensServerAPITestUtil;
 import org.apache.lens.server.api.error.LensException;
 
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.ql.parse.ParseException;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -50,12 +50,12 @@ public class TestUnionQueries extends TestQueryRewrite {
   @BeforeTest
   public void setupDriver() throws Exception {
     testConf = LensServerAPITestUtil.getConfiguration(
-      DRIVER_SUPPORTED_STORAGES, "C0,C1,C2",
-      DISABLE_AUTO_JOINS, false,
-      ENABLE_SELECT_TO_GROUPBY, true,
-      ENABLE_GROUP_BY_TO_SELECT, true,
-      DISABLE_AGGREGATE_RESOLVER, false,
-      ENABLE_STORAGES_UNION, true);
+        DRIVER_SUPPORTED_STORAGES, "C0,C1,C2",
+        DISABLE_AUTO_JOINS, false,
+        ENABLE_SELECT_TO_GROUPBY, true,
+        ENABLE_GROUP_BY_TO_SELECT, true,
+        DISABLE_AGGREGATE_RESOLVER, false,
+        ENABLE_STORAGES_UNION, true);
   }
 
   @Override
@@ -65,202 +65,191 @@ public class TestUnionQueries extends TestQueryRewrite {
 
   @Test
   public void testUnionQueries() throws Exception {
-    Configuration conf = getConf();
-    conf.set(getValidStorageTablesKey("testfact"), "C1_testFact,C2_testFact");
-    conf.set(getValidUpdatePeriodsKey("testfact", "C1"), "DAILY,HOURLY");
-    conf.set(getValidUpdatePeriodsKey("testfact2", "C1"), "YEARLY");
-    conf.set(getValidUpdatePeriodsKey("testfact", "C2"), "MONTHLY,DAILY");
-    conf.setBoolean(CubeQueryConfUtil.ENABLE_STORAGES_UNION, false);
-    ArrayList<String> storages = Lists.newArrayList("c1_testfact", 
"c2_testfact");
+    Configuration conf = 
LensServerAPITestUtil.getConfigurationWithParams(getConf(),
+        CubeQueryConfUtil.DRIVER_SUPPORTED_STORAGES, "C6",
+        getValidFactTablesKey("basecube"), "testfact",
+        FAIL_QUERY_ON_PARTIAL_DATA, false);
+    ArrayList<String> storages = Lists.newArrayList("daily_c6_testfact", 
"monthly_c6_testfact");
     try {
-      getStorageToUpdatePeriodMap().put("c1_testfact", 
Lists.newArrayList(HOURLY, DAILY));
-      getStorageToUpdatePeriodMap().put("c2_testfact", 
Lists.newArrayList(MONTHLY));
-
       // Union query
       String hqlQuery;
       String expected;
       StoragePartitionProvider provider = new StoragePartitionProvider() {
         @Override
         public Map<String, String> providePartitionsForStorage(String storage) 
{
-          return getWhereForMonthlyDailyAndHourly2monthsUnionQuery(storage);
+          if (storage.contains("daily_c6_testfact")) {
+            return getWhereForDays(storage, ONE_MONTH_BACK_TRUNCATED, 
getTruncatedDateWithOffset(MONTHLY, 0));
+          } else if (storage.contains("monthly_c6_testfact")) {
+            return getWhereForMonthly(storage, THREE_MONTHS_BACK_TRUNCATED, 
ONE_MONTH_BACK_TRUNCATED);
+          }
+          return null;
         }
       };
-      try {
-        rewrite("select cityid as `City ID`, msr8, msr7 as `Third measure` "
-          + "from testCube where " + TWO_MONTHS_RANGE_UPTO_HOURS, conf);
-        fail("Union feature is disabled, should have failed");
-      } catch (LensException e) {
-        assertEquals(e.getErrorCode(), 
LensCubeErrorCode.STORAGE_UNION_DISABLED.getLensErrorInfo().getErrorCode());
-      }
-      conf.setBoolean(CubeQueryConfUtil.ENABLE_STORAGES_UNION, true);
-
-      hqlQuery = rewrite("select ascii(cityname) as `City Name`, msr8, msr7 as 
`Third measure` "
-        + "from testCube where ascii(cityname) = 'c' and cityname = 'a' and 
zipcode = 'b' and "
-        + TWO_MONTHS_RANGE_UPTO_HOURS, conf);
+      hqlQuery = rewrite("select cityname1 as `City Name`, msr8, msr7 as 
`Third measure` "
+          + "from testCube where cityname1 = 'a' and zipcode = 'b' and "
+          + THREE_MONTHS_RANGE_UPTO_MONTH, conf);
       expected = getExpectedUnionQuery(TEST_CUBE_NAME, storages, provider,
-        "SELECT testcube.alias0 as `City Name`, sum(testcube.alias1) + 
max(testcube.alias2), "
-          + "case when sum(testcube.alias1) = 0 then 0 else 
sum(testcube.alias3)/sum(testcube.alias1) end "
-          + "as `Third Measure`",
-        null, "group by testcube.alias0",
-        "select ascii(cubecity.name) as `alias0`, sum(testcube.msr2) as 
`alias1`, "
-          + "max(testcube.msr3) as `alias2`, "
-          + "sum(case when testcube.cityid = 'x' then testcube.msr21 else 
testcube.msr22 end) as `alias3`", " join "
-          + getDbName() + "c1_citytable cubecity on testcube.cityid = 
cubecity.id and (cubecity.dt = 'latest')",
-        "ascii(cubecity.name) = 'c' and cubecity.name = 'a' and 
testcube.zipcode = 'b'",
-        "group by ascii(cubecity.name))");
-      compareQueries(hqlQuery, expected);
-      hqlQuery = rewrite("select asciicity as `City Name`, msr8, msr7 as 
`Third measure` "
-        + "from testCube where asciicity = 'c' and cityname = 'a' and zipcode 
= 'b' and "
-        + TWO_MONTHS_RANGE_UPTO_HOURS, conf);
+          "SELECT (testcube.alias0) as `City Name`, (sum((testcube.alias1)) + 
max((testcube.alias2))) "
+              + "as `msr8`, case  when (sum((testcube.alias1)) = 0) then 0 
else (sum((testcube.alias4)) / "
+              + "sum((testcube.alias1))) end as `Third measure` ",
+          null, "group by testcube.alias0",
+          "SELECT (cubecity1.name) as `alias0`, sum((testcube.msr2)) as 
`alias1`, max((testcube.msr3)) "
+              + "as `alias2`, sum(case  when ((testcube.cityid) = 'x') then 
(testcube.msr21) "
+              + "else (testcube.msr22) end) as `alias4` ", " join "
+              + getDbName() + "c6_citytable cubecity1 on testcube.cityid1 = 
cubecity1.id "
+              + "and (cubecity1.dt = 'latest') ",
+          "((cubecity1.name) = 'a') and ((testcube.zipcode) = 'b')",
+          "group by (cubecity1.name)");
       compareQueries(hqlQuery, expected);
 
       hqlQuery = rewrite("select ascii(cityid) as `City ID`, msr8, msr7 as 
`Third measure` "
-        + "from testCube where ascii(cityid) = 'c' and cityid = 'a' and 
zipcode = 'b' and "
-        + TWO_MONTHS_RANGE_UPTO_HOURS, conf);
+          + "from testCube where ascii(cityid) = 'c' and cityid = 'a' and 
zipcode = 'b' and "
+          + THREE_MONTHS_RANGE_UPTO_MONTH, conf);
 
       expected = getExpectedUnionQuery(TEST_CUBE_NAME, storages, provider,
-        "SELECT testcube.alias0 as `City ID`, sum(testcube.alias1) + 
max(testcube.alias2), "
-          + "case when sum(testcube.alias1) = 0 then 0 else 
sum(testcube.alias3)/sum(testcube.alias1) end "
-          + "as `Third Measure`",
-        null, "group by testcube.alias0",
-        "select ascii(testcube.cityid) as `alias0`, sum(testcube.msr2) as 
`alias1`, "
-          + "max(testcube.msr3) as `alias2`, "
-          + "sum(case when testcube.cityid = 'x' then testcube.msr21 else 
testcube.msr22 end) as `alias3`",
-        "ascii(testcube.cityid) = 'c' and testcube.cityid = 'a' and 
testcube.zipcode = 'b'",
-        "group by ascii(testcube.cityid)");
+          "SELECT (testcube.alias0) as `City ID`, (sum((testcube.alias1)) + 
max((testcube.alias2))) as `msr8`, "
+              + "case  when (sum((testcube.alias1)) = 0) then 0 else 
(sum((testcube.alias4)) / sum((testcube.alias1))) "
+              + "end as `Third measure`",
+          null, "group by testcube.alias0",
+          "SELECT ascii((testcube.cityid)) as `alias0`, sum((testcube.msr2)) 
as `alias1`, max((testcube.msr3)) "
+              + "as `alias2`, sum(case  when ((testcube.cityid) = 'x') then 
(testcube.msr21) "
+              + "else (testcube.msr22) end) as `alias4`",
+          "ascii(testcube.cityid) = 'c' and testcube.cityid = 'a' and 
testcube.zipcode = 'b'",
+          "group by ascii(testcube.cityid)");
 
       compareQueries(hqlQuery, expected);
 
       hqlQuery = rewrite("select cityid as `City ID`, msr8, msr7 as `Third 
measure` "
-        + "from testCube where cityid = 'a' and zipcode = 'b' and " + 
TWO_MONTHS_RANGE_UPTO_HOURS, conf);
+          + "from testCube where cityid = 'a' and zipcode = 'b' and " + 
THREE_MONTHS_RANGE_UPTO_MONTH, conf);
 
       expected = getExpectedUnionQuery(TEST_CUBE_NAME, storages, provider,
-        "SELECT testcube.alias0 as `City ID`, sum(testcube.alias1) + 
max(testcube.alias2), "
-          + "case when sum(testcube.alias1) = 0 then 0 else 
sum(testcube.alias3)/sum(testcube.alias1) end "
-          + "as `Third Measure`",
-        null, "group by testcube.alias0",
-        "select testcube.cityid as `alias0`, sum(testcube.msr2) as `alias1`, "
-          + "max(testcube.msr3) as `alias2`, "
-          + "sum(case when testcube.cityid = 'x' then testcube.msr21 else 
testcube.msr22 end) as `alias3`",
-        "testcube.cityid = 'a' and testcube.zipcode = 'b'", "group by 
testcube.cityid");
+          "SELECT (testcube.alias0) as `City ID`, (sum((testcube.alias1)) + 
max((testcube.alias2))) as `msr8`, "
+              + "case  when (sum((testcube.alias1)) = 0) then 0 else 
(sum((testcube.alias4)) / sum((testcube.alias1)))"
+              + " end as `Third measure`",
+          null, "group by testcube.alias0",
+          "SELECT (testcube.cityid) as `alias0`, sum((testcube.msr2)) as 
`alias1`, max((testcube.msr3)) as `alias2`, "
+              + "sum(case  when ((testcube.cityid) = 'x') then 
(testcube.msr21) else (testcube.msr22) end) as `alias4`",
+          "testcube.cityid = 'a' and testcube.zipcode = 'b'", "group by 
testcube.cityid");
 
       compareQueries(hqlQuery, expected);
 
       hqlQuery = rewrite("select cityid as `City ID`, msr3 as `Third measure` 
from testCube where "
-        + TWO_MONTHS_RANGE_UPTO_HOURS + " having msr7 > 10", conf);
+          + THREE_MONTHS_RANGE_UPTO_MONTH + " having msr7 > 10", conf);
 
       expected = getExpectedUnionQuery(TEST_CUBE_NAME, storages, provider,
-        "SELECT testcube.alias0 as `City ID`, max(testcube.alias1) as `Third 
measure`",
-        null, "group by testcube.alias0 having "
-          + "(case when sum(testcube.alias2)=0 then 0 else 
sum(testcube.alias3)/sum(testcube.alias2) end > 10 )",
-        "SELECT testcube.cityid as `alias0`, max(testcube.msr3) as `alias1`, "
-          + "sum(testcube.msr2) as `alias2`, "
-          + "sum(case when testcube.cityid='x' then testcube.msr21 else 
testcube.msr22 end) as `alias3`",
-        null, "group by testcube.cityid");
+          "SELECT testcube.alias0 as `City ID`, max(testcube.alias1) as `Third 
measure`",
+          null, "group by testcube.alias0 having "
+              + "(case when sum(testcube.alias2)=0 then 0 else 
sum(testcube.alias3)/sum(testcube.alias2) end > 10 )",
+          "SELECT testcube.cityid as `alias0`, max(testcube.msr3) as `alias1`, 
"
+              + "sum(testcube.msr2) as `alias2`, "
+              + "sum(case when testcube.cityid='x' then testcube.msr21 else 
testcube.msr22 end) as `alias3`",
+          null, "group by testcube.cityid");
       compareQueries(hqlQuery, expected);
 
       hqlQuery = rewrite("select cityid as `City ID`, msr3 as `Third measure` 
from testCube where "
-        + TWO_MONTHS_RANGE_UPTO_HOURS + " having msr8 > 10", conf);
+          + THREE_MONTHS_RANGE_UPTO_MONTH + " having msr8 > 10", conf);
 
       expected = getExpectedUnionQuery(TEST_CUBE_NAME, storages, provider,
-        "SELECT testcube.alias0 as `City ID`, max(testcube.alias1) as `Third 
measure`",
-        null, "GROUP BY testcube.alias0 "
-          + "HAVING (sum(testcube.alias2) + max(testcube.alias1)) > 10 ",
-        "SELECT testcube.cityid as `alias0`, max(testcube.msr3) as `alias1`, "
-          + "sum(testcube.msr2)as `alias2`", null, "group by testcube.cityid");
+          "SELECT testcube.alias0 as `City ID`, max(testcube.alias1) as `Third 
measure`",
+          null, "GROUP BY testcube.alias0 "
+              + "HAVING (sum(testcube.alias2) + max(testcube.alias1)) > 10 ",
+          "SELECT testcube.cityid as `alias0`, max(testcube.msr3) as `alias1`, 
"
+              + "sum(testcube.msr2)as `alias2`", null, "group by 
testcube.cityid");
       compareQueries(hqlQuery, expected);
 
       hqlQuery = rewrite("select msr3 as `Measure 3` from testCube where "
-        + TWO_MONTHS_RANGE_UPTO_HOURS + " having msr2 > 10 and msr2 < 100", 
conf);
+          + THREE_MONTHS_RANGE_UPTO_MONTH + " having msr2 > 10 and msr2 < 
100", conf);
 
       expected = getExpectedUnionQuery(TEST_CUBE_NAME, storages, provider,
-        "SELECT max(testcube.alias0) as `Measure 3` ",
-        null, " HAVING sum(testcube.alias1) > 10 and sum(testcube.alias1) < 
100",
-        "SELECT max(testcube.msr3) as `alias0`, sum(testcube.msr2) as 
`alias1`", null, null);
+          "SELECT max(testcube.alias0) as `Measure 3` ",
+          null, " HAVING sum(testcube.alias1) > 10 and sum(testcube.alias1) < 
100",
+          "SELECT max(testcube.msr3) as `alias0`, sum(testcube.msr2) as 
`alias1`", null, null);
       compareQueries(hqlQuery, expected);
 
       hqlQuery = rewrite("select zipcode, cityid as `City ID`, msr3 as 
`Measure 3`, msr4, "
-        + "SUM(msr2) as `Measure 2` from testCube where "
-        + TWO_MONTHS_RANGE_UPTO_HOURS + " having msr4 > 10 order by cityid 
desc limit 5", conf);
+          + "SUM(msr2) as `Measure 2` from testCube where "
+          + THREE_MONTHS_RANGE_UPTO_MONTH + " having msr4 > 10 order by cityid 
desc limit 5", conf);
 
       expected = getExpectedUnionQuery(TEST_CUBE_NAME, storages, provider,
-        "SELECT testcube.alias0, testcube.alias1 as `City ID`, 
max(testcube.alias2) as `Measure 3`, "
-          + "count(testcube.alias3), sum(testcube.alias4) as `Measure 2`",
-        null, "group by testcube.alias0, testcube.alias1 "
-          + " having count(testcube.alias3) > 10 order by testcube.alias1 desc 
limit 5",
-        "select testcube.zipcode as `alias0`, testcube.cityid as `alias1`, "
-          + "max(testcube.msr3) as `alias2`,count(testcube.msr4) as `alias3`, 
sum(testcube.msr2) as `alias4`",
-        null, "group by testcube.zipcode, testcube.cityid ");
-      compareQueries(hqlQuery, expected);
-
-      conf.setBoolean(CubeQueryConfUtil.ENABLE_GROUP_BY_TO_SELECT, false);
-      conf.setBoolean(ENABLE_SELECT_TO_GROUPBY, false);
-      hqlQuery = rewrite("select cityid as `City ID`, msr3 as `Measure 3`, "
-        + "SUM(msr2) as `Measure 2` from testCube" + " where "
-        + TWO_MONTHS_RANGE_UPTO_HOURS + " group by zipcode having msr4 > 10 
order by cityid desc limit 5", conf);
-
-      expected = getExpectedUnionQuery(TEST_CUBE_NAME, storages, provider,
-        "SELECT testcube.alias0 as `City ID`,max(testcube.alias1) as `Measure 
3`,sum(testcube.alias2) as `Measure 2` ",
-        null, "group by testcube.alias3 having count(testcube.alias4) > 10 
order by testcube.alias0 desc limit 5",
-        "SELECT testcube.cityid as `alias0`, max(testcube.msr3) as `alias1`, "
-          + "sum(testcube.msr2) as `alias2`, testcube.zipcode as `alias3`, 
count(testcube .msr4) as `alias4` FROM ",
-        null, "GROUP BY testcube.zipcode");
+          "SELECT (testcube.alias0) as `zipcode`, (testcube.alias1) as `City 
ID`, max((testcube.alias2)) "
+              + "as `Measure 3`, count((testcube.alias3)) as `msr4`, 
sum((testcube.alias4)) as `Measure 2`",
+          null, "group by testcube.alias0, testcube.alias1 "
+              + " having count(testcube.alias3) > 10 order by testcube.alias1 
desc limit 5",
+          "SELECT (testcube.zipcode) as `alias0`, (testcube.cityid) as 
`alias1`, max((testcube.msr3)) as `alias2`, "
+              + "count((testcube.msr4)) as `alias3`, sum((testcube.msr2)) as 
`alias4`",
+          null, "group by testcube.zipcode, testcube.cityid ");
       compareQueries(hqlQuery, expected);
     } finally {
       getStorageToUpdatePeriodMap().clear();
     }
   }
-
   @Test
   public void testDimAttrExpressionQuery() throws Exception {
-    Configuration conf = getConf();
-    conf.set(getValidStorageTablesKey("testfact"), "C1_testFact,C2_testFact");
-    conf.set(getValidUpdatePeriodsKey("testfact", "C1"), "DAILY,HOURLY");
-    conf.set(getValidUpdatePeriodsKey("testfact2", "C1"), "YEARLY");
-    conf.set(getValidUpdatePeriodsKey("testfact", "C2"), "MONTHLY,DAILY");
+    Configuration conf = 
LensServerAPITestUtil.getConfigurationWithParams(getConf(),
+        CubeQueryConfUtil.DRIVER_SUPPORTED_STORAGES, "C6",
+        getValidFactTablesKey("testcube"), "testfact",
+        FAIL_QUERY_ON_PARTIAL_DATA, false);
+    ArrayList<String> storages = Lists.newArrayList("daily_c6_testfact", 
"monthly_c6_testfact");
 
+    StoragePartitionProvider provider = new StoragePartitionProvider() {
+      @Override
+      public Map<String, String> providePartitionsForStorage(String storage) {
+        if (storage.contains("daily_c6_testfact")) {
+          return getWhereForDays(storage, ONE_MONTH_BACK_TRUNCATED, 
getTruncatedDateWithOffset(MONTHLY, 0));
+        } else if (storage.contains("monthly_c6_testfact")) {
+          return getWhereForMonthly(storage, THREE_MONTHS_BACK_TRUNCATED, 
ONE_MONTH_BACK_TRUNCATED);
+        }
+        return null;
+      }
+    };
+    // exception in following line
     String hqlQuery = rewrite("select asciicity as `City Name`, cityAndState 
as citystate, isIndia as isIndia,"
-      + " msr8, msr7 as `Third measure` "
-      + "from testCube where asciicity = 'c' and cityname = 'a' and zipcode = 
'b' and "
-      + TWO_MONTHS_RANGE_UPTO_HOURS, conf);
+        + " msr8, msr7 as `Third measure` "
+        + "from testCube where asciicity = 'c' and cityname = 'a' and zipcode 
= 'b' and "
+        + THREE_MONTHS_RANGE_UPTO_MONTH, conf);
     String joinExpr1 =  " join "
-      + getDbName() + "c1_statetable cubestate on testcube.stateid = 
cubestate.id and (cubestate.dt = 'latest') join"
-      + getDbName() + "c1_citytable cubecity on testcube.cityid = cubecity.id 
and (cubecity.dt = 'latest')";
+        + getDbName() + "c6_statetable cubestate on testcube.stateid = 
cubestate.id and (cubestate.dt = 'latest') join"
+        + getDbName() + "c6_citytable cubecity on testcube.cityid = 
cubecity.id and (cubecity.dt = 'latest')";
     String joinExpr2 =  " join "
-      + getDbName() + "c1_citytable cubecity on testcube.cityid = cubecity.id 
and (cubecity.dt = 'latest') join"
-      + getDbName() + "c1_statetable cubestate on testcube.stateid = 
cubestate.id and (cubestate.dt = 'latest')";
+        + getDbName() + "c6_citytable cubecity on testcube.cityid = 
cubecity.id and (cubecity.dt = 'latest') join"
+        + getDbName() + "c6_statetable cubestate on testcube.stateid = 
cubestate.id and (cubestate.dt = 'latest')";
 
     String expected1 = getExpectedQueryForDimAttrExpressionQuery(joinExpr1);
     String expected2 = getExpectedQueryForDimAttrExpressionQuery(joinExpr2);
     assertTrue(new TestQuery(hqlQuery).equals(new TestQuery(expected1))
-      || new TestQuery(hqlQuery).equals(new TestQuery(expected2)),
-      "Actual :" + hqlQuery + " Expected1:" + expected1 + " Expected2 : "+ 
expected2);
+            || new TestQuery(hqlQuery).equals(new TestQuery(expected2)),
+        "Actual :" + hqlQuery + " Expected1:" + expected1 + " Expected2 : "+ 
expected2);
   }
 
   private String getExpectedQueryForDimAttrExpressionQuery(String joinExpr) {
     try {
-      ArrayList<String> storages = Lists.newArrayList("c1_testfact", 
"c2_testfact");
-      getStorageToUpdatePeriodMap().put("c1_testfact", 
Lists.newArrayList(HOURLY, DAILY));
-      getStorageToUpdatePeriodMap().put("c2_testfact", 
Lists.newArrayList(MONTHLY));
+      ArrayList<String> storages = Lists.newArrayList("daily_c6_testfact", 
"monthly_c6_testfact");
+
       StoragePartitionProvider provider = new StoragePartitionProvider() {
         @Override
         public Map<String, String> providePartitionsForStorage(String storage) 
{
-          return getWhereForMonthlyDailyAndHourly2monthsUnionQuery(storage);
+          if (storage.contains("daily_c6_testfact")) {
+            return getWhereForDays(storage, ONE_MONTH_BACK_TRUNCATED, 
getTruncatedDateWithOffset(MONTHLY, 0));
+          } else if (storage.contains("monthly_c6_testfact")) {
+            return getWhereForMonthly(storage, THREE_MONTHS_BACK_TRUNCATED, 
ONE_MONTH_BACK_TRUNCATED);
+          }
+          return null;
         }
       };
       return getExpectedUnionQuery(TEST_CUBE_NAME, storages, provider,
-        "SELECT testcube.alias0 as `City Name`, testcube.alias1 as citystate, 
testcube.alias2 as isIndia, "
-          + "sum(testcube.alias3) + max(testcube.alias4), "
-          + "case when sum(testcube.alias3) = 0 then 0 else 
sum(testcube.alias5)/sum(testcube.alias3) end "
-          + "as `Third Measure`",
-        null, " group by testcube.alias0, testcube.alias1, testcube.alias2",
-        "select ascii(cubecity.name) as `alias0`, concat(cubecity.name, \":\", 
cubestate.name) as alias1,"
-          + "cubecity.name == 'DELHI' OR cubestate.name == 'KARNATAKA' OR 
cubestate.name == 'MAHARASHTRA' as alias2,"
-          + "sum(testcube.msr2) as `alias3`, max(testcube.msr3) as `alias4`, "
-          + "sum(case when testcube.cityid = 'x' then testcube.msr21 else 
testcube.msr22 end) as `alias5`", joinExpr,
-        "ascii(cubecity.name) = 'c' and cubecity.name = 'a' and 
testcube.zipcode = 'b'",
-        " group by ascii(cubecity.name)), concat(cubecity.name, \":\", 
cubestate.name),"
-          + "cubecity.name == 'DELHI' OR cubestate.name == 'KARNATAKA' OR 
cubestate.name == 'MAHARASHTRA'");
+          "SELECT (testcube.alias0) as `City Name`, (testcube.alias1) as 
`citystate`, (testcube.alias2) as `isIndia`, "
+              + "(sum((testcube.alias3)) + max((testcube.alias4))) as `msr8`, 
case  when (sum((testcube.alias3)) = 0) "
+              + "then 0 else (sum((testcube.alias6)) / sum((testcube.alias3))) 
end as `Third measure` ",
+          null, " group by testcube.alias0, testcube.alias1, testcube.alias2",
+          "SELECT ascii((cubecity.name)) as `alias0`, concat((cubecity.name), 
\":\", (cubestate.name)) as `alias1`, "
+              + "(((cubecity.name) == 'DELHI') or ((cubestate.name) == 
'KARNATAKA') or ((cubestate.name) "
+              + "== 'MAHARASHTRA')) as `alias2`, sum((testcube.msr2)) as 
`alias3`, max((testcube.msr3)) as `alias4`, "
+              + "sum(case  when ((testcube.cityid) = 'x') then 
(testcube.msr21) else (testcube.msr22) end) "
+              + "as `alias6` ", joinExpr,
+          "ascii(cubecity.name) = 'c' and cubecity.name = 'a' and 
testcube.zipcode = 'b'",
+          " GROUP BY ascii((cubecity.name)), concat((cubecity.name), \":\", 
(cubestate.name)), "
+              + "(((cubecity.name) == 'DELHI') or ((cubestate.name) == 
'KARNATAKA') "
+              + "or ((cubestate.name) == 'MAHARASHTRA'))");
     } finally {
       getStorageToUpdatePeriodMap().clear();
     }
@@ -268,134 +257,34 @@ public class TestUnionQueries extends TestQueryRewrite {
   @Test
   public void testNonAggregateOverAggregateFunction() throws Exception {
     try {
-      Configuration conf = getConf();
-      conf.set(getValidStorageTablesKey("testfact"), 
"C1_testFact,C2_testFact");
-      conf.set(getValidUpdatePeriodsKey("testfact", "C1"), "DAILY,HOURLY");
-      conf.set(getValidUpdatePeriodsKey("testfact2", "C1"), "YEARLY");
-      conf.set(getValidUpdatePeriodsKey("testfact", "C2"), "MONTHLY,DAILY");
-      ArrayList<String> storages = Lists.newArrayList("c1_testfact", 
"c2_testfact");
-      getStorageToUpdatePeriodMap().put("c1_testfact", 
Lists.newArrayList(HOURLY, DAILY));
-      getStorageToUpdatePeriodMap().put("c2_testfact", 
Lists.newArrayList(MONTHLY));
+      Configuration conf = 
LensServerAPITestUtil.getConfigurationWithParams(getConf(),
+          CubeQueryConfUtil.DRIVER_SUPPORTED_STORAGES, "C6",
+          getValidFactTablesKey("testcube"), "testfact",
+          FAIL_QUERY_ON_PARTIAL_DATA, false);
+      ArrayList<String> storages = Lists.newArrayList("daily_c6_testfact", 
"monthly_c6_testfact");
+
       StoragePartitionProvider provider = new StoragePartitionProvider() {
         @Override
         public Map<String, String> providePartitionsForStorage(String storage) 
{
-          return getWhereForMonthlyDailyAndHourly2monthsUnionQuery(storage);
+          if (storage.contains("daily_c6_testfact")) {
+            return getWhereForDays(storage, ONE_MONTH_BACK_TRUNCATED, 
getTruncatedDateWithOffset(MONTHLY, 0));
+          } else if (storage.contains("monthly_c6_testfact")) {
+            return getWhereForMonthly(storage, THREE_MONTHS_BACK_TRUNCATED, 
ONE_MONTH_BACK_TRUNCATED);
+          }
+          return null;
         }
       };
-      String hqlQuery = rewrite("select cityid as `City ID`, msr3 as `Measure 
3`, "
-        + "round(SUM(msr2)) as `Measure 2` from testCube" + " where "
-        + TWO_MONTHS_RANGE_UPTO_HOURS + " group by zipcode having msr4 > 10 
order by cityid desc, stateid asc, zipcode "
-        + "asc limit 5",
-        conf);
-      String expected = getExpectedUnionQuery(TEST_CUBE_NAME, storages, 
provider,
-        "SELECT testcube.alias0 as `City ID`,max(testcube.alias1) as `Measure 
3`,round(sum(testcube.alias2)) as "
-          + "`Measure 2` ", null, "group by testcube.alias3 having 
count(testcube.alias4) > 10 "
-          + "order by testcube.alias0 desc, testcube.alias5 asc, 
testcube.alias3 asc limit 5",
-        "SELECT testcube.cityid as `alias0`, max(testcube.msr3) as `alias1`, 
sum(testcube.msr2) as `alias2`, "
-          + "testcube.zipcode as `alias3`, count(testcube .msr4) as `alias4`, 
(testcube.stateid) as `alias5` FROM ",
-        null, "GROUP BY testcube.zipcode");
-      compareQueries(hqlQuery, expected);
-    } finally {
-      getStorageToUpdatePeriodMap().clear();
-    }
-  }
 
-  @Test
-  public void testMultiFactMultiStorage() throws ParseException, LensException 
{
-    try {
-      Configuration conf = 
LensServerAPITestUtil.getConfigurationWithParams(getConf(),
-        CubeQueryConfUtil.DRIVER_SUPPORTED_STORAGES, "C1,C2",
-        getValidStorageTablesKey("testfact"), "C1_testFact,C2_testFact",
-        getValidUpdatePeriodsKey("testfact", "C1"), "HOURLY",
-        getValidUpdatePeriodsKey("testfact", "C2"), "DAILY",
-        getValidUpdatePeriodsKey("testfact2_raw", "C1"), "YEARLY",
-        getValidUpdatePeriodsKey("testfact2_raw", "C2"), "YEARLY");
-      getStorageToUpdatePeriodMap().put("c1_testfact", 
Lists.newArrayList(HOURLY));
-      getStorageToUpdatePeriodMap().put("c2_testfact", 
Lists.newArrayList(DAILY));
-      String whereCond = "zipcode = 'a' and cityid = 'b' and (" + 
TWO_DAYS_RANGE_SPLIT_OVER_UPDATE_PERIODS + ")";
-      String hqlQuery = rewrite("select zipcode, count(msr4), sum(msr15) from 
testCube where " + whereCond, conf);
-      System.out.println(hqlQuery);
-      String possibleStart1 = "SELECT COALESCE(mq1.zipcode, mq2.zipcode) 
zipcode, mq1.expr2 `count(msr4)`,"
-        + " mq2.expr3 `sum(msr15)` FROM ";
-      String possibleStart2 = "SELECT COALESCE(mq1.zipcode, mq2.zipcode) 
zipcode, mq2.expr2 `count(msr4)`,"
-        + " mq1.expr3 `sum(msr15)` FROM ";
-
-      assertTrue(hqlQuery.startsWith(possibleStart1) || 
hqlQuery.startsWith(possibleStart2));
-      compareContains(rewrite("select zipcode as `zipcode`, sum(msr15) as 
`expr3` from testcube where " + whereCond,
-        conf), hqlQuery);
-      compareContains(rewrite("select zipcode as `zipcode`, count(msr4) as 
`expr2` from testcube where " + whereCond,
-        conf), hqlQuery);
-      assertTrue(hqlQuery.endsWith("on mq1.zipcode <=> mq2.zipcode"));
-      // No time_range_in should be remaining
-      assertFalse(hqlQuery.contains("time_range_in"));
-      //TODO: handle having after LENS-813, also handle for order by and limit
-    } finally {
-      getStorageToUpdatePeriodMap().clear();
-    }
-  }
-
-  @Test
-  public void testCubeWhereQueryWithMultipleTables() throws Exception {
-    Configuration conf = getConf();
-    conf.setBoolean(CubeQueryConfUtil.ENABLE_STORAGES_UNION, true);
-    conf.set(getValidStorageTablesKey("testfact"), "C1_testFact,C2_testFact");
-    conf.set(getValidUpdatePeriodsKey("testfact", "C1"), "DAILY");
-    conf.set(getValidUpdatePeriodsKey("testfact2", "C1"), "YEARLY");
-    conf.set(getValidUpdatePeriodsKey("testfact", "C2"), "HOURLY");
-
-    getStorageToUpdatePeriodMap().put("c1_testfact", 
Lists.newArrayList(DAILY));
-    getStorageToUpdatePeriodMap().put("c2_testfact", 
Lists.newArrayList(HOURLY));
-    StoragePartitionProvider provider = new StoragePartitionProvider() {
-      @Override
-      public Map<String, String> providePartitionsForStorage(String storage) {
-        return getWhereForDailyAndHourly2days(TEST_CUBE_NAME, storage);
-      }
-    };
-    try {
-      // Union query
-      String hqlQuery = rewrite("select SUM(msr2) from testCube" + " where " + 
TWO_DAYS_RANGE, conf);
-      System.out.println("HQL:" + hqlQuery);
-
-      String expected = getExpectedUnionQuery(TEST_CUBE_NAME,
-        Lists.newArrayList("c1_testfact", "c2_testfact"), provider,
-        "select sum(testcube.alias0) ", null, null,
-        "select sum(testcube.msr2) as `alias0` from ", null, null
-      );
-      compareQueries(hqlQuery, expected);
-    } finally {
-      getStorageToUpdatePeriodMap().clear();
-    }
-  }
-
-  @Test
-  public void testCubeWhereQueryWithMultipleTablesForMonth() throws Exception {
-    Configuration conf = getConf();
-    conf.set(DRIVER_SUPPORTED_STORAGES, "C1,C2,C3");
-    conf.set(getValidStorageTablesKey("testfact"), "");
-    conf.set(getValidUpdatePeriodsKey("testfact", "C1"), "HOURLY");
-    conf.set(getValidUpdatePeriodsKey("testfact2", "C1"), "YEARLY");
-    conf.set(getValidUpdatePeriodsKey("testfact2_raw", "C3"), "YEARLY");
-    conf.set(getValidUpdatePeriodsKey("testfact", "C2"), "DAILY");
-    conf.set(getValidUpdatePeriodsKey("testfact", "C3"), "MONTHLY");
-
-    getStorageToUpdatePeriodMap().put("c1_testfact", 
Lists.newArrayList(HOURLY));
-    getStorageToUpdatePeriodMap().put("c2_testfact", 
Lists.newArrayList(DAILY));
-    getStorageToUpdatePeriodMap().put("c3_testfact", 
Lists.newArrayList(MONTHLY));
-    StoragePartitionProvider provider = new StoragePartitionProvider() {
-      @Override
-      public Map<String, String> providePartitionsForStorage(String storage) {
-        return getWhereForMonthlyDailyAndHourly2monthsUnionQuery(storage);
-      }
-    };
-    try {
-      // Union query
-      String hqlQuery = rewrite("select SUM(msr2) from testCube" + " where " + 
TWO_MONTHS_RANGE_UPTO_HOURS, conf);
-      System.out.println("HQL:" + hqlQuery);
-      ArrayList<String> storages = Lists.newArrayList("c1_testfact", 
"c2_testfact", "c3_testfact");
+      String hqlQuery = rewrite("select cityid as `City ID`, msr3 as `Measure 
3`, "
+          + "round(SUM(msr2)) as `Measure 2` from testCube" + " where "
+          + THREE_MONTHS_RANGE_UPTO_MONTH + " group by cityid having msr3 > 10 
order by cityid desc limit 5", conf);
       String expected = getExpectedUnionQuery(TEST_CUBE_NAME, storages, 
provider,
-        "select sum(testcube.alias0)", null, null,
-        "select sum(testcube.msr2) as `alias0` from ", null, null
-      );
+          "SELECT (testcube.alias0) as `City ID`, max((testcube.alias1)) as 
`Measure 3`, round(sum((testcube.alias2))) "
+              + "as `Measure 2` ", null, "GROUP BY (testcube.alias0) HAVING 
(max((testcube.alias1)) > 10) "
+              + "ORDER BY testcube.alias0 desc LIMIT 5",
+          "SELECT (testcube.cityid) as `alias0`, max((testcube.msr3)) as 
`alias1`, "
+              + "sum((testcube.msr2)) as `alias2` FROM ",
+          null, "GROUP BY testcube.cityid");
       compareQueries(hqlQuery, expected);
     } finally {
       getStorageToUpdatePeriodMap().clear();
@@ -434,33 +323,77 @@ public class TestUnionQueries extends TestQueryRewrite {
   @Test
   public void testSingleFactMultiStorage() throws Exception {
     Configuration conf = 
LensServerAPITestUtil.getConfigurationWithParams(getConf(),
-      CubeQueryConfUtil.DRIVER_SUPPORTED_STORAGES, "C3,C5",
-      getValidFactTablesKey("testcube"), "testfact",
-      getValidUpdatePeriodsKey("testfact", "C3"), "DAILY",
-      getValidUpdatePeriodsKey("testfact", "C5"), "DAILY",
-      FAIL_QUERY_ON_PARTIAL_DATA, false);
+        CubeQueryConfUtil.DRIVER_SUPPORTED_STORAGES, "C6",
+        getValidFactTablesKey("testcube"), "testfact",
+        FAIL_QUERY_ON_PARTIAL_DATA, false);
 
-    String hqlQuery = rewrite("select count(msr4) from testCube where " + 
TWO_MONTHS_RANGE_UPTO_DAYS, conf);
+    String hqlQuery = rewrite("select count(msr4) from testCube where " + 
THREE_MONTHS_RANGE_UPTO_MONTH, conf);
     System.out.println(hqlQuery);
 
     // No time_range_in should be remaining
     assertFalse(hqlQuery.contains("time_range_in"));
-    ArrayList<String> storages = Lists.newArrayList("c3_testfact", 
"c5_testfact");
+    ArrayList<String> storages = Lists.newArrayList("daily_c6_testfact", 
"monthly_c6_testfact");
     StoragePartitionProvider provider = new StoragePartitionProvider() {
       @Override
       public Map<String, String> providePartitionsForStorage(String storage) {
-        if (storage.contains("c3")) {
-          return getWhereForDays(storage, TWO_MONTHS_BACK, 
getDateWithOffset(DAILY, -10));
-        } else if (storage.contains("c5")) {
-          return getWhereForDays(storage, getDateWithOffset(DAILY, -10), NOW);
+        if (storage.contains("daily_c6_testfact")) {
+          return getWhereForDays(storage, ONE_MONTH_BACK_TRUNCATED, 
getTruncatedDateWithOffset(MONTHLY, 0));
+        } else if (storage.contains("monthly_c6_testfact")) {
+          return getWhereForMonthly(storage, THREE_MONTHS_BACK_TRUNCATED, 
ONE_MONTH_BACK_TRUNCATED);
         }
         return null;
       }
     };
     String expected = getExpectedUnionQuery(TEST_CUBE_NAME, storages, provider,
-      "select count(testcube.alias0)", null, null,
-      "select count(testcube.msr4) as `alias0` from ", null, null
+        "SELECT count((testcube.alias0)) as `count(msr4)`", null, null,
+        "select count(testcube.msr4) as `alias0` from ", null, null
     );
     compareQueries(hqlQuery, expected);
   }
+
+
+  @Test
+  public void testSingleFactSingleStorageWithMultipleTableDescriptions() 
throws Exception {
+    Configuration conf = 
LensServerAPITestUtil.getConfigurationWithParams(getConf(),
+        CubeQueryConfUtil.DRIVER_SUPPORTED_STORAGES, "C6",
+        getValidFactTablesKey("testcube"), "testfact",
+        FAIL_QUERY_ON_PARTIAL_DATA, false);
+
+    //If not beginning of month. Expecting this to pass at beginning of every 
month (example April 01 00:00)
+    if (!THREE_MONTHS_RANGE_UPTO_DAYS.equals(THREE_MONTHS_RANGE_UPTO_MONTH)) {
+      LensException e = getLensExceptionInRewrite("select count(msr4) from 
testCube where "
+          + THREE_MONTHS_RANGE_UPTO_DAYS, conf);
+      assertTrue(e instanceof NoCandidateFactAvailableException);
+      Set<Map.Entry<StorageCandidate, List<CandidateTablePruneCause>>> causes =
+          ((NoCandidateFactAvailableException) e).getBriefAndDetailedError()
+              .entrySet().stream().filter(x -> x.getKey().getStorageTable()
+              .equalsIgnoreCase("c6_testfact")).collect(Collectors.toSet());
+      assertEquals(causes.size(), 1);
+      List<CandidateTablePruneCause> pruneCauses = 
causes.iterator().next().getValue();
+      assertEquals(pruneCauses.size(), 1);
+      assertEquals(pruneCauses.get(0).getCause(), CandidateTablePruneCause.
+          CandidateTablePruneCode.STORAGE_NOT_AVAILABLE_IN_RANGE);
+    }
+
+    String hqlQuery2 = rewrite("select count(msr4) from testCube where " + 
THREE_MONTHS_RANGE_UPTO_MONTH, conf);
+    System.out.println(hqlQuery2);
+
+    ArrayList<String> storages = Lists.newArrayList("daily_c6_testfact", 
"monthly_c6_testfact");
+    StoragePartitionProvider provider = new StoragePartitionProvider() {
+      @Override
+      public Map<String, String> providePartitionsForStorage(String storage) {
+        if (storage.contains("daily_c6_testfact")) {
+          return getWhereForDays(storage, ONE_MONTH_BACK_TRUNCATED, 
getTruncatedDateWithOffset(MONTHLY, 0));
+        } else if (storage.contains("monthly_c6_testfact")) {
+          return getWhereForMonthly(storage, THREE_MONTHS_BACK_TRUNCATED, 
ONE_MONTH_BACK_TRUNCATED);
+        }
+        return null;
+      }
+    };
+    String expected = getExpectedUnionQuery(TEST_CUBE_NAME, storages, provider,
+        "select count(testcube.alias0) AS `count(msr4)`", null, null,
+        "select count((testcube.msr4)) AS `alias0` from ", null, null
+    );
+    compareQueries(hqlQuery2, expected);
+  }
 }

http://git-wip-us.apache.org/repos/asf/lens/blob/ae83caae/lens-cube/src/test/resources/schema/cubes/base/basecube.xml
----------------------------------------------------------------------
diff --git a/lens-cube/src/test/resources/schema/cubes/base/basecube.xml 
b/lens-cube/src/test/resources/schema/cubes/base/basecube.xml
new file mode 100644
index 0000000..22703ab
--- /dev/null
+++ b/lens-cube/src/test/resources/schema/cubes/base/basecube.xml
@@ -0,0 +1,972 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+
+-->
+<x_base_cube name="basecube" xmlns="uri:lens:cube:0.1">
+  <properties>
+    <property name="cube.timedim.partition.et" value="et"/>
+    <property name="cube.timedim.partition.it" value="it"/>
+    <property name="cube.timedim.partition.d_time" value="dt"/>
+    <property name="cube.timedim.relation.processing_time" 
value="test_time_dim+[-5 days,5 days]"/>
+    <property name="cube.timedim.partition.processing_time" value="pt"/>
+    <property name="cube.timedim.partition.test_time_dim" value="ttd"/>
+    <property name="cube.timedim.relation.d_time" value="processing_time+[-5 
days,5 days]"/>
+    <property name="cube.timedim.partition.test_time_dim2" value="ttd2"/>
+    <property name="cube.basecube.timed.dimensions.list" 
value="d_time,pt,it,et,test_time_dim,test_time_dim2"/>
+    <property name="cube.allfields.queriable" value="false"/>
+    <property name="cube.table.basecube.weight" value="0.0"/>
+  </properties>
+  <measures>
+    <measure _type="FLOAT" default_aggr="SUM" unit="RS" name="msr21" 
display_string="Measure22"
+             description="second measure">
+    </measure>
+    <measure _type="BIGINT" default_aggr="COUNT" name="msr4" 
display_string="Measure4" description="fourth measure">
+    </measure>
+    <measure _type="INT" default_aggr="SUM" unit="RS" name="msr15" 
display_string="Measure15"
+             description="fifteenth measure">
+    </measure>
+    <measure _type="INT" name="union_join_ctx_msr3" 
description="union_join_ctx_third measure">
+    </measure>
+    <measure _type="INT" name="union_join_ctx_msr2" 
description="union_join_ctx_second measure">
+    </measure>
+    <measure _type="FLOAT" default_aggr="SUM" unit="RS" name="msr2" 
display_string="Measure2"
+             description="second measure">
+    </measure>
+    <measure _type="BIGINT" default_aggr="SUM" name="directMsr" 
display_string="Direct Measure"
+             description="fifth measure">
+    </measure>
+    <measure _type="DOUBLE" default_aggr="MAX" name="msr3" 
display_string="Measure3" description="third measure">
+    </measure>
+    <measure _type="FLOAT" default_aggr="SUM" unit="RS" name="msr22" 
display_string="Measure22"
+             description="second measure">
+    </measure>
+    <measure _type="BIGINT" name="msr9" description="ninth measure">
+      <tags>
+        <property name="cube.measure.datacompleteness.tag" value="tag1"/>
+      </tags>
+    </measure>
+    <measure _type="INT" name="msr1" description="first measure">
+      <tags>
+        <property name="cube.measure.datacompleteness.tag" value="tag1"/>
+      </tags>
+    </measure>
+    <measure _type="BIGINT" default_aggr="COUNT" name="msr14" 
display_string="Measure4" description="fourth measure">
+    </measure>
+    <measure _type="BIGINT" name="noAggrMsr" display_string="No aggregateMsr"
+             description="measure without a default aggregate">
+    </measure>
+    <measure _type="FLOAT" default_aggr="SUM" unit="RS" name="msr12" 
display_string="Measure2"
+             description="second measure">
+    </measure>
+    <measure _type="DOUBLE" default_aggr="MAX" name="msr13" 
display_string="Measure3" description="third measure">
+    </measure>
+    <measure _type="BIGINT" start_time="2017-03-07T19:30:00.000+05:30" 
name="newmeasure" display_string="New measure"
+             description="measure available  from now">
+    </measure>
+    <measure _type="INT" name="msr11" description="first measure">
+    </measure>
+    <measure _type="INT" name="union_join_ctx_msr1" 
description="union_join_ctx_first measure">
+    </measure>
+  </measures>
+  <dim_attributes>
+    <dim_attribute _type="string" name="union_join_ctx_cityname" 
display_string="union_join_ctx_city name"
+                   description="union_join_ctx_city name">
+      <chain_ref_column chain_name="cubecityjoinunionctx" ref_col="name" 
dest_table="citydim"/>
+    </dim_attribute>
+    <dim_attribute _type="string" name="cityname" display_string="city name" 
description="city name">
+      <chain_ref_column chain_name="cubecity" ref_col="name" 
dest_table="citydim"/>
+    </dim_attribute>
+    <dim_attribute _type="string" name="citycountry" display_string="city 
country" description="">
+      <chain_ref_column chain_name="cubecitystatecountry" ref_col="name" 
dest_table="countrydim"/>
+    </dim_attribute>
+    <dim_attribute _type="int" name="union_join_ctx_zipcode" 
description="union_join_ctx_the zipcode">
+    </dim_attribute>
+    <dim_attribute _type="string" name="unreachablename" display_string="urdim 
name" description="">
+      <chain_ref_column chain_name="unreachabledim_chain" ref_col="name" 
dest_table="unreachabledim"/>
+    </dim_attribute>
+    <dim_attribute _type="bigint" name="dim2big1" display_string="dim2 refer" 
description="ref dim">
+      <chain_ref_column chain_name="dim2chain" ref_col="bigid1" 
dest_table="testdim2"/>
+    </dim_attribute>
+    <dim_attribute _type="array&lt;string&gt;" name="ysports" 
display_string="yuser sports" description="">
+      <chain_ref_column chain_name="yusersports" ref_col="name" 
dest_table="sports"/>
+    </dim_attribute>
+    <dim_attribute _type="array&lt;int&gt;" name="sportids" 
display_string="user sports" description="">
+      <chain_ref_column chain_name="userinterestids" ref_col="sport_id" 
dest_table="user_interests"/>
+    </dim_attribute>
+    <dim_attribute _type="String" name="cubecountrycapital" 
display_string="Country capital" description="ref dim">
+      <chain_ref_column chain_name="cubestate" ref_col="countrycapital" 
dest_table="statedim"/>
+      <chain_ref_column chain_name="cubecitystatecountry" ref_col="capital" 
dest_table="countrydim"/>
+    </dim_attribute>
+    <dim_attribute _type="int" name="cityid1" display_string="City1" 
description="id to city">
+    </dim_attribute>
+    <dim_attribute _type="int" name="dim12" display_string="Dim2 refer" 
description="ref dim">
+      <chain_ref_column chain_name="dim2chain" ref_col="id" 
dest_table="testdim2"/>
+    </dim_attribute>
+    <dim_attribute _type="int" name="xuserid" description="userid">
+    </dim_attribute>
+    <dim_attribute _type="int" name="cityid2" display_string="City2" 
description="id to city">
+    </dim_attribute>
+    <dim_attribute _type="string" name="dim11" description="basedim">
+    </dim_attribute>
+    <dim_attribute _type="int" start_time="2017-03-07T19:30:00.000+05:30" 
name="cdim2" display_string="Dim2 refer"
+                   description="ref dim">
+    </dim_attribute>
+    <dim_attribute _type="int" name="test_time_dim_day_id2" description="ref 
dim">
+    </dim_attribute>
+    <dim_attribute _type="int" name="union_join_ctx_cityid" 
description="union_join_ctx_the cityid ">
+    </dim_attribute>
+    <dim_attribute _type="int" name="urdimid" display_string="urdim refer" 
description="ref dim">
+    </dim_attribute>
+    <dim_attribute _type="bigint" name="dim2big2" display_string="dim2 refer" 
description="ref dim">
+      <chain_ref_column chain_name="dim2chain" ref_col="bigid2" 
dest_table="testdim2"/>
+    </dim_attribute>
+    <dim_attribute _type="int" name="user_id_deprecated" 
description="user_id_deprecated">
+    </dim_attribute>
+    <dim_attribute _type="date" name="test_time_dim2" display_string="Timedim 
full date" description="chained dim">
+      <chain_ref_column chain_name="timehourchain2" ref_col="full_hour" 
dest_table="hourdim"/>
+      <chain_ref_column chain_name="timedatechain2" ref_col="full_date" 
dest_table="daydim"/>
+    </dim_attribute>
+    <dim_attribute _type="string" name="citystatecapital" 
display_string="State's capital thru city"
+                   description="State's capital thru city">
+      <chain_ref_column chain_name="citystate" ref_col="capital" 
dest_table="statedim"/>
+    </dim_attribute>
+    <dim_attribute _type="string" name="statecountry" display_string="state 
country" description="">
+      <chain_ref_column chain_name="cubestatecountry" ref_col="name" 
dest_table="countrydim"/>
+    </dim_attribute>
+    <dim_attribute _type="bigint" start_time="2017-03-07T19:30:00.000+05:30" 
name="dim2bignew"
+                   display_string="Dim2 refer" description="ref dim">
+    </dim_attribute>
+    <dim_attribute _type="int" name="test_time_dim_hour_id2" description="ref 
dim">
+    </dim_attribute>
+    <dim_attribute _type="int" name="dim2" display_string="dim2 refer" 
description="ref dim">
+      <chain_ref_column chain_name="dim2chain" ref_col="id" 
dest_table="testdim2"/>
+    </dim_attribute>
+    <dim_attribute _type="int" name="test_time_dim_hour_id" 
display_string="Timedim reference" description="ref dim">
+    </dim_attribute>
+    <dim_attribute _type="timestamp" name="d_time" description="d time">
+    </dim_attribute>
+    <dim_attribute _type="string" name="dim1" description="basedim">
+    </dim_attribute>
+    <dim_attribute _type="int" name="user_id_added_far_future" 
description="user_id_added_far_future">
+    </dim_attribute>
+    <dim_attribute _type="string" name="testdim3id" display_string="dim3 
refer" description="direct id to testdim3">
+      <chain_ref_column chain_name="dim3chain" ref_col="id" 
dest_table="testdim3"/>
+    </dim_attribute>
+    <dim_attribute _type="int" name="yuserid" description="userid">
+    </dim_attribute>
+    <dim_attribute _type="array&lt;string&gt;" name="xsports" 
display_string="xuser sports" description="">
+      <chain_ref_column chain_name="xusersports" ref_col="name" 
dest_table="sports"/>
+    </dim_attribute>
+    <dim_attribute _type="string" name="ambigdim1" description="used in 
testColumnAmbiguity">
+    </dim_attribute>
+    <dim_attribute _type="array&lt;string&gt;" name="sports" 
display_string="user sports" description="">
+      <chain_ref_column chain_name="usersports" ref_col="name" 
dest_table="sports"/>
+    </dim_attribute>
+    <dim_attribute _type="date" name="test_time_dim" display_string="Timedim 
full date" description="ref dim">
+      <chain_ref_column chain_name="timedatechain1" ref_col="full_date" 
dest_table="daydim"/>
+      <chain_ref_column chain_name="timehourchain1" ref_col="full_hour" 
dest_table="hourdim"/>
+    </dim_attribute>
+    <dim_attribute _type="string" name="concatedcitystate" 
display_string="CityState" description="citystate">
+    </dim_attribute>
+    <dim_attribute _type="string" name="dim13" description="basedim">
+    </dim_attribute>
+    <dim_attribute name="location" description="Location hierarchy">
+      <hierarchy>
+        <dim_attribute _type="int" name="zipcode" description="zip">
+        </dim_attribute>
+        <dim_attribute _type="int" name="cityid" description="city">
+        </dim_attribute>
+        <dim_attribute _type="int" name="stateid" description="state">
+        </dim_attribute>
+        <dim_attribute _type="int" name="countryid" description="country">
+        </dim_attribute>
+        <dim_attribute _type="string" num_distinct_values="3" 
name="regionname" display_string="regionname"
+                       description="region">
+          <values>APAC</values>
+          <values>EMEA</values>
+          <values>USA</values>
+        </dim_attribute>
+      </hierarchy>
+    </dim_attribute>
+    <dim_attribute _type="timestamp" name="processing_time" 
description="processing time">
+    </dim_attribute>
+    <dim_attribute _type="int" name="dim22" display_string="Dim2 refer" 
description="ref dim">
+      <chain_ref_column chain_name="dim2chain" ref_col="id" 
dest_table="testdim2"/>
+    </dim_attribute>
+    <dim_attribute _type="int" name="userid" description="userid">
+    </dim_attribute>
+    <dim_attribute _type="string" name="statename_cube" display_string="state 
name" description="state name">
+      <chain_ref_column chain_name="cubestate" ref_col="name" 
dest_table="statedim"/>
+    </dim_attribute>
+    <dim_attribute _type="int" name="user_id_added_in_past" 
description="user_id_added_in_past">
+    </dim_attribute>
+    <dim_attribute _type="int" name="test_time_dim_day_id" 
display_string="Timedim reference" description="ref dim">
+    </dim_attribute>
+  </dim_attributes>
+  <expressions>
+    <expression _type="string" name="singlecolchainfield" 
display_string="cubecityname" description="cubecity.name">
+      <expr_spec expr="cubecity.name"/>
+    </expression>
+    <expression _type="double" name="msr8" display_string="Sixth Msr" 
description="measure expression">
+      <expr_spec expr="msr2 + msr3"/>
+    </expression>
+    <expression _type="double" name="msr2expr" display_string="Nested expr" 
description="nested expr">
+      <expr_spec expr="case when cityStateName = 'xyz' then msr2 else 0 end"/>
+    </expression>
+    <expression _type="String" name="cubestatename" display_string="CubeState 
Name"
+                description="statename from cubestate">
+      <expr_spec expr="substr(cubestate.name, 5)"/>
+    </expression>
+    <expression _type="int" name="union_join_ctx_non_zero_msr2_sum" 
display_string="union_join_ctx_non zero msr2 sum"
+                description="union_join_ctx_non zero msr2 sum">
+      <expr_spec expr="sum(case when union_join_ctx_msr2 &gt; 0 then 
union_join_ctx_msr2 else 0 end)"/>
+    </expression>
+    <expression _type="double" name="flooredmsr12" display_string="Floored 
msr12" description="floored measure12">
+      <expr_spec expr="floor(msr12)"/>
+    </expression>
+    <expression _type="String" name="cityandstate" display_string="City and 
State"
+                description="city and state together">
+      <expr_spec expr="concat(cityname, &quot;:&quot;, statename_cube)"/>
+      <expr_spec expr="substr(concatedcitystate, 10)"/>
+    </expression>
+    <expression _type="double" name="avgmsr" display_string="Avg Msr" 
description="avg measure">
+      <expr_spec expr="avg(msr1 + msr2)"/>
+    </expression>
+    <expression _type="double" name="equalsums" display_string="equalsums" 
description="sums are equals">
+      <expr_spec expr="msr3 + msr4"/>
+      <expr_spec expr="(msr3 + msr2)/100"/>
+    </expression>
+    <expression _type="array&lt;string&gt;" name="sportids_abbr" 
display_string="user sports" description="">
+      <expr_spec expr="case when sportids == 1 then 'CKT' when sportids == 2 
then 'FTB' else 'NON' end"/>
+    </expression>
+    <expression _type="double" name="summsrs" display_string="Sum Msrs" 
description="sum measures">
+      <expr_spec expr="(1000 + sum(msr1) + sum(msr2))/100"/>
+    </expression>
+    <expression _type="boolean" name="booleancut" display_string="Boolean cut" 
description="a boolean expression">
+      <expr_spec expr="(dim1 != 'x' AND dim2 != 10)"/>
+    </expression>
+    <expression _type="int" name="notnullcityid" display_string="Not null 
cityid Expr" description="Not null cityid">
+      <expr_spec expr="case when cityid is null then 0 else cityid end"/>
+    </expression>
+    <expression _type="double" name="roundedmsr1" display_string="Rounded 
msr1" description="rounded measure1">
+      <expr_spec expr="round(msr1/1000)"/>
+    </expression>
+    <expression _type="double" name="msr5" display_string="Fifth Msr" 
description="materialized in some facts">
+      <expr_spec expr="msr2 + msr3"/>
+    </expression>
+    <expression _type="String" name="citystatename" display_string="City 
State" description="city state">
+      <expr_spec expr="concat('CityState:', cubecity.statename)"/>
+    </expression>
+    <expression _type="string" name="singlecoldim1expr" display_string="dim1" 
description="dim1">
+      <expr_spec expr="dim1)"/>
+    </expression>
+    <expression _type="string" name="singlecolchainrefexpr" 
display_string="dim3chainid"
+                description="testcube.testDim3id">
+      <expr_spec expr="testcube.testDim3id"/>
+    </expression>
+    <expression _type="bigint" name="directmsrexpr" display_string="Direct 
Measure" description="">
+      <expr_spec expr="directMsr + 0"/>
+      <expr_spec expr="msr13 + msr14"/>
+    </expression>
+    <expression _type="double" name="msr7" display_string="Seventh Msr" 
description="measure expression">
+      <expr_spec
+        expr="case when sum(msr2) = 0 then 0 else sum(case when cityid='x' 
then msr21 else msr22 end)/sum(msr2) end"/>
+    </expression>
+    <expression _type="string" name="substrexpr" display_string="Substr expr" 
description="a sub-string expression">
+      <expr_spec expr="substr(dim1, 3))"/>
+      <expr_spec expr="substr(ascii(dim2chain.name), 3)"/>
+    </expression>
+    <expression _type="string" name="refexpr" display_string="Expr with cube 
and dim fields"
+                description="expression which facts and dimensions">
+      <expr_spec expr="concat(dim1, &quot;:&quot;, citydim.name)"/>
+    </expression>
+    <expression _type="string" name="singlecoldim1qualifiedexpr" 
display_string="dim1" description="testcube.dim1">
+      <expr_spec expr="testcube.dim1"/>
+    </expression>
+    <expression _type="int" name="countofdistinctcityid" display_string="Count 
of Distinct CityId Expr"
+                description="Count of Distinct CityId">
+      <expr_spec expr="count(distinct(cityid))"/>
+    </expression>
+    <expression _type="array&lt;string&gt;" name="xsports_abbr" 
display_string="xuser sports" description="">
+      <expr_spec expr="substr(xsports, 3)"/>
+    </expression>
+    <expression _type="string" name="singlecolchainid" 
display_string="dim3chainid" description="dim3chain.id">
+      <expr_spec expr="dim3chain.id)"/>
+    </expression>
+    <expression _type="String" name="asciicity" display_string="ascii cityname 
substr" description="ascii cityname">
+      <expr_spec expr="ascii(cityname)"/>
+    </expression>
+    <expression _type="string" name="nocolexpr" display_string="No col expr"
+                description="expression which non existing colun">
+      <expr_spec expr="myfun(nonexist)"/>
+    </expression>
+    <expression _type="int" name="union_join_ctx_sum_msr1_msr2" 
display_string="union_join_ctx_sum of msr1 and msr2"
+                description="union_join_ctx_sum of msr1 and msr2">
+      <expr_spec expr="sum(union_join_ctx_msr1) + sum(union_join_ctx_msr2)"/>
+    </expression>
+    <expression _type="array&lt;string&gt;" name="sports_abbr" 
display_string="user sports" description="">
+      <expr_spec expr="substr(sports, 3)"/>
+    </expression>
+    <expression _type="boolean" name="indiasubstr" display_string="Nested expr"
+                description="nested sub string expression">
+      <expr_spec expr="substrexpr = 'INDIA'"/>
+    </expression>
+    <expression _type="int" name="union_join_ctx_notnullcityid" 
display_string="union_join_ctx_Not null cityid Expr"
+                description="union_join_ctx_Not null cityid">
+      <expr_spec expr="case when union_join_ctx_cityid is null then 0 else 
union_join_ctx_cityid end"/>
+    </expression>
+    <expression _type="String" name="cityandstatenew" display_string="City and 
State"
+                description="city and state together">
+      <expr_spec expr="concat(cityname, &quot;:&quot;, statename_cube)" 
end_time="$gregorian{now.month-2months}"/>
+      <expr_spec expr="substr(concatedcitystate, 10)"/>
+    </expression>
+    <expression _type="String" name="isindia" display_string="Is Indian 
City/state" description="is indian city/state">
+      <expr_spec expr="cubecity.name == 'DELHI' OR cubestate.name == 
'KARNATAKA' OR cubestate.name == 'MAHARASHTRA'"/>
+    </expression>
+    <expression _type="int" name="union_join_ctx_msr1_greater_than_100"
+                display_string="union_join_ctx_msr1 greater than 100"
+                description="union_join_ctx_msr1 greater than 100">
+      <expr_spec expr="case when sum(union_join_ctx_msr1) &gt; 100 then 
&quot;high&quot; else &quot;low&quot; end"/>
+    </expression>
+    <expression _type="double" name="singlecolmsr2qualifiedexpr" 
display_string="Msr2" description="testcube.measure2">
+      <expr_spec expr="testcube.msr2"/>
+    </expression>
+    <expression _type="bigint" name="msr6" display_string="Measure6" 
description="sixth measure">
+      <expr_spec expr="sum(msr2) + max(msr3)/ count(msr4)"/>
+    </expression>
+    <expression _type="double" name="nestedexpr" display_string="Nested expr" 
description="nested expr">
+      <expr_spec expr="avg(roundedmsr2)"/>
+      <expr_spec expr="avg(equalsums)"/>
+      <expr_spec expr="case when substrexpr = 'xyz' then avg(msr5) when 
substrexpr = 'abc' then avg(msr4)/100 end"/>
+    </expression>
+    <expression _type="String" name="substrsprorts" display_string="substr 
sports" description="substr of sports">
+      <expr_spec expr="substr(sports, 10)"/>
+    </expression>
+    <expression _type="array&lt;string&gt;" name="ysports_abbr" 
display_string="yuser sports" description="">
+      <expr_spec expr="substr(ysports, 3)"/>
+    </expression>
+    <expression _type="string" name="newexpr" display_string="new measure expr"
+                description="expression which non existing colun">
+      <expr_spec expr="myfun(newmeasure)"/>
+    </expression>
+    <expression _type="string" name="substrexprdim2" display_string="Substr 
expr" description="a sub-string expression">
+      <expr_spec expr="substr(dim2, 3))"/>
+      <expr_spec expr="substr(ascii(dim2chain.name), 3)"/>
+    </expression>
+    <expression _type="double" name="singlecolmsr2expr" display_string="Msr2" 
description="measure2">
+      <expr_spec expr="msr2)"/>
+    </expression>
+    <expression _type="String" name="substrdim2big1" display_string="dim2big1 
substr" description="substr of dim2big1">
+      <expr_spec expr="substr(dim2big1, 5)"/>
+    </expression>
+    <expression _type="double" name="roundedmsr2" display_string="Rounded 
msr2" description="rounded measure2">
+      <expr_spec expr="round(msr2/1000)"/>
+    </expression>
+    <expression _type="double" name="nestedexprwithtimes" 
display_string="Nested expr" description="nested expr">
+      <expr_spec expr="avg(roundedmsr2)"/>
+      <expr_spec expr="avg(equalsums)"/>
+      <expr_spec expr="case when substrexpr = 'xyz' then avg(msr5) when 
substrexpr = 'abc' then avg(msr4)/100 end"
+                 start_time="2017-03-07T19:30:00.000+05:30"/>
+      <expr_spec expr="avg(newmeasure)"/>
+    </expression>
+  </expressions>
+  <join_chains>
+    <join_chain dest_table="userdim" name="user_id_added_far_future_chain"
+                display_string="user_id_added_far_future_chain" 
description="user_id_added_far_future_chain">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="user_id_added_far_future" 
maps_to_many="false"/>
+              <to table="userdim" column="user_id_added_far_future" 
maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="countrydim" name="cubecountry" 
display_string="cube-country"
+                description="country thru cube">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="countryid" maps_to_many="false"/>
+              <to table="countrydim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="userdim" name="userchain" 
display_string="user-chain" description="user chain">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="userid" maps_to_many="false"/>
+              <to table="userdim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="sports" name="usersports" 
display_string="user-sports" description="user sports">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="userid" maps_to_many="false"/>
+              <to table="userdim" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="userdim" column="id" maps_to_many="false"/>
+              <to table="user_interests" column="user_id" maps_to_many="true"/>
+            </edge>
+            <edge>
+              <from table="user_interests" column="sport_id" 
maps_to_many="false"/>
+              <to table="sports" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="citydim" name="cubecity" 
display_string="cube-city" description="city thru cube">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="cityid" maps_to_many="false"/>
+              <to table="citydim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim2" maps_to_many="false"/>
+              <to table="testdim2" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim2" column="cityid" maps_to_many="false"/>
+              <to table="citydim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="testdim4" name="dim4chain" 
display_string="cube-testdim3" description="cyclicdim thru cube">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim2" maps_to_many="false"/>
+              <to table="testdim2" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim2" column="testdim3id" maps_to_many="false"/>
+              <to table="testdim3" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim3" column="testdim4id" maps_to_many="false"/>
+              <to table="testdim4" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim2big1" maps_to_many="false"/>
+              <to table="testdim2" column="bigid1" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim2" column="testdim3id" maps_to_many="false"/>
+              <to table="testdim3" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim3" column="testdim4id" maps_to_many="false"/>
+              <to table="testdim4" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim2big2" maps_to_many="false"/>
+              <to table="testdim2" column="bigid2" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim2" column="testdim3id" maps_to_many="false"/>
+              <to table="testdim3" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim3" column="testdim4id" maps_to_many="false"/>
+              <to table="testdim4" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim2bignew" maps_to_many="false"/>
+              <to table="testdim2" column="bigidnew" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim2" column="testdim3id" maps_to_many="false"/>
+              <to table="testdim3" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim3" column="testdim4id" maps_to_many="false"/>
+              <to table="testdim4" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="testdim3id" maps_to_many="false"/>
+              <to table="testdim3" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim3" column="testdim4id" maps_to_many="false"/>
+              <to table="testdim4" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim12" maps_to_many="false"/>
+              <to table="testdim2" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim2" column="testdim3id" maps_to_many="false"/>
+              <to table="testdim3" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim3" column="testdim4id" maps_to_many="false"/>
+              <to table="testdim4" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="citydim" name="cubecity2" 
display_string="cube-city" description="city thru cube">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="cityid2" maps_to_many="false"/>
+              <to table="citydim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="statedim" name="citystate" 
display_string="city-state" description="state thru city">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="cityid" maps_to_many="false"/>
+              <to table="citydim" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="citydim" column="stateid" maps_to_many="false"/>
+              <to table="statedim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="cityid" maps_to_many="false"/>
+              <to table="citydim" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="citydim" column="statename" maps_to_many="false"/>
+              <to table="statedim" column="name" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="hourdim" name="timehourchain1" 
display_string="time chain"
+                description="time dim thru hour dim">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="test_time_dim_hour_id" 
maps_to_many="false"/>
+              <to table="hourdim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="zipdim" name="cubezip" display_string="cube-zip" 
description="Zipcode thru cube">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="zipcode" maps_to_many="false"/>
+              <to table="zipdim" column="code" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="union_join_ctx_zipcode" 
maps_to_many="false"/>
+              <to table="zipdim" column="code" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="sports" name="xusersports" 
display_string="xuser-sports" description="xuser sports">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="xuserid" maps_to_many="false"/>
+              <to table="userdim" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="userdim" column="id" maps_to_many="false"/>
+              <to table="user_interests" column="user_id" maps_to_many="true"/>
+            </edge>
+            <edge>
+              <from table="user_interests" column="sport_id" 
maps_to_many="false"/>
+              <to table="sports" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="statedim" name="cubestate" 
display_string="cube-state" description="state thru cube">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="stateid" maps_to_many="false"/>
+              <to table="statedim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="citydim" name="cubecityjoinunionctx" 
display_string="cube-city"
+                description="city thru cube">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="union_join_ctx_cityid" 
maps_to_many="false"/>
+              <to table="citydim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="countrydim" name="cubecitystatecountry" 
display_string="cube-city-state-country"
+                description="country through state thru city">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="cityid" maps_to_many="false"/>
+              <to table="citydim" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="citydim" column="stateid" maps_to_many="false"/>
+              <to table="statedim" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="statedim" column="countryid" maps_to_many="false"/>
+              <to table="countrydim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="zipdim" name="cityzip" display_string="city-zip" 
description="zip thru city">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="cityid" maps_to_many="false"/>
+              <to table="citydim" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="citydim" column="zipcode" maps_to_many="false"/>
+              <to table="zipdim" column="code" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="daydim" name="timedatechain2" display_string="time 
chain"
+                description="time dim thru date dim">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="test_time_dim_day_id2" 
maps_to_many="false"/>
+              <to table="daydim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="testdim3" name="dim3chain" 
display_string="cube-testdim3" description="cyclicdim thru cube">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim2" maps_to_many="false"/>
+              <to table="testdim2" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim2" column="testdim3id" maps_to_many="false"/>
+              <to table="testdim3" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim2big1" maps_to_many="false"/>
+              <to table="testdim2" column="bigid1" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim2" column="testdim3id" maps_to_many="false"/>
+              <to table="testdim3" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim2big2" maps_to_many="false"/>
+              <to table="testdim2" column="bigid2" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim2" column="testdim3id" maps_to_many="false"/>
+              <to table="testdim3" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim2bignew" maps_to_many="false"/>
+              <to table="testdim2" column="bigidnew" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim2" column="testdim3id" maps_to_many="false"/>
+              <to table="testdim3" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="testdim3id" maps_to_many="false"/>
+              <to table="testdim3" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim12" maps_to_many="false"/>
+              <to table="testdim2" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="testdim2" column="testdim3id" maps_to_many="false"/>
+              <to table="testdim3" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="cycledim1" name="cdimchain" 
display_string="cube-cyclicdim"
+                description="cyclicdim thru cube">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="cdim2" maps_to_many="false"/>
+              <to table="cycledim1" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="unreachabledim" name="unreachabledim_chain" 
display_string="cube-unreachableDim"
+                description="unreachableDim thru cube">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="urdimid" maps_to_many="false"/>
+              <to table="unreachabledim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="citydim" name="cubecity1" 
display_string="cube-city" description="city thru cube">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="cityid1" maps_to_many="false"/>
+              <to table="citydim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="sports" name="yusersports" 
display_string="user-sports" description="user sports">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="yuserid" maps_to_many="false"/>
+              <to table="userdim" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="userdim" column="id" maps_to_many="false"/>
+              <to table="user_interests" column="user_id" maps_to_many="true"/>
+            </edge>
+            <edge>
+              <from table="user_interests" column="sport_id" 
maps_to_many="false"/>
+              <to table="sports" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="hourdim" name="timehourchain2" 
display_string="time chain"
+                description="time dim thru hour dim">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="test_time_dim_hour_id2" 
maps_to_many="false"/>
+              <to table="hourdim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="user_interests" name="userinterestids" 
display_string="user-interestsIds"
+                description="user interest ids">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="userid" maps_to_many="false"/>
+              <to table="userdim" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="userdim" column="id" maps_to_many="false"/>
+              <to table="user_interests" column="user_id" maps_to_many="true"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="testdim2" name="dim2chain" 
display_string="cube-testdim2" description="testdim2 thru cube">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim2" maps_to_many="false"/>
+              <to table="testdim2" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim2big1" maps_to_many="false"/>
+              <to table="testdim2" column="bigid1" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim2big2" maps_to_many="false"/>
+              <to table="testdim2" column="bigid2" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim2bignew" maps_to_many="false"/>
+              <to table="testdim2" column="bigidnew" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="dim12" maps_to_many="false"/>
+              <to table="testdim2" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="countrydim" name="cubestatecountry" 
display_string="cube-state-country"
+                description="country through state">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="stateid" maps_to_many="false"/>
+              <to table="statedim" column="id" maps_to_many="false"/>
+            </edge>
+            <edge>
+              <from table="statedim" column="countryid" maps_to_many="false"/>
+              <to table="countrydim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain dest_table="daydim" name="timedatechain1" display_string="time 
chain"
+                description="time dim thru date dim">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="basecube" column="test_time_dim_day_id" 
maps_to_many="false"/>
+              <to table="daydim" column="id" maps_to_many="false"/>
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+  </join_chains>
+</x_base_cube>

Reply via email to