Cubes 0.9.1: Ranges, denormalization and query cell
The new minor release of Cubes – light-weight Python
OLAP framework –
brings range cuts,
denormalization
with the slicer tool and cells in /report
query, together with fixes and
important changes.
See the second part of this post for the full list.
Range Cuts
Range cuts were implemented in the SQL Star Browser. They are used as follows:
Python:
cut = RangeCut("date", [2010], [2012,5,10]) cut_hi = RangeCut("date", None, [2012,5,10]) cut_low = RangeCut("date", [2010], None)
To specify a range in slicer server where keys are sortable:
http://localhost:5000/aggregate?cut=date:2004-2005 http://localhost:5000/aggregate?cut=date:2004,2-2005,5,1
Open ranges:
http://localhost:5000/aggregate?cut=date:2010- http://localhost:5000/aggregate?cut=date:2004,1,1- http://localhost:5000/aggregate?cut=date:-2005,5,10 http://localhost:5000/aggregate?cut=date:-2012,5
Denormalization with slicer Tool
Now it is possible to denormalize tour data with the slicer tool. You do not have to denormalize using python script. Data are denormalized in a way how denormalized browser would expect them to be. You can tune the process using command line switches, if you do not like the defaults.
Denormalize all cubes in the model:
$ slicer denormalize slicer.ini
Denormalize only one cube::
$ slicer denormalize -c contracts slicer.ini
Create materialized denormalized view with indexes::
$ slicer denormalize --materialize --index slicer.ini
Example slicer.ini
:
[workspace] denormalized_view_prefix = mft_ denormalized_view_schema = denorm_views # This switch is used by the browser: use_denormalization = yes
For more information see Cubes slicer tool documentation
Cells in Report
Use cell
to specify all cuts (type can be range
, point
or set
):
{ "cell": [ { "dimension": "date", "type": "range", "from": [2010,9], "to": [2011,9] } ], "queries": { "report": { "query": "aggregate", "drilldown": {"date":"year"} } } }
For more information see the slicer server documentation.
New Features
- cut_from_string(): added parsing of range and set cuts from string; introduced requirement for key format: Keys should now have format "alphanumeric character or underscore" if they are going to be converted to strings (for example when using slicer HTTP server)
- cut_from_dict(): create a cut (of appropriate class) from a dictionary description
- Dimension.attribute(name): get attribute instance from name
- added exceptions: CubesError, ModelInconsistencyError, NoSuchDimensionError, NoSuchAttributeError, ArgumentError, MappingError, WorkspaceError and BrowserError
StarBrowser:
- implemented RangeCut conditions
Slicer Server:
/report
JSON now acceptscell
with full cell description as dictionary, overrides URL parameters
Slicer tool:
denormalize
option for (bulk) denormalization of cubes (see the the slicer documentation for more information)
Changes
- important: all
/report
JSON requests should now have queries wrapped in the keyqueries
. This was originally intended way of use, but was not correctly implemented. A descriptive error message is returned from the server if the keyqueries
is not present. Despite being rather a bug-fix, it is listed here as it requires your attention for possible change of your code. - warn when no backend is specified during slicer context creation
Fixes
- Better handling of missing optional packages, also fixes #57 (now works without slqalchemy and without werkzeug as expected)
- see change above about
/report
andqueries
- push more errors as JSON responses to the requestor, instead of just failing with an exception
Links
Sources can be found on github. Read the documentation.
Join the Google Group for discussion, problem solving and announcements.
Submit issues and suggestions on github
IRC channel #databrewery on irc.freenode.net
If you have any questions, comments, requests, do not hesitate to ask.