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:12 UTC

[38/50] [abbrv] incubator-lens git commit: LENS-491: Create example metastore schema for sales

LENS-491: Create example metastore schema for sales


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

Branch: refs/heads/current-release-line
Commit: f0798b14afce6b3634e1150a6d6ae7e0c276b5be
Parents: c20120c
Author: Amareshwari Sriramadasu <am...@apache.org>
Authored: Thu Apr 9 14:49:04 2015 +0530
Committer: Rajat Khandelwal <ra...@gmail.com>
Committed: Thu Apr 9 14:49:04 2015 +0530

----------------------------------------------------------------------
 .../lens/cli/commands/BaseLensCommand.java      |   3 +
 .../apache/lens/cube/metadata/JoinChain.java    |  16 ++-
 .../org/apache/lens/examples/DatabaseUtil.java  |   4 +-
 .../lens/examples/PopulateSampleMetastore.java  |   8 --
 .../apache/lens/examples/SampleMetastore.java   | 100 ++++++-------
 lens-examples/src/main/resources/city.xml       |  33 +++++
 .../src/main/resources/city_subset.xml          |  39 +++++
 lens-examples/src/main/resources/city_table.xml |  47 ++++++
 lens-examples/src/main/resources/customer.xml   |  55 +++++++
 .../src/main/resources/customer_table.xml       |  58 ++++++++
 .../src/main/resources/db-storage-schema.sql    |  12 ++
 lens-examples/src/main/resources/product.xml    |  36 +++++
 .../src/main/resources/product_table.xml        |  59 ++++++++
 .../src/main/resources/sales-aggr-fact1.xml     |  83 +++++++++++
 .../src/main/resources/sales-aggr-fact2.xml     |  74 ++++++++++
 lens-examples/src/main/resources/sales-cube.xml | 142 +++++++++++++++++++
 .../src/main/resources/sales-raw-fact.xml       |  65 +++++++++
 .../apache/lens/server/metastore/JAXBUtils.java |   4 +-
 18 files changed, 772 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/f0798b14/lens-cli/src/main/java/org/apache/lens/cli/commands/BaseLensCommand.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/main/java/org/apache/lens/cli/commands/BaseLensCommand.java b/lens-cli/src/main/java/org/apache/lens/cli/commands/BaseLensCommand.java
index cdfdbe8..dbb8b39 100644
--- a/lens-cli/src/main/java/org/apache/lens/cli/commands/BaseLensCommand.java
+++ b/lens-cli/src/main/java/org/apache/lens/cli/commands/BaseLensCommand.java
@@ -30,6 +30,7 @@ import org.codehaus.jackson.JsonGenerationException;
 import org.codehaus.jackson.JsonGenerator;
 import org.codehaus.jackson.impl.Indenter;
 import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
 import org.codehaus.jackson.util.DefaultPrettyPrinter;
 
 /**
@@ -74,6 +75,8 @@ public class BaseLensCommand {
   public BaseLensCommand() {
     getClient();
     mapper = new ObjectMapper();
+    mapper.setSerializationInclusion(Inclusion.NON_NULL);
+    mapper.setSerializationInclusion(Inclusion.NON_DEFAULT);
     pp = new DefaultPrettyPrinter();
     pp.indentObjectsWith(new Indenter() {
       @Override

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/f0798b14/lens-cube/src/main/java/org/apache/lens/cube/metadata/JoinChain.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/metadata/JoinChain.java b/lens-cube/src/main/java/org/apache/lens/cube/metadata/JoinChain.java
index 3c8cb3a..a3d15a7 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/metadata/JoinChain.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/metadata/JoinChain.java
@@ -61,8 +61,12 @@ public class JoinChain implements Named {
       props.put(MetastoreUtil.getCubeJoinChainFullChainKey(getName(), i),
         MetastoreUtil.getReferencesString(paths.get(i).getReferences()));
     }
-    props.put(MetastoreUtil.getCubeJoinChainDisplayKey(getName()), displayString);
-    props.put(MetastoreUtil.getCubeJoinChainDescriptionKey(getName()), description);
+    if (displayString != null) {
+      props.put(MetastoreUtil.getCubeJoinChainDisplayKey(getName()), displayString);
+    }
+    if (description != null) {
+      props.put(MetastoreUtil.getCubeJoinChainDescriptionKey(getName()), description);
+    }
   }
 
   public void addProperties(Dimension dimension) {
@@ -72,8 +76,12 @@ public class JoinChain implements Named {
       props.put(MetastoreUtil.getDimensionJoinChainFullChainKey(getName(), i),
         MetastoreUtil.getReferencesString(paths.get(i).getReferences()));
     }
-    props.put(MetastoreUtil.getDimensionJoinChainDisplayKey(getName()), displayString);
-    props.put(MetastoreUtil.getDimensionJoinChainDescriptionKey(getName()), description);
+    if (displayString != null) {
+      props.put(MetastoreUtil.getDimensionJoinChainDisplayKey(getName()), displayString);
+    }
+    if (description != null) {
+      props.put(MetastoreUtil.getDimensionJoinChainDescriptionKey(getName()), description);
+    }
   }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/f0798b14/lens-examples/src/main/java/org/apache/lens/examples/DatabaseUtil.java
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/java/org/apache/lens/examples/DatabaseUtil.java b/lens-examples/src/main/java/org/apache/lens/examples/DatabaseUtil.java
index 9bcbd9a..6191aa5 100644
--- a/lens-examples/src/main/java/org/apache/lens/examples/DatabaseUtil.java
+++ b/lens-examples/src/main/java/org/apache/lens/examples/DatabaseUtil.java
@@ -39,7 +39,7 @@ public final class DatabaseUtil {
    *
    * @throws Exception the exception
    */
