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

Modify RedshiftConnectionManager to extend from SQLConnectionManager, migrate from psycopg2 to redshift python connector #251

Conversation

sathiish-kumar
Copy link
Contributor

define a _get_connect_method method to leverage Redshift python connector to retrieve the connect method

resolves #219

Description

This is a draft PR to solicit opinions on the changes that would help in the eventual migration to Redshift python connector from psycopg2 connector. Due to its draft nature, the PR doesn't have any tests.

  • Extend RedshiftConnectionManager from SQLConnectionManager
  • Implement mandatory methods from the abstract SQLConnectionManager
  • Define _get_connect_method method to provide low-level Redshift Python Connector based connection methods for establishing Connections

Checklist

… define a _get_connect_method method to leverage Redshift python connector to retrieve the connect method
@cla-bot
Copy link

cla-bot bot commented Dec 19, 2022

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, don't hesitate to ping @drewbanin.

CLA has not been signed by users: @sathiish-kumar

@sathiish-kumar sathiish-kumar marked this pull request as draft December 20, 2022 19:12
@cla-bot
Copy link

cla-bot bot commented Dec 30, 2022

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, don't hesitate to ping @drewbanin.

CLA has not been signed by users: @sathiish-kumar

@cla-bot
Copy link

cla-bot bot commented Jan 3, 2023

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, don't hesitate to ping @drewbanin.

CLA has not been signed by users: @sathiish-kumar

dbt/adapters/redshift/connections.py Outdated Show resolved Hide resolved
dbt/adapters/redshift/connections.py Outdated Show resolved Hide resolved
…h due to in-built support in Redshift Python Connector
@cla-bot
Copy link

cla-bot bot commented Jan 9, 2023

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, don't hesitate to ping @drewbanin.

CLA has not been signed by users: @sathiish-kumar

keepalives_idle: int = 4
iam_duration_seconds: Optional[
int
] = 900 # TODO:Not supported in redshift python connector, should we remove this?
Copy link
Contributor

Choose a reason for hiding this comment

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

if it doesn't support these options is it because it's no longer needed or because the functionality isn't supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is obfuscated from the users of redshift python connector, it's managed by redshift connector whenever we want to use IAM profile as the mode of authn. In essence, no longer needed.


@classmethod
def get_response(cls, cursor: redshift_connector.Cursor) -> AdapterResponse:
rows = cursor.rowcount
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@colin-rogers-dbt to follow-up on the removal of cursor.statusmessage in get_response

connect_timeout: int = 10
role: Optional[str] = None
sslmode: Optional[str] = None
sslcert: Optional[
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@colin-rogers-dbt to follow-up on sslcert, sslrootcert and sslkey usage and if it's really needed to be kept.

Copy link
Contributor

Choose a reason for hiding this comment

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

cc: @jtcohen6 &@Fleid
Looking around I don't think this is being used (and I don't think it even makes sense for redshift anyways) so we can probably remove. AFAIK I don't think having extra values in the profile.yml will break anything but we should probably add a warning that it's no longer utilized?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not being used to my knowledge. Confirmed that users will not see an error if they add extra unused / unrecognized values into profiles.yml. I think a deprecation warning is reasonable, given that these were previously documented.

@colin-rogers-dbt colin-rogers-dbt marked this pull request as ready for review January 13, 2023 19:59
@colin-rogers-dbt colin-rogers-dbt added the ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering label Jan 13, 2023
@cla-bot cla-bot bot added the cla:yes label Jan 18, 2023
@sathiish-kumar sathiish-kumar changed the title [DRAFT] Change RedshiftConnectionManager to extend from SQLConnectionManager Modify RedshiftConnectionManager to extend from SQLConnectionManager, migrate from psycopg2 to redshift python connector Jan 18, 2023
@cla-bot cla-bot bot added the cla:yes label Jan 27, 2023
@jiezhen-chen jiezhen-chen force-pushed the migrate_psycopg2_to_rshift_connector branch from 1dc3ebe to d3113ca Compare February 3, 2023 16:03
Copy link
Contributor

@colin-rogers-dbt colin-rogers-dbt left a comment

Choose a reason for hiding this comment

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

two nits but otherwise this should be good to go

setup.py Outdated Show resolved Hide resolved
dbt/adapters/redshift/connections.py Outdated Show resolved Hide resolved
@colin-rogers-dbt
Copy link
Contributor

waiting on some other large changes to merge this

@colin-rogers-dbt colin-rogers-dbt merged commit 2cc47bb into dbt-labs:main Feb 15, 2023
@Fleid
Copy link
Contributor

Fleid commented Feb 15, 2023

\o/

@dataders dataders mentioned this pull request Jun 9, 2023
6 tasks
@dbeatty10 dbeatty10 mentioned this pull request Jul 13, 2023
4 tasks
abbywh pushed a commit to abbywh/dbt-redshift that referenced this pull request Oct 11, 2023
… migrate from psycopg2 to redshift python connector (dbt-labs#251)

* Change RedshiftConnectionManager to extend from SQLConnectionManager, define a _get_connect_method method to leverage Redshift python connector to retrieve the connect method

* Add/fix unit tests, create RedshiftConnectMethodFactory to vend connect_method

* Fix _connection_keys to mimic PostgresConnectionManager

* Remove unneeded functions for tmp_cluster_creds and env_var creds auth due to in-built support in Redshift Python Connector

* Resolve some TODOs

* Fix references to old exceptions, add changelog

* Fix errors with functional tests by overriding add_query & execute and modifying multi statement execution

* Attempt to fix integration tests by adding `valid_incremental_strategies` in impl.py

* Fix unit tests

* Attempt to fix integration tests

* add unit tests for execute

* add unit tests for add_query

* make get_connection_method work with serverless

* add unit tests for serverless iam connections

* add redshift connector version, remove sslmode, connection time out, role, application_name

* change redshift_connector version

---------

Co-authored-by: jiezhec <[email protected]>
Co-authored-by: colin-rogers-dbt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes ok to test ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering test all
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-1504] [Feature] Replace psycopg2 with redshift_connector
6 participants