YouTube2Text

Code along - build an ELT Pipeline in 1 Hour (dbt, Snowflake, Airflow) — Transcript

by jayzern · 4,267 words · 706 segments · language en · Watch on YouTube

Full transcript

  1. 0:00what's the difference between ETL and
  2. 0:03elt they both have extract transformed
  3. 0:06load but they're range differently in
  4. 0:09the past when ETL was created cloud
  5. 0:11storage was very expensive in order to
  6. 0:14minimize cost businesses would transform
  7. 0:17the data first and load them in a data
  8. 0:20warehouse fast forward to today with the
  9. 0:22Advent of all these new exciting
  10. 0:24Technologies like snowflake storage is
  11. 0:27much cheaper which is why elt was cre it
  12. 0:30makes more sense to dump your data in a
  13. 0:33data warehouse and slice and dice them
  14. 0:36later on there are so many tools in the
  15. 0:38market for creating elt pipelines for
  16. 0:41example we have DBT snowflake prefect
  17. 0:45Daxter spark how do I pick the right one
  18. 0:49this is going to be a live coding
  19. 0:50tutorial where I'll walk you through how
  20. 0:52to build an elt pipeline from scratch
  21. 0:55I'll show you every step of the way and
  22. 0:57we'll talk about the thought process
  23. 0:59we'll cover basic data modeling
  24. 1:01techniques such as how to build fact
  25. 1:03tables data Marts we'll look into
  26. 1:05Snowflake rbac and how to deploy our
  27. 1:08model on airflow for all tools we will
  28. 1:10be using DBT for transformation
  29. 1:13snowflake for data warehousing and
  30. 1:15airflow for orchestration for
  31. 1:17orchestration feel free to use something
  32. 1:19else you're more comfortable with I hope
  33. 1:21you enjoyed this tutorial we'll use this
  34. 1:23snowflake tpch data set which is a free
  35. 1:26data set provided by snowflake make sure
  36. 1:28to have your snowflake personal account
  37. 1:30ready and let's Dive Right
  38. 1:33In for this Hands-On tutorial we're
  39. 1:36going to be developing locally using DBT
  40. 1:39core so the first thing to do is to go
  41. 1:42to DBT core which is this website over
  42. 1:44here and make sure you install DPT core
  43. 1:48using pip so you can run pip install DBT
  44. 1:52core on your terminal you can create a
  45. 1:54virtual environment if you want to there
  46. 1:56are several other ways to install DPT
  47. 1:58core you can install on
  48. 2:01Homebrew make sure you have your
  49. 2:03snowflake account set up so I have my
  50. 2:06account right
  51. 2:08here let's
  52. 2:21see then pip install DPT core the first
  53. 2:25thing we're going to do is to set up
  54. 2:26environments in Snowflake so we're going
  55. 2:29to create a warehouse a database and a
  56. 2:32roll in Snowflake and in that database
  57. 2:34we're going to create a schema and
  58. 2:37that's where we're going to write our
  59. 2:39DBT tables into for the role we're going
  60. 2:42to make sure this role is assigned to
  61. 2:44our user in Snowflake and we're also
  62. 2:46going to Grant access for your warehouse
  63. 2:48and your databases to that role so let's
  64. 2:51do that so let's use roll account admin
  65. 2:56account admin is sort of the super user
  66. 2:59for snowflake by the way and I'm going
  67. 3:01to create a
  68. 3:03warehouse I'm going to call it DBT
  69. 3:06Warehouse with Warehouse size
  70. 3:10equals small X
  71. 3:14small okay and I'm going to create a
  72. 3:18database let's call it DBT
  73. 3:22database and create a role let's call it
  74. 3:26DBT
  75. 3:28rooll so let's run
  76. 3:31that so press command enter to run your
  77. 3:35commands in your snowflake
  78. 3:37worksheet okay let's check the grants in
  79. 3:40your DBT
  80. 3:42Warehouse first before we actually
  81. 3:46Grant the warehouse usage onto the role
  82. 3:50so let's show grants on
  83. 3:52Warehouse BBT
  84. 3:54warehouse and you can see that there's
  85. 3:56only one user that has ownership PR
  86. 3:59privileg which is the account admin so
  87. 4:03what we're going to do next is to
  88. 4:05Grant
  89. 4:07usage on
  90. 4:10Warehouse DBT to roll DBT
  91. 4:16roll and if we run this show grants on
  92. 4:19Warehouse command again we can see that
  93. 4:22there's another another user that has
  94. 4:24usage privilege on this
  95. 4:27warehouse and it's the grante name is
  96. 4:30DBT roll so that looks good then the
  97. 4:33second thing we're going to do is to
  98. 4:34Grant
  99. 4:36roll we're we're going to Grant this
  100. 4:39role to our user so I'm using my own
  101. 4:43user this could be make sure to replace
  102. 4:47this with your own user so what we're
  103. 4:49going to do next is to Grant all on
  104. 4:52database
  105. 4:54DBT DB to roll DBT roll so so we're
  106. 4:59going to make sure this Ro has access to
  107. 5:02this database that we've created so
  108. 5:05let's run that
  109. 5:08again okay now that we've created our
  110. 5:11warehouses databases and roles let's
  111. 5:14switch into the role we just created so
  112. 5:17let's use DBT
  113. 5:19rooll and now we are going to create a
  114. 5:24schema DBT db. DBT schema
  115. 5:30like
  116. 5:31this and if we look here in our
  117. 5:35databases objects we can let's refresh
  118. 5:38the
  119. 5:39page you can see DBT schema exists but
  120. 5:43no objects are
  121. 5:44found so everything looks
  122. 5:50good if you have trouble rerunning this
  123. 5:53again you can also do something like
  124. 5:55create database if not exist otherwise
  125. 6:00if you try to create a rle again it's
  126. 6:01going to say the r already exist so
  127. 6:05create R if not exist you can do that
  128. 6:08too if you want to drop your warehouses
  129. 6:11later just so you don't incur cost you
  130. 6:14can do something like use roll account
  131. 6:18admin use account admin again and you
  132. 6:21can drop your
  133. 6:24Warehouse if
  134. 6:27exists DBT Warehouse drop
  135. 6:31database if exists DBT DB drop roll if
  136. 6:37exist DBT
  137. 6:39roll so now we're going to initialize
  138. 6:42our DBT project and all you have to do
  139. 6:44is run DBT in
  140. 6:46it I'm going to call my project
  141. 6:50dataor
  142. 6:52pipeline for the database I'm going to
  143. 6:55set up my profile as
  144. 6:57snowflake for account make sure you go
  145. 7:00to Snowflake and then go to your locator
  146. 7:03type here hover over so now copy that
  147. 7:07paste it here for user type in the user
  148. 7:10you created for
  149. 7:12Snowflake and I'm going to put password
  150. 7:14for Simplicity so just type in my
  151. 7:18password for roll we're going to add in
  152. 7:20the r that we just created so it's DBT
  153. 7:23uncore roll for warehouse It's DBT
  154. 7:27uncore Warehouse
  155. 7:29so Warehouse like this for database it's
  156. 7:33DBT
  157. 7:35DB schema is
  158. 7:37dtore
  159. 7:39schema for threats I'm going to use 10
  160. 7:42threats now CD into Data
  161. 7:47pipeline all right and let's open V
  162. 7:54code so let's configure our DBT project
  163. 7:58yo file
  164. 8:00and this file basically tells DBT that
  165. 8:04this is a project folder right this is
  166. 8:06the main file that's going to reference
  167. 8:08and it contains a bunch of useful
  168. 8:10information like where where to find
  169. 8:12your models where where you putting your
  170. 8:14test where your seats where your Macros
  171. 8:17so forth I'm going to create two two
  172. 8:20tables one called staging and this
  173. 8:24staging is going to be materialized as a
  174. 8:27view and I'm going to set the snowflake
  175. 8:31Warehouse as DBT
  176. 8:34warehouse and for I'm going to create
  177. 8:36another table called
  178. 8:39Mars and this is going to be
  179. 8:43materialized as a
  180. 8:45table and I'm also going to use the same
  181. 8:49snowflake Warehouse which is
  182. 8:51DBT
  183. 8:53Warehouse let's delete the example
  184. 8:58models and create new folders first one
  185. 9:01let's call it
  186. 9:03staging and let's call the next
  187. 9:06one Mars let's install some third party
  188. 9:11libraries this is going to be useful
  189. 9:13later when we're creating suret
  190. 9:16keys for our models so let's create a
  191. 9:19new folder let's call it packages.
  192. 9:24yo and in packages. yo
  193. 9:30I'm going
  194. 9:32to add DBT Labs DBT utils so this is a
  195. 9:38really common library in
  196. 9:40DBT let's look up what versions they
  197. 9:43have on DBT
  198. 9:58utils let's use the latest version
  199. 10:00actually to install your packages hit
  200. 10:03DBT
  201. 10:05depths to kind of give you a high level
  202. 10:08tour of DBT projects so this DBT project
  203. 10:12yamamo file tells DBT where to look for
  204. 10:15your models so the models folder is
  205. 10:17where we're going to write our SQL logic
  206. 10:20our source data sets are going to live
  207. 10:22here our staging files it's really good
  208. 10:25practice to separate your staging files
  209. 10:29staging files are Ono one with your
  210. 10:31source files and you should separate
  211. 10:33them with Ms folder all these models are
  212. 10:36going to materialize in Snowflake and
  213. 10:39this bottom piece of code here where we
  214. 10:41tell DBT hey I want to materialize all
  215. 10:44my models in this staging folder as
  216. 10:46views and I want to materialize all my
  217. 10:48models in this SMS folders as tables the
  218. 10:51macros folder you can write reusable
  219. 10:53macros here and I'm going to show you
  220. 10:55how to do that later for DBT packages by
  221. 10:59running DBT depths this is where third
  222. 11:01party libraries are going to live here
  223. 11:03seeds is for static file so files that
  224. 11:06the data is not going to change very
  225. 11:08often maybe you have a data set you have
  226. 11:11a CSV file that you need to reference
  227. 11:13and you know it doesn't change for every
  228. 11:15few months and you can put it in your C
  229. 11:17folder here snapshots are useful when
  230. 11:19you are trying to create incremental
  231. 11:22models and test folder here DBT test
  232. 11:27types there's two types of tests in DBT
  233. 11:30and the first one is singular tests and
  234. 11:32generic tests are parameterized queries
  235. 11:35and accepts Arguments for example check
  236. 11:38if this model doesn't have no values or
  237. 11:40check if this model has values greater
  238. 11:42than
  239. 11:46zero so that's kind of a high Lev tour
  240. 11:49of DBT projects now what we're going to
  241. 11:52do next is to set up our source and
  242. 11:54staging tables so go to models go to
  243. 11:59models and let's create a TP
  244. 12:03chore
  245. 12:05sources. yo the name of this file
  246. 12:08doesn't really matter so I'm going
  247. 12:11to create sources so the First Source
  248. 12:15I'm going to get it from the tpch data
  249. 12:20set I'm going to name it tpch and it's
  250. 12:23coming from Snowflake sample
  251. 12:26data and that basically
  252. 12:29comes
  253. 12:32from right here snowfake sample data and
  254. 12:36you have these bunch of schemas here I'm
  255. 12:37going to reference them so go back to
  256. 12:41schema tpch
  257. 12:45sf1 for tables pull in the orders
  258. 12:49table and this orders table has a bunch
  259. 12:52of
  260. 12:53columns but I'm going to write some
  261. 12:56tests here so there's a order key here
  262. 13:02and I want to make sure this
  263. 13:04key
  264. 13:06is
  265. 13:08unique and it's not null so like like
  266. 13:11what I said about generic tests so the
  267. 13:13second table I want to pull in is line
  268. 13:16item
  269. 13:19table and this line item table has a
  270. 13:22bunch of
  271. 13:23colums that's order key L order key
  272. 13:29is a foreign key to this table so let's
  273. 13:31test this relationship there's a generic
  274. 13:33test called
  275. 13:35relationships in two
  276. 13:38Source oops
  277. 13:41tpch
  278. 13:43orders and the field is order key so
  279. 13:49this test is going to make sure that
  280. 13:51this value here is actually a foreign
  281. 13:53key of this table so now that we have
  282. 13:55our sources table let's create our
  283. 13:57staging models
  284. 13:59staging models let's call it staging
  285. 14:02tpch
  286. 14:04orders. SQL so let's try to pull in data
  287. 14:08from our sources first to make sure
  288. 14:11everything
  289. 14:12works so the way you pull data from
  290. 14:14source is using this Source function
  291. 14:16wrapped around this Ginger curly braces
  292. 14:21bracket let's let's pick up data from
  293. 14:24orders let's do DBT
  294. 14:27run
  295. 14:30oo it's not
  296. 14:31working let's see what's the problem
  297. 14:34here oh
  298. 14:36okay so the issue is the yamamo files
  299. 14:39have to
  300. 14:40be indented correctly so it wasn't
  301. 14:44indented as a typo should be name not
  302. 14:48names and there should be a indentation
  303. 14:51here
  304. 14:52relations let's try to run that again
  305. 14:55everything looks good staging folder
  306. 14:58let's hit DBT run to run all your
  307. 15:03models okay see it says that it passed
  308. 15:07and if we go back if we go back here to
  309. 15:10our worksheet and
  310. 15:13refresh we can see our first table
  311. 15:16staging tpch ORD is created right here
  312. 15:19so that's pretty cool so what we want to
  313. 15:21do in our staging folder is I want to
  314. 15:24rename some of these values so let's do
  315. 15:27o order key as order key and then o cust
  316. 15:33key as
  317. 15:35customer key o order status
  318. 15:40as status
  319. 15:43code o total price as total price o
  320. 15:49order date as order date so I'm just
  321. 15:54going to rename my variables
  322. 15:57here and do the same same thing
  323. 16:00for let's create staging
  324. 16:03tpch line items. SQL so let's do the
  325. 16:08same thing let's call get our source and
  326. 16:11then the name of the table line
  327. 16:14item so this time I'm going to copy
  328. 16:17paste a bunch of the columns here and
  329. 16:21I'm going to create a surrogate key
  330. 16:24using dbts and a surrogate key is it's
  331. 16:27useful in dimensional modeling when you
  332. 16:29have a bunch of fact tables and
  333. 16:31dimensional tables that you want to
  334. 16:33connect so let's create our serate key
  335. 16:36here DBT utils surrogate
  336. 16:40key let's do something like
  337. 16:43this so I'm going to use l order
  338. 16:49key I'm going to use both the line
  339. 16:52number and the order key to create my
  340. 16:54circuit
  341. 16:55key let's name this as order order item
  342. 17:00key think of it as a
  343. 17:03hash to run this model only press DBT
  344. 17:08run- select
  345. 17:10or- s for short staging tpch line
  346. 17:17items let's
  347. 17:21go okay says that compilation error
  348. 17:25warning this function has been replaced
  349. 17:28by a new name so let's rename that run
  350. 17:35again okay it works
  351. 17:42perfect The Next Step we're going to do
  352. 17:44is we're going to transform our models
  353. 17:46when you work for a company you have to
  354. 17:48do some kind of business transformation
  355. 17:50on these staging tables staging tables
  356. 17:53are one to one with Source table and
  357. 17:56we're going to aggregate some data in
  358. 17:58this this line items table here and
  359. 18:01create a fact table as a result so what
  360. 18:04is a fact
  361. 18:08table so fact table is a dimensional
  362. 18:11modeling technique that stores results
  363. 18:14from a business
  364. 18:16process so data warehouse
  365. 18:22toolkit so let's look at what a fact
  366. 18:24table
  367. 18:26is so a fact table contains numeric
  368. 18:29measures produced by an operational
  369. 18:31measurement in the real world so you can
  370. 18:33think of a green in effect table as a a
  371. 18:37table that represents a bunch of numeric
  372. 18:40events and it's connected to other
  373. 18:42tables that you call dimensional tables
  374. 18:45so effect table always contains foreign
  375. 18:47keys for each of its Associated
  376. 18:50Dimensions so that's why we created our
  377. 18:52serate key so let's go back here and
  378. 18:55what I'm going to do
  379. 18:57is
  380. 18:59I'm going to reference the files I
  381. 19:02created just now so let's use the ref
  382. 19:05function staging tpch orders and let's
  383. 19:09call it
  384. 19:11orders
  385. 19:14oops and I'm going to join this
  386. 19:18table with staging tpch line
  387. 19:25items as line
  388. 19:28item and we're going to join it on this
  389. 19:31key so orders. order key equals line
  390. 19:35item line item. order key I'm going to
  391. 19:40copy a bunch of columns
  392. 19:42here and we're going to order
  393. 19:45this by orders. order date let's see if
  394. 19:50this works TBT
  395. 19:57run
  396. 20:01so remove this comma here syntax
  397. 20:07error orders order
  398. 20:10key make sure you run your orders table
  399. 20:14again
  400. 20:20oops and then make sure you run your in
  401. 20:24order items table
  402. 20:27again
  403. 20:29[Music]
  404. 20:33okay everything works so what I'm going
  405. 20:35to do next is to create a macro function
  406. 20:38and macro functions are a good way to
  407. 20:41reuse business logic across multiple
  408. 20:43models so let's create a file called
  409. 20:46pricing.
  410. 20:48SQL let's create pricing. SQL I'm going
  411. 20:52to Google DBT
  412. 20:56macros go here
  413. 21:00let's copy this example let's copy put
  414. 21:03it here I'm going to rename this as
  415. 21:07discounted
  416. 21:09amount it's going to have two inputs the
  417. 21:11first is extended
  418. 21:14price and discounted price discount
  419. 21:20percentage so over here is where we
  420. 21:22typically write our business logic write
  421. 21:24some business logic like this and let's
  422. 21:27reuse uses macro in this Ms folder so
  423. 21:32I'm going to call this function
  424. 21:34discounted amount on line item extended
  425. 21:38price and line item discount
  426. 21:41percentage so I'm trying to get the item
  427. 21:43discount amount right here let's see if
  428. 21:46this works DBT run in order items okay
  429. 21:52it
  430. 21:53works good by the way I'm going to add a
  431. 21:56new column here
  432. 21:59let's add extended
  433. 22:02price let's create more intermediate
  434. 22:04files I'm going to do this really
  435. 22:06quickly in order items summary. SQL just
  436. 22:11going to do a simple group bu taking the
  437. 22:14intermediate files we created and just
  438. 22:16do a group buyer over the extended price
  439. 22:18and discount amount and finally let's
  440. 22:21create a fact model so
  441. 22:24fct orders. SQL and in this fact model
  442. 22:28here let's
  443. 22:30select star from
  444. 22:34ref staging tpch
  445. 22:38orders as orders and we're going to join
  446. 22:42it with ref int order items
  447. 22:49summary as order item
  448. 22:55summary on
  449. 22:59let's join it with the order
  450. 23:06key order by the order
  451. 23:13date I'm going to take everything from
  452. 23:15the ORD table so
  453. 23:18star and I'm going to combine this order
  454. 23:21item
  455. 23:25summary it DBT run
  456. 23:32let's see if this
  457. 23:41works everything works so we have our
  458. 23:44fact table let's go back to Snowflake
  459. 23:48and click
  460. 23:52refresh if we click on tables we can see
  461. 23:55fact
  462. 23:56orders
  463. 23:58and this fact orders table is connected
  464. 24:00to our orders key right here so the way
  465. 24:04it works is this orders item is our
  466. 24:07dimensional dimensional model this is a
  467. 24:10huge oversimplification and there's a
  468. 24:12lot more to it to fact tables and
  469. 24:14dimensional tables but we're not going
  470. 24:16to talk about it in this
  471. 24:19video all
  472. 24:24right now let's create some test code
  473. 24:27there two types of test in DBT singular
  474. 24:29test where you write SQL queries that
  475. 24:31returns failing rowes and a generic test
  476. 24:34so let's write some generic tests so the
  477. 24:36models folder here I'm going to
  478. 24:40create generic
  479. 24:45test you can name this file whatever you
  480. 24:47want I'm going to call it generic test
  481. 24:49let's
  482. 24:56say
  483. 25:00write some generic test so this is what
  484. 25:03I mean by that there's a bunch of
  485. 25:04inbuilt tests in built generic tests
  486. 25:07like
  487. 25:08unique notnull
  488. 25:12relationships so let's test the
  489. 25:14relationship of the foreign keys right
  490. 25:18here staging tpch
  491. 25:21orders
  492. 25:25field and severity
  493. 25:28let's put
  494. 25:30warning let's add another test for
  495. 25:33status
  496. 25:39code and let's put accepted
  497. 25:53values so I'm saying that for this
  498. 25:55column status code I only want to accept
  499. 25:58p o and F and for this relationships
  500. 26:01generic test I want to test the foreign
  501. 26:04keys so make sure to indent these values
  502. 26:08here correctly accept the values values
  503. 26:10p o and F so this piece of code here is
  504. 26:14telling DBT to say check for these
  505. 26:17values these are the only acceptable
  506. 26:19values for relationships here it's
  507. 26:21checking the foreign keys and you're
  508. 26:23checking order key must be unique and it
  509. 26:25must not be null hit the BT
  510. 26:30test nice Works completed successfully
  511. 26:33let's build some singular
  512. 26:35tests let's create fact
  513. 26:39orders discount. SQL now let's write a
  514. 26:43test to check if the item discount is
  515. 26:47always greater than
  516. 26:49zero because you can't have a negative
  517. 26:51discount if you have a negative discount
  518. 26:54that means you are paying more money
  519. 26:56right fact
  520. 26:58orders let's do
  521. 27:01where item discount amount is greater
  522. 27:05than zero so DBT
  523. 27:09test so what happens if you
  524. 27:13do less than
  525. 27:18zero it's going to
  526. 27:21fail so it fails because your this query
  527. 27:25is returning a non-null value and you
  528. 27:27can see here the failure there are one
  529. 27:31is it 1 million 1.4 million values that
  530. 27:35didn't meet this test so it should be
  531. 27:38greater than
  532. 27:42zero okay now it's passed I'm going to
  533. 27:45write one more singular test let's call
  534. 27:47it fact orders date valid. SQL and over
  535. 27:53here let's do
  536. 27:56select star
  537. 27:59from ref fact
  538. 28:03orders
  539. 28:06where let's check if the date of the
  540. 28:10order date I'm going to cast this value
  541. 28:13as a date is greater than the current
  542. 28:18date or the
  543. 28:21date
  544. 28:24is older
  545. 28:26than
  546. 28:281990 which is a long time ago so what
  547. 28:31this test is saying is make sure the
  548. 28:33values are within an acceptable range so
  549. 28:36let's do DBT
  550. 28:40test everything is working
  551. 28:43again so now that we have our singular
  552. 28:45test set up we have a bunch of generic
  553. 28:48tests to summarize everything we've
  554. 28:50built so far we've created our source
  555. 28:53tables here we have a bunch of staging
  556. 28:56tables that reference the source tables
  557. 29:00for this line item St staging table we
  558. 29:02generated a ciruit key so it can
  559. 29:04reference later in our Downstream fact
  560. 29:07tables we have a bunch of Mars tables
  561. 29:11here and they do a bunch of
  562. 29:13Transformations these Transformations
  563. 29:15use macros that we wrote right
  564. 29:19here and finally we have an or fact
  565. 29:21table that references some dimensional
  566. 29:25models so we've done a lot so far now
  567. 29:27let's actually deploy this using
  568. 29:32[Music]
  569. 29:35airflow so I'm going to use airflow to
  570. 29:37deploy this DBT dag but you can choose
  571. 29:40your own orchestration platform of
  572. 29:42choice whether it's prefect
  573. 29:44Daxter you can even try to run this on
  574. 29:47AWS if you prefer
  575. 29:51to prefect and Daxter are great
  576. 29:53Alternatives that build upon airflow but
  577. 29:56let's just stick with airow flow and I'm
  578. 29:58going to use this Library called
  579. 30:00astronomer
  580. 30:04Cosmos and this Library here is going to
  581. 30:08allow us to run our DBT core projects
  582. 30:10using airflow Dax and task groups it's
  583. 30:14really simple to install all I have to
  584. 30:16do is go to your terminal here and run
  585. 30:21Brew install
  586. 30:23Astro I already have it installed so
  587. 30:26this is probably
  588. 30:27not going to work for me or it's going
  589. 30:30to update my Astro
  590. 30:33okay so we're going to initialize a new
  591. 30:35project using airflow so let's make
  592. 30:39directory let's call it DBT do CD into
  593. 30:43DBT D and run Astro Dev
  594. 30:47init so it's going to initialize a new
  595. 30:50astro
  596. 30:51project let's take a look at the code go
  597. 30:55to a Docker file and add this to your
  598. 30:57Docker
  599. 30:58file at the
  600. 31:01bottom so this command is going to
  601. 31:05install DBT
  602. 31:07snowflake after you add this piece of
  603. 31:11code to your Docker file okay after add
  604. 31:13this your darker file we're not done yet
  605. 31:16we need to add to our requirements file
  606. 31:20let's add as stomer
  607. 31:23cosmos and add Apache air
  608. 31:28flow providers
  609. 31:31snowflake so make sure to add these two
  610. 31:33lines for requirements txt file Astro
  611. 31:36def
  612. 31:40start okay air flow starting up
  613. 31:45amazing amazing amazing so let's go to
  614. 31:48Local Host
  615. 31:528080 username is username is admin
  616. 31:58password is admin
  617. 32:02okay so in order to run DBT on airflow
  618. 32:06copy paste data pipeline DBT folder into
  619. 32:10Dax folder right here so I've just did
  620. 32:12it is Dax DBT data
  621. 32:17Pipeline and here's the piece of code to
  622. 32:20write your DBT D so I'm basically just
  623. 32:23importing a bunch of libraries right
  624. 32:24here for datetime OS using the cosmos
  625. 32:29Library I am setting my connection to
  626. 32:32snowf using snowl con for my profile
  627. 32:36arguments I make sure I set that up to
  628. 32:38the database we created in Snowflake and
  629. 32:40the schema we created in
  630. 32:42Snowflake for your DBT dag right here
  631. 32:46make sure to point it towards the right
  632. 32:49directory and let's call it DBT dag ID
  633. 32:52and I'm going to schedule it for a daily
  634. 32:54run so everything here looks quite good
  635. 32:57if I go back to my airflow right here I
  636. 33:01can go to DBT dag there's one more thing
  637. 33:05we have to do left so go to admin go to
  638. 33:10connections and then click add a
  639. 33:14connection let's call it
  640. 33:16snowflake
  641. 33:18con and let's go to find
  642. 33:22snowflake so put in your snowflake
  643. 33:25account put
  644. 33:27M your Warehouse DBT
  645. 33:30Warehouse whoops DBT Warehouse DBT
  646. 33:35DB roll is DBT
  647. 33:38roll and that's
  648. 33:41it just double checking everything looks
  649. 33:44good okay everything looks good hit save
  650. 33:47let's go back to our DXs go to DBT
  651. 33:50D and let's try to run this so before we
  652. 33:54run it we can see this is how Cosmos
  653. 33:56will actually create a graph using graph
  654. 34:00for us to show us how this fact orders
  655. 34:02table is constructed we see the two
  656. 34:04staging models that we created goes to
  657. 34:07this intermediate table goes to another
  658. 34:09intermediate table and this table goes
  659. 34:11to fact orders you can even see your
  660. 34:14test code right here the trigger D let's
  661. 34:17see if this
  662. 34:22works
  663. 34:24fi let's take a look at why it f
  664. 34:29go to
  665. 34:32loog fail to
  666. 34:35execute okay I know so go back to admin
  667. 34:42connections I need to type in my
  668. 34:43snowflake username password
  669. 34:46so going type my password and user right
  670. 34:49here I'm going to throw this out and
  671. 34:51then click
  672. 34:53save let's try right
  673. 34:55again
  674. 35:01okay it looks like it's
  675. 35:06working you can see the user interface
  676. 35:09okay perfect it ran
  677. 35:12successfully if we go to run and go to
  678. 35:15logs you can see DBT code here actually
  679. 35:20running you can see your that code XCOM
  680. 35:24is pretty difficult to use in my opinion
  681. 35:26in there's a limit to how much data you
  682. 35:29can pass on XCOM okay awesome if you
  683. 35:32made it this far to the tutorial I hope
  684. 35:35you learn a lot we've made a lot of
  685. 35:37progress in this tutorial let's wrap up
  686. 35:39thank you for watching I genuinely hope
  687. 35:41that you got a lot of value out of these
  688. 35:43Hands-On tutorials and to summarize what
  689. 35:46we learned today we learned how to set
  690. 35:48up our snowflake environments with our
  691. 35:51warehouses our roles our users tables
  692. 35:54schemas databases we learned learn how
  693. 35:57to connect DBT core with Snowflake and
  694. 36:00inside DBT we've built models in our
  695. 36:02staging folders and our Mars folders for
  696. 36:05different in order to organize our
  697. 36:07models better after building the models
  698. 36:11we learned how to use macros to templae
  699. 36:14code and reuse business logic we know a
  700. 36:17difference between generic tests and
  701. 36:18singular tests using DBT and finally we
  702. 36:22orchestrated this DBT code inside
  703. 36:24airflow let me know the comments what
  704. 36:27kind of videos you want to see next as
  705. 36:29usual thank you so much for watching and
  706. 36:31I'll see you next time peace

About this transcript

This page contains the full transcript of Code along - build an ELT Pipeline in 1 Hour (dbt, Snowflake, Airflow) by jayzern, generated from the public captions YouTube serves with the video. The transcript has 4,267 words across 706 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.