You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lens.apache.org by Amruth Sampath <am...@flipkart.com> on 2015/04/06 11:10:14 UTC

Newbie question - Creating cube definition with role playing dimensions

Hi, I am trying to create one cube definition with role playing dimension.

To explain, I have a fact with source_city_id and destination_city_id
columns. Both of this has to map to the same dimension City.

Tried to dereference cube-0.1.xsd and I was able to get to this state.
I am not sure what is wrong here.

It would be great if you can give me an example cube file with this use
case. It would be of great help for anyone who wants to understand this a
little more deeply.

<?xml version="1.0" encoding="UTF-8"?>
<x_base_cube name="sales_cube" 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="units" type="INT" default_aggr="SUM" />
    <measure name="amounts" type="INT" default_aggr="SUM" />
  </measures>
  <expressions>
    <expression name="expr_msr" type="DOUBLE" expr="units + amounts" />
  </expressions>
  <dim_attributes>
    <dim_attribute name="category" type="STRING" />
    <dim_attribute name="source_city_id" type="INT">
      <ref_spec>
        <chain_ref_column chain_name="source_city" ref_col="id" />
      </ref_spec>
    </dim_attribute>
    <dim_attribute name="dest_city_id" type="INT">
      <ref_spec>
        <chain_ref_column chain_name="dest_city" ref_col="id" />
      </ref_spec>
    </dim_attribute>
  </dim_attributes>
  <join_chains>
    <join_chain name="source_city">
      <paths>
        <path>
          <edges>
            <edge>
              <from table="sales_cube" column="source_city_id"/>
              <to table="city" column="id"/>
            </edge>
          </edges>
        </path>
      </paths>
    </join_chain>
    <join_chain name="dest_city">
      <paths>
        <path>
          <edges>
            <edge>
              <from table="sales_cube" column="dest_city_id"/>
              <to table="city" column="id"/>
            </edge>
          </edges>
        </path>
      </paths>
    </join_chain>
  </join_chains>
  <properties>
    <property name="sample_cube.prop" value="sample" />
    <property name="cube.sample_cube.timed.dimensions.list" value="dt" />
  </properties>
</x_base_cube>

Thanks and regards,

-- 
Amruth S
(09486075517)

Re: Newbie question - Creating cube definition with role playing dimensions

Posted by Amruth Sampath <am...@flipkart.com>.
Cool thanks for the quick response! 😃
On 09-Apr-2015 9:36 am, "amareshwarisr ." <am...@gmail.com> wrote:

