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

Add support for query parameters to BigQueryCheckOperator (#40556) #40558

Merged
merged 4 commits into from
Jul 3, 2024

Conversation

aldenstpage
Copy link
Contributor

@aldenstpage aldenstpage commented Jul 2, 2024

BigQueryCheckOperator doesn't support query parameters. Query parameters should always be supported to discourage string-formatting, which can introduce SQL injection vulnerabilities.

The attack surface of BigQueryCheckOperator is basically non-existent. However, using query parameters everywhere is a matter of common sense and good housekeeping. A user of the module shouldn't have to choose query parameters for one operator and string formatting for the other; we should always support the safe route, which is through query parameters.

To add support, we'll imitate BigQueryExecuteQueryOperator's approach of adding a query_params argument to the constructor of BigQueryCheckOperator. An alternative approach would have been to make it possible to pass in configuration as BigQueryInsertJobOperator does, but that would have other breaking changes (like making the sql argument redundant).

Closes: #40556

@boring-cyborg boring-cyborg bot added area:providers provider:google Google (including GCP) related issues labels Jul 2, 2024
Copy link

boring-cyborg bot commented Jul 2, 2024

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)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@aldenstpage aldenstpage force-pushed the bigquerycheckoperator_query_params branch from ad2ad3a to 14d6469 Compare July 2, 2024 18:46
@aldenstpage aldenstpage marked this pull request as ready for review July 2, 2024 18:47
@potiuk
Copy link
Member

potiuk commented Jul 2, 2024

A unit test is needed for that one.

@aldenstpage
Copy link
Contributor Author

aldenstpage commented Jul 2, 2024

That was fast! Thanks for the speedy response.

I added a unit test (and added a missing self reference it uncovered).

@potiuk
Copy link
Member

potiuk commented Jul 2, 2024

That was fast! Thanks for the speedy response.

You were just lucky and the change is small. Both help.

@potiuk
Copy link
Member

potiuk commented Jul 2, 2024

Still static checks failing (I recommend to install pre-commit - it will fix things for you)

@aldenstpage aldenstpage force-pushed the bigquerycheckoperator_query_params branch from 8a3f865 to ee9e2d5 Compare July 2, 2024 21:34
@aldenstpage
Copy link
Contributor Author

aldenstpage commented Jul 2, 2024

I fixed the static check. The MySQL failure is a bit more surprising - flaky integration test / separate issue already existing in main?

@potiuk potiuk merged commit 7e80dc6 into apache:main Jul 3, 2024
51 checks passed
Copy link

boring-cyborg bot commented Jul 3, 2024

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@potiuk
Copy link
Member

potiuk commented Jul 3, 2024

Yep. Was flaky it seems

romsharon98 pushed a commit to romsharon98/airflow that referenced this pull request Jul 26, 2024
…) (apache#40558)

* Add support for query parameters to BigQueryCheckOperator (apache#40556)

Remove unnecessary space

* Add a unit test for BigQueryCheckOperator query params; fix missing 'self' reference

* Fix lint (apache#40558)

---------

Co-authored-by: Alden S. Page <alden.page@doubleverify.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:google Google (including GCP) related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BigQueryCheckOperator does not support parameterized queries
3 participants