You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by am...@apache.org on 2015/04/15 21:50:20 UTC

[46/50] [abbrv] incubator-lens git commit: LENS-496: Populate sample data for sales cube and add example queries

LENS-496: Populate sample data for sales cube and add example queries


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

Branch: refs/heads/current-release-line
Commit: 9b97c19f9ccb1cbb092fe1719cc6a22835cb31b6
Parents: cddfc84
Author: Amareshwari Sriramadasu <am...@apache.org>
Authored: Tue Apr 14 16:59:06 2015 +0530
Committer: Rajat Khandelwal <ra...@gmail.com>
Committed: Tue Apr 14 16:59:06 2015 +0530

----------------------------------------------------------------------
 lens-dist/src/main/assembly/bin-dist.xml        | 110 +++++++++++++++++++
 .../lens/examples/PopulateSampleMetastore.java  |  78 ++++++++-----
 .../apache/lens/examples/SampleMetastore.java   |   1 +
 .../src/main/resources/city-local-part.xml      |  28 +++++
 .../src/main/resources/city-local.data          |   4 +
 lens-examples/src/main/resources/city_table.xml |   2 +-
 .../src/main/resources/cube-queries.sql         |  18 +++
 .../src/main/resources/customer-local-part.xml  |  29 +++++
 .../src/main/resources/customer-local.data      |   4 +
 .../src/main/resources/db-storage-schema.sql    |  32 +++++-
 .../src/main/resources/dimension-queries.sql    |   8 ++
 .../main/resources/product-local-clothes.data   |   1 +
 .../src/main/resources/product-local-food.data  |   1 +
 .../src/main/resources/product-local-parts.xml  |  60 ++++++++++
 .../resources/product-local-stationary.data     |   2 +
 .../main/resources/product-local-wearables.data |   1 +
 .../src/main/resources/product_db_table.xml     |  47 ++++++++
 .../src/main/resources/product_table.xml        |   9 --
 .../resources/sales-aggr-fact1-local-parts.xml  |  48 ++++++++
 .../main/resources/sales-aggr-fact1-local1.data |   2 +
 .../main/resources/sales-aggr-fact1-local2.data |   2 +
 .../main/resources/sales-aggr-fact1-local3.data |   2 +
 .../resources/sales-aggr-fact1-mydb-parts.xml   |  34 ++++++
 .../src/main/resources/sales-aggr-fact1.xml     |   2 -
 .../resources/sales-aggr-fact2-local-parts.xml  |  42 +++++++
 .../main/resources/sales-aggr-fact2-local1.data |   2 +
 .../main/resources/sales-aggr-fact2-local2.data |   2 +
 .../main/resources/sales-aggr-fact2-local3.data |   2 +
 .../resources/sales-aggr-fact2-mydb-parts.xml   |  34 ++++++
 lens-examples/src/main/resources/sales-cube.xml |  15 ++-
 .../src/main/resources/sales-raw-fact.xml       |   1 -
 .../main/resources/sales-raw-local-parts.xml    |  40 +++++++
 .../src/main/resources/sales-raw-local1.data    |   2 +
 .../src/main/resources/sales-raw-local2.data    |   3 +
 34 files changed, 621 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-dist/src/main/assembly/bin-dist.xml
----------------------------------------------------------------------
diff --git a/lens-dist/src/main/assembly/bin-dist.xml b/lens-dist/src/main/assembly/bin-dist.xml
index 3554425..b7b74d5 100644
--- a/lens-dist/src/main/assembly/bin-dist.xml
+++ b/lens-dist/src/main/assembly/bin-dist.xml
@@ -172,6 +172,76 @@
 
     <fileSet>
       <directory>../lens-examples/src/main/resources/</directory>
+      <outputDirectory>/client/examples/data/product_local_clothes</outputDirectory>
+      <includes>
+        <include>product-local-clothes.data</include>
+      </includes>
+    </fileSet>
+
+    <fileSet>
+      <directory>../lens-examples/src/main/resources/</directory>
+      <outputDirectory>/client/examples/data/product_local_food</outputDirectory>
+      <includes>
+        <include>product-local-food.data</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>../lens-examples/src/main/resources/</directory>
+      <outputDirectory>/client/examples/data/product_local_stationary</outputDirectory>
+      <includes>
+        <include>product-local-stationary.data</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>../lens-examples/src/main/resources/</directory>
+      <outputDirectory>/client/examples/data/product_local_wearables</outputDirectory>
+      <includes>
+        <include>product-local-wearables.data</include>
+      </includes>
+    </fileSet>
+
+    <fileSet>
+      <directory>../lens-examples/src/main/resources/</directory>
+      <outputDirectory>/client/examples/data/customer_local</outputDirectory>
+      <includes>
+        <include>customer-local.data</include>
+      </includes>
+    </fileSet>
+
+    <fileSet>
+      <directory>../lens-examples/src/main/resources/</directory>
+      <outputDirectory>/client/examples/data/city_local</outputDirectory>
+      <includes>
+        <include>city-local.data</include>
+      </includes>
+    </fileSet>
+
+    <fileSet>
+      <directory>../lens-examples/src/main/resources/</directory>
+      <outputDirectory>/client/examples/data/sales_aggr_fact1_local1</outputDirectory>
+      <includes>
+        <include>sales-aggr-fact1-local1*.data</include>
+      </includes>
+    </fileSet>
+
+    <fileSet>
+      <directory>../lens-examples/src/main/resources/</directory>
+      <outputDirectory>/client/examples/data/sales_aggr_fact1_local2</outputDirectory>
+      <includes>
+        <include>sales-aggr-fact1-local2*.data</include>
+      </includes>
+    </fileSet>
+
+    <fileSet>
+      <directory>../lens-examples/src/main/resources/</directory>
+      <outputDirectory>/client/examples/data/sales_aggr_fact1_local3</outputDirectory>
+      <includes>
+        <include>sales-aggr-fact1-local3*.data</include>
+      </includes>
+    </fileSet>
+
+    <fileSet>
+      <directory>../lens-examples/src/main/resources/</directory>
       <outputDirectory>/client/examples/data/fact1_local1</outputDirectory>
       <includes>
         <include>fact1-local1*.data</include>
@@ -220,6 +290,46 @@
 
     <fileSet>
       <directory>../lens-examples/src/main/resources/</directory>
+      <outputDirectory>/client/examples/data/sales_aggr_fact2_local1</outputDirectory>
+      <includes>
+        <include>sales-aggr-fact2-local1*.data</include>
+      </includes>
+    </fileSet>
+
+    <fileSet>
+      <directory>../lens-examples/src/main/resources/</directory>
+      <outputDirectory>/client/examples/data/sales_aggr_fact2_local2</outputDirectory>
+      <includes>
+        <include>sales-aggr-fact2-local2*.data</include>
+      </includes>
+    </fileSet>
+
+    <fileSet>
+      <directory>../lens-examples/src/main/resources/</directory>
+      <outputDirectory>/client/examples/data/sales_aggr_fact2_local3</outputDirectory>
+      <includes>
+        <include>sales-aggr-fact2-local3*.data</include>
+      </includes>
+    </fileSet>
+
+    <fileSet>
+      <directory>../lens-examples/src/main/resources/</directory>
+      <outputDirectory>/client/examples/data/sales_raw_local1</outputDirectory>
+      <includes>
+        <include>sales-raw-local1*.data</include>
+      </includes>
+    </fileSet>
+
+    <fileSet>
+      <directory>../lens-examples/src/main/resources/</directory>
+      <outputDirectory>/client/examples/data/sales_raw_local2</outputDirectory>
+      <includes>
+        <include>sales-raw-local2*.data</include>
+      </includes>
+    </fileSet>
+
+    <fileSet>
+      <directory>../lens-examples/src/main/resources/</directory>
       <outputDirectory>/client/examples/data/raw_local1</outputDirectory>
       <includes>
         <include>raw-local1*.data</include>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/java/org/apache/lens/examples/PopulateSampleMetastore.java
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/java/org/apache/lens/examples/PopulateSampleMetastore.java b/lens-examples/src/main/java/org/apache/lens/examples/PopulateSampleMetastore.java
index 0b2f37c..7883b15 100644
--- a/lens-examples/src/main/java/org/apache/lens/examples/PopulateSampleMetastore.java
+++ b/lens-examples/src/main/java/org/apache/lens/examples/PopulateSampleMetastore.java
@@ -24,6 +24,7 @@ import javax.xml.bind.JAXBException;
 
 import org.apache.lens.api.APIResult;
 import org.apache.lens.api.metastore.XPartition;
+import org.apache.lens.api.metastore.XPartitionList;
 import org.apache.lens.client.LensClientSingletonWrapper;
 import org.apache.lens.client.LensMetadataClient;
 
@@ -57,7 +58,9 @@ public class PopulateSampleMetastore {
       if (populate != null) {
         populate.close();
       }
-
+    }
+    if (populate.retCode != 0) {
+      System.exit(populate.retCode);
     }
   }
 
@@ -67,42 +70,45 @@ public class PopulateSampleMetastore {
   }
 
   public void populateDimTables() throws JAXBException, IOException {
-    XPartition partition = (XPartition) SampleMetastore.readFromXML("dim1-local-part.xml");
+    createDimTablePartition("dim1-local-part.xml", "dim_table", "local");
+    createDimTablePartition("dim2-local-part.xml", "dim_table2", "local");
+    createDimTablePartition("dim4-local-part.xml", "dim_table4", "local");
+    createDimTablePartitions("product-local-parts.xml", "product_table", "local");
+    createDimTablePartition("city-local-part.xml", "city_table", "local");
+    createDimTablePartition("customer-local-part.xml", "customer_table", "local");
+  }
+
+  private void createDimTablePartition(String fileName, String dimTable, String storage)
+    throws JAXBException, IOException {
+    XPartition partition = (XPartition) SampleMetastore.readFromXML(fileName);
     String partLocation = partition.getLocation();
     if (!partLocation.startsWith("/")) {
       partition.setLocation("file://" + System.getProperty("lens.home") + "/" + partLocation);
     }
-    result = metaClient.addPartitionToDimensionTable("dim_table", "local", partition);
+    result = metaClient.addPartitionToDimensionTable(dimTable, storage, partition);
     if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Adding partition from:dim1-local-part.xml failed");
+      System.err.println("Adding partition from:"+ fileName + " failed");
       retCode = 1;
     } else {
-      System.out.println("Added partition from:dim1-local-part.xml");
-    }
-    partition = (XPartition) SampleMetastore.readFromXML("dim2-local-part.xml");
-    partLocation = partition.getLocation();
-    if (!partLocation.startsWith("/")) {
-      partition.setLocation("file://" + System.getProperty("lens.home") + "/" + partLocation);
-    }
-    result = metaClient.addPartitionToDimensionTable("dim_table2", "local", partition);
-    if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Adding partition from:dim2-local-part.xml failed");
-      retCode = 1;
-    } else {
-      System.out.println("Added partition from:dim2-local-part.xml");
+      System.out.println("Added partition from:" + fileName);
     }
+  }
 
