atoti.query package¶
Submodules¶
atoti.query.auth module¶
Query Authentication.
-
atoti.query.auth.
Auth
= typing.Callable[[str], typing.Union[typing.Mapping[str, str], NoneType]]¶ Called with the URL of the request and return the HTTP headers necessary to authenticate it.
atoti.query.basic_auth module¶
Basic Authentication.
atoti.query.cube module¶
Query cube.
-
class
atoti.query.cube.
QueryCube
(name, hierarchies, measures, _session)¶ Bases:
object
Query cube.
-
hierarchies
: QueryHierarchies = None¶
-
property
levels
¶ Levels of the cube.
- Return type
-
measures
: QueryMeasures = None¶
-
name
: str = None¶
-
query
(*measures, levels=None, condition=None, scenario='Base', timeout=30, **kwargs)¶ Query the cube to get the value of some measures.
The value of the measures is given on all the members of the given levels.
- Parameters
measures (
QueryMeasure
) – The measures to query. If none are specified, all the measures are returned.levels (
Union
[QueryLevel
,Sequence
[QueryLevel
],None
]) – The levels to split on. If none are specified, the value of the measures at the top level is returned.condition (
Union
[LevelCondition
,MultiCondition
,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")
scenario (
str
) – The scenario to query.timeout (
int
) – The query timeout in seconds.
- Return type
DataFrame
- Returns
The resulting DataFrame.
-
atoti.query.cubes module¶
Query cubes.
-
class
atoti.query.cubes.
QueryCubes
(_data)¶ Bases:
atoti._mappings.ImmutableMapping
Manage the query cubes.
atoti.query.hierarchies module¶
Query hierarchies.
-
class
atoti.query.hierarchies.
QueryHierarchies
(_data)¶ Bases:
atoti._mappings.ImmutableMapping
Manage the query hierarchies.
atoti.query.hierarchy module¶
Query hierarchy.
-
class
atoti.query.hierarchy.
QueryHierarchy
(name, dimension, levels, slicing)¶ Bases:
object
Hierarchy for query cube.
-
dimension
: str = None¶
-
isin
(*member_paths)¶ Return a condition to check that the hierarchy is on one of the given members.
Considering
hierarchy_1
containinglevel_1
andlevel_2
,hierarchy_1.isin((a, x), (b,))
is equivalent to((level_1 == a) & (level_2 == x)) | (level_1 == b)
.Example
Considering a “Geography” hierarchy containing two levels “Country” and “City”, and this measure:
measures["Price in USA/Paris and Germany"] = atoti.filter( measures["Price"], hierarchies["Geography"].isin(("USA", "Paris"), ("Germany", )) )
The behavior is the following one:
Country
City
Price
measures[“Price in USA/Paris and Germany”]
France
Paris
200.0
Germany
Berlin
150.0
150.0
UK
London
240.0
USA
New York
270.0
USA
Paris
500.0
500.0
- Parameters
members – One or more members expressed as tuples on which the hierarchy should be. Each element in a tuple corresponds to a level of the hierarchy, from the shallowest to the deepest.
- Return type
HierarchyIsInCondition
-
levels
: ImmutableMapping[str, QueryLevel] = None¶
-
name
: str = None¶
-
slicing
: bool = None¶
-
atoti.query.level module¶
Query level.
-
class
atoti.query.level.
QueryLevel
(name, dimension, hierarchy)¶ Bases:
object
Level for query cube.
-
dimension
: str = None¶
-
hierarchy
: str = None¶
-
isin
(*members)¶ Return a condition to check that the level is on one of the given members.
levels["x"].isin("a", "b")
is equivalent tolevels["x"] == "a" OR levels["x"] == "b"
.Example
Considering this measure:
measures["Price in Paris and London"] = atoti.filter( measures["Price"], levels["City"].isin("Paris", "London") )
The behavior is the following one:
City
Price
measures[“Price in Paris and London”]
Paris
200.0
200.0
Berlin
150.0
London
240.0
240.0
New York
270.0
- Parameters
members (
Any
) – One or more members on which the level should be.- Return type
LevelIsInCondition
-
name
: str = None¶
-
atoti.query.levels module¶
Query levels.
-
class
atoti.query.levels.
QueryLevels
(_hierarchies)¶ Bases:
atoti._base_levels.BaseLevels
Flat representation of all the levels in the cube.
atoti.query.measure module¶
Query measure.
atoti.query.measures module¶
Query measures.
-
class
atoti.query.measures.
QueryMeasures
(_data)¶ Bases:
atoti._mappings.ImmutableMapping
Manage the query measures.
atoti.query.session module¶
Making MDX queries on existing sessions.