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.89%. Comparing base (f83964f) to head (5cc6c66).
⚠️ Report is 2 commits behind head on main.

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.89%   79.89%   -0.01%     
==========================================
  Files        1781     1781              
  Lines      243417   243438      +21     
  Branches     3044     3050       +6     
==========================================
+ Hits       194475   194491      +16     
- Misses      48162    48165       +3     
- Partials      780      782       +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
@wtn wtn marked this pull request as draft December 5, 2025 04:18
@wtn wtn force-pushed the map branch 3 times, most recently from 88fb829 to 897eea1 Compare December 5, 2025 04:47
@wtn wtn marked this pull request as ready for review December 5, 2025 04:53
@wtn wtn force-pushed the map branch 5 times, most recently from e4597b8 to 29c9396 Compare December 10, 2025 19:51
@wtn wtn force-pushed the map branch 2 times, most recently from 68211bb to cf9edc3 Compare January 7, 2026 17:35
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