
Better templating handling in SQL compilation
Some mostly invisible tweaks to how SQL is compiled with templating, reducing rare errors and improving performance.
Transcript
This transcript is auto-generated. Names and product terms may be wrong.
I could do one more uh but it it's uh this actually it doesn't look like much but it was kind of a pain uh you zoom a little bit yeah uh we have basically calite does will simplify things by default for you but we've actually spent the entire time at Omni turning that behavior off everywhere it pops up because it like simplifies too much and does things that we don't want it to do but uh what's been coming up is that people write these like big nasty case statements that essentially just reduce that to like render like case when some mustache value equals something then something else something then blah blah blah blah that once you actually have the value from the user attribute or
filter reference is just a constant but we're writing out the whole thing in SQL which both causes people to be scared possibly causes slower database queries if it takes forever to parse like a you know many megabyte query uh and then in certain situations causes us causes bugs where we fail to plan so anyway this is currently only local and it's a little risky so it's a bit of an experiment but basically I've got this field that right it has it's written as a case when uh on a US user attribute um but you see over here in the dialect sequel when I actually run the query right we boiled it down and it's just one so not super exciting here but it like when
when you have these like many many case statements uh in your query that can make it huge uh when down now that because it's rewriting when it land it it'll rewrite everyone's sequel in a way that's like maybe minorly scary uh also this is a demo this other thing that if no one on the team vetos uh just like a little basically like without trying to make a huge mechanism for to making model features just this little like enable feature gesture that I've tucked in to the model codes you just put it in a comment so if we ever want to experiment with things with the model layer without the whole a like feature Flags don't work in cotlin B it's just on or off
for the whole instance and people might want to toggle them on a branch in a workbook so just some other kind of model level way to toggle model level feature uh so I think I'll land this turn this on for the customer who's hitting the bug um make sure it works then flip it default on to default off or sorry default off to default on and then you've got a similar disabled feature so anyway a way of doing a model level roll out features does the bang mean disable it or I just made that something like look there's code syntax happening here you know it could be a pound bang it could be like yeah yeah yeah yeah no cool kids call that a sha
bang Stephen just make sure I I I'm thinking about that right too that that'll be mostly for like basic model compilation stuff because like model properties probably have to be supported kind of going forward and backwards is that that right yes yeah most a lot of model featur is essentially what you're say you just opt into if there's a new property you opt into it by just using the property so for a lot of things you don't need this so this is really like a SQL for SQL generation features or other things um I may want to use like we're having these problems with caching where like Resort cash misses don't understand why I might also use this to basically be like enable feature super
duper verbose cach logging and then just like or like literally rather than running the query it just if it fails to run the cache it like errors and spits out an enormous error message with like here's why I didn't why I think I couldn't run this requery so things like that yeah Stephen would your intent with those be that they would be shortlived or long lived or either shortlived shortlived and hence like also the very inaccessible unfriendly syntax like the idea is not really to like I mean customers can watch this demo whatever but not really to be like hey customers go do this this is really like a couple of us to just get in there and mess with the system yeah