prql: Don't format s-strings
From #965, broadening that issue to being able to avoid the auto-formatting. For context, this is can be important with non-standard SQL, like Snowflake’s semi-structured data.
A couple of options for how we could do this:
- Implement an “ignore” option upstream, in https://github.com/shssoichiro/sqlformat-rs/issues/15. I’m not sure whether upstream would accept a PR (though it seems reasonable, and worst case we could maintain a fork)
- Replace s-strings after the auto-formatting, using
$s_string_n. This requires passing s-strings all the way through the compiler, reducing the modularity of the compiler phases, but otherwise being fairly simple. - Relying on the new
Optionsstruct to disable formatting entirely. This has the disadvantage of being an all-or-nothing option, but might be an acceptable temporary solution.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 3
- Comments: 15 (15 by maintainers)
I did remember you just asking about this: https://github.com/PRQL/prql/issues/2694#issuecomment-1575693384
😄
That’s a good idea, but a bit problematic because you have to translate
my_colsomehow. If can could do this separately, then that’s the way to go.Is there anything to having the whole S-string as a variable?
So the expression to be formatted is:
…and then we replace the variable after the formatting? So the S-string is completely opaque to the formatter.
This used to be all of the compiler! 😀
I’m going to look at this. I will explore a fix for this based on the second option above to see how feasible this is.
Yeah, we should never format s-strings. I think the second in is the best option and we can fallback to using the third for the time being.