Skip to content

Add PyDABs support for SQL Alerts - #6335

Open
Sankalp-Mittal wants to merge 8 commits into
mainfrom
sankalp-mittal/pydabs-support-for-alerts
Open

Add PyDABs support for SQL Alerts#6335
Sankalp-Mittal wants to merge 8 commits into
mainfrom
sankalp-mittal/pydabs-support-for-alerts

Conversation

@Sankalp-Mittal

@Sankalp-Mittal Sankalp-Mittal commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds support for using alerts via Python

def load_resources() -> Resources:
    resources = Resources()

    resources.add_alert(
        "my_alert_2",
        {
            "display_name": "My Alert (2)",
            "query_text": "SELECT 2",
            "warehouse_id": "my_warehouse_2",
            "evaluation": {
                "comparison_operator": "LESS_THAN",
                "source": {"name": "column_2"},
            },
            "schedule": {
                "quartz_cron_schedule": "0 0 12 * * ?",
                "timezone_id": "UTC",
            },
        },
    )

    return resources

Changes

  • Add PyDABs (Python) support for the alert resource: register resources.Alert for codegen and load the sql and iam namespace (packages.py), wire Alert into the core package (add_alert, alerts collection, alert_mutator, resource-type registration), and commit the generated databricks/bundles/alerts/ package.

Why

This change was requested by a PyDABs user, and is part of eventually supporting all resources in PyDABs

Tests

  • Unit: added an Alert case to test_resources.py (add/merge/mutator/duplicate/location).
  • Acceptance: new alerts-support scenario validating YAML + Python alerts coexist, serialize (nested evaluation/schedule + enum), and are mutated by alert_mutator, on both terraform and direct engines.

@Sankalp-Mittal Sankalp-Mittal changed the title sankalp mittal/pydabs support for alerts Add PyDABs support for SQL Alerts Aug 20, 2026
@@ -0,0 +1,19 @@
from enum import Enum

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire directory _models/ is autogenerated

@@ -0,0 +1,123 @@
__all__ = [

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is also auto generated

@@ -12,6 +12,7 @@
"VariableOrDict",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These had to be manually added to add mutators

@@ -69,6 +70,38 @@ def my_job_mutator(bundle: Bundle, job: Job) -> Job:
# was deemed overly implicit and potentially confusing.


Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again manually added but standard template code

@@ -31,6 +31,7 @@ def all(cls) -> tuple["_ResourceType", ...]:
# intentionally lazily load all resource types to avoid imports from databricks.bundles.core to
# be imported in databricks.bundles.<resource_type>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should also be autogenerated we should just have a cli interface where singular and plural can be defined

@@ -249,6 +258,34 @@ def add_volume(

self._volumes[resource_name] = volume

def add_alert(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only function that I'm not sure on whether to autogenerate or not??

@@ -74,6 +83,40 @@ class TestCase:
),
resource_types[Schema],
),
(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the unit test params that I think need to be manually written

@@ -26,6 +34,7 @@ class TestCase:
dict_example: dict
dataclass_example: Resource
mutator: Callable
article: str = "a" # grammatical article in the duplicate-resource error message

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default article can be overriden for example in the case of alert

@@ -21,6 +22,8 @@
"pipelines",
"resources",
"catalog",
"sql",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 2 had to be added manually but I think they can be found out using BFS and potentially stored in a yaml file

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 43bc6f1

Run: 32468991845

Env 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ aws linux 1 4 274 1163 5:52
💚​ aws windows 1 4 276 1161 3:32
💚​ azure linux 1 4 273 1163 5:56
💚​ azure windows 1 4 275 1161 3:18
💚​ gcp linux 1 4 274 1163 5:26
💚​ gcp windows 1 4 276 1161 3:26
Test Name aws linux aws windows azure linux azure windows gcp linux gcp windows
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
Top 6 slowest tests (at least 2 minutes):
duration env testname
3:55 aws linux TestAccept
3:52 azure linux TestAccept
3:39 gcp linux TestAccept
3:23 aws windows TestAccept
3:10 azure windows TestAccept
3:08 gcp windows TestAccept

@Sankalp-Mittal
Sankalp-Mittal marked this pull request as ready for review August 21, 2026 12:43
@github-actions

Copy link
Copy Markdown
Contributor

Approval status: pending

/acceptance/bundle/ - needs approval

7 files changed
Suggested: @andrewnester
Also eligible: @anton-107, @denik, @janniklasrose, @lennartkats-db, @pietern, @shreyas-goenka

General files (require maintainer)

24 files changed
Based on git history:

  • @andrewnester -- recent work in python/codegen/codegen/

Any maintainer (@andrewnester, @anton-107, @denik, @pietern, @shreyas-goenka, @simonfaltum, @renaudhartert-db, @janniklasrose, @lennartkats-db, @rugpanov, @rclarey) can approve all areas.
See OWNERS for ownership rules.

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.

2 participants