pql.py
PQL
¶
A PQL query object can contain columns (Dimensions or KPIs in Celonis), filters, variables, limit and offset.
It can be turned into a query that the engine accepts using the query
property. Various objects can be
added to it when it is initiated, by using the add
method or by using the +
operator. The object contains
the following attributes that are accessible by the user:
Attributes:
Name | Type | Description |
---|---|---|
columns |
A dictionary of containing PQL columns with name as key. |
|
filters |
A list of filters. |
|
variables |
A dictionary of variables with name as key. |
|
limit |
The LIMIT of the PQL query. |
|
offset |
The OFFSET of the PQL query. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
Initialize |
required | |
limit |
int |
The |
-1 |
offset |
int |
The |
0 |
query: List
property
readonly
¶
Get the PQL query list in Celonis engine format, containing a TABLE
statement and optional filters.
add(self, obj)
¶
Tries to add the given object to the PQL query.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
Union[PQL, PQLColumn, PQLFilter, Dict, Iterable] |
|
required |
Exceptions:
Type | Description |
---|---|
PyCelonisTypeError |
If type of |
PQLColumn
¶
A PQL Column dictionary that can be added to a PQL query statement. Behaves like dict. Corresponds to Dimension and KPI in Celonis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
str |
The PQL query of the column (KPI or Dimension). |
None |
name |
str |
The name of te column. |
'Unnamed column' |
sorting_index |
Union[str, int] |
The sorting index of the column in a table (starts at 0). |
None |
sorting_direction |
str |
The sorting direction. One of [ |
None |
PQLFilter (UserString)
¶
A PQL filter that can be added to a PQL query statement. Behaves like string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
str |
The PQL query of the filter. |
required |
count(self, sub, start=0, end=9223372036854775807)
inherited
¶
S.count(value) -> integer -- return number of occurrences of value
index(self, sub, start=0, end=9223372036854775807)
inherited
¶
S.index(value, [start, [stop]]) -> integer -- return first index of value. Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
PQLDebugger
¶
A PQL Debugger to check for query errors.
debug(query, dm)
staticmethod
¶
Debugs the PQL query columns and filters one by one to find errors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
Union[celonis_api.pql.pql.PQLColumn, celonis_api.pql.pql.PQLFilter, celonis_api.pql.pql.PQL, List] |
The PQL query to be debugged. |
required |
dm |
Datamodel |
The Datamodel on which the query will be executed. |
required |
Returns:
Type | Description |
---|---|
List[str] |
A List of Errors. |