-
Notifications
You must be signed in to change notification settings - Fork 7
Expressions Reference
This module provides basic support for converting expression strings (defined in a python-like DSL) into crunch expression objects.
For example, the expression 'disposition == 0 or exit_status == 0' would be transformed by this module's parser into:
{
'function': 'or',
'args': [
{
'function': '==',
'args': [
{
'variable': 'disposition'
},
{
'value': 0
}
]
},
{
'function': '==',
'args': [
{
'variable': 'exit_status'
},
{
'value': 0
}
]
}
]
}
Its important to note that the expression objects produced by this module's
parser are not ready for being sent to crunch, as they refer to variables
by alias
rather than by variable_id
(which is a URL). So, this module
also provides a process_expr
function that creates an expression object
ready for the crunch API.
Translate the crunch expression dictionary to the string representation.
- :param expr: crunch expression
- :param ds: dataset instance
- :return: string representation of the expression
Given a Crunch expression object (or objects) and a Dataset entity object (i.e. a Shoji entity), this function returns a new expression object (or a list of new expression objects) with all variable aliases transformed into variable URLs, just as the crunch API needs them to be.