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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

georgesittas
Copy link

@georgesittas georgesittas commented Oct 17, 2024

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

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

Checklist

  • Local run of ./build.sh succeeds
  • Code changes have been run against the repository's pre-commit hooks
  • Commit messages follow Conventional Commit Specification
  • I have read the README document
  • I have added tests to cover my changes
  • 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.

…n as is

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

This commit ensures the resulting DataFrame's columns are the same as the ones in the
cursor's description, thus reflecting Redshift's behavior and respecting the underlying
case-sensitivity configuration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The Cursor.fetch_dataframe method doesn't respect case-sensitivity
1 participant