> Yes Amruth! I also noticed when I'm writing examples in LENS-491. Fixing
> it as part of LENS-491.
>
> On Thu, Apr 9, 2015 at 12:28 AM, Amruth Sampath <am...@flipkart.com>
> wrote:
>
>> Thanks!
>>
>> Also I had to compulsorily populate other attributes of join_chain
>>
>> <join_chain name="source_location" description="Source location" display_string="Source location" dest_table="location" >
>>
>> ...
>>
>> Without description, display_string and dest_table it was giving an NP.
>>
>> Thanks and regards,
>>
>>
>> On Tue, Apr 7, 2015 at 9:35 AM, amareshwarisr . <am...@gmail.com>
>> wrote:
>>
>>> Hello Amruth,
>>>
>>> Your joinchain definitions look correct. The source_city_id and
>>> dest_city_id should simple dim attributes, not with ref spec. if you
>>> have want some more fields of city exposed to users with more description,
>>> they can be added added as chain ref columns.
>>> Regarding the example, sure, we are planning to do it as part of
>>> LENS-233 in some time this month. Keep watching it for updates.
>>>
>>> Thanks
>>> Amareshwari
>>>
>>> On Mon, Apr 6, 2015 at 2:40 PM, Amruth Sampath <am...@flipkart.com>
>>> wrote:
>>>
>>>> Hi, I am trying to create one cube definition with role playing
>>>> dimension.
>>>>
>>>> To explain, I have a fact with source_city_id and destination_city_id
>>>> columns. Both of this has to map to the same dimension City.
>>>>
>>>> Tried to dereference cube-0.1.xsd and I was able to get to this state.
>>>> I am not sure what is wrong here.
>>>>
>>>> It would be great if you can give me an example cube file with this use
>>>> case. It would be of great help for anyone who wants to understand this a
>>>> little more deeply.
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <x_base_cube name="sales_cube" 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="units" type="INT" default_aggr="SUM" />
>>>>     <measure name="amounts" type="INT" default_aggr="SUM" />
>>>>   </measures>
>>>>   <expressions>
>>>>     <expression name="expr_msr" type="DOUBLE" expr="units + amounts" />
>>>>   </expressions>
>>>>   <dim_attributes>
>>>>     <dim_attribute name="category" type="STRING" />
>>>>     <dim_attribute name="source_city_id" type="INT">
>>>>       <ref_spec>
>>>>         <chain_ref_column chain_name="source_city" ref_col="id" />
>>>>       </ref_spec>
>>>>     </dim_attribute>
>>>>     <dim_attribute name="dest_city_id" type="INT">
>>>>       <ref_spec>
>>>>         <chain_ref_column chain_name="dest_city" ref_col="id" />
>>>>       </ref_spec>
>>>>     </dim_attribute>
>>>>   </dim_attributes>
>>>>   <join_chains>
>>>>     <join_chain name="source_city">
>>>>       <paths>
>>>>         <path>
>>>>           <edges>
>>>>             <edge>
>>>>               <from table="sales_cube" column="source_city_id"/>
>>>>               <to table="city" column="id"/>
>>>>             </edge>
>>>>           </edges>
>>>>         </path>
>>>>       </paths>
>>>>     </join_chain>
>>>>     <join_chain name="dest_city">
>>>>       <paths>
>>>>         <path>
>>>>           <edges>
>>>>             <edge>
>>>>               <from table="sales_cube" column="dest_city_id"/>
>>>>               <to table="city" column="id"/>
>>>>             </edge>
>>>>           </edges>
>>>>         </path>
>>>>       </paths>
>>>>     </join_chain>
>>>>   </join_chains>
>>>>   <properties>
>>>>     <property name="sample_cube.prop" value="sample" />
>>>>     <property name="cube.sample_cube.timed.dimensions.list" value="dt" />
>>>>   </properties>
>>>> </x_base_cube>
>>>>
>>>> Thanks and regards,
>>>>
>>>> --
>>>> Amruth S
>>>> (09486075517)
>>>>
>>>
>>>
>>
>>
>> --
>> Amruth S
>> (09486075517)
>>
>
>

Re: Newbie question - Creating cube definition with role playing dimensions

Posted by "amareshwarisr ." <am...@gmail.com>.
Yes Amruth! I also noticed when I'm writing examples in LENS-491. Fixing it
as part of LENS-491.

On Thu, Apr 9, 2015 at 12:28 AM, Amruth Sampath <am...@flipkart.com>
wrote:

> Thanks!
>
> Also I had to compulsorily populate other attributes of join_chain
>
> <join_chain name="source_location" description="Source location" display_string="Source location" dest_table="location" >
>
> ...
>
> Without description, display_string and dest_table it was giving an NP.
>
> Thanks and regards,
>
>
> On Tue, Apr 7, 2015 at 9:35 AM, amareshwarisr . <am...@gmail.com>
> wrote:
>
>> Hello Amruth,
>>
>> Your joinchain definitions look correct. The source_city_id and
>> dest_city_id should simple dim attributes, not with ref spec. if you
>> have want some more fields of city exposed to users with more description,
>> they can be added added as chain ref columns.
>> Regarding the example, sure, we are planning to do it as part of LENS-233
>> in some time this month. Keep watching it for updates.
>>
>> Thanks
>> Amareshwari
>>
>> On Mon, Apr 6, 2015 at 2:40 PM, Amruth Sampath <am...@flipkart.com>
>> wrote:
>>
>>> Hi, I am trying to create one cube definition with role playing
>>> dimension.
>>>
>>> To explain, I have a fact with source_city_id and destination_city_id
>>> columns. Both of this has to map to the same dimension City.
>>>
>>> Tried to dereference cube-0.1.xsd and I was able to get to this state.
>>> I am not sure what is wrong here.
>>>
>>> It would be great if you can give me an example cube file with this use
>>> case. It would be of great help for anyone who wants to understand this a
>>> little more deeply.
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <x_base_cube name="sales_cube" 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="units" type="INT" default_aggr="SUM" />
>>>     <measure name="amounts" type="INT" default_aggr="SUM" />
>>>   </measures>
>>>   <expressions>
>>>     <expression name="expr_msr" type="DOUBLE" expr="units + amounts" />
>>>   </expressions>
>>>   <dim_attributes>
>>>     <dim_attribute name="category" type="STRING" />
>>>     <dim_attribute name="source_city_id" type="INT">
>>>       <ref_spec>
>>>         <chain_ref_column chain_name="source_city" ref_col="id" />
>>>       </ref_spec>
>>>     </dim_attribute>
>>>     <dim_attribute name="dest_city_id" type="INT">
>>>       <ref_spec>
>>>         <chain_ref_column chain_name="dest_city" ref_col="id" />
>>>       </ref_spec>
>>>     </dim_attribute>
>>>   </dim_attributes>
>>>   <join_chains>
>>>     <join_chain name="source_city">
>>>       <paths>
>>>         <path>
>>>           <edges>
>>>             <edge>
>>>               <from table="sales_cube" column="source_city_id"/>
>>>               <to table="city" column="id"/>
>>>             </edge>
>>>           </edges>
>>>         </path>
>>>       </paths>
>>>     </join_chain>
>>>     <join_chain name="dest_city">
>>>       <paths>
>>>         <path>
>>>           <edges>
>>>             <edge>
>>>               <from table="sales_cube" column="dest_city_id"/>
>>>               <to table="city" column="id"/>
>>>             </edge>
>>>           </edges>
>>>         </path>
>>>       </paths>
>>>     </join_chain>
>>>   </join_chains>
>>>   <properties>
>>>     <property name="sample_cube.prop" value="sample" />
>>>     <property name="cube.sample_cube.timed.dimensions.list" value="dt" />
>>>   </properties>
>>> </x_base_cube>
>>>
>>> Thanks and regards,
>>>
>>> --
>>> Amruth S
>>> (09486075517)
>>>
>>
>>
>
>
> --
> Amruth S
> (09486075517)
>

Re: Newbie question - Creating cube definition with role playing dimensions

Posted by Amruth Sampath <am...@flipkart.com>.
Thanks!

Also I had to compulsorily populate other attributes of join_chain

<join_chain name="source_location" description="Source location"
display_string="Source location" dest_table="location" >

...

Without description, display_string and dest_table it was giving an NP.

Thanks and regards,


On Tue, Apr 7, 2015 at 9:35 AM, amareshwarisr . <am...@gmail.com>
wrote:

> Hello Amruth,
>
> Your joinchain definitions look correct. The source_city_id and
> dest_city_id should simple dim attributes, not with ref spec. if you have
> want some more fields of city exposed to users with more description, they
> can be added added as chain ref columns.
> Regarding the example, sure, we are planning to do it as part of LENS-233
> in some time this month. Keep watching it for updates.
>
> Thanks
> Amareshwari
>
> On Mon, Apr 6, 2015 at 2:40 PM, Amruth Sampath <am...@flipkart.com>
> wrote:
>
>> Hi, I am trying to create one cube definition with role playing
>> dimension.
>>
>> To explain, I have a fact with source_city_id and destination_city_id
>> columns. Both of this has to map to the same dimension City.
>>
>> Tried to dereference cube-0.1.xsd and I was able to get to this state.
>> I am not sure what is wrong here.
>>
>> It would be great if you can give me an example cube file with this use
>> case. It would be of great help for anyone who wants to understand this a
>> little more deeply.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <x_base_cube name="sales_cube" 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="units" type="INT" default_aggr="SUM" />
>>     <measure name="amounts" type="INT" default_aggr="SUM" />
>>   </measures>
>>   <expressions>
>>     <expression name="expr_msr" type="DOUBLE" expr="units + amounts" />
>>   </expressions>
>>   <dim_attributes>
>>     <dim_attribute name="category" type="STRING" />
>>     <dim_attribute name="source_city_id" type="INT">
>>       <ref_spec>
>>         <chain_ref_column chain_name="source_city" ref_col="id" />
>>       </ref_spec>
>>     </dim_attribute>
>>     <dim_attribute name="dest_city_id" type="INT">
>>       <ref_spec>
>>         <chain_ref_column chain_name="dest_city" ref_col="id" />
>>       </ref_spec>
>>     </dim_attribute>
>>   </dim_attributes>
>>   <join_chains>
>>     <join_chain name="source_city">
>>       <paths>
>>         <path>
>>           <edges>
>>             <edge>
>>               <from table="sales_cube" column="source_city_id"/>
>>               <to table="city" column="id"/>
>>             </edge>
>>           </edges>
>>         </path>
>>       </paths>
>>     </join_chain>
>>     <join_chain name="dest_city">
>>       <paths>
>>         <path>
>>           <edges>
>>             <edge>
>>               <from table="sales_cube" column="dest_city_id"/>
>>               <to table="city" column="id"/>
>>             </edge>
>>           </edges>
>>         </path>
>>       </paths>
>>     </join_chain>
>>   </join_chains>
>>   <properties>
>>     <property name="sample_cube.prop" value="sample" />
>>     <property name="cube.sample_cube.timed.dimensions.list" value="dt" />
>>   </properties>
>> </x_base_cube>
>>
>> Thanks and regards,
>>
>> --
>> Amruth S
>> (09486075517)
>>
>
>


