
Omni's dbt integration: Co-development between dbt and Omni
Transcript
This transcript is auto-generated. Names and product terms may be wrong.
Hi, my name is Gordon Rose and I'm an SE with Omni Analytics. Welcome to this session on keeping our Omni and DBT development in lockep. Today we'll see how we can leverage the powerful integration between Omni and DBT to coordinate our development and deployment across the two platforms. Let's dive right in. We'll be working with this fantastic Omni dashboard throughout our session.
This dashboard was built on top of data from our data warehouse that was generated by DBT. Let's look at one of those data tables in Omni order items. Here we can see that order items is contained in a virtual DBT schema. In Omni, DBT virtual schemas are dynamic and automatically generated schemas that mirror our DBT data models.
Note, by the way, that the DBT logic is available for us to view in the order items model file. And we could also use Omni's readonly DBT editor to view this model's DBT code as well. Now, let's jump over to DBT where we have our model open and we're in the process of making some changes. We're adding a new column.
We're changing the name of another column. And then finally, we're modifying the sale price. you know a small adjustment for inflation. Now in a typical workflow the next step for a DBT developer would be to build the model locally in their dev schema. This is to make sure that it builds correctly and to execute any tests associated with it.
And if everything looks good, the DBT developer would check the code into their dev branch and initiate a pull request. And this is where the process breaks down for most organizations. At this point, the DBT developers changes are on a path headed toward production and our dashboards have been left behind. What's lacking is a coordinated way of testing the changes in DBT against our dashboards at every step along that path, unless of course you're using Omni.
Now, let's continue to walk in the shoes of a DBT developer and build our model. We see that the build was successful. Now, to help to continue paint the picture, let's take a look at where that object was built in Snowflake. We'll refresh, and we see that DBT built the object in a custom DBT schema. We know that this is a custom DBT schema because it's based on the name of our dev schema and includes an additional name appended to the end.
And in our project, we have multiple custom schema names mapped to DBT folders in our DBT project YAML file. Will Omni be able to handle things like custom schema names in DBT? We'll see. Before we do anything else, let's think about what we've just built. Our goal is to test our dashboard against the data changes. And it's unlikely that the dashboard only references one table order items.
We need to be sure that it has access to all of the data needed for testing. There are three approaches for doing that. One is if you're using defer to production and we are here, you can turn it off and do a complete build in your dev sandbox. Bear in mind that with defer to production on, we may fail to build one or more objects in our dev schema that our dashboard depends on.
The second option is to run dbt clone. DBT has some great articles that'll help you understand cloning and when to use it. And you can see one here that points out that one of the prime use cases for cloning is to test downstream changes in our BI tool. The third option would be if you can be certain that only objects from your mart layer are being used by any of your omni dashboards.
You can simply build out the objects at the mart layer with defer to production turned on. That's what we're going to do now. For simplicity sake, we'll just build the ecom mart schema. Again, our build is successful. Please note we are using DBT cloud for our examples today, but Omni fully supports DBT core as well. Now to test the changes, let's move over to Omni.
The first thing we need to do in Omni is go into branch mode. Branch mode is an Omni development feature that creates an isolated temporary environment for us to work in to make changes to our data models and content without affecting production. Now, if you're a DBT developer and that sounds familiar, that's because it should. Omni leverages software development best practices in many of the same ways that DBT does and that's why they work so beautifully together.
Now, when we're in branch mode, we have access to our DBT environments. An Omni DBT environment is a set of configuration values that allow us to connect Omni to a DBT development or deployment environment. Now, please be aware that these are defined in Omni and aren't exactly the same as DBT environments. When we look at the environment, we see that this one points to the exact same dev schema that we were working with in dbt just a moment ago.
And an OmniBBT environment does allow us to configure target names, role names, and DBT environment variables. We'll use this environment to test our dashboard. When we access the health view, we can also see that Omni has correctly processed our custom schema settings from our DBT project. L file and is looking for our DBT models in the correct locations.
And one important note about this view, you do need to do a schema refresh in order for this view to reflect the most recent changes. So we did a schema refresh before opening this. And as a result, all of the tables that we created in DBT are visible to Omni and are reported back to us here in the health page for our Omni DBT environment.
Now that we're in branch mode, let's close this and look at what changes have been made to the view file for order items. When we scroll down, we see that sure enough, the nude fields have been added to our model file automatically. So, we know that when we point Omni to this dev environment, we will be testing it against the changes that we made in DBT.
And we can also smoke test those changes in Omni. Let's come over here to where we have a new query. Again, we're in dev mode. And in dev mode, we have the inspector turned on. That allows us to see the raw SQL being sent to our data warehouse. So, let's rerun the SQL. We get a sum of $111,000 and we see that we are querying against our dev schema.
Now, let's switch our DBT environment to production. Notice that Omni immediately switched to our production schema. And when we run the SQL, we get a sum of sales price that is oneten the size of the value that it was when pointed to our dev schema. So we have successfully smoke tested our connection to the dbtdev environment. Now how about the acid test?
Let's see what is going on with our dashboard. When we left our smoke test, we were still pointing to production. Now let's change to our dbtdev environment and notice that we have an error here. That's not a complete surprise because we made a lot of changes to that DBT model. We'll see that we get very detailed information about what exactly is causing the error that we're seeing on our dashboard.
Well, we know there's an issue with this dashboard. Our next thought is, are there other dashboards that have also been affected by this change? And how do we fix this so that when the DBT changes are ready to be rolled into production, we can roll out corresponding changes on the omni side that guarantee that everything will work.
Well, our first step is to open content validator. Content validator is specifically designed to help us ensure that our BI content remains functional and accurate after changes have been made to the underlying data model. And we can see right away at two instances of dashboards that have been broken by the change we made. We can see right away that fixing this is extremely important.
And here's one way that the shared data model in Omni really shines. In addition to acting as a single source of truth and in addition to being a source of rich context for supporting AI, Omni shared data model also serves as a layer of abstraction. Let's see how trivial it is to fix all of our dashboards in one fell swoop.
Now again, we're pointed to our dbt dev environment. And first, we're going to notice that the logical dimension time to ship remains in the model file. But unlike the other logical dimensions, it's not related to a column from our database or an expression based on columns from our database. All we need to do is take the logical time to ship dimension and connect it to the right column from our data table.
Now again, we're working in branch mode and that means that nothing we do will have any impact on production. So let's see if we've managed to fix the dashboard. We're pointed to our dev environment. Let's do a refresh. The change was that simple. And it not only fixed this dashboard, it fixed all of the dashboards that were affected.
So this is the incredibly powerful and elegant way that DBT and Omni work together to help you achieve both quality data and BI products.