Kevin Wang
01/09/2025, 11:09 PMjoin_prefix and join_suffix are only applicable for renaming columns, which should also only happen via the builder. @Desmond Cheong recently added another initializer to some ops for that reason, but it bypasses the validation that is typically done and is not standardized across ops.
My solution - every op should provide a non-erroring new constructor which contain explicit debug_asserts for all the requirements about the op's state (one example would be that all expression columns exist in the schema), but otherwise should simply put those values into the struct and return it.
⢠Functions such as LogicalPlan::with_new_children will just call new.
⢠Other constructors may exist that explicitly provide additional functionality and ultimately call new. E.g. a Join::new_with_renaming_project to rename the right side columns that conflict with the left side.
⢠Things that may error due to user input, such as expression resolution, should be handled by the logical plan builder.jay
01/10/2025, 5:50 AMnew_unchecked?Kevin Wang
01/10/2025, 5:59 PMCory Grinstead
01/10/2025, 7:01 PMASTPlan that contains the plan as typed (potentially invalid) that gets converted into the LogicalPlan. IIRC, either @jay or @Sammy Sidhu brought up this idea before.Kevin Wang
01/10/2025, 7:05 PMKevin Wang
01/10/2025, 7:24 PMtry_new that also does the same thing as what I described for new but instead returns errors instead of asserting. That way the builder does not have to have equivalent errors to the assertsKevin Wang
01/15/2025, 1:07 AMRobert Howell
01/15/2025, 7:41 PMnew_with_children delegating to new but the Github issue has new_with_children delegating to try_new. Could you tell me a little bit more about new_with_children and maybe there's try_new_with_children which follows the same convention?
⢠I do like the new -> T / try_new -> Result<T> but I'm curious where the _unchecked convention might come in? I've only bumped into this when writing unsafe Rust with things like to_foo -> ResultT> and to_foo_unchecked -> T which I think is slightly different than the new/try_new convention you are proposing.Kevin Wang
01/15/2025, 7:41 PMRobert Howell
01/15/2025, 7:47 PMKevin Wang
01/15/2025, 8:11 PMtry_new to reduce the amount of state validation logic. If I had a new that only did (debug_)asserts, then I would also need to potentially check the same things in the builder but with errors.
2. I believe you are correct in that new_unchecked is typically used for unsafe code. I don't plan on having thatKevin Wang
01/15/2025, 8:37 PMCory Grinstead
01/15/2025, 9:12 PMKevin Wang
01/16/2025, 6:38 PM