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(python): Fixes a read_database issue loading specific datetime types from SQL Server backends #14627

Merged

Conversation

alexander-beedie
Copy link
Collaborator

Closes #11912.

Very slightly reworks cursor introspection/load for read_database, avoiding a SQL Server issue with DATETIMEOFFSET cols. Validated against a local SQL Server Docker image with a suitable test table...

(Also improves ODBC connection string detection as a trivial drive-by).

@github-actions github-actions bot added fix Bug fix python Related to Python Polars labels Feb 21, 2024
Copy link
Member

@stinodego stinodego left a comment

Choose a reason for hiding this comment

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

Looks good to me - feel free to merge if CI is green.

If it's possible to test (part of) this locally, adding a test would be good.

@alexander-beedie
Copy link
Collaborator Author

alexander-beedie commented Feb 21, 2024

If it's possible to test (part of) this locally, adding a test would be good.

Hmm, I might be able to mock something, but what we really need are some ephemeral DBs integrated into the CI pipeline1 so we can do a better job covering read_database😅

(PostgreSQL and SQL Server have official Docker images; no doubt a few others do too).

Footnotes

  1. Ref: https://github.com/pola-rs/polars/issues/12815

@stinodego
Copy link
Member

stinodego commented Feb 21, 2024

I didn't really intend for you to set up a complicated mocking structure for this PR 😄 I was just thinking maybe extract part of the logic as a testable function. But it's up to you!

@alexander-beedie
Copy link
Collaborator Author

alexander-beedie commented Feb 21, 2024

I didn't really intend for you to set up a complicated mocking structure for this PR 😄 I was just thinking maybe extract part of the logic as a testable function. But it's up to you!

Tricky... it needs a pretty specific interaction with the DB cursor to expose it; without mocking it would be hard to tease it out from inside ConnectionExecutor :(

I did find a related gremlin that's much easier to isolate though; will create a separate Issue for that shortly.

Copy link

codecov bot commented Feb 21, 2024

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (b036459) 80.84% compared to head (cc61718) 80.83%.
Report is 3 commits behind head on main.

Files Patch % Lines
py-polars/polars/io/database.py 33.33% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14627      +/-   ##
==========================================
- Coverage   80.84%   80.83%   -0.01%     
==========================================
  Files        1326     1326              
  Lines      173065   173071       +6     
  Branches     2450     2453       +3     
==========================================
- Hits       139907   139903       -4     
- Misses      32684    32693       +9     
- Partials      474      475       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alexander-beedie alexander-beedie merged commit a0bcb2b into pola-rs:main Feb 21, 2024
13 checks passed
@alexander-beedie alexander-beedie deleted the read-database-sql-server branch February 21, 2024 14:16
@alexander-beedie alexander-beedie added the A-io-database Area: reading/writing to databases label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-io-database Area: reading/writing to databases fix Bug fix python Related to Python Polars
Projects
None yet
2 participants