-    partition = (XPartition) SampleMetastore.readFromXML("dim4-local-part.xml");
-    partLocation = partition.getLocation();
-    if (!partLocation.startsWith("/")) {
-      partition.setLocation("file://" + System.getProperty("lens.home") + "/" + partLocation);
+  private void createDimTablePartitions(String fileName, String dimTable, String storage)
+    throws JAXBException, IOException {
+    XPartitionList partitionList = (XPartitionList) SampleMetastore.readFromXML(fileName);
+    for (XPartition partition : partitionList.getPartition()) {
+      String partLocation = partition.getLocation();
+      if (!partLocation.startsWith("/")) {
+        partition.setLocation("file://" + System.getProperty("lens.home") + "/" + partLocation);
+      }
     }
-    result = metaClient.addPartitionToDimensionTable("dim_table4", "local", partition);
+    result = metaClient.addPartitionsToDimensionTable(dimTable, storage, partitionList);
     if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Adding partition from:dim4-local-part.xml failed");
+      System.err.println("Adding partitions from:" + fileName + " failed");
       retCode = 1;
     } else {
-      System.out.println("Added partition from:dim4-local-part.xml");
+      System.out.println("Added partitions from:" + fileName);
     }
   }
 
@@ -114,13 +120,30 @@ public class PopulateSampleMetastore {
     }
     result = metaClient.addPartitionToFactTable(fact, storage, partition);
     if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Adding partition from:" + fileName + " failed");
+      System.err.println("Adding partition from:" + fileName + " failed");
       retCode = 1;
     } else {
       System.out.println("Added partition from:" + fileName);
     }
   }
 
+  private void createFactPartitions(String fileName, String fact, String storage) throws JAXBException, IOException {
+    XPartitionList partitionList = (XPartitionList) SampleMetastore.readFromXML(fileName);
+    for (XPartition partition : partitionList.getPartition()) {
+      String partLocation = partition.getLocation();
+      if (!partLocation.startsWith("/")) {
+        partition.setLocation("file://" + System.getProperty("lens.home") + "/" + partLocation);
+      }
+    }
+    result = metaClient.addPartitionsToFactTable(fact, storage, partitionList);
+    if (result.getStatus().equals(APIResult.Status.FAILED)) {
+      System.err.println("Adding partitions from:" + fileName + " failed");
+      retCode = 1;
+    } else {
+      System.out.println("Added partitions from:" + fileName);
+    }
+  }
+
   public void populateFactTables() throws JAXBException, IOException {
     createFactPartition("fact1-local-part1.xml", "fact1", "local");
     createFactPartition("fact1-local-part2.xml", "fact1", "local");
@@ -134,6 +157,11 @@ public class PopulateSampleMetastore {
     createFactPartition("raw-local-part4.xml", "rawfact", "local");
     createFactPartition("raw-local-part5.xml", "rawfact", "local");
     createFactPartition("raw-local-part6.xml", "rawfact", "local");
+    createFactPartitions("sales-raw-local-parts.xml", "sales_raw_fact", "local");
+    createFactPartitions("sales-aggr-fact1-local-parts.xml", "sales_aggr_fact1", "local");
+    createFactPartitions("sales-aggr-fact2-local-parts.xml", "sales_aggr_fact2", "local");
+    createFactPartitions("sales-aggr-fact1-mydb-parts.xml", "sales_aggr_fact1", "mydb");
+    createFactPartitions("sales-aggr-fact2-mydb-parts.xml", "sales_aggr_fact2", "mydb");
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java b/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
index df67ed7..2f28e5d 100644
--- a/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
+++ b/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
@@ -137,6 +137,7 @@ public class SampleMetastore {
     createDimTable("city_table.xml");
     createDimTable("city_subset.xml");
     createDimTable("product_table.xml");
+    createDimTable("product_db_table.xml");
     createDimTable("customer_table.xml");
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/city-local-part.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/city-local-part.xml b/lens-examples/src/main/resources/city-local-part.xml
new file mode 100644
index 0000000..528b880
--- /dev/null
+++ b/lens-examples/src/main/resources/city-local-part.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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_partition fact_or_dimension_table_name="city_table" location="examples/data/city_local" update_period="HOURLY"
+  xmlns="uri:lens:cube:0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+  <time_partition_spec>
+    <part_spec_element key="dt" value="2014-03-27T12:00:00"/>
+  </time_partition_spec>
+</x_partition>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/city-local.data
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/city-local.data b/lens-examples/src/main/resources/city-local.data
new file mode 100644
index 0000000..a7a2d5e
--- /dev/null
+++ b/lens-examples/src/main/resources/city-local.data
@@ -0,0 +1,4 @@
+1,Bangalore,Parks:Temples:Software companies,10000000
+2,Hyderabad,Minars:Museums:Software companies,11000000
+3,Austin,Lakes:University:Museums:Software companies,800000
+4,San Francisco,Golden gate bridge:Beaches:Software companies,800000

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/city_table.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/city_table.xml b/lens-examples/src/main/resources/city_table.xml
index 5ce18b6..27be305 100644
--- a/lens-examples/src/main/resources/city_table.xml
+++ b/lens-examples/src/main/resources/city_table.xml
@@ -36,7 +36,7 @@
         <update_period>HOURLY</update_period>
       </update_periods>
       <storage_name>local</storage_name>
-      <table_desc external="true" field_delimiter="," table_location="/tmp/examples/city">
+      <table_desc external="true" field_delimiter="," collection_delimiter=":" table_location="/tmp/examples/city">
         <part_cols>
           <column comment="Time column" name="dt" type="STRING"/>
         </part_cols>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/cube-queries.sql
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/cube-queries.sql b/lens-examples/src/main/resources/cube-queries.sql
index 8fee5a8..7a0b542 100644
--- a/lens-examples/src/main/resources/cube-queries.sql
+++ b/lens-examples/src/main/resources/cube-queries.sql
@@ -85,3 +85,21 @@ drop table temp3
 create table temp3(name string, msr4 float) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' WITH SERDEPROPERTIES ('serialization.null.format'='-NA-','field.delim'=','  ) STORED AS TEXTFILE
 insert overwrite table temp3 cube select sample_dim.name, measure4 from sample_cube where time_range_in(dt, '2014-06-24-23', '2014-06-25-00')
 select * from temp3
+cube select product_id, store_sales from sales where time_range_in(order_time, '2015-04-11-00', '2015-04-13-00')
+cube select product_id, store_sales from sales where time_range_in(order_time, '2015-04-11-00', '2015-04-13-01')
+cube select product_id, store_sales from sales where time_range_in(order_time, '2015-04-12-00', '2015-04-13-00')
+cube select product_id, store_sales from sales where time_range_in(order_time, '2015-04-13-00', '2015-04-13-02')
+cube select product_id, store_sales from sales where time_range_in(delivery_time, '2015-04-11-00', '2015-04-13-00')
+cube select product_id, store_sales from sales where time_range_in(delivery_time, '2015-04-12-00', '2015-04-13-00')
+cube select promotion_sales, store_sales from sales where time_range_in(order_time, '2015-04-13-00', '2015-04-13-02')
+cube select promotion_sales, store_sales from sales where time_range_in(order_time, '2015-04-13-00', '2015-04-13-01')
+cube select customer_city_name, store_sales from sales where time_range_in(delivery_time, '2015-04-12-00', '2015-04-13-00')
+cube select customer_city_name, store_sales from sales where time_range_in(delivery_time, '2015-04-11-00', '2015-04-13-00')
+cube select customer_city_name, delivery_city.name, production_city.name, store_sales from sales where time_range_in(delivery_time, '2015-04-11-00', '2015-04-13-00')
+cube select product_details.color, store_sales from sales where time_range_in(order_time, '2015-04-11-00', '2015-04-13-00') and product_details.category='Stationary'
+cube select product_details.category, store_sales from sales where time_range_in(order_time, '2015-04-11-00', '2015-04-13-01')
+cube select product_details.color, store_sales from sales where time_range_in(order_time, '2015-04-12-00', '2015-04-13-00')and product_details.category='Stationary'
+cube select product_details.category, store_sales from sales where time_range_in(order_time, '2015-04-11-00', '2015-04-13-01')
+cube select product_details.category, store_sales from sales where time_range_in(order_time, '2015-04-12-00', '2015-04-13-00')
+cube select product_details.color, store_sales from sales where time_range_in(delivery_time, '2015-04-11-00', '2015-04-13-00') and product_details.category='Stationary'
+cube select product_details.color, store_sales from sales where time_range_in(delivery_time, '2015-04-12-00', '2015-04-13-00') and product_details.category='Stationary'

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/customer-local-part.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/customer-local-part.xml b/lens-examples/src/main/resources/customer-local-part.xml
new file mode 100644
index 0000000..2b9e137
--- /dev/null
+++ b/lens-examples/src/main/resources/customer-local-part.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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_partition fact_or_dimension_table_name="customer_table" location="examples/data/customer_local"
+  update_period="HOURLY"
+  xmlns="uri:lens:cube:0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+  <time_partition_spec>
+    <part_spec_element key="dt" value="2014-03-27T12:00:00"/>
+  </time_partition_spec>
+</x_partition>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/customer-local.data
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/customer-local.data b/lens-examples/src/main/resources/customer-local.data
new file mode 100644
index 0000000..619a0e4
--- /dev/null
+++ b/lens-examples/src/main/resources/customer-local.data
@@ -0,0 +1,4 @@
+1,Ramu,Male,25,1,Good
+2,Meena,Female,30,2,Good
+3,JohnX,Male,25,3,Bad
+4,Anju,Female,35,4,Good
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/db-storage-schema.sql
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/db-storage-schema.sql b/lens-examples/src/main/resources/db-storage-schema.sql
index 653d2fd..bbb62e8 100644
--- a/lens-examples/src/main/resources/db-storage-schema.sql
+++ b/lens-examples/src/main/resources/db-storage-schema.sql
@@ -30,21 +30,41 @@ CREATE TABLE mydb_dim_table4 (id integer, name varchar(255), detail varchar(255)
 
 insert into mydb_dim_table4(id, name, detail, d2id) values (1,'first','this is one',11)
 insert into mydb_dim_table4(id, name, detail, d2id) values (2,'second','this is two',12)
-
-
 insert into mydb_dim_table4(id, name, detail, d2id) values (3,'third','this is three',12)
 
 DROP TABLE IF EXISTS mydb_sales_aggr_fact2
 CREATE TABLE mydb_sales_aggr_fact2 (order_time timestamp, delivery_time timestamp, product_id integer, promotion_id integer, customer_city_id integer, production_city_id integer, delivery_city_id integer, unit_sales double, store_sales double, store_cost double)
 
+INSERT INTO mydb_sales_aggr_fact2(order_time, delivery_time, product_id, promotion_id, customer_city_id, production_city_id, delivery_city_id, unit_sales, store_sales, store_cost) values ('2015-04-12 00:00:00','2015-04-12 00:00:00',1,1,1,1,1,1,5,0)
+INSERT INTO mydb_sales_aggr_fact2(order_time, delivery_time, product_id, promotion_id, customer_city_id, production_city_id, delivery_city_id, unit_sales, store_sales, store_cost) values ('2015-04-12 00:00:00','2015-04-12 00:00:00',2,1,2,2,2,1,8,2)
+
 DROP TABLE IF EXISTS mydb_sales_aggr_fact1
-CREATE TABLE mydb_sales_aggr_fact1 (order_time timestamp, delivery_time timestamp, customer_id integer, product_id integer, promotion_id integer, customer_city_id integer, production_city_id integer, delivery_city_id integer, unit_sales double, store_sales double, store_cost double, average_line_item_price float, average_line_item_discount float, max_line_item_price float, max_line_item_discount float)
+CREATE TABLE mydb_sales_aggr_fact1 (order_time timestamp, delivery_time timestamp, customer_id integer, product_id integer, promotion_id integer, customer_city_id integer, production_city_id integer, delivery_city_id integer, unit_sales double, store_sales double, store_cost double, max_line_item_price float, max_line_item_discount float)
+
+INSERT INTO mydb_sales_aggr_fact1 (order_time, delivery_time, customer_id, product_id, promotion_id, customer_city_id, production_city_id, delivery_city_id, unit_sales, store_sales, store_cost, max_line_item_price, max_line_item_discount) values ('2015-04-12 00:00:00','2015-04-12 00:00:00',1,1,1,1,1,1,1,5,0,5,0)
+INSERT INTO mydb_sales_aggr_fact1 (order_time, delivery_time, customer_id, product_id, promotion_id, customer_city_id, production_city_id, delivery_city_id, unit_sales, store_sales, store_cost, max_line_item_price, max_line_item_discount) values ('2015-04-12 00:00:00','2015-04-12 00:00:00',2,2,1,2,2,2,1,8,2,10,2)
 
-DROP TABLE IF EXISTS mydb_product_table
-CREATE TABLE mydb_product_table (id integer, SKU_number integer, description varchar(255), color varchar(50), category varchar(255), weight float, manufacturer varchar(255))
+DROP TABLE IF EXISTS mydb_product_db_table
+CREATE TABLE mydb_product_db_table (id integer, SKU_number integer, description varchar(255), color varchar(50), category varchar(255), weight float, manufacturer varchar(255))
+
+INSERT INTO mydb_product_db_table (id, SKU_number, description, color, category, weight, manufacturer) values (1,111,'Book','White','Stationary',200,'BookCompany')
+INSERT INTO mydb_product_db_table (id, SKU_number, description, color, category, weight, manufacturer) values (2,222,'Pen','Blue','Stationary',50,'BookCompany')
+INSERT INTO mydb_product_db_table (id, SKU_number, description, color, category, weight, manufacturer) values (3,333,'Shirt','Purple','Clothes',200,'StylistCompany')
+INSERT INTO mydb_product_db_table (id, SKU_number, description, color, category, weight, manufacturer) values (4,444,'Shoes','Blue','Wearables',1000,'StylistCompany')
+INSERT INTO mydb_product_db_table (id, SKU_number, description, color, category, weight, manufacturer) values (5,555,'Chocolates','Brown','Food',500,'ChocoManufacturer')
 
 DROP TABLE IF EXISTS mydb_customer_table
-CREATE TABLE mydb_customer_table (id integer, name varchar(255), description varchar(255), gender varchar(50), age integer, city_id integer, customer_credit_status varchar(255))
+CREATE TABLE mydb_customer_table (id integer, name varchar(255), gender varchar(50), age integer, city_id integer, customer_credit_status varchar(255))
+
+INSERT INTO mydb_customer_table (id, name, gender, age, city_id, customer_credit_status) values (1,'Ramu','Male',25,1,'Good')
+INSERT INTO mydb_customer_table (id, name, gender, age, city_id, customer_credit_status) values (2,'Meena','Female',30,2,'Good')
+INSERT INTO mydb_customer_table (id, name, gender, age, city_id, customer_credit_status) values (3,'JohnX','Male',25,3,'Bad')
+INSERT INTO mydb_customer_table (id, name, gender, age, city_id, customer_credit_status) values (4,'Anju','Female',35,4,'Good')
 
 DROP TABLE IF EXISTS mydb_city_subset
 CREATE TABLE mydb_city_subset (id integer, name varchar(255))
+
+INSERT INTO mydb_city_subset (id, name) values (1, 'Bangalore')
+INSERT INTO mydb_city_subset (id, name) values (2, 'Hyderabad')
+INSERT INTO mydb_city_subset (id, name) values (3, 'Austin')
+INSERT INTO mydb_city_subset (id, name) values (4, 'San Fransisco')

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/dimension-queries.sql
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/dimension-queries.sql b/lens-examples/src/main/resources/dimension-queries.sql
index 5807336..7aff639 100644
--- a/lens-examples/src/main/resources/dimension-queries.sql
+++ b/lens-examples/src/main/resources/dimension-queries.sql
@@ -69,3 +69,11 @@ drop table temp3
 create table temp3(id int, name string) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' WITH SERDEPROPERTIES ('serialization.null.format'='-NA-','field.delim'=','  ) STORED AS TEXTFILE
 insert overwrite table temp3 cube select id,name from sample_dim
 select * from temp3
+cube select name from city
+cube select name from city where population > 1000000
+cube select name, poi from city
+cube select distinct category from product
+cube select id, description from product where weight > 100
+cube select category, count(1) as `Number of products` from product
+cube select name, customer_city_name from customer
+cube select customer.name, customer_city.population from customer

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/product-local-clothes.data
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/product-local-clothes.data b/lens-examples/src/main/resources/product-local-clothes.data
new file mode 100644
index 0000000..b85e329
--- /dev/null
+++ b/lens-examples/src/main/resources/product-local-clothes.data
@@ -0,0 +1 @@
+3,333,Shirt,Purple,200,StylistCompany
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/product-local-food.data
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/product-local-food.data b/lens-examples/src/main/resources/product-local-food.data
new file mode 100644
index 0000000..78fe205
--- /dev/null
+++ b/lens-examples/src/main/resources/product-local-food.data
@@ -0,0 +1 @@
+5,555,Chocolates,Brown,500,ChocoManufacturer
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/product-local-parts.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/product-local-parts.xml b/lens-examples/src/main/resources/product-local-parts.xml
new file mode 100644
index 0000000..426dec0
--- /dev/null
+++ b/lens-examples/src/main/resources/product-local-parts.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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_partition_list xmlns="uri:lens:cube:0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+  <partition fact_or_dimension_table_name="product_table" location="examples/data/product_local_clothes"
+    update_period="HOURLY">
+    <non_time_partition_spec>
+      <part_spec_element key="category" value="Clothes" />
+    </non_time_partition_spec>
+    <time_partition_spec>
+      <part_spec_element key="dt" value="2014-03-27T12:00:00" />
+    </time_partition_spec>
+  </partition>
+  <partition fact_or_dimension_table_name="product_table" location="examples/data/product_local_food"
+    update_period="HOURLY">
+    <non_time_partition_spec>
+      <part_spec_element key="category" value="Food" />
+    </non_time_partition_spec>
+    <time_partition_spec>
+      <part_spec_element key="dt" value="2014-03-27T12:00:00" />
+    </time_partition_spec>
+  </partition>
+  <partition fact_or_dimension_table_name="product_table" location="examples/data/product_local_stationary"
+    update_period="HOURLY">
+    <non_time_partition_spec>
+      <part_spec_element key="category" value="Stationary" />
+    </non_time_partition_spec>
+    <time_partition_spec>
+      <part_spec_element key="dt" value="2014-03-27T12:00:00" />
+    </time_partition_spec>
+  </partition>
+  <partition fact_or_dimension_table_name="product_table" location="examples/data/product_local_wearables"
+    update_period="HOURLY">
+    <non_time_partition_spec>
+      <part_spec_element key="category" value="Wearables" />
+    </non_time_partition_spec>
+    <time_partition_spec>
+      <part_spec_element key="dt" value="2014-03-27T12:00:00" />
+    </time_partition_spec>
+  </partition>
+</x_partition_list>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/product-local-stationary.data
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/product-local-stationary.data b/lens-examples/src/main/resources/product-local-stationary.data
new file mode 100644
index 0000000..9b994af
--- /dev/null
+++ b/lens-examples/src/main/resources/product-local-stationary.data
@@ -0,0 +1,2 @@
+1,111,Book,White,200,BookCompany
+2,222,Pen,Blue,50,BookCompany
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/product-local-wearables.data
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/product-local-wearables.data b/lens-examples/src/main/resources/product-local-wearables.data
new file mode 100644
index 0000000..16ff905
--- /dev/null
+++ b/lens-examples/src/main/resources/product-local-wearables.data
@@ -0,0 +1 @@
+4,444,Shoes,Blue,1000,StylistCompany

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/product_db_table.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/product_db_table.xml b/lens-examples/src/main/resources/product_db_table.xml
new file mode 100644
index 0000000..d961c44
--- /dev/null
+++ b/lens-examples/src/main/resources/product_db_table.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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_dimension_table dimension_name="product" table_name="product_db_table" weight="0.0" xmlns="uri:lens:cube:0.1"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+  <columns>
+    <column comment="ID" name="id" type="INT"/>
+    <column comment="SKU_number" name="SKU_number" type="INT"/>
+    <column comment="" name="description" type="STRING"/>
+    <column comment="" name="color" type="STRING"/>
+    <column comment="Category" name="category" type="STRING"/>
+    <column comment="" name="weight" type="FLOAT"/>
+    <column comment="" name="manufacturer" type="STRING"/>
+  </columns>
+  <properties>
+    <property name="dim4.prop" value="d1"/>
+  </properties>
+  <storage_tables>
+    <storage_table>
+      <storage_name>mydb</storage_name>
+      <table_desc external="true" table_location="/tmp/db-storage.db"
+        storage_handler_name="org.apache.lens.storage.db.DBStorageHandler">
+        <table_parameters>
+          <property name="lens.metastore.native.db.name" value="default"/>
+        </table_parameters>
+      </table_desc>
+    </storage_table>
+  </storage_tables>
+</x_dimension_table>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/product_table.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/product_table.xml b/lens-examples/src/main/resources/product_table.xml
index f7e804f..86a1115 100644
--- a/lens-examples/src/main/resources/product_table.xml
+++ b/lens-examples/src/main/resources/product_table.xml
@@ -47,14 +47,5 @@
         <time_part_cols>dt</time_part_cols>
       </table_desc>
     </storage_table>
-    <storage_table>
-      <storage_name>mydb</storage_name>
-      <table_desc external="true" field_delimiter="," table_location="/tmp/db-storage.db"
-        storage_handler_name="org.apache.lens.storage.db.DBStorageHandler">
-        <table_parameters>
-          <property name="lens.metastore.native.db.name" value="default"/>
-        </table_parameters>
-      </table_desc>
-    </storage_table>
   </storage_tables>
 </x_dimension_table>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-aggr-fact1-local-parts.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-aggr-fact1-local-parts.xml b/lens-examples/src/main/resources/sales-aggr-fact1-local-parts.xml
new file mode 100644
index 0000000..3bba7fa
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-aggr-fact1-local-parts.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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_partition_list xmlns="uri:lens:cube:0.1"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+  <partition fact_or_dimension_table_name="sales_aggr_fact1" location="examples/data/sales_aggr_fact1_local1"
+    update_period="DAILY">
+    <time_partition_spec>
+      <part_spec_element key="pt" value="2015-04-12T00:00:00"/>
+      <part_spec_element key="ot" value="2015-04-11T00:00:00"/>
+      <part_spec_element key="dt" value="2015-04-11T00:00:00"/>
+    </time_partition_spec>
+  </partition>
+  <partition fact_or_dimension_table_name="sales_aggr_fact1" location="examples/data/sales_aggr_fact1_local2"
+    update_period="DAILY">
+    <time_partition_spec>
+      <part_spec_element key="pt" value="2015-04-13T00:00:00"/>
+      <part_spec_element key="ot" value="2015-04-12T00:00:00"/>
+      <part_spec_element key="dt" value="2015-04-12T00:00:00"/>
+    </time_partition_spec>
+  </partition>
+  <partition fact_or_dimension_table_name="sales_aggr_fact1" location="examples/data/sales_aggr_fact1_local3"
+    update_period="HOURLY">
+    <time_partition_spec>
+      <part_spec_element key="pt" value="2015-04-13T05:00:00"/>
+      <part_spec_element key="ot" value="2015-04-13T00:00:00"/>
+      <part_spec_element key="dt" value="2015-04-13T04:00:00"/>
+    </time_partition_spec>
+  </partition>
+</x_partition_list>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-aggr-fact1-local1.data
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-aggr-fact1-local1.data b/lens-examples/src/main/resources/sales-aggr-fact1-local1.data
new file mode 100644
index 0000000..859f326
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-aggr-fact1-local1.data
@@ -0,0 +1,2 @@
+2015-04-11 00:00:00,2015-04-11 00:00:00,1,1,1,1,1,1,1,5,0,5,0
+2015-04-11 00:00:00,2015-04-11 00:00:00,2,2,1,2,2,2,1,8,2,10,2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-aggr-fact1-local2.data
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-aggr-fact1-local2.data b/lens-examples/src/main/resources/sales-aggr-fact1-local2.data
new file mode 100644
index 0000000..6fd01f7
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-aggr-fact1-local2.data
@@ -0,0 +1,2 @@
+2015-04-12 00:00:00,2015-04-12 00:00:00,1,1,1,1,1,1,1,5,0,5,0
+2015-04-12 00:00:00,2015-04-12 00:00:00,2,2,1,2,2,2,1,8,2,10,2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-aggr-fact1-local3.data
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-aggr-fact1-local3.data b/lens-examples/src/main/resources/sales-aggr-fact1-local3.data
new file mode 100644
index 0000000..2cdbe45
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-aggr-fact1-local3.data
@@ -0,0 +1,2 @@
+2015-04-13 00:00:00,2015-04-13 04:00:00,1,1,1,1,1,1,1,5,0,5,0
+2015-04-13 00:00:00,2015-04-13 04:00:00,2,2,1,2,2,2,1,8,2,10,2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-aggr-fact1-mydb-parts.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-aggr-fact1-mydb-parts.xml b/lens-examples/src/main/resources/sales-aggr-fact1-mydb-parts.xml
new file mode 100644
index 0000000..451e165
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-aggr-fact1-mydb-parts.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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_partition_list xmlns="uri:lens:cube:0.1"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+  <partition fact_or_dimension_table_name="sales_aggr_fact1" location="/tmp/examples/data/sales_aggr_fact1_local2"
+    update_period="DAILY"
+    xmlns="uri:lens:cube:0.1"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+    <time_partition_spec>
+      <part_spec_element key="pt" value="2015-04-13T00:00:00"/>
+      <part_spec_element key="ot" value="2015-04-12T00:00:00"/>
+      <part_spec_element key="dt" value="2015-04-12T00:00:00"/>
+    </time_partition_spec>
+  </partition>
+</x_partition_list>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-aggr-fact1.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-aggr-fact1.xml b/lens-examples/src/main/resources/sales-aggr-fact1.xml
index 8d50554..073052d 100644
--- a/lens-examples/src/main/resources/sales-aggr-fact1.xml
+++ b/lens-examples/src/main/resources/sales-aggr-fact1.xml
@@ -33,8 +33,6 @@
     <column comment="" name="unit_sales" type="BIGINT"/>
     <column comment="" name="store_sales" type="DOUBLE"/>
     <column comment="" name="store_cost" type="DOUBLE"/>
-    <column comment="" name="average_line_item_price" type="FLOAT"/>
-    <column comment="" name="average_line_item_discount" type="FLOAT"/>
     <column comment="" name="max_line_item_price" type="FLOAT"/>
     <column comment="" name="max_line_item_discount" type="FLOAT"/>
   </columns>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-aggr-fact2-local-parts.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-aggr-fact2-local-parts.xml b/lens-examples/src/main/resources/sales-aggr-fact2-local-parts.xml
new file mode 100644
index 0000000..35a8801
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-aggr-fact2-local-parts.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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_partition_list xmlns="uri:lens:cube:0.1"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+  <partition fact_or_dimension_table_name="sales_aggr_fact2" location="examples/data/sales_aggr_fact2_local1"
+    update_period="DAILY">
+    <time_partition_spec>
+      <part_spec_element key="dt" value="2015-04-11T00:00:00"/>
+    </time_partition_spec>
+  </partition>
+  <partition fact_or_dimension_table_name="sales_aggr_fact2" location="examples/data/sales_aggr_fact2_local2"
+    update_period="DAILY">
+    <time_partition_spec>
+      <part_spec_element key="dt" value="2015-04-12T00:00:00"/>
+    </time_partition_spec>
+  </partition>
+  <partition fact_or_dimension_table_name="sales_aggr_fact2" location="examples/data/sales_aggr_fact2_local3"
+    update_period="HOURLY">
+    <time_partition_spec>
+      <part_spec_element key="dt" value="2015-04-13T04:00:00"/>
+    </time_partition_spec>
+  </partition>
+</x_partition_list>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-aggr-fact2-local1.data
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-aggr-fact2-local1.data b/lens-examples/src/main/resources/sales-aggr-fact2-local1.data
new file mode 100644
index 0000000..e0ccd5b
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-aggr-fact2-local1.data
@@ -0,0 +1,2 @@
+2015-04-11 00:00:00,2015-04-11 00:00:00,1,1,1,1,1,1,5,0
+2015-04-11 00:00:00,2015-04-11 00:00:00,2,1,2,2,2,1,8,2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-aggr-fact2-local2.data
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-aggr-fact2-local2.data b/lens-examples/src/main/resources/sales-aggr-fact2-local2.data
new file mode 100644
index 0000000..0fe9442
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-aggr-fact2-local2.data
@@ -0,0 +1,2 @@
+2015-04-12 00:00:00,2015-04-12 00:00:00,1,1,1,1,1,1,5,0
+2015-04-12 00:00:00,2015-04-12 00:00:00,2,1,2,2,2,1,8,2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-aggr-fact2-local3.data
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-aggr-fact2-local3.data b/lens-examples/src/main/resources/sales-aggr-fact2-local3.data
new file mode 100644
index 0000000..a0cb704
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-aggr-fact2-local3.data
@@ -0,0 +1,2 @@
+2015-04-13 00:00:00,2015-04-13 04:00:00,1,1,1,1,1,1,5,0
+2015-04-13 00:00:00,2015-04-13 04:00:00,2,1,2,2,2,1,8,2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-aggr-fact2-mydb-parts.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-aggr-fact2-mydb-parts.xml b/lens-examples/src/main/resources/sales-aggr-fact2-mydb-parts.xml
new file mode 100644
index 0000000..ae8a663
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-aggr-fact2-mydb-parts.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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_partition_list xmlns="uri:lens:cube:0.1"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+  <partition fact_or_dimension_table_name="sales_aggr_fact2" location="/tmp/examples/data/sales_aggr_fact2_local2"
+    update_period="DAILY"
+    xmlns="uri:lens:cube:0.1"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+    <time_partition_spec>
+      <part_spec_element key="pt" value="2015-04-13T00:00:00"/>
+      <part_spec_element key="ot" value="2015-04-12T00:00:00"/>
+      <part_spec_element key="dt" value="2015-04-12T00:00:00"/>
+    </time_partition_spec>
+  </partition>
+</x_partition_list>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-cube.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-cube.xml b/lens-examples/src/main/resources/sales-cube.xml
index d4768cc..951ace9 100644
--- a/lens-examples/src/main/resources/sales-cube.xml
+++ b/lens-examples/src/main/resources/sales-cube.xml
@@ -30,9 +30,6 @@
     <measure name="line_item_product_price" type="FLOAT" default_aggr="SUM" display_string="Line item product price"/>
     <measure name="line_item_discount_amount" type="FLOAT" default_aggr="SUM" display_string="Line item discount"/>
     <measure name="line_item_tax" type="FLOAT" default_aggr="SUM" display_string="Line item tax"/>
-    <measure name="average_line_item_price" type="FLOAT" default_aggr="AVG" display_string="Average Line item price"/>
-    <measure name="average_line_item_discount" type="FLOAT" default_aggr="AVG"
-     display_string="Average Line item discount"/>
     <measure name="max_line_item_price" type="FLOAT" default_aggr="MAX" display_string="Maximum Line item price"/>
     <measure name="max_line_item_discount" type="FLOAT" default_aggr="MAX"
      display_string="Maximum Line item discount"/>
@@ -85,6 +82,18 @@
         </path>
       </paths>
     </join_chain>
+    <join_chain name="product_details">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="sales" column="product_id" />
+              <to table="product" column="id" />
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
     <join_chain name="customer_city">
       <paths>
         <path>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-raw-fact.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-raw-fact.xml b/lens-examples/src/main/resources/sales-raw-fact.xml
index 5b4fa18..4c2d571 100644
--- a/lens-examples/src/main/resources/sales-raw-fact.xml
+++ b/lens-examples/src/main/resources/sales-raw-fact.xml
@@ -47,7 +47,6 @@
     <storage_table>
       <update_periods>
         <update_period>HOURLY</update_period>
-        <update_period>DAILY</update_period>
       </update_periods>
       <storage_name>local</storage_name>
       <table_desc external="true" field_delimiter="," table_location="/tmp/examples/rawfact">

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-raw-local-parts.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-raw-local-parts.xml b/lens-examples/src/main/resources/sales-raw-local-parts.xml
new file mode 100644
index 0000000..4cbda31
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-raw-local-parts.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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_partition_list xmlns="uri:lens:cube:0.1"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+  <partition fact_or_dimension_table_name="sales_raw_fact" location="examples/data/sales_raw_local1"
+    update_period="HOURLY">
+    <time_partition_spec>
+      <part_spec_element key="pt" value="2015-04-13T05:00:00"/>
+      <part_spec_element key="ot" value="2015-04-13T00:00:00"/>
+      <part_spec_element key="dt" value="2015-04-13T04:00:00"/>
+    </time_partition_spec>
+  </partition>
+  <partition fact_or_dimension_table_name="sales_raw_fact" location="examples/data/sales_raw_local2"
+    update_period="HOURLY">
+    <time_partition_spec>
+      <part_spec_element key="pt" value="2015-04-13T06:00:00"/>
+      <part_spec_element key="ot" value="2015-04-13T01:00:00"/>
+      <part_spec_element key="dt" value="2015-04-13T05:00:00"/>
+    </time_partition_spec>
+  </partition>
+</x_partition_list>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-raw-local1.data
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-raw-local1.data b/lens-examples/src/main/resources/sales-raw-local1.data
new file mode 100644
index 0000000..5c8a909
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-raw-local1.data
@@ -0,0 +1,2 @@
+2015-04-13 00:00:00,2015-04-13 04:00:00,1,1,1,1,1,1,1,1,1,5,0,1,5,0,0
+2015-04-13 00:00:00,2015-04-13 04:00:00,2,2,1,1,1,2,2,2,1,8,2,1,10,2,0
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/9b97c19f/lens-examples/src/main/resources/sales-raw-local2.data
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-raw-local2.data b/lens-examples/src/main/resources/sales-raw-local2.data
new file mode 100644
index 0000000..a5d5cc5
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-raw-local2.data
@@ -0,0 +1,3 @@
+2015-04-13 01:00:00,2015-04-13 05:00:00,1,1,1,1,1,1,1,1,1,5,0,1,5,0,0
+2015-04-13 01:00:00,2015-04-13 05:00:00,2,2,2,1,1,2,2,2,1,8,2,1,10,2,0
+2015-04-13 01:00:00,2015-04-13 05:00:00,2,2,3,0,1,2,2,2,1,8,2,1,10,2,0
\ No newline at end of file