Skip to content

Comments

Install sqlalchemy-spanner package into Google provider#31925

Merged
potiuk merged 5 commits intoapache:mainfrom
lwyszomi:install-sqlalchemy-spanner
Jul 21, 2023
Merged

Install sqlalchemy-spanner package into Google provider#31925
potiuk merged 5 commits intoapache:mainfrom
lwyszomi:install-sqlalchemy-spanner

Conversation

@MaksYermak
Copy link
Contributor

In this PR I have added sqlalchemy-spanner package to Google provider and updated the Google Spanner hook for supporting DbApiHook.


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@boring-cyborg boring-cyborg bot added area:providers provider:google Google (including GCP) related issues labels Jun 15, 2023
Copy link
Contributor

@phanikumv phanikumv left a comment

Choose a reason for hiding this comment

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

CI checks are failing, please fix them

@MaksYermak
Copy link
Contributor Author

@phanikumv I fixed tests, could you please check this PR one more time?

@phanikumv
Copy link
Contributor

@phanikumv I fixed tests, could you please check this PR one more time?

whats the use case behind this change? What problem were you facing

@MaksYermak
Copy link
Contributor Author

@phanikumv I fixed tests, could you please check this PR one more time?

whats the use case behind this change? What problem were you facing

@phanikumv In this PR I have added ability to connect to Google Spanner Database using SQLAlchemy

Comment on lines +53 to +56
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont see an existing connection type gcpspanner, wondering how will this work ?

Copy link
Contributor Author

@MaksYermak MaksYermak Jun 19, 2023

Choose a reason for hiding this comment

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

@phanikumv it's a new connection. I have created it, because the google_cloud_default connection doesn't have an extra field. The extra field is needed for passing database_id and instance_id parameters. This connection will work the same like google_cloud_default

Copy link
Contributor

Choose a reason for hiding this comment

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

if its just an extra field - can we think about adding it to google connection as an optional param rather than creating new connection altogether?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some time ago we had this extra field for extra parameters in the google_cloud_default connection, but then we decided for each extra parameter to create its own field. In my opinion it is not a good idea to return the extra field for google_cloud_default.

Copy link
Member

Choose a reason for hiding this comment

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

Agree. Extra is well, dangerous. There were many CVEs issued recently because having access to edit extras would open all kinds of ways for those who have access to edit connections to do unintended things > Remote Code Execution, DOS, revealing extra information. We had to even reflect that in our security model and specifically flag the users who have connection editing capabilities as having to be trusted not to abuse those capabilities: https://airflow.apache.org/docs/apache-airflow/stable/security/index.html#capabilities-of-authenticated-ui-users

Generally speaking extras should be very limited and we maybe even should get rid of them at some point in time.

@MaksYermak
Copy link
Contributor Author

@phanikumv could you please approve my PR if everything looks good to you?

Copy link
Member

Choose a reason for hiding this comment

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

nitpick: Should we add a return type annotation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Lee-W it is an overridden method from extended class and in the extended class we also do not have type annotation. Also I have checked the create_engine function and this function also doesn't have type annotation. I don't know what type should be here.

Copy link
Member

Choose a reason for hiding this comment

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

nitpick: Should we use it not all([instance_id, database_id])?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Lee-W thank you for the note I have changed this row.

@MaksYermak MaksYermak force-pushed the install-sqlalchemy-spanner branch 3 times, most recently from 176ad62 to a6f3b9a Compare July 12, 2023 08:01
@MaksYermak
Copy link
Contributor Author

@potiuk hi, could you please look at this PR and merge it if everything is good?

@VladaZakharova
Copy link
Contributor

Hi @potiuk @Lee-W
Could you please check those changes if there is something to fix here?
Thanks!

Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

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

Everything looks great to me 🙂

@phanikumv
Copy link
Contributor

Rebase your PR please @MaksYermak

@MaksYermak MaksYermak force-pushed the install-sqlalchemy-spanner branch 3 times, most recently from 4a30059 to ff141ef Compare July 18, 2023 07:07
@MaksYermak MaksYermak force-pushed the install-sqlalchemy-spanner branch from ff141ef to f0795b4 Compare July 19, 2023 06:33
@VladaZakharova
Copy link
Contributor

@potiuk @Lee-W
Could you please check the PR? :)

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.

5 participants