-- 
Amruth S
(09486075517)

Re: Newbie question - Creating cube definition with role playing dimensions

Posted by "amareshwarisr ." <am...@gmail.com>.
Hello Amruth,

Your joinchain definitions look correct. The source_city_id and
dest_city_id should
simple dim attributes, not with ref spec. if you have want some more fields
of city exposed to users with more description, they can be added added as
chain ref columns.
Regarding the example, sure, we are planning to do it as part of LENS-233
in some time this month. Keep watching it for updates.

Thanks
Amareshwari

On Mon, Apr 6, 2015 at 2:40 PM, Amruth Sampath <am...@flipkart.com>
wrote:

> Hi, I am trying to create one cube definition with role playing dimension.
>
> To explain, I have a fact with source_city_id and destination_city_id
> columns. Both of this has to map to the same dimension City.
>
> Tried to dereference cube-0.1.xsd and I was able to get to this state.
> I am not sure what is wrong here.
>
> It would be great if you can give me an example cube file with this use
> case. It would be of great help for anyone who wants to understand this a
> little more deeply.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <x_base_cube name="sales_cube" 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="units" type="INT" default_aggr="SUM" />
>     <measure name="amounts" type="INT" default_aggr="SUM" />
>   </measures>
>   <expressions>
>     <expression name="expr_msr" type="DOUBLE" expr="units + amounts" />
>   </expressions>
>   <dim_attributes>
>     <dim_attribute name="category" type="STRING" />
>     <dim_attribute name="source_city_id" type="INT">
>       <ref_spec>
>         <chain_ref_column chain_name="source_city" ref_col="id" />
>       </ref_spec>
>     </dim_attribute>
>     <dim_attribute name="dest_city_id" type="INT">
>       <ref_spec>
>         <chain_ref_column chain_name="dest_city" ref_col="id" />
>       </ref_spec>
>     </dim_attribute>
>   </dim_attributes>
>   <join_chains>
>     <join_chain name="source_city">
>       <paths>
>         <path>
>           <edges>
>             <edge>
>               <from table="sales_cube" column="source_city_id"/>
>               <to table="city" column="id"/>
>             </edge>
>           </edges>
>         </path>
>       </paths>
>     </join_chain>
>     <join_chain name="dest_city">
>       <paths>
>         <path>
>           <edges>
>             <edge>
>               <from table="sales_cube" column="dest_city_id"/>
>               <to table="city" column="id"/>
>             </edge>
>           </edges>
>         </path>
>       </paths>
>     </join_chain>
>   </join_chains>
>   <properties>
>     <property name="sample_cube.prop" value="sample" />
>     <property name="cube.sample_cube.timed.dimensions.list" value="dt" />
>   </properties>
> </x_base_cube>
>
> Thanks and regards,
>
> --
> Amruth S
> (09486075517)
>