-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Fix template rendering for Common SQL operators #28202
Fix template rendering for Common SQL operators #28202
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 Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
|
dff8ea4
to
5dd5b8a
Compare
Static checks I am afraid |
5dd5b8a
to
cc3b804
Compare
Yes, sorry, I missed those yesterday. This code took the slightly more complex approach of moving things around such that the SQL gets generated only in the execute method. I did notice some of the operators take the approach of templating what would be What do you think? |
Ah, the static checks for BigQuery are failing because there's no longer a The new version of the PR does template out |
cc3b804
to
bac62ee
Compare
Yeah. Cool. This is exactly why we have tests for :) |
Static checks need to be fixed :( @jon-evergreen - I recommend to install pre-commit, it will fix everything for you. |
@potiuk I did install the hooks after the first commit which got bounced. And when I make changes to the
I think the precommit definition needs to change from
to
to have it run on changes to both |
Closes: apache#28195 This patch fixes all the common SQL operators I could find which showed the same problem as reported in apache#28195, that statements are generated "too early", before the templated variables have been applied. I think all changes should have tests which break without the fix. Some of these tests are quite brittle in that they mock complex nested SQL which is not ideal. This patch adds the `self.sql` variable as a templated parameter, allowing for templated `table`, `partition_clause`, `checks` etc.
bac62ee
to
1c3016c
Compare
Also, in case it wasn't clear, I have now checked in the updated |
^scripts/ci/pre_commit/pre_commit_update_common_sql_api.py|^airflow/providers/common/sql/.*.pyi?$ Correct 🤦 . The |
Awesome work, congrats on your first merged pull request! |
Closes: #28195
This patch fixes all the common SQL operators I could find which showed the same problem as reported in #28195, that statements are generated "too early", before the templated variables have been applied. I think all changes should have tests which break without the fix. Some of these tests are quite brittle in that they mock complex nested SQL which is not ideal. In my defence though, so do a lot of the tests in the file
This patch adds the
self.sql
variable as a templated parameter, allowing for templatedtable
,partition_clause
,checks
etc.