mondrian 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/mondrian/schema.rb +21 -4
- data/lib/mondrian/version.rb +1 -1
- data/spec/mondrian/schema_spec.rb +40 -0
- metadata +3 -3
data/README.md
CHANGED
@@ -56,7 +56,7 @@ Here is example how to define OLAP schema and its mapping to relational database
|
|
56
56
|
require "rubygems"
|
57
57
|
require "mondrian"
|
58
58
|
|
59
|
-
schema = Mondrian::
|
59
|
+
schema = Mondrian::Schema.define do
|
60
60
|
cube 'Sales' do
|
61
61
|
table 'sales'
|
62
62
|
dimension 'Customers', :foreign_key => 'customer_id' do
|
data/lib/mondrian/schema.rb
CHANGED
@@ -49,7 +49,8 @@ module Mondrian
|
|
49
49
|
public
|
50
50
|
|
51
51
|
attributes :name, :description
|
52
|
-
|
52
|
+
#dimension must be first in order for dimension_usage to work
|
53
|
+
elements :dimension, :cube
|
53
54
|
|
54
55
|
class Cube < SchemaElement
|
55
56
|
attributes :name, :description,
|
@@ -60,7 +61,7 @@ module Mondrian
|
|
60
61
|
:cache,
|
61
62
|
# Whether element is enabled - if true, then the Cube is realized otherwise it is ignored.
|
62
63
|
:enabled
|
63
|
-
elements :table, :view, :dimension, :measure, :calculated_member
|
64
|
+
elements :table, :view, :dimension, :dimension_usage, :measure, :calculated_member
|
64
65
|
end
|
65
66
|
|
66
67
|
class Table < SchemaElement
|
@@ -81,7 +82,7 @@ module Mondrian
|
|
81
82
|
end
|
82
83
|
|
83
84
|
class Dimension < SchemaElement
|
84
|
-
attributes :name, :description,
|
85
|
+
attributes :name, :description, :high_cardinality,
|
85
86
|
# The dimension's type may be one of "Standard" or "Time".
|
86
87
|
# A time dimension will allow the use of the MDX time functions (WTD, YTD, QTD, etc.).
|
87
88
|
# Use a standard dimension if the dimension is not a time-related dimension.
|
@@ -90,10 +91,26 @@ module Mondrian
|
|
90
91
|
# The name of the column in the fact table which joins to the leaf level of this dimension.
|
91
92
|
# Required in a private Dimension or a DimensionUsage, but not in a public Dimension.
|
92
93
|
:foreign_key
|
93
|
-
data_dictionary_names :foreign_key # values in XML will be uppercased when using Oracle driver
|
94
|
+
data_dictionary_names :foreign_key, :high_cardinality # values in XML will be uppercased when using Oracle driver
|
94
95
|
elements :hierarchy
|
95
96
|
end
|
96
97
|
|
98
|
+
class DimensionUsage < SchemaElement
|
99
|
+
# Name of the source dimension. Must be a dimension in this schema. Case-sensitive.
|
100
|
+
attributes :source,
|
101
|
+
# Name of the level to join to. If not specified, joins to the lowest level of the dimension.
|
102
|
+
:level,
|
103
|
+
# If present, then this is prepended to the Dimension column names during the building of collapse dimension aggregates allowing
|
104
|
+
# 1) different dimension usages to be disambiguated during aggregate table recognition and
|
105
|
+
# 2) multiple shared dimensions that have common column names to be disambiguated.
|
106
|
+
:usage_prefix,
|
107
|
+
# The name of the column in the fact table which joins to the leaf level of this dimension.
|
108
|
+
# Required in a private Dimension or a DimensionUsage, but not in a public Dimension.
|
109
|
+
:foreign_key
|
110
|
+
|
111
|
+
data_dictionary_names :foreign_key, :usage_prefix #values in XML will be uppercased when using Oracle driver
|
112
|
+
end
|
113
|
+
|
97
114
|
class Hierarchy < SchemaElement
|
98
115
|
attributes :name, :description,
|
99
116
|
# Whether this hierarchy has an 'all' member.
|
data/lib/mondrian/version.rb
CHANGED
@@ -7,6 +7,28 @@ describe Mondrian::Schema do
|
|
7
7
|
@schema = Mondrian::Schema.new
|
8
8
|
end
|
9
9
|
|
10
|
+
|
11
|
+
describe "dimension cube order" do
|
12
|
+
it "should render dimensions before cubes" do
|
13
|
+
@schema.define do
|
14
|
+
cube 'Sales' do
|
15
|
+
dimension_usage :usage_prefix => "Test", :source => 'Gender'
|
16
|
+
end
|
17
|
+
dimension "Gender"
|
18
|
+
end
|
19
|
+
@schema.to_xml.should be_equivalent_to <<-XML
|
20
|
+
<?xml version="1.0"?>
|
21
|
+
<Schema name="default">
|
22
|
+
<Dimension name="Gender"/>
|
23
|
+
<Cube name="Sales">
|
24
|
+
<DimensionUsage usagePrefix="Test" source="Gender"/>
|
25
|
+
</Cube>
|
26
|
+
</Schema>
|
27
|
+
XML
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
10
32
|
describe "root element" do
|
11
33
|
it "should render to XML" do
|
12
34
|
@schema.to_xml.should be_equivalent_to <<-XML
|
@@ -363,6 +385,24 @@ describe Mondrian::Schema do
|
|
363
385
|
|
364
386
|
end
|
365
387
|
|
388
|
+
describe "DimensionUsage" do
|
389
|
+
it "should render to XML" do
|
390
|
+
@schema.define do
|
391
|
+
cube 'Sales' do
|
392
|
+
dimension_usage :usage_prefix => "Test", :source => 'Gender'
|
393
|
+
end
|
394
|
+
end
|
395
|
+
@schema.to_xml.should be_equivalent_to <<-XML
|
396
|
+
<?xml version="1.0"?>
|
397
|
+
<Schema name="default">
|
398
|
+
<Cube name="Sales">
|
399
|
+
<DimensionUsage source="Gender" usagePrefix="Test">
|
400
|
+
</Cube>
|
401
|
+
</Schema>
|
402
|
+
XML
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
366
406
|
describe "Measure" do
|
367
407
|
it "should render XML" do
|
368
408
|
@schema.define do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mondrian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-05-08 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
|
-
requirement: &
|
16
|
+
requirement: &70350923495220 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 1.5.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70350923495220
|
25
25
|
description: Schema DSL for mondrian
|
26
26
|
email:
|
27
27
|
- scott.ellard@gmail.com
|