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 a new parameter to SQL operators to specify conn id field #30784

Merged
merged 7 commits into from
Aug 7, 2023

Conversation

hussein-awala
Copy link
Member

related: #30778

curretly for the operators sub class of BaseOperator, we provide the field value to super as conn_id which is a template field, and the field is rendered in execution time and everything works fine, but in the rendered-templates view, we have the original field name with the jinja template before rendering.

This PR add a new field for BaseOperator to specify the conn field name, and use it directly from the ancestor with needing to provide it to parent class, then we can add the new conn field name to template_fields to render it.

Before:
Screenshot from 2023-04-21 02-49-25

After:
Screenshot from 2023-04-21 02-51-04

And they both works fine in the hook.

P.S: I just update the not deprecated operators, and this change is b/c, so if the new field is not defined, and the conn_id is provider to parent class, it will work as before.

@hussein-awala hussein-awala changed the title [WIP] Add a new parameter to SQL operators to specify conn id field Add a new parameter to SQL operators to specify conn id field Apr 21, 2023
@potiuk
Copy link
Member

potiuk commented Apr 23, 2023

I am afraid this change is not backwards-compatible with the old common.sql providers. We have to remember that we have potentially complex relation between SQL providers and common.sql - and one can have common.sql 1.0 and latest databricks for example.

There are two ways of handling it:

  1. make the change backwards compatible for each provider (it will complicate the code of each of them a bit and defeat the purpose of the change IMHO)

  2. update all SQL providers to common-sql >= 1.5.0 and set common.sql version to 1.5.0 for the next release (much better IMHO)

BTW. This is the main reason why we want to make sure common.sql provider is 100% backwards compatible - for all the providers - because the moment we make common.sql == 2.0.0, it with some breaking chnages, it will mean that if one provider will start using features from 2.0 and require it, all the other providers will also need to be upgraded which might be undesireable and we loose the "you can upgrade/downgrde providers independently" property.

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

We need to take care about backwards-compatibility

@github-actions
Copy link

github-actions bot commented Jun 8, 2023

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.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Jun 8, 2023
@hussein-awala hussein-awala added pinned Protect from Stalebot auto closing and removed stale Stale PRs per the .github/workflows/stale.yml policy file labels Jun 10, 2023
@hussein-awala hussein-awala force-pushed the fix/sql_operator_conn_template branch from d278a42 to 391f345 Compare August 6, 2023 14:31
@hussein-awala
Copy link
Member Author

@potiuk This PR is ready and fully b/c:

  • If we use an old version of sub providers with new version of common SQL -> BaseSqlOperator will not find the new attribute conn_id_field in the sub class and it will fallback to the default one conn_id which is provided as param.
  • If we use a new version of sub provider with old version of common SQL -> conn_id_field will be ignored, and the BaseSqlOperator will use the provided param.
  • If we use new versions for both -> the provided param conn_id will be ignored, and the BaseSqlOperator will get the attr provided in conn_id_field, and the issue will be fixed.

@hussein-awala hussein-awala requested a review from potiuk August 6, 2023 16:05
Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

❤️ it. Looks cool and safe.

@potiuk potiuk merged commit 9736143 into apache:main Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers pinned Protect from Stalebot auto closing provider:common-sql provider:databricks provider:google Google (including GCP) related issues provider:snowflake Issues related to Snowflake provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants