in this video we are going to take a look at using seeds in your dbt project seeds are essentially
csv files with data that you can then reference as if they're another table or model in your project
some good use cases that they mention here are mappings of country codes a list of test emails
seeds are best suited to static data which changes infrequently really what they're
trying to drive home here is you don't want to use seeds as essentially a way of loading raw
data that has been exported to csvs it's more for using as a reference point in this video i
will show you how to create a seed file how to deploy it and then how to reference it
in a model so as mentioned seeds are really just csv files by default dbt will look in your data
directory for these csv files that you're looking to load so if we hop back into our project we can
see here by default it puts this data pass here as data meaning it is looking under this data
folder right now there's nothing in it so this is where we can put in our example csv file so
in this example as background the model that i'm going to use to start is one called team it just
has a list of a couple mba teams and we are going to create a seed file that has their associated
city and state and then we'll join them together to create a different model here is an example
of the csv file that i'm going to use back in here we can create a new file and call this
team locations let's call it that dot csv because this is a csv file and all i'm going to do
is copy and paste this in here to hold that csv file i could have just dragged that fold that
file in here but decided to copy and paste it now the first step here in using seeds is to actually
deploy this and the way to do that is through the dbtc command which is going to load anything
in that data pass location to our project and right now we have this here so let's go ahead
and do that dbt seed one seed file it recognizes this here so it should grab that and load it
okay so it inserted public team locations inserted four records let's take a look
public team locations there it is so we can see this loaded our data and again this is a decent
example because this is information that is not likely to change it's more of a reference
so now how can we use this in a c in a script let's say you know how would you actually use
this in in a real model as they mention in here you can reference it like this so you reference
the name of your seed file in this case they created one called country codes
they're referencing country codes we will do the same thing but for us it will be team locations
so i'm going to create a new model here we'll call this example team details dot sql
and how we'll write this here is we're going to reference the original model here first and then
in the next one we'll say team locations as and this time we will use we'll do the same thing but
instead of the name of a model we're going to use the name of this data file team locations
now let's join them together now let's deploy this model
to see it to see if it worked dbt run use the model flag dash m example team details
all right success let's take a look we now see team details it has all the columns let's take
a quick look at the compiled code see what happened here team details so you can see
it took our original model for here it looked at public team locations so it understood where this
is deployed and the name of it even though it's in a different schema dbt knows where to look
and then it joins them together so to recap we added a csv file to our data folder
and the reason we put it in the data folder is because that's where we're indicating this
here we could always change this but this is the default we referenced this file in our new model
using the ref function and join it to an existing model so you can see there's
obviously this is a very simple example but there's a lot of cool use cases as they mention
you know filtering test records keeping country codes or maybe specific user ids that you need
to reference but it's not really going to change often so i hope you found this helpful if you did
please feel free to like the video leave a comment and i will see you at the next one thank you