Cube Utils is a Python library for parsing and extracting information from query payloads.
You can install Cube Utils using pip:
pip install cube-utils
Usage Here is an example of how to use the extract_cubes function from the cube_utils.query_parser module:
from cube_utils.query_parser import extract_cubes
# Example payload
payload = {
"dimensions": ["test_a.city", "test_a.country", "test_a.state"],
"measures": ["test_b.count"],
"filters": [
{"values": ["US"], "member": "test_a.country", "operator": "equals"}
],
"timeDimensions": [
{
"dimension": "test_c.time",
"dateRange": ["2021-01-01", "2021-12-31"],
"granularity": "month",
}
],
}
# Extract cubes
cubes = extract_cubes(payload)
print(cubes) # Output: ['test_a', 'test_b', 'test_c']
To run the tests, use the following command:
python -m unittest discover tests
This project is licensed under the MIT License - see the LICENSE file for details.