slicer - Command Line Tool¶
Cubes comes with a command line tool that can:
- run OLAP server
- build and compute cubes
- validate and translate models
Usage:
slicer command [command_options]
or:
slicer command sub_command [sub_command_options]
Commands are:
Command | Description |
---|---|
list |
List available cubes in current workspace |
serve |
Start OLAP server |
model validate |
Validates logical model for OLAP cubes |
model convert |
Convert between model formats |
test |
Test the configuration and model against backends |
sql aggregate |
Create aggregated table |
sql denormalize |
Create denormalized table |
serve¶
Run Cubes OLAP HTTP server.
Example server configuration file slicer.ini
:
[server]
host: localhost
port: 5000
reload: yes
log_level: info
[workspace]
url: sqlite:///tutorial.sqlite
view_prefix: vft_
[model]
path: models/model_04.json
To run local server:
slicer serve slicer.ini
In the [server]
section, space separated list of modules to be imported can
be specified under option modules
:
[server]
modules=cutom_backend
...
Note
Use –debug option if you would like to see more detailed error messages in the browser (generated by Flask).
For more information about OLAP HTTP server see OLAP Server
model convert¶
Usage:
slicer model convert --format bundle model.json model.cubesmodel
slicer model convert model.cubesmodel > model.json
Optional arguments:
--format model format: json or bundle
--force replace the target if exists
model validate¶
Usage:
slicer model validate /path/to/model/directory
slicer model validate model.json
slicer model validate http://somesite.com/model.json
Optional arguments:
-d, --defaults show defaults
-w, --no-warnings disable warnings
-t TRANSLATION, --translation TRANSLATION
model translation file
For more information see Model Validation in Logical Model and Metadata
Example output:
loading model wdmmg_model.json
-------------------------
cubes: 1
wdmmg
dimensions: 5
date
pog
region
cofog
from
-------------------------
found 3 issues
validation results:
warning: No hierarchies in dimension 'date', flat level 'year' will be used
warning: Level 'year' in dimension 'date' has no key attribute specified
warning: Level 'from' in dimension 'from' has no key attribute specified
0 errors, 3 warnings
The tool output contains recommendation whether the model can be used:
- model can be used - if there are no errors, no warnings and no defaults used, mostly when the model is explicitly described in every detail
- model can be used, make sure that defaults reflect reality - there are no errors, no warnings, but the model might be not complete and default assumptions are applied
- not recommended to use the model, some issues might emerge - there are just warnings, no validation errors. Some queries or any other operations might produce invalid or unexpected output
- model can not be used - model contain errors and it is unusable
test¶
Every cube in the model is tested through the backend whether it can be accessed and whether the mappings reflect reality.
Usage:
slicer test [-h] [-E EXCLUDE_STORES] [config] [cubes]
Positional arguments:
config server configuration .ini file
cubes list of cubes to be tested
Optional arguments:
--aggregate Test aggregate of whole cube
-E, --exclude-store TEXT
--store TEXT
--help Show this message and exit.
sql denormalize¶
Usage:
slicer sql denormalize [-h] [-f] [-m] [-i] [-s SCHEMA] [--config config]
[CUBE] [TARGET]
positional arguments:
CUBE cube to be denormalized
TARGET target table name
optional arguments:
--force replace existing views
-m, --materialize create materialized view (table)
--index / --no-index create index for key attributes
-s, --schema TEXT target view schema (overrides default fact schema
--help Show this message and exit.
--store TEXT Name of the store to use other than default. Must be SQL.
--config TEXT Name of slicer.ini configuration file
If no cube is specified then all cubes are denormalized according to the naming conventions in the configuration file.
Examples¶
If you plan to use denormalized views, you have to specify it in the
configuration in the [workspace]
section:
[workspace]
denormalized_view_prefix = mft_
denormalized_view_schema = denorm_views
# This switch is used by the browser:
use_denormalized = yes
The denormalization will create tables like denorm_views.mft_contracts
for
a cube named contracts
. The browser will use the view if option
use_denormalization
is set to a true value.
Denormalize all cubes in the model:
slicer sql denormalize
Denormalize only one cube:
slicer sql denormalize contracts
Create materialized denormalized view with indexes:
slicer denormalize --materialize --index slicer.ini
Replace existing denormalized view of a cube:
slicer denormalize --force -c contracts slicer.ini
Schema¶
Schema where denormalized view is created is schema specified in the
configuration file. Schema is shared with fact tables and views. If you want
to have views in separate schema, specify denormalized_schema
option
in the configuration.
If for any specific reason you would like to denormalize into a completely
different schema than specified in the configuration, you can specify it with
the --schema
option.
View name¶
By default, a view name is the same as corresponding cube name. If there is
denormalized_prefix
option in the configuration, then the prefix is
prepended to the cube name. Or it is possible to override the option with
command line argument --prefix
.
Note
The tool will not allow to create view if it’s name is the same as fact
table name and is in the same schema. It is not even possible to
--force
it. A view prefix or different schema has to be specified.
sql aggregate¶
Create pre-aggregated table from cube(s). If no cube is specified, then all cubes are aggregated. Target table can be specified only for one cube, for multiple cubes naming convention is used.
Usage:
slicer sql aggregate [OPTIONS] [CUBE] [TARGET]
positional arguments:
CUBE cube to be denormalized
TARGET target table name
optional arguments:
--force replace existing views
--index / --no-index create index for key attributes
-s, --schema TEXT target view schema (overrides default fact schema
-d, --dimension TEXT dimension to be used for aggregation
--help Show this message and exit.
--store TEXT Name of the store to use other than default. Must be SQL.
--config TEXT Name of slicer.ini configuration file
If no cube is specified then all cubes are denormalized according to the naming conventions in the configuration file.