
Snowflake semantic views
An end to end demo of both querying and building Snowflake Semantic Views via Omni.
Transcript
This transcript is auto-generated. Names and product terms may be wrong.
Hello everyone. Today we're going to talk about all the ways that you can interact with Snowflake semantic views with Omni. We'll start in Omni and we'll see how we can actually query semantic view directly. Like here on this dashboard, if I look at what SQL or SQL queries back up this dashboard and move into the workbook, you can see that it's all created based on querying semantic views that we've predefined within Snowflake.
So here I can see all of these are just different semantic view queries that we can just query directly. Also another way of interacting with those semantic views in Omni is that I can actually save this semantic view as a query view in Omni. So if I go to edit here and I actually wanted to save this as a query view.
I can then bake this definition down into my model and I can start building Omni semantic layer directly on top of that. Now the other way of interacting with uh semantic views is you can leverage Omni semantic layer to actually push those definitions to your semantic views within Snowflake. So we can do this through Omni's um API uh where we have a definition of an SDK where we can actually just take the Omni semantic layer and then push that down there.
So I'm going to be pushing this order items curated topic down to a semantic view where essentially we're just going to create a uh DDL function. So a create or replace statement with all these these definitions baked into them. Now I've created a small streamllet app here where actually all we need to do is pass over our omni URL an API key that I created our model ID which you can find directly in the URL on top of your model right here.
Um, and then which topic we actually want to create in a semantic view. So, I'm going to use the order items curated here. I'm going to fetch the topic fields. I'm going to choose a couple um tables. Uh, let's grab order items. Let's grab users. And then I can select which fields I actually want to generate within there.
So, maybe I'll get rid of these ID fields. Um, and then here's the users table. We can then choose the relationship we want. So, I'm going to do the order items to users relationship. And I'm going to hit generate semantic view. And you can see here that DDL function that is actually going to create that semantic view.
Um I am going to copy this and go to our snowflake and I'm going to um actually run this here. So we can create that semantic view. Here you can see it created that order items uh semantic view. If I pop open my schema right here and semantic views, we have that right here. So let's open this quick in uh cortex analyst.
And now we can start interacting with this just as we would uh before. I'm actually going to change my new user so I can interact with it here. Um let's go show me um total sale price per state. And this is going to craft that query via Cortex Analyst leveraging that semantic view on the back end. So here we go.
We now have that um uh query right here backed up by that semantic view and we can see it right here in Cortex Analyst.