Skip to content

paco-valdez/cube-utils

Repository files navigation

Cube Utils

Cube Utils is a Python library for parsing and extracting information from query payloads.

Installation

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']

Running Tests

To run the tests, use the following command:

python -m unittest discover tests

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Cube Utils for Python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages