amazon-redshift-python-driver icon indicating copy to clipboard operation
amazon-redshift-python-driver copied to clipboard

fix(cursor, fetch_dataframe): use column names in cursor's description as is

Open georgesittas opened this issue 4 months ago • 0 comments

Previously, the Cursor.fetch_dataframe method lowercased column names preemptively, thus not respecting the case-sensitivity configuration value. This could lead to issues, when e.g. two different columns resolved to the same name when lowercased.

This PR fixes the issue by ensuring the resulting DataFrame's columns are the same as the ones in the cursor's description attribute, thus making the driver match Redshift's behavior.

Motivation and Context

Fixes #238

Testing

Implemented a unit test that demonstrates how fetch_dataframe preserves the column names as they appear in the cursor's description attribute.

After making the change, I ran python -m pytest test/unit in a fresh environment and observed all tests succeeding:

922 passed, 11 warnings in 3.26s

Types of changes

  • [x] Bug fix (non-breaking change which fixes an issue)

Checklist

  • [x] Local run of ./build.sh succeeds
  • [x] Code changes have been run against the repository's pre-commit hooks
  • [x] Commit messages follow Conventional Commit Specification
  • [x] I have read the README document
  • [x] I have added tests to cover my changes
  • [x] I have run all unit tests using pytest test/unit and they are passing.

License

  • By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

georgesittas avatar Oct 17 '24 22:10 georgesittas