Well, I prefer the polars version. And now if I want to reuse the CTEs elsewhere, I have to reach out to another tool like DBT or hand roll something to do string manipulation.
... does it? I don't think it does, even in this form.
And now write it such that all the conditions and transformations are injected into the string (somehow) rather than written in explicitly. Much worse.
Really? You've written out all the ratios and thresholds manually. If a user wanted to change the set of thresholds the polars way is far superior. In what way do you consider this better?