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

feat: Add JSON encoding for polars list type: pl.Expr.list.json_encode() #18353

Closed
wants to merge 6 commits into from

Conversation

tim-stephenson
Copy link
Contributor

@tim-stephenson tim-stephenson commented Aug 24, 2024

#14029
#8482

Involve most of the relevant discussion. It seems as though src/json/write/serialize.rs had all the relevant code, all that needed to be done was wrap these calls as the pl.Struct / struct_ does.

Is there any reason why all (or nearly all) polars types shouldn't have a .json_encode method? This might be preferred and reduce code duplication if it is desired to add a json_encode to more types than pl.Struct and pl.List.

A few lingering questions:

  • Should we have a more universial json_encode to all (or nearly all) polars types
  • Should inf & nan be treated differently to how the currently are? (see included test for current functionality)
  • Should an option for mapping null rows to null rows with a ignore_nulls flag be present (instead of the current mapping to the string "null", similar to what feat: Add ignore_nulls option to struct.json_encode #17867 is working on?

@tim-stephenson tim-stephenson changed the title feat: pl.Expr.list.json_encode() feat: pl.Expr.list.json_encode() Aug 24, 2024
@tim-stephenson tim-stephenson changed the title feat: pl.Expr.list.json_encode() feat: Add JSON encoding for polars list type: pl.Expr.list.json_encode() Aug 24, 2024
@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars and removed title needs formatting labels Aug 24, 2024
Copy link

codecov bot commented Aug 25, 2024

Codecov Report

Attention: Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.

Project coverage is 79.85%. Comparing base (dd1fc86) to head (6ddb616).
Report is 11 commits behind head on main.

Files Patch % Lines
crates/polars-plan/src/dsl/function_expr/list.rs 92.85% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #18353   +/-   ##
=======================================
  Coverage   79.84%   79.85%           
=======================================
  Files        1496     1496           
  Lines      200333   200357   +24     
  Branches     2841     2841           
=======================================
+ Hits       159952   159986   +34     
+ Misses      39856    39846   -10     
  Partials      525      525           

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

@orlp
Copy link
Collaborator

orlp commented Aug 25, 2024

Instead of adding this to the list namespace perhaps we should just consider making everything json_encode-able and putting it in the root namespace.

@tim-stephenson
Copy link
Contributor Author

Instead of adding this to the list namespace perhaps we should just consider making everything json_encode-able and putting it in the root namespace.

I would agree withing making everything json_encode-able. My guess would be that all data types should be able to work besides polars.datatypes.Object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants