
Querying Snowflake semantic views directly
Now you can query Snowflake semantic views directly in Omni. This means we now have translators back and forth for more native experience, but also have rounded out querying them directly…
Transcript
This transcript is auto-generated. Names and product terms may be wrong.
All righty. Hey there. Hey. All right. Um, in rare form, I'm not demoing a DBT thing. Uh, but this is somewhat related to the work that I've been doing lately. So, I've been doing a lot of DBT semantic layer stuff, and switching over to snowflake semantic layer stuff seemed like a good easy transition. Um so for those who don't know I'll give a quick little summary of snowflake semantic views uh which are seem to be very similar to uh to topics in omni.
So you make a semantic view and inside of that you have a list of tables, you define relationships, you define facts and dimensions just like columns or calculations on top of columns and then metrics and um Jamie has done a lot of work recently to import these things into Omni like so. So his work has us creating these views that are inside this nice orders folder.
Um I have been working on instead of doing it that way to import a single view that wraps up the semantic view because Snowflake is releasing some new SQL syntax that's going to let us just query this thing directly. And so rather than importing relationships and figuring out like the definition of this column as a count uh thing uh we will just import it as the view itself.
And so you see we have this semantic view orders here and it has the dimensions which are the combination of facts and dimensions in snowflake and the measures and um yeah and then when you query it snowflake has this syntax where this is the new thing that they're releasing uh where you just select the column like any dimensions or facts you can just select and then the metrics you use this a aggregate which kind of doesn't actually do anything.
It's just going to under the hood use whatever um aggregation you defined in your metric, like whatever calculation you define in your metric. Um and so this is the full syntax for querying one of these things. And so we have to import it and then support this new aggregate type uh which is up in the air. We might rename what that's called exactly within Omni.
Um but let's go ahead and show that we can uh bury it now. So, I discovered a bug in the process of this where it's a problem with Snowflake like this query probably won't work. Um, but this one will and this one does a calculation with a metric. Uh, so there you go. That's basically it. So, this work is importing them and then supporting the ability to query them.
There's a feature flag for it. Um, there may need to still be some stuff we need to do. Like you can't query this thing and then join to another table. Snowflake just doesn't let you do that. Um, you would instead need to like go update your definition, have a new relationship, and then do it all within the context of that view.
Um, so we may want to prevent people from creating relationships between semantic views and other views. Um so some of those kind of edge cases need to be worked out but the basics are uh are there. Oh wow. So semantic views are not just regular SQL statements in Snowflake right? They look like regular statements. You could conceivably do it in a subquery and then join the results but you can't like you're not gonna you're not gonna be you could trick it basically.
I haven't tried it. I just assume you can do it that way, but you're you're at the end of the day, you're just kind of joining whatever the result of your calculation is. So if you do if you have a metric in there, you know, you might be able to trick it. Um it's just not going to work the same way that our view joining would where you're doing the join before doing the aggregation.
We may want a flag or something on the semantic views specifically because there's sort of there's like additive things we want to enable a user to do. This is sort of like adding new new measures, new joins, new me, you know, new transformational things to that we may want to sidestep the kind of current current Snowflake explicit SQL generation process, but I think this is super exciting and there's definitely benefits to having Snowflake drive it directly to like not having to maintain sort of cons, you know, the logic AC across both places is, you know, the biggest uh the biggest for You'll have to sync up with the Snowflake team, too, and find out whether some of those limitations are going to be opened
up over time. Yeah. Awesome. Okay. Yeah.