-  public static void initalizeDatabaseStorage() throws Exception {
+  public static void initializeDatabaseStorage() throws Exception {
 
     try {
       Class.forName("org.hsqldb.jdbcDriver");
@@ -72,6 +72,6 @@ public final class DatabaseUtil {
    * @throws Exception the exception
    */
   public static void main(String[] args) throws Exception {
-    DatabaseUtil.initalizeDatabaseStorage();
+    DatabaseUtil.initializeDatabaseStorage();
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/f0798b14/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 6604553..0b2f37c 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
@@ -104,14 +104,6 @@ public class PopulateSampleMetastore {
     } else {
       System.out.println("Added partition from:dim4-local-part.xml");
     }
-
-    try {
-      DatabaseUtil.initalizeDatabaseStorage();
-      System.out.println("Created DB storages for dim_table3 and dim_table4");
-    } catch (Exception e) {
-      e.printStackTrace();
-      System.out.println("Creating DB storage failed for dim_table3 and dim_table4");
-    }
   }
 
   private void createFactPartition(String fileName, String fact, String storage) throws JAXBException, IOException {

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/f0798b14/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 09be3f2..df67ed7 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
@@ -63,38 +63,39 @@ public class SampleMetastore {
     LensClientSingletonWrapper.instance().getClient().closeConnection();
   }
 
-  public void createCube() throws JAXBException, IOException {
-    result = metaClient.createCube("sample-cube.xml");
+  private void createCube(String cubeSpec) {
+    result = metaClient.createCube(cubeSpec);
     if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Creating cube from:sample-cube.xml failed, reason:" + result.getMessage());
+      System.err.println("Creating cube from:" + cubeSpec + " failed, reason:" + result.getMessage());
       retCode = 1;
     }
   }
 
-  public void createDimensions() throws JAXBException, IOException {
-    result = metaClient.createDimension("sample-dimension.xml");
-    if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Creating dimension from:sample-dimension.xml failed, reason:" + result.getMessage());
-      retCode = 1;
-    }
-
-    result = metaClient.createDimension("sample-dimension2.xml");
-    if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Creating dimension from:sample-dimension2.xml failed, reason:" + result.getMessage());
-      retCode = 1;
-    }
+  public void createCubes() throws JAXBException, IOException {
+    createCube("sample-cube.xml");
+    createCube("sales-cube.xml");
+  }
 
-    result = metaClient.createDimension("sample-db-only-dimension.xml");
+  private void createDimension(String dimensionSpec) {
+    result = metaClient.createDimension(dimensionSpec);
     if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Creating dimension from:sample-db-only-dimension.xml failed, reason:" + result.getMessage());
+      System.err.println("Creating dimension from:" + dimensionSpec + " failed, reason:" + result.getMessage());
       retCode = 1;
     }
   }
+  public void createDimensions() throws JAXBException, IOException {
+    createDimension("sample-dimension.xml");
+    createDimension("sample-dimension2.xml");
+    createDimension("sample-db-only-dimension.xml");
+    createDimension("city.xml");
+    createDimension("customer.xml");
+    createDimension("product.xml");
+  }
 
   private void createStorage(String fileName) throws JAXBException, IOException {
     result = metaClient.createNewStorage(fileName);
     if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Creating storage from:" + fileName + " failed, reason:" + result.getMessage());
+      System.err.println("Creating storage from:" + fileName + " failed, reason:" + result.getMessage());
       retCode = 1;
     }
   }
@@ -107,53 +108,52 @@ public class SampleMetastore {
 
   public void createAll() throws JAXBException, IOException {
     createStorages();
-    createCube();
+    createCubes();
     createDimensions();
     createFacts();
     createDimensionTables();
-  }
-
-  private void createDimensionTables() throws JAXBException, IOException {
-    result = metaClient.createDimensionTable("dim_table.xml");
-    if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Creating dim table from: dim_table.xml failed, reason:" + result.getMessage());
-      retCode = 1;
-    }
-    result = metaClient.createDimensionTable("dim_table2.xml");
-    if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Creating dim table from: dim_table2.xml failed, reason:" + result.getMessage());
+    try {
+      DatabaseUtil.initializeDatabaseStorage();
+      System.out.println("Created DB storages");
+    } catch (Exception e) {
       retCode = 1;
+      e.printStackTrace();
+      System.err.println("Creating DB storage failed");
     }
+  }
 
-    result = metaClient.createDimensionTable("dim_table3.xml");
+  private void createDimTable(String dimTableSpec) {
+    result = metaClient.createDimensionTable(dimTableSpec);
     if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Creating dim table from: dim_table3.xmlfailed, reason:" + result.getMessage());
+      System.err.println("Creating dim table from: " + dimTableSpec + " failed, reason:" + result.getMessage());
       retCode = 1;
     }
+  }
+  private void createDimensionTables() throws JAXBException, IOException {
+    createDimTable("dim_table.xml");
+    createDimTable("dim_table2.xml");
+    createDimTable("dim_table3.xml");
+    createDimTable("dim_table4.xml");
+    createDimTable("city_table.xml");
+    createDimTable("city_subset.xml");
+    createDimTable("product_table.xml");
+    createDimTable("customer_table.xml");
+  }
 
-    result = metaClient.createDimensionTable("dim_table4.xml");
+  private void createFact(String factSpec) {
+    result = metaClient.createFactTable(factSpec);
     if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Creating dim table from: dim_table4.xml failed, reason:" + result.getMessage());
+      System.err.println("Creating fact table from: " + factSpec + " failed, reason:" + result.getMessage());
       retCode = 1;
     }
   }
-
   private void createFacts() throws JAXBException, IOException {
-    result = metaClient.createFactTable("fact1.xml");
-    if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Creating fact table from: fact1.xml failed, reason:" + result.getMessage());
-      retCode = 1;
-    }
-    result = metaClient.createFactTable("fact2.xml");
-    if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Creating fact table from: fact2.xml failed, reason:" + result.getMessage());
-      retCode = 1;
-    }
-    result = metaClient.createFactTable("rawfact.xml");
-    if (result.getStatus().equals(APIResult.Status.FAILED)) {
-      System.out.println("Creating fact table from: rawfact.xml failed, reason:" + result.getMessage());
-      retCode = 1;
-    }
+    createFact("fact1.xml");
+    createFact("fact2.xml");
+    createFact("rawfact.xml");
+    createFact("sales-raw-fact.xml");
+    createFact("sales-aggr-fact1.xml");
+    createFact("sales-aggr-fact2.xml");
   }
 
   public static void main(String[] args) throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/f0798b14/lens-examples/src/main/resources/city.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/city.xml b/lens-examples/src/main/resources/city.xml
new file mode 100644
index 0000000..1a89a2a
--- /dev/null
+++ b/lens-examples/src/main/resources/city.xml
@@ -0,0 +1,33 @@
+<?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 name="city" 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 ">
+  <attributes>
+    <dim_attribute name="id" type="INT"/>
+    <dim_attribute name="name" type="STRING"/>
+    <dim_attribute name="POI" type="ARRAY&lt;STRING&gt;" description="Point of interests"/>
+    <dim_attribute name="population" type="BIGINT" />
+  </attributes>
+  <properties>
+    <property name="dimension.city.timed.dimension" value="dt"/>
+  </properties>
+</x_dimension>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/f0798b14/lens-examples/src/main/resources/city_subset.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/city_subset.xml b/lens-examples/src/main/resources/city_subset.xml
new file mode 100644
index 0000000..5059e5e
--- /dev/null
+++ b/lens-examples/src/main/resources/city_subset.xml
@@ -0,0 +1,39 @@
+<?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="city" table_name="city_subset" 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="name" name="name" type="STRING"/>
+  </columns>
+  <storage_tables>
+    <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/f0798b14/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
new file mode 100644
index 0000000..5ce18b6
--- /dev/null
+++ b/lens-examples/src/main/resources/city_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="city" table_name="city_table" weight="10.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="name" name="name" type="STRING"/>
+    <column comment="Point of interests" name="POI" type="ARRAY&lt;STRING&gt;"/>
+    <column comment="city population" name="population" type="BIGINT"/>
+  </columns>
+  <properties>
+    <property name="city.prop" value="d1"/>
+  </properties>
+  <storage_tables>
+    <storage_table>
+      <update_periods>
+        <update_period>HOURLY</update_period>
+      </update_periods>
+      <storage_name>local</storage_name>
+      <table_desc external="true" field_delimiter="," table_location="/tmp/examples/city">
+        <part_cols>
+          <column comment="Time column" name="dt" type="STRING"/>
+        </part_cols>
+        <time_part_cols>dt</time_part_cols>
+      </table_desc>
+    </storage_table>
+  </storage_tables>
+</x_dimension_table>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/f0798b14/lens-examples/src/main/resources/customer.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/customer.xml b/lens-examples/src/main/resources/customer.xml
new file mode 100644
index 0000000..e78dab2
--- /dev/null
+++ b/lens-examples/src/main/resources/customer.xml
@@ -0,0 +1,55 @@
+<?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 name="customer" 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 ">
+  <attributes>
+    <dim_attribute name="id" type="INT"/>
+    <dim_attribute name="name" type="STRING"/>
+    <dim_attribute name="gender" type="STRING" />
+    <dim_attribute name="age" type="INT" />
+    <dim_attribute name="city_id" type="INT" />
+    <dim_attribute name="customer_city_name" type="string" description="City name to which the customer belongs"
+      displayString=" Customer City">
+      <ref_spec>
+        <chain_ref_column chain_name="customer_city" ref_col="name" />
+      </ref_spec>
+    </dim_attribute>
+    <dim_attribute name="customer_credit_status" type="STRING" start_time='2015-03-01-00:00'/>
+  </attributes>
+  <join_chains>
+    <join_chain name="customer_city">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="customer" column="city_id" />
+              <to table="city" column="id" />
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+  </join_chains>
+  <properties>
+    <property name="dimension.customer.timed.dimension" value="dt"/>
+  </properties>
+</x_dimension>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/f0798b14/lens-examples/src/main/resources/customer_table.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/customer_table.xml b/lens-examples/src/main/resources/customer_table.xml
new file mode 100644
index 0000000..18c387f
--- /dev/null
+++ b/lens-examples/src/main/resources/customer_table.xml
@@ -0,0 +1,58 @@
+<?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="customer" table_name="customer_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="name" name="name" type="STRING"/>
+    <column comment="" name="gender" type="STRING"/>
+    <column comment="" name="age" type="INT"/>
+    <column comment="" name="city_id" type="INT"/>
+    <column comment="" name="customer_credit_status" type="STRING"/>
+  </columns>
+  <properties>
+    <property name="dim4.prop" value="d1"/>
+  </properties>
+  <storage_tables>
+    <storage_table>
+      <update_periods>
+        <update_period>HOURLY</update_period>
+      </update_periods>
+      <storage_name>local</storage_name>
+      <table_desc external="true" field_delimiter="," table_location="/tmp/examples/customer">
+        <part_cols>
+          <column comment="Time column" name="dt" type="STRING"/>
+        </part_cols>
+        <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/f0798b14/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 160590f..653d2fd 100644
--- a/lens-examples/src/main/resources/db-storage-schema.sql
+++ b/lens-examples/src/main/resources/db-storage-schema.sql
@@ -34,5 +34,17 @@ insert into mydb_dim_table4(id, name, detail, d2id) values (2,'second','this is
 
 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)
 
+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)
 
+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_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))
+
+DROP TABLE IF EXISTS mydb_city_subset
+CREATE TABLE mydb_city_subset (id integer, name varchar(255))

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/f0798b14/lens-examples/src/main/resources/product.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/product.xml b/lens-examples/src/main/resources/product.xml
new file mode 100644
index 0000000..8093561
--- /dev/null
+++ b/lens-examples/src/main/resources/product.xml
@@ -0,0 +1,36 @@
+<?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 name="product" 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 ">
+  <attributes>
+    <dim_attribute name="id" type="INT"/>
+    <dim_attribute name="SKU_number" type="INT" />
+    <dim_attribute name="description" type="STRING" />
+    <dim_attribute name="color" type="STRING" />
+    <dim_attribute name="weight" type="FLOAT" />
+    <dim_attribute name="category" type="STRING" />
+    <dim_attribute name="manufacturer" type="STRING" />
+  </attributes>
+  <properties>
+    <property name="dimension.product.timed.dimension" value="dt"/>
+  </properties>
+</x_dimension>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/f0798b14/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
new file mode 100644
index 0000000..4babca6
--- /dev/null
+++ b/lens-examples/src/main/resources/product_table.xml
@@ -0,0 +1,59 @@
+<?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_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="" 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>
+      <update_periods>
+        <update_period>HOURLY</update_period>
+      </update_periods>
+      <storage_name>local</storage_name>
+      <table_desc external="true" field_delimiter="," table_location="/tmp/examples/product">
+        <part_cols>
+          <column comment="Time column" name="dt" type="STRING"/>
+        </part_cols>
+        <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/f0798b14/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
new file mode 100644
index 0000000..8d50554
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-aggr-fact1.xml
@@ -0,0 +1,83 @@
+<?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_fact_table cube_name="sales" name="sales_aggr_fact1" weight="300.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="" name="order_time" type="TIMESTAMP"/>
+    <column comment="" name="delivery_time" type="TIMESTAMP"/>
+    <column comment="" name="customer_id" type="INT"/>
+    <column comment="" name="product_id" type="INT"/>
+    <column comment="" name="promotion_id" type="INT"/>
+    <column comment="" name="customer_city_id" type="INT"/>
+    <column comment="" name="production_city_id" type="INT"/>
+    <column comment="" name="delivery_city_id" type="INT"/>
+    <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>
+  <properties>
+    <property name="cube.fact.is.aggregated" value="true"/>
+  </properties>
+  <storage_tables>
+    <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/aggrfact1">
+        <part_cols>
+          <column comment="Process time partition" name="pt" type="STRING"/>
+          <column comment="Order time partition" name="ot" type="STRING"/>
+          <column comment="Delivery time partition" name="dt" type="STRING"/>
+        </part_cols>
+        <time_part_cols>pt</time_part_cols>
+        <time_part_cols>ot</time_part_cols>
+        <time_part_cols>dt</time_part_cols>
+      </table_desc>
+    </storage_table>
+    <storage_table>
+      <update_periods>
+        <update_period>DAILY</update_period>
+      </update_periods>
+      <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>
+        <part_cols>
+          <column comment="Process time partition" name="pt" type="STRING"/>
+          <column comment="Order time partition" name="ot" type="STRING"/>
+          <column comment="Delivery time partition" name="dt" type="STRING"/>
+        </part_cols>
+        <time_part_cols>pt</time_part_cols>
+        <time_part_cols>ot</time_part_cols>
+        <time_part_cols>dt</time_part_cols>
+      </table_desc>
+    </storage_table>
+  </storage_tables>
+</x_fact_table>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/f0798b14/lens-examples/src/main/resources/sales-aggr-fact2.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/sales-aggr-fact2.xml b/lens-examples/src/main/resources/sales-aggr-fact2.xml
new file mode 100644
index 0000000..b535a87
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-aggr-fact2.xml
@@ -0,0 +1,74 @@
+<?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_fact_table cube_name="sales" name="sales_aggr_fact2" weight="100.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="" name="order_time" type="TIMESTAMP"/>
+    <column comment="" name="delivery_time" type="TIMESTAMP"/>
+    <column comment="" name="product_id" type="INT"/>
+    <column comment="" name="promotion_id" type="INT"/>
+    <column comment="" name="customer_city_id" type="INT"/>
+    <column comment="" name="production_city_id" type="INT"/>
+    <column comment="" name="delivery_city_id" type="INT"/>
+    <column comment="" name="unit_sales" type="BIGINT"/>
+    <column comment="" name="store_sales" type="DOUBLE"/>
+    <column comment="" name="store_cost" type="DOUBLE"/>
+  </columns>
+  <properties>
+    <property name="cube.fact.is.aggregated" value="true"/>
+  </properties>
+  <storage_tables>
+    <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/aggrfact2">
+        <part_cols>
+          <column comment="Delivery time partition" name="dt" type="STRING"/>
+        </part_cols>
+        <time_part_cols>dt</time_part_cols>
+      </table_desc>
+    </storage_table>
+    <storage_table>
+      <update_periods>
+        <update_period>DAILY</update_period>
+      </update_periods>
+      <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>
+        <part_cols>
+          <column comment="Process time partition" name="pt" type="STRING"/>
+          <column comment="Order time partition" name="ot" type="STRING"/>
+          <column comment="Delivery time partition" name="dt" type="STRING"/>
+        </part_cols>
+        <time_part_cols>pt</time_part_cols>
+        <time_part_cols>ot</time_part_cols>
+        <time_part_cols>dt</time_part_cols>
+      </table_desc>
+    </storage_table>
+  </storage_tables>
+</x_fact_table>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/f0798b14/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
new file mode 100644
index 0000000..d4768cc
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-cube.xml
@@ -0,0 +1,142 @@
+<?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_base_cube name="sales" 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 ">
+  <measures>
+    <measure name="unit_sales" type="BIGINT" default_aggr="SUM" display_string="Unit Sales" format_string="#,###"/>
+    <measure name="store_sales" type="DOUBLE" default_aggr="SUM" display_string="Store Sales" format_string="#,###.##"/>
+    <measure name="store_cost" type="DOUBLE" default_aggr="SUM" display_string="Store Cost" format_string="#,###.00"
+     start_time='2015-03-01-00:00' />
+    <measure name="line_item_quantity" type="INT" default_aggr="SUM" display_string="Line item quantity"/>
+    <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"/>
+  </measures>
+  <expressions>
+    <expression name="profit" type="DOUBLE" expr="store_sales - store_cost" display_string="Profit"/>
+    <expression name="promotion_sales" type="DOUBLE" expr="sum(case when promotion_id = 0 then 0 else store_sales end)"
+     display_string="Promotion sales"/>
+  </expressions>
+  <dim_attributes>
+    <dim_attribute name="customer_id" type="INT" />
+    <dim_attribute name="product_id" type="INT" />
+    <dim_attribute name="promotion_id" type="INT" />
+    <dim_attribute name="order_id" type="INT" />
+    <dim_attribute name="order_line_number" type="INT" />
+    <dim_attribute name="order_time" type="TIMESTAMP" />
+    <dim_attribute name="delivery_time" type="TIMESTAMP" />
+    <dim_attribute name="customer_city_id" type="INT" start_time='2015-03-01-00:00' />
+    <dim_attribute name="production_city_id" type="INT" />
+    <dim_attribute name="delivery_city_id" type="INT" />
+    <dim_attribute name="customer_city_name" type="string" description="City name to which the customer belongs"
+      displayString=" Customer City">
+      <ref_spec>
+        <chain_ref_column chain_name="customer_city" ref_col="name" />
+      </ref_spec>
+    </dim_attribute>
+    <dim_attribute name="production_city_name" type="STRING" description="City name in which the product was produced"
+      displayString=" Production City">
+      <ref_spec>
+        <chain_ref_column chain_name="production_city" ref_col="name" />
+      </ref_spec>
+    </dim_attribute>
+    <dim_attribute name="delivery_city_name" type="STRING" description="City name to which the product was delivered"
+      displayString=" Delivery City">
+      <ref_spec>
+        <chain_ref_column chain_name="delivery_city" ref_col="name" />
+      </ref_spec>
+    </dim_attribute>
+  </dim_attributes>
+  <join_chains>
+    <join_chain name="customer_details">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="sales" column="customer_id" />
+              <to table="customer" column="id" />
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain name="customer_city">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="sales" column="customer_city_id" />
+              <to table="city" column="id" />
+            </edge>
+          </edges>
+        </path>
+        <path>
+          <edges>
+            <edge>
+              <from table="sales" column="customer_id" />
+              <to table="customer" column="id" />
+            </edge>
+            <edge>
+              <from table="customer" column="city_id" />
+              <to table="city" column="id" />
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain name="delivery_city">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="sales" column="delivery_city_id" />
+              <to table="city" column="id" />
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain name="production_city">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="sales" column="production_city_id" />
+              <to table="city" column="id" />
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+  </join_chains>
+  <properties>
+    <property name="cube.sales.timed.dimensions.list" value="order_time,delivery_time" />
+    <property name="cube.timedim.partition.order_time" value="ot" />
+    <property name="cube.timedim.partition.delivery_time" value="dt" />
+  </properties>
+</x_base_cube>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/f0798b14/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
new file mode 100644
index 0000000..5b4fa18
--- /dev/null
+++ b/lens-examples/src/main/resources/sales-raw-fact.xml
@@ -0,0 +1,65 @@
+<?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_fact_table cube_name="sales" name="sales_raw_fact" weight="500.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="" name="order_time" type="TIMESTAMP"/>
+    <column comment="" name="delivery_time" type="TIMESTAMP"/>
+    <column comment="" name="customer_id" type="INT"/>
+    <column comment="" name="product_id" type="INT"/>
+    <column comment="" name="order_id" type="INT"/>
+    <column comment="" name="promotion_id" type="INT"/>
+    <column comment="" name="order_line_number" type="INT"/>
+    <column comment="" name="customer_city_id" type="INT"/>
+    <column comment="" name="production_city_id" type="INT"/>
+    <column comment="" name="delivery_city_id" type="INT"/>
+    <column comment="" name="unit_sales" type="BIGINT"/>
+    <column comment="" name="store_sales" type="DOUBLE"/>
+    <column comment="" name="store_cost" type="DOUBLE"/>
+    <column comment="" name="line_item_quantity" type="INT"/>
+    <column comment="" name="line_item_product_price" type="INT"/>
+    <column comment="" name="line_item_discount_amount" type="INT"/>
+    <column comment="" name="line_item_tax" type="INT"/>
+  </columns>
+  <properties>
+    <property name="cube.fact.is.aggregated" value="false"/>
+  </properties>
+  <storage_tables>
+    <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">
+        <part_cols>
+          <column comment="Process time partition" name="pt" type="STRING"/>
+          <column comment="Order time partition" name="ot" type="STRING"/>
+          <column comment="Delivery time partition" name="dt" type="STRING"/>
+        </part_cols>
+        <time_part_cols>pt</time_part_cols>
+        <time_part_cols>ot</time_part_cols>
+        <time_part_cols>dt</time_part_cols>
+      </table_desc>
+    </storage_table>
+  </storage_tables>
+</x_fact_table>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/f0798b14/lens-server/src/main/java/org/apache/lens/server/metastore/JAXBUtils.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/metastore/JAXBUtils.java b/lens-server/src/main/java/org/apache/lens/server/metastore/JAXBUtils.java
index 138797e..b76ddc0 100644
--- a/lens-server/src/main/java/org/apache/lens/server/metastore/JAXBUtils.java
+++ b/lens-server/src/main/java/org/apache/lens/server/metastore/JAXBUtils.java
@@ -456,11 +456,11 @@ public final class JAXBUtils {
   }
 
   public static List<XColumn> columnsFromFieldSchemaList(List<FieldSchema> fslist) {
+    List<XColumn> cols = new ArrayList<XColumn>();
     if (fslist == null || fslist.isEmpty()) {
-      return null;
+      return cols;
     }
 
-    List<XColumn> cols = new ArrayList<XColumn>();
     for (FieldSchema fs : fslist) {
       cols.add(columnFromFieldSchema(fs));
     }