Skip to content

Conversation

@wtn
Copy link
Contributor

@wtn wtn commented Nov 24, 2025

Fixes #17182.

PolarsInefficientMapWarning incorrectly suggested .is_in() for string containment operations like substring in string inside map_elements.

Cause

Bytecode parser treated all in operations identically without checking operand types.

Fix

Use runtime type checking via _get_all_caller_variables() to distinguish:

  • Collection literals/variables → .is_in()
  • String literals/variables → .str.contains() with proper pl.lit() wrapping

@github-actions github-actions bot added fix Bug fix python Related to Python Polars labels Nov 24, 2025
@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

❌ Patch coverage is 39.13043% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.64%. Comparing base (8ab1657) to head (fa6da50).

Files with missing lines Patch % Lines
py-polars/src/polars/_utils/udfs.py 39.13% 10 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25472      +/-   ##
==========================================
+ Coverage   79.58%   79.64%   +0.06%     
==========================================
  Files        1743     1743              
  Lines      240439   240460      +21     
  Branches     3038     3044       +6     
==========================================
+ Hits       191347   191517     +170     
+ Misses      48310    48159     -151     
- Partials      782      784       +2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wtn wtn force-pushed the map branch 2 times, most recently from e1a1e11 to 10c86d5 Compare November 24, 2025 03:43
@alexander-beedie alexander-beedie self-assigned this Nov 24, 2025
@alexander-beedie
Copy link
Collaborator

Nice; when you think it's ready to roll, ping me and I'll review ;)

@wtn
Copy link
Contributor Author

wtn commented Nov 24, 2025

@alexander-beedie Ready for review. 🏓

@wtn wtn force-pushed the map branch 2 times, most recently from ac2fbe6 to 1028d0d Compare November 27, 2025 04:53
@alexander-beedie
Copy link
Collaborator

@alexander-beedie Ready for review. 🏓

Nice; will take a look at the weekend :)

@wtn wtn force-pushed the map branch 6 times, most recently from 2f16598 to 2f54647 Compare December 4, 2025 19:33
@alexander-beedie
Copy link
Collaborator

Umm... THIS weekend 😄

@wtn wtn marked this pull request as draft December 5, 2025 04:18
@wtn wtn force-pushed the map branch 2 times, most recently from 001d48f to 88fb829 Compare December 5, 2025 04:40
@wtn wtn marked this pull request as ready for review December 5, 2025 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix python Related to Python Polars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect PolarsInefficientMapWarning for string containment with in

2 participants