Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "default" instead of None when creating distilled_hierarchies. #306

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions cubes/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ def distilled_hierarchies(self):
hierarchies[key] = levels

if dim.default_hierarchy_name == hier.name:
hierarchies[(dim.name, None)] = levels
hierarchies[(dim.name, "default")] = levels

return hierarchies

Expand Down Expand Up @@ -773,7 +773,7 @@ def validate(self):
results = []

# Check whether all attributes, measures and keys are Attribute objects
# This is internal consistency chceck
# This is internal consistency check

measures = set()

Expand Down Expand Up @@ -1090,13 +1090,13 @@ def __init__(self, name, levels=None, hierarchies=None,
elif nonadditive in ["all", "any"]:
self.nonadditive = "all"
elif nonadditive != "time":
raise ModelError("Unknown non-additive diension type '%s'"
raise ModelError("Unknown non-additive dimension type '%s'"
% nonadditive)

self.nonadditive = nonadditive

if not levels and not attributes:
raise ModelError("No levels or attriutes specified for dimension %s" % name)
raise ModelError("No levels or attributes specified for dimension %s" % name)
elif levels and attributes:
raise ModelError("Both levels and attributes specified")

Expand Down Expand Up @@ -1354,7 +1354,7 @@ def clone(self, hierarchies=None, exclude_hierarchies=None,
else:
default_hierarchy_name = hierarchies[0].name

# TODO: should we do deppcopy on info?
# TODO: should we do deepcopy on info?
name = alias or self.name

return Dimension(name=name,
Expand Down Expand Up @@ -1438,7 +1438,7 @@ def validate(self):
if len(self._hierarchies) > 1 and \
not "default" in self._hierarchies:
results.append(('error',
"No defaut hierarchy specified, there is "
"No default hierarchy specified, there is "
"more than one hierarchy in dimension "
"'%s'" % self.name))

Expand Down Expand Up @@ -1882,7 +1882,7 @@ def __init__(self, name, attributes, key=None, order_attribute=None,
elif nonadditive in ["all", "any"]:
self.nonadditive = "all"
elif nonadditive != "time":
raise ModelError("Unknown non-additive diension type '%s'"
raise ModelError("Unknown non-additive dimension type '%s'"
% nonadditive)
self.nonadditive = nonadditive

Expand Down Expand Up @@ -2158,7 +2158,7 @@ def localized_ref(self, locale):
"""
if locale:
if not self.locales:
raise ArgumentError("Attribute '{}' is not loalizable "
raise ArgumentError("Attribute '{}' is not localizable "
"(localization {} requested)"
.format(self.name, locale))
elif locale not in self.locales:
Expand All @@ -2175,7 +2175,7 @@ def localized_ref(self, locale):
@property
def dependencies(self):
"""Set of attributes that the `attribute` depends on. If the
`attribute` is an expresion, then returns the direct dependencies from
`attribute` is an expression, then returns the direct dependencies from
the expression. If the attribute is an aggregate with an unary
function operating on a measure, then the measure is considered as a
dependency. Attribute can't have both expression and measure
Expand Down Expand Up @@ -2301,7 +2301,7 @@ def __init__(self, name, label=None, description=None, order=None,
other measure that refers to this one (no circular reference).

The `aggregates` is an optional property and is used for:
* measure aggergate object preparation
* measure aggregate object preparation
* optional validation

String representation of a `Measure` returns its full reference.
Expand Down Expand Up @@ -2400,12 +2400,12 @@ def __init__(self, name, label=None, description=None, order=None,
info=None, format=None, missing_value=None, measure=None,
function=None, formula=None, expression=None,
nonadditive=None, window_size=None, **kwargs):
"""Masure aggregate
"""Measure aggregate

Attributes:

* `function` – aggregation function for the measure
* `formula` – name of a formula that contains the arithemtic
* `formula` – name of a formula that contains the arithmetic
expression (optional)
* `measure` – measure name for this aggregate (optional)
* `expression` – arithmetic expression (only if backend supported)
Expand Down
2 changes: 1 addition & 1 deletion cubes/sql/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ def conditions_for_cuts(self, cuts):
conditions = []

for cut in cuts:
hierarchy = str(cut.hierarchy) if cut.hierarchy else None
hierarchy = str(cut.hierarchy) if cut.hierarchy else "default"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guys, we need this fix in master.

And the few lines below, in case of SetCut, we need to use "hierarchy" var instead of "str(cut.hierarchy)".
Here: https://github.com/DataBrewery/cubes/blob/master/cubes/sql/query.py#L973

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed it here: #391


if isinstance(cut, PointCut):
path = cut.path
Expand Down
6 changes: 3 additions & 3 deletions cubes/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def cube_names(self, identity=None):
"""Return names all available cubes."""
return [cube["name"] for cube in self.list_cubes()]

# TODO: this is not loclized!!!
# TODO: this is not localized!!!
def list_cubes(self, identity=None):
"""Get a list of metadata for cubes in the workspace. Result is a list
of dictionaries with keys: `name`, `label`, `category`, `info`.
Expand Down Expand Up @@ -550,7 +550,7 @@ def cube(self, ref, identity=None, locale=None):
lookup = namespace.translation_lookup(locale)

if lookup:
# TODO: pass lookup instead of jsut first found translation
# TODO: pass lookup instead of just first found translation
context = LocalizationContext(lookup[0])
trans = context.object_localization("cubes", cube.name)
cube = cube.localized(trans)
Expand Down Expand Up @@ -622,7 +622,7 @@ def browser(self, cube, locale=None, identity=None):
options.update(cube_options)

# TODO: Construct options for the browser from cube's options
# dictionary and workspece default configuration
# dictionary and workspace default configuration

browser_name = cube.browser
if not browser_name and hasattr(store, "default_browser_name"):
Expand Down
2 changes: 1 addition & 1 deletion doc/model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Mappings and Joins
One can specify shared mappings and joins on the model-level. Those mappings
and joins are inherited by all the cubes in the model.

The ``mappigns`` dictionary of a cube is merged with model's global mapping
The ``mappings`` dictionary of a cube is merged with model's global mapping
dictionary. Cube's values overwrite the model's values.

The ``joins`` can be considered as named templates. They should contain
Expand Down
6 changes: 3 additions & 3 deletions doc/schemas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Simple Dimension
neither hierarchy.*

Similar schema as `Simple Star Schema`_ Note the dimension `year` which is
represented just by one numeroc attribute.
represented just by one numeric attribute.

It is important that no attributes are specified for the dimension. There
dimension will be referenced just by its name and dimension label is going to
Expand Down Expand Up @@ -142,7 +142,7 @@ it in the `schema` argument of :meth:`cubes.Workspace.register_store`:
url=DATABASE_URL,
schema="sales_datamart")

For the :doc:`server` the schema is specifiedn in the ``[store]`` section
For the :doc:`server` the schema is specified in the ``[store]`` section
of the `slicer.ini` configuration file:

.. code-block:: ini
Expand Down Expand Up @@ -520,7 +520,7 @@ attribute) with the `label` attribute:
Key and Label Attribute
-----------------------

*Synopsis: specify which attributes are going to be used for flitering (keys)
*Synopsis: specify which attributes are going to be used for filtering (keys)
and which are going to be displayed in the user interface (labels)*

.. image:: images/schemas/schema-label_attributes.png
Expand Down
2 changes: 1 addition & 1 deletion tests/test_localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ def test_translate_cube(self):
self.assertEqual(cube.label, "inner_LAB")

# TODO: test non existent top object
# TODO: test non existend child object
# TODO: test non existent child object
# TODO: test plain label