Kevin Wang
02/07/2025, 8:55 PMdf.where("a > 10") be by default interpreted as sql.
You made some good points about why not to do it at this time. Do you remember what they were?Cory Grinstead
02/07/2025, 9:11 PMa as b
df.select("a", "a as b")
the implicit coercion so sql can be confusing if you are unaware of the behavior. In my experience, explicit is usually better and less error prone in the long term.
we added the sql_expr function that does this. Which makes it very clear to the reader of the code what exactly is happening.
df.where(sql_expr("a > 10"))Kevin Wang
02/07/2025, 9:12 PMCory Grinstead
02/07/2025, 9:17 PMdf.select("a, b, c") would we allow expr expansion inside a single string?
IMO it adds a lot of complexity and diverging ways to write queries. I really don't want to end up like pandas where there are usually 10+ ways of doing every operation.
What problem are we trying to solve by adding it in to the dataframe?Kevin Wang
02/07/2025, 9:18 PMCory Grinstead
02/07/2025, 9:18 PMdf.sql method that could be used instead
df.sql("select * from self where a > 10")Robert Howell
02/07/2025, 9:18 PMCory Grinstead
02/07/2025, 9:19 PMI mostly just want to get rid of the struct get syntactic sugar stuff we have right now and just use SQL behavior for that kind of thinghmm. i wonder if there's a more python-esque way of doing struct access.
Robert Howell
02/07/2025, 9:20 PM__getitem__ to have a nice path dslKevin Wang
02/07/2025, 9:22 PMcol("a.b") can be used as syntactic sugar for col("a").struct.get("b") . I'm honestly not opposed to removing that. We could maybe just allow col("a")["b"]Robert Howell
02/07/2025, 9:22 PMAn idea I had recently is to try to find it as a column name first, and if it does not match any columns, to then parse it as a sql exprI was referring to this for the exact-case vs case-insensitive. If you failed to find the column for "A" when the column is named "a" – then parsing as an SQL expression will find it because "a" matches "A" in SQL. This might be surprising coming from python. I agree with Cory about explicit vs implicit – and keep SQL oddities contained to SQL.
Robert Howell
02/07/2025, 9:22 PMCory Grinstead
02/07/2025, 9:23 PMstruct namespace col("my_struct").struct["b"] https://docs.pola.rs/api/python/stable/reference/expressions/api/polars.Expr.struct.field.html#polars.Expr.struct.field
i like the idea of just flattening it into col though. col("my_struct")["b"]Kevin Wang
02/07/2025, 9:23 PMRobert Howell
02/07/2025, 9:24 PM.path and some special chars for wildcards and unpivoting.Cory Grinstead
02/07/2025, 9:24 PMWe want to move away from namespaces right?yes i believe so.
Robert Howell
02/07/2025, 9:24 PMCory Grinstead
02/07/2025, 9:26 PMcol('list')[0:2] -> list.slice(0,2)
col('list')[-1] -> list.tail()
col('list')[0] -> list.get(0)Kevin Wang
02/07/2025, 9:26 PMKevin Wang
02/07/2025, 9:28 PM__getitem__Robert Howell
02/07/2025, 9:29 PMRobert Howell
02/07/2025, 9:29 PMcol("a")."*"
col("a").["*"]Kevin Wang
02/07/2025, 9:29 PM