Nishant Bhakar
02/20/2025, 1:54 AMdf = df._add_monotonically_increasing_id("id")
but I want to adapt it to be something along the lines of
df = df.with_column("id").mid()
Would .mid() belong in daft.expressions or something new like daft.functions or something else entirely?Robert Howell
02/20/2025, 1:57 AMRobert Howell
02/20/2025, 2:00 AMColin Ho
02/20/2025, 2:01 AMColin Ho
02/20/2025, 2:01 AMColin Ho
02/20/2025, 2:02 AMColin Ho
02/20/2025, 2:03 AMRobert Howell
02/20/2025, 2:03 AMColin Ho
02/20/2025, 2:03 AMfrom pyspark.sql import functions as sf
spark.range(0, 10, 1, 2).select(sf.monotonically_increasing_id()).show()
this is how it works in sparkRobert Howell
02/20/2025, 2:04 AMRobert Howell
02/20/2025, 2:07 AMKevin Wang
02/20/2025, 2:18 AMKevin Wang
02/20/2025, 2:19 AMKevin Wang
02/20/2025, 2:20 AMRobert Howell
02/20/2025, 6:24 AMNishant Bhakar
02/20/2025, 6:36 PMKevin Wang
02/20/2025, 6:42 PMExpressionKevin Wang
02/20/2025, 6:44 PMdaft.expression? We already have col, lit, list, struct, interval, and coalesce in thereRobert Howell
02/20/2025, 6:52 PMdaft.functions rather than daft.expression so they are grouped, but I don't think there are issues with re-exporting? I believe we could easily support both composition and chaining automagically with some monkey patching. Here's an example, Nishant.
col("my_str").lower() # chaining
lower(col("my_str")) # composed
Functional languages often support both, and I think deprecating all current function APIs might be jarring to customers.
Additionally, there are ways to do even regular function composition that are preferred over theformulation. Scala has theh(g(f(x))). Haskell hasf andThen g andThen h. F# has a forward composition operatorh . g . fthat returns a composed function and something similar called the forward pipe operator (f >> g >> h). Functional programmers prefer these formulations because of the lack of nesting. Nesting is a lot harder cognitively to track than juxtaposition.|>
Robert Howell
02/20/2025, 6:53 PM|> and they have a nice doc @Nishant Bhakar https://elixirschool.com/en/lessons/basics/pipe_operatorNishant Bhakar
02/20/2025, 6:56 PMKevin Wang
02/20/2025, 6:57 PMRobert Howell
02/20/2025, 7:01 PMif_else is a control-flow expression and not a function.Robert Howell
02/20/2025, 7:02 PMKevin Wang
02/20/2025, 7:03 PMKevin Wang
02/20/2025, 7:04 PMRobert Howell
02/20/2025, 7:05 PMKevin Wang
02/20/2025, 7:08 PMRobert Howell
02/20/2025, 7:09 PMRobert Howell
02/20/2025, 7:10 PMRobert Howell
02/20/2025, 7:11 PMRobert Howell
02/20/2025, 7:12 PMKevin Wang
02/20/2025, 7:13 PMRobert Howell
02/20/2025, 7:17 PMRobert Howell
03/25/2025, 11:00 PM