Description Usage Arguments Details Examples
This function returns XML definition of Mondrian schema. Optionally returns file with data source definition for Saiku.
1 2 3 4 |
engine |
Data engine. Valid options are: |
table |
Table for which schema should be created. In Mondrian terminology, this is fact table |
primary_key |
Primary key of |
con |
Connection to PostgreSQL database. Character
vector of exactly five (5) elements: |
dimension |
Rule to modify inclusion/exclusion of
columns in |
aggregator |
Rule to modify inclusion/exclusion of
aggregators for columns in |
schema_dest |
Path to file where Mondrian schema will be stored. Has to include file name. |
data_source_dest |
Path to file where data source definition for Saiku will be stored. Has to include file name. Optional. |
calculated_member |
List defining additional calculated members (measures calculated on results of other measures). Unlimited number of calculated members can be created. Every component in list has to have exactly three elements:
Optional. |
time_table |
Name of table with time dimension. If
PostgreSQL than this should be name of existing table
with columns |
security_type |
Type of security for Saiku.
Currently only one2one is supported. Using this makes
sense only when |
security_roles |
Vector defining what roles will
have access to cube. Meaningful only when
|
debug |
Print additional information useful for debugging. |
Arguments dimension
and aggregator
are
required to be valid SQL CASE
statement. Case
statement is similar to if
statement available in
many languages. Basic structure is: CASE WHEN
<CONDITION> THEN <VALUE> [[WHEN <CONDITION> THEN <VALUE>]
ELSE <VALUE>] END
. Both dimension
and
aggregator
arguments are used to modify content of
data frame with default design (see
get_default_design
for details). This means
that you can use columns name, class, type,
dimension, aggregator
in case statement. Examples for
dimension:
For numeric data types do not
create dimenions, otherwise do create dimensions:
case when class='numeric' then 0 else 1 end
For columns a, b create dimenions and for other columns
keep default value: case when name in('a','b') then 1
else dimension end
Examples for aggregator:
Only count
aggregator for non-numeric columns and default for other
columns: case when class <> 'numeric' then '010000'
else aggregator end
No aggregator for date and text
columns and count for all others: case when class
in('text','numeric') then '000000' else '010000' end
No aggregator for dimensions, default for others:
case when dimension=1 then '000000' else aggregator
end
No aggregators at all (only count for PK will be
displayed): 000000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | # Get some valid destinations
schema_dest <- paste0(getwd(),'/','test.xml')
data_source_dest <- paste0(getwd(),'/','test')
# Simple schema, no time dimension, no data source definition
create_schema(engine='R',table='big_portfolio',primary_key='id', schema_dest=schema_dest)
# Do this again, but print additional debug messages.
create_schema(engine='R',table='big_portfolio',primary_key='id',
schema_dest=schema_dest, debug=TRUE)
# Create schema with time dimension
create_schema(engine='R',table='big_portfolio',primary_key='id', time_table = 'any',
schema_dest=schema_dest, data_source_dest=data_source_dest)
# Modify default dimensions (create dimension only for factors)
create_schema(engine='R',table='big_portfolio',primary_key='id', time_table = 'any',
schema_dest=schema_dest, dimension="case when type='factor' then 1 else 0 end")
# Modify default dimensions (create dimension only for specified columns)
create_schema(engine='R',table='big_portfolio',primary_key='id', time_table = 'any',
schema_dest=schema_dest,
dimension="case when name in('product','region') then 1 else 0 end")
# Modify aggregators - enable all aggregators for numeric columns, keep default for others
create_schema(engine='R',table='big_portfolio',primary_key='id', time_table = 'any',
schema_dest=schema_dest,
aggregator="case when type='numeric' then '111111' else aggregator end")
# Create schema with calculated members
create_schema(engine='R',table='big_portfolio',primary_key='id',time_table = 'any_name',
schema_dest=schema_dest, data_source_dest=data_source_dest,
calculated_member=list(
c('Not repaid pct',
'[Measures].[Current balance-Sum]/[Measures].[Original balance-Sum]',NA),
c('Repaid pct',
'[Measures].[Current balance-Sum]/[Measures].[Original balance-Sum]','##.00%')
))
## Not run:
# Complex example for PostgreSQL. tmp_time has to exist
create_schema(engine='PostgreSQL',table='big_portfolio',primary_key='id',time_table = 'tmp_time',
schema_dest=schema_dest, data_source_dest=data_source_dest,
con=c('usr','pwd','db','host','port'),
calculated_member=list(
c('Not repaid pct',
'[Measures].[Current balance-Sum]/[Measures].[Original balance-Sum]',NA),
c('Repaid pct',
'[Measures].[Current balance-Sum]/[Measures].[Original balance-Sum]','##.00%')
))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.