atoti.experimental.distributed.cube module

class atoti.experimental.distributed.cube.DistributedCube(java_api, name, session)

Bases: atoti._local_cube.LocalCube[atoti.experimental.distributed.hierarchies.DistributedHierarchies, atoti.experimental.distributed.levels.DistributedLevels, atoti.experimental.distributed.measures.DistributedMeasures]

Cube of a distributed session.

property aggregates_cache

Aggregates cache of the cube.

Return type

AggregatesCache

explain_query(*measures, condition=None, include_totals=False, levels=None, scenario='Base', timeout=30)

Run the query but return an explanation of the query instead of the result.

The explanation contains a summary, global timings and the query plan with all the retrievals.

Parameters
  • measures (Union[NamedMeasure, QueryMeasure]) – The measures to query. If None, all the measures are queried.

  • condition (Union[LevelCondition, MultiCondition, LevelIsInCondition, HierarchyIsInCondition, None]) –

    The filtering condition. Only conditions on level equality with a string are supported. For instance:

    • lvl["Country"] == "France"

    • (lvl["Country"] == "USA") & (lvl["Currency"] == "USD")

    • h["Geography"].isin(("Asia",), ("Europe", "France"))

  • include_totals (bool) – Whether the returned DataFrame should include the grand total and subtotals. Totals can be useful but they make the DataFrame harder to work with since its index will have some empty values.

  • levels (Union[~_Level, Sequence[~_Level], None]) – The levels to split on. If None, the value of the measures at the top of the cube is returned.

  • scenario (str) – The scenario to query.

  • timeout (int) – The query timeout in seconds.

Return type

QueryAnalysis

property hierarchies

Hierarchies of the cube.

Return type

~_LocalHierarchies

property levels

Levels of the cube.

Return type

~_Levels

property measures

Measures of the cube.

Return type

~_LocalMeasures

property name

Name of the cube.

Return type

str

query(*measures, condition=None, include_totals=False, levels=None, mode='pretty', scenario='Base', timeout=30)

Query the cube to retrieve the value of the passed measures on the given levels.

In JupyterLab with the atoti-jupyterlab plugin installed, query results can be converted to interactive widgets with the Convert to Widget Below action available in the command palette or by right clicking on the representation of the returned Dataframe.

Parameters
  • measures (Union[NamedMeasure, QueryMeasure]) – The measures to query. If None, all the measures are queried.

  • condition (Union[LevelCondition, MultiCondition, LevelIsInCondition, HierarchyIsInCondition, None]) –

    The filtering condition. Only conditions on level equality with a string are supported. For instance:

    • lvl["Country"] == "France"

    • (lvl["Country"] == "USA") & (lvl["Currency"] == "USD")

    • h["Geography"].isin(("Asia",), ("Europe", "France"))

  • include_totals (bool) – Whether the returned DataFrame should include the grand total and subtotals. Totals can be useful but they make the DataFrame harder to work with since its index will have some empty values.

  • levels (Union[~_Level, Sequence[~_Level], None]) – The levels to split on. If None, the value of the measures at the top of the cube is returned.

  • scenario (str) – The scenario to query.

  • timeout (int) – The query timeout in seconds.

  • mode (Literal[‘pretty’, ‘raw’]) –

    The query mode.

    • "pretty" is best for queries returning small results:

      • A QueryResult will be returned and its rows will be sorted according to the level comparators.

    • "raw" is best for benchmarks or large exports:

    • A faster and more efficient endpoint reducing the data transfer from Java to Python will be used.

    • A classic pandas.DataFrame will be returned.

    • include_totals="True" will not be allowed.

    • The Convert to Widget Below action provided by the atoti-jupyterlab plugin will not be available.

Return type

Union[QueryResult, DataFrame]