pola-rs / polars

Dataframes powered by a multithreaded, vectorized query engine, written in Rust
https://docs.pola.rs
Other
30.28k stars 1.96k forks source link

Suppress Unneeded Parenthesizing of Stringized Expressions #5994

Open BSalita opened 1 year ago

BSalita commented 1 year ago

Problem description

Expression stringizer is blindly nesting sub-expressions in parenthesis. Parenthesis should only be added if the sub-expression contains a priority dependent operator.

>>> expr = pl.col("foo") > 2
>>> print(str(expr))
[(col("foo")) > (2i32)]   # should be [col("foo") > 2i32] or (future) [col("foo").gt(2i32)]
ritchie46 commented 1 year ago

This requires some state in serialization and to me is something that is not worth our efforts as the extra parentheses are not wrong. If anybody feels this should be addressed, feel free to open a PR.

BSalita commented 1 year ago

Thanks. Exactly.