aws / amazon-redshift-python-driver

Redshift Python Connector. It supports Python Database API Specification v2.0.
Apache License 2.0
202 stars 72 forks source link

fix(connection, cursor): raise DataError when bind parameter limit is… #187

Closed soksamnanglim closed 10 months ago

soksamnanglim commented 10 months ago

catches struct.error as DataError when params exceed 32767

Description

Execute method in the Connection class checks if there are too many parameters before an overflow error can occur when trying to pack int32 with an int16 pack function.

Motivation and Context

Passing in 32767 parameters is the upper limit for a prepared statement sent using extended query protocol. There is no short term fix to raise the parameter limit. Users right now need a better error message output. The new error message output: classifies error as DataError instead of struct.error, communicates that the bind parameter limit has been exceeded, and suggests work arounds to the user.

This change addresses this issue.

Testing

Conducted manual testing to raise the error parameters > 32767 as well as to not raise the error < 32767

Wrote unit and integration tests for the cursor. The tests check that both cursor.insert_data_bulk (csv) and cursor.execute (parameterized query) throw the error.

pre-commit hooks successfully run and reformatted the code as expected.

Screenshots (if appropriate)

Types of changes

Checklist