Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add aggregate support #22

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

ag-ramachandran
Copy link
Contributor

  • Adds support for all aggregates (in the context of superset)
  • Adds additional tests
  • Bumps library versions

* Update library revisions
…anipulate a temporary table in Azure Data Explorer (Kusto) for testing purposes. It includes several functions and fixtures to set up, run tests, and tear down the test environment. Below is a breakdown of what each part of the code does:

1. **Imports and Setup**:
   - The script imports necessary modules such as `pytest`, `uuid`, `KustoConnectionStringBuilder`, etc. These are used for creating connections to Azure Data Explorer, handling database operations, and managing test fixtures.

2. **Helper Functions**:
   - `get_kcsb()`: This function returns a Kusto connection string based on the authentication method (Azure CLI or AAD application key).
   - `_create_temp_table(table_name: str)`: Creates a temporary table with specified columns (`Id` and `Text`).
   - `_create_temp_fn(fn_name: str)`: Creates a temporary function that prints the current time.
   - `_ingest_data_to_table(table_name: str)`: Ingests sample data into the specified table.
   - `_drop_table(table_name: str)`: Drops the specified table and its associated function after testing.

3. **Fixtures**:
   - `temp_table_name()`: Generates a unique name for the temporary table using UUID.
   - `run_around_tests(temp_table_name)`: This fixture sets up the test environment by creating a temporary table and its function, ingesting data into the table, and then tearing down the table after the tests are run.

4. **Tests**:
   - The commented-out functions (`test_fizzbuzz` and `test_limit`) were intended to be unit tests but are not implemented in the provided code. These would typically contain assertions to verify the behavior of the Kusto queries or other operations.

5. **KustoClient**:
   - The script uses the `KustoClient` class from the `azure-kusto-data` library to interact with Azure Data Explorer, executing commands to create tables, functions, and ingest data.

### Example of How to Use the Fixture
Here's an example of how you might use the `temp_table_name` fixture in a test:

```python
def test_something(temp_table_name):
    # Now you can use temp_table_name as a unique table name for your tests
    assert isinstance(temp_table_name, str)  # Just an example assertion
```

### Running the Tests
To run these tests, you would typically set up a testing environment that includes Azure Data Explorer and ensure that the necessary credentials are configured. You can then execute pytest to run the tests:

```bash
pytest your_test_file.py
```

This script is useful for ensuring that your Kusto queries and interactions work as expected in an isolated test environment, allowing you to write reliable and repeatable unit tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant