Repository: lens Updated Branches: refs/heads/master 3076b26c8 -> 278a02473
LENS-1502 : Fixt in virtual fact properties. Project: http://git-wip-us.apache.org/repos/asf/lens/repo Commit: http://git-wip-us.apache.org/repos/asf/lens/commit/278a0247 Tree: http://git-wip-us.apache.org/repos/asf/lens/tree/278a0247 Diff: http://git-wip-us.apache.org/repos/asf/lens/diff/278a0247 Branch: refs/heads/master Commit: 278a02473a2dc72044b4e72e04d79ada64b4d12f Parents: 3076b26 Author: Rajitha R <[email protected]> Authored: Wed Jun 27 16:40:11 2018 +0530 Committer: Rajitha.R <[email protected]> Committed: Wed Jun 27 16:40:11 2018 +0530 ---------------------------------------------------------------------- .../lens/cube/parse/StorageCandidate.java | 10 ++++--- .../lens/cube/parse/TestVirtualFactQueries.java | 31 ++++++++++++++++++++ .../resources/schema/cubes/base/testcube2.xml | 7 ++++- .../resources/schema/cubes/base/virtualcube.xml | 1 + .../resources/schema/facts/testfact9_base.xml | 3 +- .../schema/facts/virtual/virtualfact2.xml | 28 ++++++++++++++++++ lens_bk | 1 + 7 files changed, 75 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lens/blob/278a0247/lens-cube/src/main/java/org/apache/lens/cube/parse/StorageCandidate.java ---------------------------------------------------------------------- diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/StorageCandidate.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/StorageCandidate.java index b48be7f..193ce6b 100644 --- a/lens-cube/src/main/java/org/apache/lens/cube/parse/StorageCandidate.java +++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/StorageCandidate.java @@ -315,11 +315,12 @@ public class StorageCandidate implements Candidate, CandidateTable { public Optional<Date> getColumnStartTime(String column) { Date startTime = null; - for (String key : this.getFact().getSourceFactProperties().keySet()) { + Map<String, String> propertiesMap = this.getFact().getSourceFactProperties(); + for (String key : propertiesMap.keySet()) { if (key.contains(MetastoreConstants.FACT_COL_START_TIME_PFX)) { String propCol = StringUtils.substringAfter(key, MetastoreConstants.FACT_COL_START_TIME_PFX); if (column.equals(propCol)) { - startTime = MetastoreUtil.getDateFromProperty(getTable().getProperties().get(key), false, true); + startTime = MetastoreUtil.getDateFromProperty(propertiesMap.get(key), false, true); } } } @@ -329,11 +330,12 @@ public class StorageCandidate implements Candidate, CandidateTable { @Override public Optional<Date> getColumnEndTime(String column) { Date endTime = null; - for (String key : this.getFact().getSourceFactProperties().keySet()) { + Map<String, String> propertiesMap = this.getFact().getSourceFactProperties(); + for (String key : propertiesMap.keySet()) { if (key.contains(MetastoreConstants.FACT_COL_END_TIME_PFX)) { String propCol = StringUtils.substringAfter(key, MetastoreConstants.FACT_COL_END_TIME_PFX); if (column.equals(propCol)) { - endTime = MetastoreUtil.getDateFromProperty(getTable().getProperties().get(key), false, true); + endTime = MetastoreUtil.getDateFromProperty(propertiesMap.get(key), false, true); } } } http://git-wip-us.apache.org/repos/asf/lens/blob/278a0247/lens-cube/src/test/java/org/apache/lens/cube/parse/TestVirtualFactQueries.java ---------------------------------------------------------------------- diff --git a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestVirtualFactQueries.java b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestVirtualFactQueries.java index fe6b20d..e2f1074 100644 --- a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestVirtualFactQueries.java +++ b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestVirtualFactQueries.java @@ -33,6 +33,7 @@ import org.apache.lens.server.api.error.LensException; import org.apache.hadoop.conf.Configuration; +import org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -66,6 +67,36 @@ public class TestVirtualFactQueries extends TestQueryRewrite { compareQueries(hql, expected); } + + @Test + public void testVirtualFactColStartTimeQuery() { + try { + rewriteCtx("select dim1,SUM(msr1) from virtualcube where " + TWO_DAYS_RANGE, getConfWithStorages("C1")); + Assert.fail("Should not come here..Column Start time feature is failing.."); + }catch (LensException e) { + if(e.getErrorCode() == 3024) { + System.out.println("Expected flow :" + e.getMessage()); + }else { + Assert.fail("Exception not as expected"); + } + } + } + + @Test + public void testVirtualFactColEndTimeQuery() { + try { + rewriteCtx("select dim2,SUM(msr1) from virtualcube where " + TWO_DAYS_RANGE, getConfWithStorages("C1")); + Assert.fail("Should not come here..Column End time feature is failing.."); + }catch (LensException e) { + if(e.getErrorCode() == 3024) { + System.out.println("Expected flow :" + e.getMessage()); + }else { + Assert.fail("Exception not as expected"); + } + } + } + + @Test public void testVirtualFactMonthQuery() throws Exception { http://git-wip-us.apache.org/repos/asf/lens/blob/278a0247/lens-cube/src/test/resources/schema/cubes/base/testcube2.xml ---------------------------------------------------------------------- diff --git a/lens-cube/src/test/resources/schema/cubes/base/testcube2.xml b/lens-cube/src/test/resources/schema/cubes/base/testcube2.xml index 237e85a..8d80a03 100644 --- a/lens-cube/src/test/resources/schema/cubes/base/testcube2.xml +++ b/lens-cube/src/test/resources/schema/cubes/base/testcube2.xml @@ -22,7 +22,7 @@ <x_base_cube name="testcube2" xmlns="uri:lens:cube:0.1"> <properties> <property name="cube.timedim.partition.d_time" value="dt"/> - <property name="cube.testcube.timed.dimensions.list" value="d_time"/> + <property name="cube.testcube2.timed.dimensions.list" value="d_time"/> </properties> <measures> <measure _type="FLOAT" default_aggr="SUM" unit="RS" name="msr1" display_string="Measure1" @@ -30,4 +30,9 @@ <measure _type="FLOAT" default_aggr="SUM" unit="RS" name="msr4" display_string="Measure4" description="fourth measure"/> </measures> + <dim_attributes> + <dim_attribute name="dim1" _type="string" /> + <dim_attribute name="dim2" _type="string" /> + </dim_attributes> + </x_base_cube> http://git-wip-us.apache.org/repos/asf/lens/blob/278a0247/lens-cube/src/test/resources/schema/cubes/base/virtualcube.xml ---------------------------------------------------------------------- diff --git a/lens-cube/src/test/resources/schema/cubes/base/virtualcube.xml b/lens-cube/src/test/resources/schema/cubes/base/virtualcube.xml index 187ac29..38315ab 100644 --- a/lens-cube/src/test/resources/schema/cubes/base/virtualcube.xml +++ b/lens-cube/src/test/resources/schema/cubes/base/virtualcube.xml @@ -35,6 +35,7 @@ </measures> <dim_attributes> <dim_attribute _type="string" name="dim1" description="basedim"/> + <dim_attribute _type="string" name="dim2" description="basedim"/> <dim_attribute _type="int" name="cityid" description="basedim"/> <dim_attribute name="stateid" _type="int" description="state id"/> </dim_attributes> http://git-wip-us.apache.org/repos/asf/lens/blob/278a0247/lens-cube/src/test/resources/schema/facts/testfact9_base.xml ---------------------------------------------------------------------- diff --git a/lens-cube/src/test/resources/schema/facts/testfact9_base.xml b/lens-cube/src/test/resources/schema/facts/testfact9_base.xml index 9c94fe2..10222ca 100644 --- a/lens-cube/src/test/resources/schema/facts/testfact9_base.xml +++ b/lens-cube/src/test/resources/schema/facts/testfact9_base.xml @@ -21,7 +21,8 @@ --> <x_fact_table name="testfact9_base" cube_name="testcube2" weight="5.0" xmlns="uri:lens:cube:0.1"> <columns> - + <column name="dim1" _type="string" comment="first dim" start_time="2099-01-01"/> + <column name="dim2" _type="string" comment="second dim" end_time="2017-01-01"/> <column name="msr1" _type="float" comment="first measure"/> <column name="msr4" _type="float" comment="fourth measure"/> </columns> http://git-wip-us.apache.org/repos/asf/lens/blob/278a0247/lens-cube/src/test/resources/schema/facts/virtual/virtualfact2.xml ---------------------------------------------------------------------- diff --git a/lens-cube/src/test/resources/schema/facts/virtual/virtualfact2.xml b/lens-cube/src/test/resources/schema/facts/virtual/virtualfact2.xml new file mode 100644 index 0000000..b796336 --- /dev/null +++ b/lens-cube/src/test/resources/schema/facts/virtual/virtualfact2.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_virtual_fact_table source_fact_name="testfact9_base" cube_name="virtualcube" name="virtualfact2" 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 "> + <properties> + <property name="cube.fact.virtualfact1.valid.columns" + value="dim1,dim2,msr1"/> + </properties> +</x_virtual_fact_table> http://git-wip-us.apache.org/repos/asf/lens/blob/278a0247/lens_bk ---------------------------------------------------------------------- diff --git a/lens_bk b/lens_bk new file mode 160000 index 0000000..d0d9adf --- /dev/null +++ b/lens_bk @@ -0,0 +1 @@ +Subproject commit d0d9adf35ca476f28cb872285097309cdb6e55a6
