Repository navigation
Add SnowflakeNotebookOperator for executing Snowflake Notebooks - #63470
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
|
@jacobcbeaudin Converting to draft — this PR doesn't yet meet our Pull Request quality criteria.
See the linked criteria for how to fix each item, then mark the PR "Ready for review". This is not a rejection — just an invitation to bring the PR up to standard. No rush. Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you. |
@potiuk Thanks for the feedback. I've addressed the issues:
I've marked the PR as ready for review. As a first-time contributor, I believe the CI workflows need maintainer approval before they can run. Would someone be able to approve the workflow run so we can verify the checks pass? |
SameerMesiah97
left a comment
There was a problem hiding this comment.
I think the approach needs to be re-worked. Looking at the code for this new operator, it looks like you are duplcating the logic in SnowflakeSqlApiOperator with the key difference being the construction of the SQL query through _build_execute_notebook_query. I think it would be better to subclass SnowflakeSqlApiOperator and then override the parent method where you want the logic need to be slightly different like for e.g. in query construction.
jacobcbeaudin
left a comment
There was a problem hiding this comment.
@SameerMesiah97 Good call. Refactored SnowflakeNotebookOperator to subclass SnowflakeSqlApiOperator. It now only adds the notebook/parameters params and builds the EXECUTE NOTEBOOK SQL in _build_execute_notebook_query(). Everything else (hook setup, execute, polling, deferral, on_kill) is inherited from the parent. Went from about 237 lines down to 90.
|
@jacobcbeaudin Converting to draft — this PR doesn't yet meet our Pull Request quality criteria.
See the linked criteria for how to fix each item, then mark the PR "Ready for review". This is not a rejection — just an invitation to bring the PR up to standard. No rush. Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you. |
f7d8168 to
db1b564
Compare
e59d74f to
e19c761
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a dedicated SnowflakeNotebookOperator to execute Snowflake Notebooks via the Snowflake SQL API, including documentation and coverage through unit + system test examples.
Changes:
- Introduces
SnowflakeNotebookOperatorbuilt onSnowflakeSqlApiOperatorto runEXECUTE NOTEBOOK .... - Adds unit tests validating SQL construction and execution paths (immediate success/failure, polling, deferrable, XCom, on_kill).
- Adds system test example DAG and provider docs section for the new operator.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| providers/snowflake/src/airflow/providers/snowflake/operators/snowflake.py | Adds SnowflakeNotebookOperator and SQL builder for EXECUTE NOTEBOOK. |
| providers/snowflake/tests/unit/snowflake/operators/test_snowflake.py | Adds unit tests for SQL generation and operator behaviors (polling/deferral/XCom). |
| providers/snowflake/tests/system/snowflake/example_snowflake_notebook.py | Adds a system test example DAG demonstrating operator usage. |
| providers/snowflake/docs/operators/snowflake.rst | Documents SnowflakeNotebookOperator and includes example snippets. |
0937ae9 to
3bd6851
Compare
jroachgolf84
left a comment
There was a problem hiding this comment.
@jacobcbeaudin - LGTM. However, you'll want to make sure you resolve all of the open conversations (that may just mean clicking "Resolve Conversation" if the feedback does not need to be implemented).
|
One other thing; were you able to test this E2E in Snowflake? Does this work as expected? |
|
@jacobcbeaudin — There are 1 unresolved review thread on this PR from @eladkal. Could you either push a fix or reply in each thread explaining why the feedback doesn't apply? Once you believe the feedback is addressed, mark the thread as resolved so the reviewer isn't re-pinged needlessly. Thanks! Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you. |
|
@jacobcbeaudin — There are 1 unresolved review thread(s) on this PR, and you have engaged with each one (post-review commits and/or in-thread replies). Could you confirm whether you believe the feedback is fully addressed and the PR is ready for maintainer review confirmation? If yes, reply here (a short "yes / ready" is fine) and an Apache Airflow maintainer will pick the PR up from the review queue on the next sweep. If you are still working on a thread, please reply with what is outstanding so the threads stay unresolved on purpose. Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you. Drafted-by: Claude Code (Opus 4.7); reviewed by @potiuk before posting |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions. |
|
@jacobcbeaudin can you address open items and resolve conflicts? |
|
@eladkal yes, I will take care of this on Monday |
Adds SnowflakeNotebookOperator, which builds an EXECUTE NOTEBOOK statement and delegates submission, polling, deferral and cancellation to SnowflakeSqlApiOperator.
91b2878 to
5b5a68d
Compare
SnowflakeNotebookOperator reused `parameters`, which SQLExecuteQueryOperator owns for SQL bind parameters. Loading those from a .sql/.json file is a deliberate feature of the parent, but the wrong behaviour for notebook arguments: reusing the name meant a parameter that looked like a filename was replaced by that file's contents, the attribute had to be reassigned after super().__init__(), and a JSON renderer was applied to a list[str]. The generated SQL is never read from a file, so no template extension applies.
|
Thank you for your patience. I did a rebase onto the latest Test results@jroachgolf84 asked:
I ran this operator against a live Snowflake account. These functions are correct:
The template question@jroachgolf84 asked:
Airflow causes the change. Airflow writes the rendered values back into the template fields. You can do this test without a Snowflake account. The field has the name op = SnowflakeNotebookOperator(task_id="t", notebook="{{ params.db }}.NB",
notebook_parameters=["{{ params.name }}", "plain"])
op.render_template_fields({"params": {"db": "MY_DB.S", "name": "O'Brien"}})
# op.notebook_parameters is now ["O'Brien", "plain"] -- Airflow wrote it in place
# op.sql (old value): EXECUTE NOTEBOOK MY_DB.S.NB('O'Brien', 'plain') <- not valid SQL
# execute() makes: EXECUTE NOTEBOOK MY_DB.S.NB('O''Brien', 'plain') <- correctAirflow writes the rendered values into the template fields in place. Thus A different name for the parametersThe tests showed me that The parent class can read bind parameters from a But that function is wrong for notebook arguments. The two names were the same. Thus Airflow found a notebook parameter with the form of a file name. Airflow then replaced that parameter with the contents of the file: I did these three things:
The new name also removes the The new name agrees with the other operators in this hierarchy: Airflow did not release this operator yet. Thus the new name costs nothing now. After a merge, a different name makes a deprecation cycle necessary. Tell me if you prefer a smaller diff, and I will remove the new name. |
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
Add a dedicated
SnowflakeNotebookOperatorthat executes Snowflake Notebooksvia the Snowflake SQL API. The operator submits an
EXECUTE NOTEBOOKstatement,polls for completion, and pushes the query ID to XCom. Supports both synchronous
polling and deferrable (async) mode for long-running notebook executions.
Reuses the existing
SnowflakeSqlApiHookandSnowflakeSqlApiTrigger— no newhook or trigger code required.
closes: #40167
Was generative AI tooling used to co-author this PR?
Important
🛠️ Maintainer triage note for @jacobcbeaudin · by
@potiuk· 2026-07-02 17:46 UTCSome review feedback from
@eladkalis waiting on you:@eladkalneed a reply or a fix.The ball is in your court — you've been assigned to this PR. Reply or push a fix in each thread, then mark them resolved.
Automated triage — may be imperfect; a maintainer takes the next look.