YouTube2Text

Databricks Was HARD Until I Learned These 21 CONCEPTS (Databricks Ansh Lamba) — Transcript

by Ansh Lamba · 42,215 words · 6,967 segments · language en · Watch on YouTube

Full transcript

  1. 0:00Data-bricks is that single technology
  2. 0:02right now, which is the most in demand
  3. 0:04in the field of data engineering. But it
  4. 0:07has so many components and features that
  5. 0:10it can be overwhelming to grasp all at
  6. 0:13once. That's why I have created this
  7. 0:15four plus hours long tutorial covering
  8. 0:1821 plus key concepts with practical
  9. 0:21hands-on examples to help you understand
  10. 0:24and master Data-bricks effectively. This
  11. 0:26is completely beginner friendly and
  12. 0:29designed to take you from zero to a pro
  13. 0:32level in Data-bricks and will cover
  14. 0:34everything including Apache Spark and
  15. 0:37Data-bricks architecture, Data-bricks
  16. 0:38volumes, Delta tables, Lake flow
  17. 0:41connect, Lake flow jobs, Lake flow
  18. 0:43declarative pipelines, Spark streaming
  19. 0:45with auto loader, declarative automation
  20. 0:48bundles, Data-bricks SQL warehouse,
  21. 0:50Data-bricks lake base and much more. By
  22. 0:53the end of this tutorial, you will have
  23. 0:55a solid understanding of Data-bricks and
  24. 0:58you will be able to confidently work
  25. 1:01with it. And everything is explained
  26. 1:03with amazing hand-drawn doodles with
  27. 1:06real-world examples and scenarios. So
  28. 1:09simply hit the subscribe button if you
  29. 1:10want to stay ahead in the field of data
  30. 1:13engineering and let's get started with
  31. 1:15this amazing masterclass. So now first
  32. 1:18of all, we need to understand the very
  33. 1:20first concept because only then you will
  34. 1:22be able to learn any other concept. And
  35. 1:25the concept is very simple.
  36. 1:27What is
  37. 1:28Apache Spark?
  38. 1:30Cool.
  39. 1:32What is Apache Spark? So Apache Spark is
  40. 1:34first of all very very simple. Nowadays
  41. 1:36everyone knows about it,
  42. 1:37but still let's talk about it a little.
  43. 1:40So let's say you want to process your
  44. 1:43data. Okay. You would have like
  45. 1:45processed your data in your early days
  46. 1:47of
  47. 1:48any you can say
  48. 1:51profession within the data domain. Okay.
  49. 1:54So what what was the you can say default
  50. 1:57practice? Obviously you will just bring
  51. 1:59one you will perform the
  52. 2:00um processing, cleaning, anything on
  53. 2:03that, right? Perfect, everything was
  54. 2:05nice, but with the rise of data,
  55. 2:08this single machine or your system or
  56. 2:11any virtual machine that you were using
  57. 2:14was not enough. Really? Yeah, this was
  58. 2:18not working at all.
  59. 2:19Then what was the solution? The solution
  60. 2:21was very simple.
  61. 2:22We needed to bring multiple multiple
  62. 2:26machines together.
  63. 2:28Let say 1 2 3 4 5 depending upon the
  64. 2:31size of the data, right? So when we
  65. 2:33wanted to introduce this kind of
  66. 2:36distributed computing,
  67. 2:39then we got introduced to Apache Spark.
  68. 2:42Now I know there are so many you can say
  69. 2:45frameworks like Hadoop, MapReduce, which
  70. 2:47was introduced even before Apache Spark,
  71. 2:50but it was not very very you can say
  72. 2:52efficient to process your data because
  73. 2:54it keeps on writing the data on the
  74. 2:56disk, but Apache Spark started
  75. 2:58processing the data in the memory
  76. 3:00itself, which was very very fast. And
  77. 3:01this was not the only change. Then they
  78. 3:03just started
  79. 3:05building let say your you can say SQL
  80. 3:07engine, which was building DAGs for you,
  81. 3:10which was like optimizing your code. And
  82. 3:12with the course of time, they introduced
  83. 3:13something called as C++ executors. So
  84. 3:16there was like continuous improvement
  85. 3:18going on within Apache Spark. That is
  86. 3:20why currently Apache Spark is one of the
  87. 3:23most trusted big data processing
  88. 3:26framework we use, right? Very good. This
  89. 3:29is your Apache Spark. Now very well
  90. 3:31done. Then what is this Databricks? If
  91. 3:33we have Apache Spark, everything is
  92. 3:35good. Now why do we need Databricks? So
  93. 3:38basically
  94. 3:39we need to
  95. 3:40use a kind of cluster. Cluster is what?
  96. 3:43An interconnection
  97. 3:45of these machines. These machines need
  98. 3:47to talk to each other.
  99. 3:49This requires networking. This requires
  100. 3:52a lot of things like operating system,
  101. 3:53context switching, everything, right?
  102. 3:55Because we perform multiprocessing
  103. 3:56within each machine and then we run our
  104. 3:59processes, driver process, executor
  105. 4:01process. There are like so many
  106. 4:02processes running.
  107. 4:03And everything needs to be communicated
  108. 4:06nicely, with fault tolerance, with
  109. 4:08everything.
  110. 4:09So,
  111. 4:10in order to handle this particular
  112. 4:13distributed system,
  113. 4:15it is not very easy. Okay?
  114. 4:18And Databricks, the team who built
  115. 4:21Apache Spark, yes,
  116. 4:23they
  117. 4:24figured out that okay, we have just
  118. 4:27created this framework called Apache
  119. 4:29Spark and we have provided this
  120. 4:31framework to the world as a research
  121. 4:33project. Now it's time to provide the
  122. 4:35real solution as well because I know
  123. 4:37Apache Spark can be used by the big big
  124. 4:38organizations and they can handle this
  125. 4:40distributed system, but there are so
  126. 4:42many companies who cannot handle all of
  127. 4:44these things, right? So they built
  128. 4:46something called as Databricks, which
  129. 4:49was, not is, which was nothing but a
  130. 4:52kind of managed solution which built on
  131. 4:56top of your
  132. 4:58um Apache Spark. This was the story in
  133. 5:01the initial days. Okay?
  134. 5:03In the initial days, this was the
  135. 5:05Databricks
  136. 5:06where you were not supposed to handle
  137. 5:10the cluster. You do not need to um you
  138. 5:13were not need to um you can say required
  139. 5:16to um manage this cluster, um you can
  140. 5:19say handle the um communication between
  141. 5:22the machines, nothing. You were only
  142. 5:25responsible to pick the right cluster
  143. 5:26size. Let's say you just want four
  144. 5:28machines with um 16 GB of RAM on each
  145. 5:31machine, like this. That is it.
  146. 5:34Everything was handled by Databricks.
  147. 5:36And not just this, running your Spark
  148. 5:38jobs, basically submitting your Spark
  149. 5:40jobs, everything was being handled by
  150. 5:42Databricks.
  151. 5:43And not just this, they even um
  152. 5:46introduced the notebooks. Okay? Because
  153. 5:49earlier we were not submitting the
  154. 5:51notebooks to our Spark clusters. We were
  155. 5:53submitting the Python scripts. Obviously
  156. 5:56you are just writing the Spark code in
  157. 5:57that, but these were like raw files. But
  158. 6:00data professionals like to just code in
  159. 6:02the notebook. So they even introduced
  160. 6:03notebooks that you were just um able to
  161. 6:06submit directly to the cluster.
  162. 6:08Make sense? This is your Databricks.
  163. 6:10This is your platform. This is the
  164. 6:12technology right now. But then with the
  165. 6:14course of time they introduced so so so
  166. 6:17many things as I just mentioned like
  167. 6:18optimization and then C++ based
  168. 6:20executors and so on.
  169. 6:22And now we will be just looking at all
  170. 6:24of those those concepts but do not
  171. 6:26worry. This was the basic idea behind
  172. 6:28Databricks.
  173. 6:29Even today if someone asks you like what
  174. 6:31is Databricks you can tell that this is
  175. 6:33a managed Spark platform with
  176. 6:36these these these these features and
  177. 6:38these these these features will be like
  178. 6:40very soon um displayed in front in front
  179. 6:43of you. Make sense? But this is the
  180. 6:45Databricks. This is the initial version
  181. 6:47of Databricks.
  182. 6:48Right? But then um we all know the
  183. 6:50story. Now it is like it has become the
  184. 6:53one stop solution for your AI and data
  185. 6:55solution. So now it is like completely
  186. 6:57different. But this is your Databricks.
  187. 6:59Make sense? Because a lot of people are
  188. 7:00still confused like what is the
  189. 7:02difference between Spark and Databricks?
  190. 7:04There's no difference. One complements
  191. 7:06the other one. Simple.
  192. 7:07Apache Spark is the framework.
  193. 7:10Databricks is the solution built on top
  194. 7:12of Apache Spark.
  195. 7:13Simple. Very good.
  196. 7:15So this is the concept. Now
  197. 7:17the next concept that you need to
  198. 7:19understand within the Databricks or I
  199. 7:20can say the very first concept within
  200. 7:23the Databricks
  201. 7:24is nothing but
  202. 7:26Unity
  203. 7:28Catalog.
  204. 7:32Okay? Unity Catalog or not just like
  205. 7:34what is Unity Catalog? What is the Unity
  206. 7:36Catalog?
  207. 7:37And
  208. 7:38Unity Meta Store because these two
  209. 7:41concepts
  210. 7:42both go hand in hand.
  211. 7:44So that is why let's try to discuss both
  212. 7:47together. Now what is this Unity Catalog
  213. 7:49and Unity Meta Store? Because the story
  214. 7:52of Databricks is totally changed after
  215. 7:55Unity Catalog. Databricks who like have
  216. 7:58used Databricks before Unity Catalog
  217. 8:00era, they would know like it was totally
  218. 8:02different. Okay? But now with Unity
  219. 8:05Catalog we get the centralized
  220. 8:07governance and everything. So let's talk
  221. 8:08about like what exactly is Unity
  222. 8:09catalog. And before even talking about
  223. 8:12Unity catalog, you need to understand
  224. 8:13Unity meta store. Because all of these
  225. 8:16things work in a hierarchy.
  226. 8:19Okay? Work in a hierarchy. So now what
  227. 8:21is this hierarchy? Hierarchy goes like
  228. 8:23this. First of all,
  229. 8:25you will get something called as Unity
  230. 8:27meta store.
  231. 8:30Unity meta store. Now
  232. 8:34forget about Unity,
  233. 8:36forget about the word Unity.
  234. 8:38What is a meta store? You tell me.
  235. 8:40Meta store is a location where you put
  236. 8:42all of the metadata.
  237. 8:44Simple.
  238. 8:45Right?
  239. 8:46But what metadata?
  240. 8:49We all know like metadata is the
  241. 8:52information, is the data about data.
  242. 8:55But here meta store means the
  243. 8:58information about
  244. 9:00your catalogs,
  245. 9:02your schemas, your tables, everything.
  246. 9:07Everything.
  247. 9:08And you need to
  248. 9:10you need to
  249. 9:12put everything within this Unity meta
  250. 9:14store.
  251. 9:15Makes sense? There's a centralized
  252. 9:17location.
  253. 9:18Centralized location.
  254. 9:20Cool? Just understand this concept first
  255. 9:22of all. This is a centralized
  256. 9:25you can say location.
  257. 9:26Within the meta store,
  258. 9:28we get a lot of things. A lot. Not just
  259. 9:31Unity catalog, but a lot of things.
  260. 9:35Makes sense? Very good.
  261. 9:36So when we have a catalog
  262. 9:40within this
  263. 9:42Unity meta store,
  264. 9:44that is considered as
  265. 9:47Unity catalog.
  266. 9:49But we do not
  267. 9:51refer this thing as um Unity catalog as
  268. 9:55a different thing and Unity meta store
  269. 9:56as a different thing. So whenever we
  270. 9:57talk about Unity catalog, we are talking
  271. 10:00about the catalog which is created
  272. 10:03which is created inside a Unity meta
  273. 10:06store.
  274. 10:07A lot of people get confused like
  275. 10:09um Unity catalog, Unity metastore,
  276. 10:11catalog under Unity metastore.
  277. 10:13All are interrelated.
  278. 10:16Cool? So this is the catalog created
  279. 10:18within the Unity metastore. Now you will
  280. 10:21ask me what is this catalog?
  281. 10:23Have you ever used database?
  282. 10:26Ever?
  283. 10:27Any database like Postgres, MySQL, MS
  284. 10:31SQL.
  285. 10:32So we create something called as
  286. 10:34database there, right? So catalog is
  287. 10:37equivalent to database in terms of
  288. 10:39hierarchy.
  289. 10:41Within the database we create something
  290. 10:43called as schema.
  291. 10:46Right? So you get schema as well
  292. 10:49inside this.
  293. 10:51Cool?
  294. 10:52Very good. Schema.
  295. 10:53Within the schema
  296. 10:55what do we create?
  297. 10:56You will say it's very easy. We create
  298. 10:58tables.
  299. 10:59Very good. We create views.
  300. 11:02Very good. We create functions. Very
  301. 11:04good. Yeah. We have all of these things
  302. 11:06here.
  303. 11:07All of these things.
  304. 11:09Functions.
  305. 11:11We have views.
  306. 11:14Simple. So we have all of these things
  307. 11:17here as well.
  308. 11:19Very good.
  309. 11:21So this is your hierarchy.
  310. 11:23Now what is the advantage? What is the
  311. 11:25advantage here?
  312. 11:27You get a centralized location for your
  313. 11:31entire data governance. What do I mean
  314. 11:33by
  315. 11:35one-stop solution or basically
  316. 11:36centralized location for data
  317. 11:37governance?
  318. 11:38So let say you just want to query any
  319. 11:41table.
  320. 11:42Right?
  321. 11:43You will now use
  322. 11:45three level
  323. 11:47naming space
  324. 11:48to query your table. You will first of
  325. 11:51all write your catalog name,
  326. 11:53then schema name, then your table name.
  327. 11:56That way
  328. 11:58you will know from where I am fetching
  329. 12:01the table, from which catalog, from
  330. 12:03which schema.
  331. 12:05Make sense?
  332. 12:06And it's not just about tables, it's
  333. 12:09about views, it's about functions and
  334. 12:12not just bro.
  335. 12:14It's also about now models.
  336. 12:17Oh,
  337. 12:19that is why Databricks is becoming even
  338. 12:21more popular in this AI era.
  339. 12:23You can even govern all of the models as
  340. 12:26well.
  341. 12:27Everything.
  342. 12:29And there's one more thing, but do not
  343. 12:32worry about that because that is our
  344. 12:33next concept. It is called volume.
  345. 12:38Oh, okay.
  346. 12:39Just for now, I can just give you a
  347. 12:41little bit of hint.
  348. 12:43You can even govern the raw files. Can
  349. 12:46you imagine raw files? Let's say you
  350. 12:49have some CSV files and you want to dump
  351. 12:51those files let's say in the cloud
  352. 12:53storage and you want to govern those
  353. 12:55files as well. You can just track the
  354. 12:57lineage and govern those files via Unity
  355. 12:59Catalog via three-level namespace.
  356. 13:03But do not worry about volume. We will
  357. 13:04discuss this as a next concept. Simple.
  358. 13:07Very good.
  359. 13:08And within this Unity Metastore,
  360. 13:11catalog is not the only thing.
  361. 13:13Okay. We have a lot of things. Just a
  362. 13:17few. Let me just name them. Let's say
  363. 13:19external location.
  364. 13:22External location is used whenever you
  365. 13:24want to connect your Databricks with
  366. 13:27you can say third-party cloud provider.
  367. 13:29Let's say your AWS anything because
  368. 13:31obviously Databricks is an independent
  369. 13:34platform and you can just connect it via
  370. 13:38Azure AWS anything. So you do that thing
  371. 13:42using external location. Like whenever
  372. 13:44you want to access the data. So
  373. 13:45anything.
  374. 13:46Right?
  375. 13:48You can even create the credentials.
  376. 13:52You can even create the external
  377. 13:53metadata. You can even create the
  378. 13:56recipients if you just want to share the
  379. 13:57data. You can even just do the clean
  380. 13:59rooms. They're like so many things which
  381. 14:01fall under this Unity Metastore.
  382. 14:04Unity Metastore. Okay.
  383. 14:06Let's say
  384. 14:07clean room. Clean room is basically the
  385. 14:09area where you if you have worked on
  386. 14:14that particular kind of project. Where
  387. 14:16what you can do?
  388. 14:18You or your organization can share some
  389. 14:20information, some data with outside
  390. 14:24um or you can say with any other
  391. 14:26organization and they can just
  392. 14:27collaborate on that particular thing
  393. 14:28together.
  394. 14:29Okay, good. So this is the concept of
  395. 14:32Unity Catalog and Unity Meta Store.
  396. 14:34When Databricks introduced Unity
  397. 14:37Catalog,
  398. 14:38the demand of Databricks actually
  399. 14:41started growing because organizations
  400. 14:43saw the benefit of it.
  401. 14:45Where they are not
  402. 14:47responsible to manage all of these
  403. 14:50things manually. We or you can say any
  404. 14:51organization get the all of these
  405. 14:53features by default.
  406. 14:55Make sense?
  407. 14:57Very good.
  408. 14:58This is the concept of Unity Catalog or
  409. 15:00basically Unity Catalog and Unity Meta
  410. 15:02Store. Whenever anyone asks you Unity
  411. 15:04Catalog, Unity Meta Store even if and
  412. 15:06not in like
  413. 15:08if if even anyone is not asking you
  414. 15:10anything still for your understanding as
  415. 15:12well, Unity Catalog and Unity Meta Store
  416. 15:14go hand in hand. But
  417. 15:17we just use the term Unity Catalog as
  418. 15:19the whole.
  419. 15:20Make sense? Okay. So even if you are
  420. 15:22just reading some documentation, if you
  421. 15:24just find Unity Catalog, you will just
  422. 15:26find this thing as well.
  423. 15:27Make sense?
  424. 15:28So what is Unity Catalog? Unity Catalog
  425. 15:31is the unified governance layer.
  426. 15:34Okay, simple one-liner answer. Unity
  427. 15:37Catalog is the unified data governance
  428. 15:39or basically governance layer for AI and
  429. 15:41data solutions.
  430. 15:43Simple, very good.
  431. 15:44So now let's do one thing. Let's also
  432. 15:47see all of these things and practice as
  433. 15:49well so that you can grasp the most out
  434. 15:52of all of these concepts. So now if you
  435. 15:54already have one Databricks account, you
  436. 15:56can just open that account. If you do
  437. 15:57not have one, do not worry. You do not
  438. 15:59even need to deploy a paid version
  439. 16:01because we get one free Databricks
  440. 16:04workspace directly from Databricks just
  441. 16:06for the learning purpose. So you can
  442. 16:09just create one free account there.
  443. 16:11Simply search Databricks free edition in
  444. 16:12your browser, hit enter.
  445. 16:15Click on this link and here
  446. 16:18simply expand this thing and you can
  447. 16:20just This is your Oh yeah, this is very
  448. 16:22important. So first of all, if you are
  449. 16:24just trying or you can say you you are
  450. 16:27just creating the Databricks account for
  451. 16:28the very first time, make sure that you
  452. 16:30are not creating account using the 14
  453. 16:32days free trial because you need to get
  454. 16:34the free edition. These are two things.
  455. 16:36One is like your free edition, second
  456. 16:38one is different. So click on get free
  457. 16:40edition and make sure you get something
  458. 16:43like this, free forever learning and
  459. 16:45blah blah blah. Then create your account
  460. 16:47because a lot of people come late, hey I
  461. 16:48only got 14 days trial. No, because you
  462. 16:51created the wrong account. So make sure
  463. 16:53that you have the account here and I
  464. 16:54already have one account here. So I will
  465. 16:56directly jump on to that particular
  466. 16:58account. So let me just open that.
  467. 17:00So this is my Databricks workspace and
  468. 17:02as you can see that this is the
  469. 17:04homepage, nothing special. So let me
  470. 17:06just take you to that location where I
  471. 17:08have all of the Unity catalogs created
  472. 17:10and I will also show you the Unity Meta
  473. 17:12Store. Do not worry. So as we know that
  474. 17:14we are using the Databricks free
  475. 17:16edition, we do not have full control
  476. 17:18over the Unity Meta Store, but we have
  477. 17:20some control over Unity catalog. Okay?
  478. 17:23So first of all, let's click on the
  479. 17:24catalog tab.
  480. 17:25And here you will see all of the things
  481. 17:29that you have for your catalogs. This is
  482. 17:31basically called catalog explorer. Okay?
  483. 17:34So first thing first, if you are using
  484. 17:36the Databricks for the first time, you
  485. 17:38might see only these two. One is
  486. 17:40workspace, second is system.
  487. 17:42These catalogs are created by me. Okay?
  488. 17:45So you can just totally ignore. If you
  489. 17:47have your own Unity catalogs, you will
  490. 17:49see that as well. And if you want to
  491. 17:51create a new one, it's very easy. What
  492. 17:53you can do, simply click on this plus
  493. 17:54button. And here you will see create a
  494. 17:56catalog option. Cool? So this catalog is
  495. 18:00the same catalog that we have recently
  496. 18:02discussed and this is nothing but
  497. 18:03basically your Unity catalog. Basically
  498. 18:05the catalog created under Unity Meta
  499. 18:07Store.
  500. 18:08Perfect. Now okay, this is the Unity
  501. 18:10catalog, but where is the Unity Meta
  502. 18:12Store? So if you want to access the
  503. 18:14Unity Meta Store, we need to go to the
  504. 18:16Databricks admin console. And Databricks
  505. 18:19admin console is not in our control when
  506. 18:21we are using Databricks free edition,
  507. 18:23okay? But we can still check like to
  508. 18:25which unity metastore my catalog is
  509. 18:27attached. So what I can do? I can just
  510. 18:29show you my let's say any catalog if I
  511. 18:31just create in front of you or even I
  512. 18:33can just show you this as well. Let's
  513. 18:34say asset bundles, okay?
  514. 18:36If I click on this catalog,
  515. 18:38I can click on the details and here
  516. 18:41these are like all of the basic basic
  517. 18:42details that I have for the catalog,
  518. 18:44some permissions, some policies and
  519. 18:47workspaces as well. Cool? This is like
  520. 18:49some some normal basic um your
  521. 18:52introduction.
  522. 18:54Then
  523. 18:55you can click on this settings button.
  524. 18:57Make sure that this catalog is selected,
  525. 18:59okay?
  526. 19:00Then click on this button and then you
  527. 19:02will see something called as metastore.
  528. 19:04Click here.
  529. 19:06This is the metastore which is created
  530. 19:09automatically by Databricks, okay? And
  531. 19:12it is hosted on AWS. I didn't select
  532. 19:15this thing. This is automatically
  533. 19:16created for me. So whenever I create any
  534. 19:19unity catalog or basically any catalog,
  535. 19:22this will automatically be
  536. 19:25attached under this metastore.
  537. 19:27Makes sense? That is why my unity
  538. 19:30catalog is enabled for this particular
  539. 19:32workspace,
  540. 19:33for this particular Databricks account.
  541. 19:36Cool? We can even go to account console,
  542. 19:38but we do not have permission to edit or
  543. 19:40to make some changes because obviously
  544. 19:42it is managed by the Databricks, okay?
  545. 19:45Then we have some permissions on this
  546. 19:47metastore and then we have some policies
  547. 19:50and obviously no allowed charge is there
  548. 19:52as I just mentioned that this is the
  549. 19:54free edition. So this is the way we can
  550. 19:55just actually explore the Databricks
  551. 19:58free edition, okay? And we'll be like
  552. 20:00keep on referring this Databricks free
  553. 20:02edition whenever you want to understand
  554. 20:04any concept related to it. Simple? Cool.
  555. 20:07So this was all about unity catalog and
  556. 20:08unity metastore. Now let's discuss the
  557. 20:11another concept which is called
  558. 20:13Databricks volume. So I already have the
  559. 20:15heading. Okay. Cool.
  560. 20:17So now let's talk about Databricks
  561. 20:18volumes. What are Databricks volumes and
  562. 20:20why every organization is like currently
  563. 20:23using and is like literally mad about
  564. 20:26Databricks volumes. Let me just tell
  565. 20:28you.
  566. 20:29In a nutshell, in a nutshell, Databricks
  567. 20:31volume is the way to govern the files.
  568. 20:35Just an example, the files.
  569. 20:38Make sense a little bit at least.
  570. 20:41So let say
  571. 20:42you have some files, okay?
  572. 20:44Let's first of all let's say you are
  573. 20:45using any cloud account. It can be AWS,
  574. 20:48it can be ADLS Gen 2 by Azure.
  575. 20:52And you have some let's say files.
  576. 20:55Any files. It can be CSV file, it can be
  577. 20:58Excel file.
  578. 20:59Let's say CSV file.
  579. 21:02Let's bring CSV.
  580. 21:04CSV,
  581. 21:05Parquet,
  582. 21:07JSON, any files.
  583. 21:09Cool.
  584. 21:10Now you tell me can you govern these
  585. 21:13files? Obviously no because these are
  586. 21:15sitting in cloud. These are not sitting
  587. 21:17in Databricks. But with Databricks
  588. 21:20volumes you can govern these files.
  589. 21:24Really? Yes. What you can do, what
  590. 21:26Databricks says
  591. 21:28Databricks says that you can register
  592. 21:31these files,
  593. 21:33okay?
  594. 21:34Under a special concept or basically
  595. 21:35special feature called
  596. 21:37volume.
  597. 21:38Okay?
  598. 21:39Once these files are attached or not
  599. 21:43files, you first of all register the
  600. 21:45folder itself and within that folder you
  601. 21:47can just save anything. Okay?
  602. 21:49So what you will do? You will connect
  603. 21:51this folder
  604. 21:52with this volume and then once it is
  605. 21:56connected then any user
  606. 21:59any user can query something like this.
  607. 22:01Let's say
  608. 22:02select a tricks from this file.
  609. 22:05Let's say like this using three level
  610. 22:07namespace obviously because you are
  611. 22:09governing this file using the catalog
  612. 22:11name, schema name and file name.
  613. 22:13Wow.
  614. 22:14Yes, you can do this thing.
  615. 22:17That means you can access the files
  616. 22:21same way you access the tables.
  617. 22:25This is one of the biggest advantage of
  618. 22:27data bricks volume and in the rise of
  619. 22:31the era where we are literally dumping
  620. 22:34the images um media content or you can
  621. 22:38say anything any file any unstructured
  622. 22:40data
  623. 22:42governing those things
  624. 22:44is actually very important and we can
  625. 22:45govern everything using the volumes.
  626. 22:48Makes sense? So that is why you see a
  627. 22:50major major rise of volumes and because
  628. 22:53we have created the free edition as well
  629. 22:55of our data bricks um free edition. So
  630. 22:58let's try to see that as well right now.
  631. 23:01So this is our data bricks okay and here
  632. 23:04if you just want to create the data
  633. 23:06bricks volumes it's very easy simply go
  634. 23:08to catalog and let's try to create a
  635. 23:11catalog
  636. 23:12we might be using it so let's say create
  637. 23:14a catalog and let say
  638. 23:17demo okay
  639. 23:18then simply say create. So this is the
  640. 23:20catalog that I have created within just
  641. 23:22a few seconds configure um nothing to
  642. 23:25configure so you can even ignore this
  643. 23:28thing so let's say next and save.
  644. 23:31So this is my demo catalog and I only
  645. 23:34have two schemas default and information
  646. 23:36schema. If I want to let's say create
  647. 23:39the volume inside this default schema I
  648. 23:41can click on create button and I will
  649. 23:43see something called as volume.
  650. 23:45Makes sense? Very good. Let me just
  651. 23:47click on volume and I can just type any
  652. 23:49name let's say
  653. 23:52my volume. Now I have two options
  654. 23:54managed volume or external volume. What
  655. 23:56is the difference? When you pick the
  656. 23:57managed volume
  657. 23:58whatever files you will be dumping okay
  658. 24:01will be just stored in the default
  659. 24:03storage location. In external volume you
  660. 24:06can just connect your third party cloud
  661. 24:08service providers and you can just
  662. 24:10access those files and basically govern
  663. 24:12those files easily.
  664. 24:13Makes sense? Good. So let's say manage
  665. 24:15volume and that's it and I you can even
  666. 24:17read this thing this is written here
  667. 24:19files are stored in location managed by
  668. 24:21Unity catalog okay files are stored in
  669. 24:24an external location that you configure.
  670. 24:27Cool. Now you can ask me which one is
  671. 24:28popular. So,
  672. 24:30whenever I want to govern my files which
  673. 24:33are not stored in the Unity catalogs
  674. 24:36location, then obviously I will just go
  675. 24:38with the external volume. But if I do
  676. 24:40not have like much stop and I can just
  677. 24:42directly access it via the Unity catalog
  678. 24:43location, I will just go with managed
  679. 24:45one. Simple.
  680. 24:47And whenever I'm just uploading some
  681. 24:48data
  682. 24:49on the fly, then obviously managed
  683. 24:51volume is the um go-to choice.
  684. 24:54Click on create
  685. 24:56and this is created. See?
  686. 24:58So now under this schema, I have this
  687. 25:00volume. The same way I have tables, I
  688. 25:03have views, everything. So this is my
  689. 25:05volume and now in this volume, which is
  690. 25:08the name of my volume, my volume, I can
  691. 25:10upload any data. I can just click on
  692. 25:12these three dots. I can say upload to
  693. 25:13volume and I can even create multiple
  694. 25:16directories.
  695. 25:18Makes sense? So let's say if I just
  696. 25:19upload any file, this file will be
  697. 25:22uploaded directly to my volume and I can
  698. 25:24access it the same way I access my
  699. 25:27table.
  700. 25:28Okay? This is the concept of volume.
  701. 25:31It's not very difficult, but this is new
  702. 25:35and let me tell you all of the modern
  703. 25:37data platforms are trying to implement
  704. 25:39this thing, Databricks volumes with
  705. 25:41obviously different different names. So
  706. 25:42yeah, this concept is very cool. I
  707. 25:44personally love it a lot. So now let's
  708. 25:46talk about another concept
  709. 25:48which is very very important
  710. 25:51in terms of modern Databricks.
  711. 25:54So it is called Databricks architecture,
  712. 25:57but
  713. 25:59not the traditional architecture,
  714. 26:01the
  715. 26:03modern architecture, which is also
  716. 26:05called as serverless architecture
  717. 26:07because
  718. 26:08Databricks is changed, so you need to
  719. 26:09understand that as well.
  720. 26:11First of all,
  721. 26:12let me tell you there are two types of
  722. 26:14architecture that we have. Okay? And
  723. 26:16which one we follow? We follow actually
  724. 26:18both, so you need to understand both.
  725. 26:20Okay?
  726. 26:22Architecture has two major things.
  727. 26:24The first one is
  728. 26:26control plane,
  729. 26:29second one is compute plane.
  730. 26:33Control plane and compute plane.
  731. 26:35What is control plane? Control plane is
  732. 26:38nothing but basically your um UI.
  733. 26:43It includes all of the backend services
  734. 26:45that Databricks manages. Your
  735. 26:48um profile section, your Databricks um
  736. 26:52UI, the entire UI.
  737. 26:54Okay?
  738. 26:56Everything
  739. 26:57which is managed by Databricks.
  740. 26:59Everything.
  741. 27:01And here everything means the backend
  742. 27:03services only.
  743. 27:04Backend services means like all of the
  744. 27:06APIs, all of the things that you just
  745. 27:08use your mouse. See?
  746. 27:10So all of this thing is managed. This is
  747. 27:12a kind of application.
  748. 27:14This thing is managed by Databricks. So
  749. 27:16all of these things come under control
  750. 27:18plane.
  751. 27:19Makes sense? Whatever we see only in the
  752. 27:21Databricks, not the cloud.
  753. 27:24Okay?
  754. 27:25This entire application comes under
  755. 27:27control plane.
  756. 27:29Simple? Second thing, which is the most
  757. 27:31important thing, compute plane.
  758. 27:33Because whatever we are doing in
  759. 27:34Databricks, we are using compute
  760. 27:38to process the data.
  761. 27:40Right?
  762. 27:41So compute plane is the area where my
  763. 27:43data will be processed
  764. 27:45or where your data will be processed.
  765. 27:48Where here where what is very important,
  766. 27:50where it will be processed.
  767. 27:53So here the compute actually creates
  768. 27:57that distinction. Like whether your
  769. 27:59architecture is your classic
  770. 28:02architecture or serverless architecture.
  771. 28:04Because we have two types of compute.
  772. 28:07Classic compute and serverless compute.
  773. 28:10Oh.
  774. 28:11That is why we have two different
  775. 28:13architectures just because of this
  776. 28:15compute. Because control is control.
  777. 28:17Control is same. See? This application
  778. 28:19is same, right? This UI is same.
  779. 28:22There's no change in that. Okay? They
  780. 28:25will not say, hey, you need to host this
  781. 28:26thing in your cloud. No.
  782. 28:28So this is same. The major difference
  783. 28:31that we see is on the architect the
  784. 28:33architect in the architecture we see on
  785. 28:34the compute side. Okay, so let's talk
  786. 28:36about the very first one which is my
  787. 28:38classic type or you can say classic.
  788. 28:43Okay, what do we have inside this thing?
  789. 28:45So we have control plane. Let me first
  790. 28:48of all draw the
  791. 28:49control plane which is the
  792. 28:52sure sure thing. Okay.
  793. 28:54So let's say this is my Databricks
  794. 28:56account
  795. 28:57because this location is very important
  796. 28:59like where each component will reside.
  797. 29:01This is the core thing. So first of all
  798. 29:03I will be having my Databricks account
  799. 29:05that you just saw.
  800. 29:06Within that I have control plane.
  801. 29:09Okay.
  802. 29:11This is my control plane.
  803. 29:14Makes sense? Within the control plane I
  804. 29:16have the application, I have the Unity
  805. 29:19Catalog, I have the
  806. 29:21everything that I just see on the UI.
  807. 29:23Okay. Here you can just even write this
  808. 29:26thing. Let's say
  809. 29:28this particular thing. Okay.
  810. 29:31Databricks
  811. 29:32Databricks application that we see or I
  812. 29:35can just pick this one. This is better.
  813. 29:37See, this is my control plane.
  814. 29:40Cool.
  815. 29:41So that you can just understand it
  816. 29:43obviously.
  817. 29:44So this is my control plane.
  818. 29:45Now within my Databricks account
  819. 29:48I have the cloud account as well where I
  820. 29:52will be having my what? Resources.
  821. 29:55Right? Okay.
  822. 29:56So now I will be having my cloud
  823. 29:58account. Okay or even my resources as
  824. 30:01well. Not a big deal. So let's say cloud
  825. 30:02account.
  826. 30:04So let's say this is my cloud account.
  827. 30:08So in this cloud account
  828. 30:10I will be having first of all my
  829. 30:12resources.
  830. 30:13It can be inside cloud or outside cloud.
  831. 30:15So let's say my resources, some
  832. 30:17databases
  833. 30:21anything. Right? So let's say this
  834. 30:23database is there or let's create a
  835. 30:24different one here for resources.
  836. 30:27It will be easier for you. So let say
  837. 30:29this is these are my resources. Okay.
  838. 30:34Cool. These are my resources. Database
  839. 30:37one, two, three, blah, blah, blah, some
  840. 30:38Kafka, anything. Cool.
  841. 30:41Okay. Cool.
  842. 30:43And these are my resources. This can be
  843. 30:45in cloud. This can be on premise as
  844. 30:47well. That's why I just created a
  845. 30:48separate one. But now the main thing is
  846. 30:50all of the compute
  847. 30:52that I am just creating within this
  848. 30:53cloud will be or basically within this
  849. 30:56Databricks account will be in the cloud.
  850. 30:58Compute means my machines,
  851. 31:00my VMs
  852. 31:02that I'll be just using to process.
  853. 31:03Okay. These are my compute.
  854. 31:07Oh.
  855. 31:08This will reside on my cloud account.
  856. 31:11Cool.
  857. 31:12Very good.
  858. 31:13Along with that, I will also have one
  859. 31:14more thing, workspace storage bucket
  860. 31:18or you can say workspace storage
  861. 31:19account. So whatever we just create in
  862. 31:21the workspace in the Databricks, we also
  863. 31:23get one storage account as well.
  864. 31:26Makes sense?
  865. 31:29Understand this thing. This is very,
  866. 31:30very important. I know this is like a
  867. 31:32little bit complex. That is why I'm just
  868. 31:33covering this concept under this
  869. 31:35particular resource.
  870. 31:37So this is everything,
  871. 31:38right? This is my traditional
  872. 31:41traditional architecture. This is
  873. 31:43connected to this one
  874. 31:44and obviously compute is connected to
  875. 31:46this one
  876. 31:47and that's it. And there is one more
  877. 31:49thing
  878. 31:49which is compute plane. You will say
  879. 31:51Anshul, the compute plane is here.
  880. 31:53We just created this compute plane here.
  881. 31:56There's one more compute
  882. 31:59because when serverless compute was
  883. 32:01newly added, okay, then we got compute
  884. 32:04in the workspace as well, basically in
  885. 32:06the Databricks
  886. 32:08account when it was newly added,
  887. 32:10obviously.
  888. 32:11And here I can just connect this compute
  889. 32:13with the resources because compute needs
  890. 32:15to talk to the resource, right? And
  891. 32:17obviously this will also be connected.
  892. 32:18This is your classic example.
  893. 32:21But then
  894. 32:22in the serverless
  895. 32:24you can now, I think, imagine what would
  896. 32:26have happened.
  897. 32:28I think so.
  898. 32:30So first of all, let me just write this
  899. 32:31is my serverless compute.
  900. 32:33Okay.
  901. 32:34Yeah, you will just understand
  902. 32:35serverless compute. So now what will
  903. 32:36happen in this particular thing?
  904. 32:38This piece will remain as it is.
  905. 32:41As it is, because I need to have
  906. 32:43serverless compute, I need to have my
  907. 32:45control plane as it is. But
  908. 32:47I do not even need this cloud thing now.
  909. 32:49I just need my resources. That is it.
  910. 32:53That is it. I do not need anything else.
  911. 32:57I just need these resources and that's
  912. 32:59it.
  913. 33:00I hope it makes sense.
  914. 33:03This is the entire game.
  915. 33:04Why?
  916. 33:05Because here I do not need cloud
  917. 33:08compute. I will only use the serverless
  918. 33:10compute.
  919. 33:11That is the whole story.
  920. 33:14That is the whole story. Now
  921. 33:17these resources
  922. 33:19can reside in your cloud account as
  923. 33:20well, can reside outside as well.
  924. 33:23Simple thing, obviously. So you can even
  925. 33:25write here cloud
  926. 33:29or not. It doesn't matter.
  927. 33:31It doesn't matter.
  928. 33:33Because
  929. 33:34you can use cloud data as well and you
  930. 33:36can even use some, you can say obviously
  931. 33:37on-prem data as well. But usually we
  932. 33:39connect our data with the cloud.
  933. 33:42But you do not need this particular
  934. 33:43compute. Oh, okay, compute is not
  935. 33:46required. What about this um workspace
  936. 33:48storage account?
  937. 33:50Because obviously we need to store our
  938. 33:51data. So whenever we use this kind of
  939. 33:54architecture, we connect our workspace
  940. 33:57with the storage account, default
  941. 33:58storage account.
  942. 34:01This is the difference. If you
  943. 34:02understood this um understood this
  944. 34:04particular difference, you can actually
  945. 34:07understand the new Databricks.
  946. 34:09But now
  947. 34:11most of the organizations are using
  948. 34:13both. Really yes, because they built a
  949. 34:16lot of solutions using classic compute.
  950. 34:19They are doing the migration from
  951. 34:21classic compute to serverless compute
  952. 34:24and they are slowly moving towards
  953. 34:26serverless compute because serverless
  954. 34:27compute solves a lot of problems. So
  955. 34:29what is the difference between
  956. 34:30serverless and
  957. 34:31um or serverless compute and classic
  958. 34:32compute? So see,
  959. 34:34in the classic compute you need to
  960. 34:36decide the number of machines first of
  961. 34:38all.
  962. 34:39You need to decide like how scaling will
  963. 34:43take place like um on [clears throat]
  964. 34:45what load the
  965. 34:47new machine should be added, on what
  966. 34:49load the machine should be reduced,
  967. 34:51everything will be decided by you. But
  968. 34:53in serverless compute you do not need to
  969. 34:55do anything. You simply attach the
  970. 34:56compute.
  971. 34:57DataBricks will automatically
  972. 35:00scale up and scale down your resources.
  973. 35:04This is the biggest advantage. You do
  974. 35:05not even need to take care of the
  975. 35:08decisions
  976. 35:10that you take during you can say scale
  977. 35:12up, scale down scenarios.
  978. 35:14This is the major advantage and
  979. 35:16obviously when you do not have that
  980. 35:18particular boilerplate stuff in your
  981. 35:20plate you can just focus on different
  982. 35:22things, right?
  983. 35:23This is the major advantage of using
  984. 35:25serverless compute.
  985. 35:27That is why a lot of lot a lot of teams
  986. 35:30are like moving towards
  987. 35:33your serverless compute.
  988. 35:34I hope this architecture is crystal
  989. 35:36clear and within this architecture we
  990. 35:37have discussed compute concept as well.
  991. 35:40We have just discussed so many things so
  992. 35:41because this concept is very clear um
  993. 35:43important that you need to clear. Okay?
  994. 35:45Very good. So so so so so it's Ansh
  995. 35:47Lamba. So now I just want to remind you
  996. 35:50that please hit the subscribe button
  997. 35:51because it takes a lot of efforts to
  998. 35:54create these kinds of masterclasses and
  999. 35:56providing it for free. So quickly hit
  1000. 35:58the subscribe button and let's continue
  1001. 36:00with the masterclass. So the next
  1002. 36:02concept that we need to learn, we need
  1003. 36:05to understand, we need to master is
  1004. 36:06Delta Tables and in the modern data
  1005. 36:09engineering Delta Table or you can say
  1006. 36:12similar formats are non-negotiable. Ansh
  1007. 36:15Lamba, what do you mean by similar
  1008. 36:16formats? So
  1009. 36:18Delta Table
  1010. 36:19is basically you can say the bigger
  1011. 36:22umbrella of something called as open
  1012. 36:25table format. Okay?
  1013. 36:28Delta Tables go hand in hand with
  1014. 36:31DataBricks but Delta Tables or basically
  1015. 36:33Delta Lake is not the only solution we
  1016. 36:36have. We have Apache Iceberg as well. So
  1017. 36:39let me just show you. So one is
  1018. 36:42Delta Lake or basically
  1019. 36:44see first of all, do not get confused
  1020. 36:46between a data Lake and Delta Lake.
  1021. 36:48Delta Lake is nothing but just the name
  1022. 36:51we use for Delta tables. Okay? That is
  1023. 36:53why I use the word Delta table. But
  1024. 36:55wherever you see Delta Lake, it is a
  1025. 36:58Delta table. Okay? Do not worry. Do not
  1026. 37:00get confused. So this is my Delta table.
  1027. 37:03The second thing is
  1028. 37:05Apache
  1029. 37:07Iceberg. Okay?
  1030. 37:09Let's use this one. Cool. So these are
  1031. 37:11the two most popular solutions we have.
  1032. 37:13Okay? But whenever we just talk about
  1033. 37:15Databricks, we talk more about Delta
  1034. 37:18tables because Delta Lake or basically
  1035. 37:20Delta tables were created by the same
  1036. 37:22team. Okay? So that is why.
  1037. 37:24So what what is a Delta table? What is a
  1038. 37:26Delta table? So
  1039. 37:27before Delta table, before you can say
  1040. 37:30the concept of Lakehouse,
  1041. 37:32which was introduced I think couple of
  1042. 37:34years back.
  1043. 37:35So what we were doing or what data
  1044. 37:37engineers were doing, what every data
  1045. 37:39engineer was doing. So let's say I have
  1046. 37:43parquet file, which is a very popular
  1047. 37:45file
  1048. 37:46for big data processing. Right? Very
  1049. 37:47good.
  1050. 37:49We were building external tables on top
  1051. 37:51of it. Okay?
  1052. 37:53Tables.
  1053. 37:55Just tables. So we were creating parquet
  1054. 37:57table.
  1055. 37:58Like we have the file, right? And we
  1056. 38:00were just registering the metadata of
  1057. 38:01that file and we were just storing the
  1058. 38:04metadata under a metastore and that was
  1059. 38:06our table. Simple.
  1060. 38:08But what Delta table or basically Delta
  1061. 38:11Lake provided to us is they said like,
  1062. 38:14hey, you cannot do this thing. Why?
  1063. 38:17Why?
  1064. 38:18Why why why we cannot do this thing? You
  1065. 38:20can. No one can stop you, but this does
  1066. 38:23not give you features like acid,
  1067. 38:27atomicity, consistency, isolation,
  1068. 38:29durability.
  1069. 38:31These are the you can say
  1070. 38:32non-negotiables whenever you want to
  1071. 38:34work with structured data.
  1072. 38:37You do not get something called as
  1073. 38:38commits and rollbacks. Okay?
  1074. 38:41Or we also
  1075. 38:43call it as you can say um time traveling
  1076. 38:47and Delta Lake, okay?
  1077. 38:48So all of these features were not there.
  1078. 38:50We didn't have indexes, we didn't have
  1079. 38:52you can say some kind of optimization
  1080. 38:55that we just apply on top of our data
  1081. 38:57for better search results. So we had
  1082. 38:59nothing. We had nothing. We just had the
  1083. 39:02raw parquet files and that's it.
  1084. 39:04Then this team created this thing. So
  1085. 39:07they said we will keep your data in the
  1086. 39:09parquet files for sure because parquet
  1087. 39:11is one of the best solutions out there
  1088. 39:13for big data um storage, okay?
  1089. 39:16They said we will just keep this thing
  1090. 39:17as it is, but on top of this thing, on
  1091. 39:20top of these files, we will create a
  1092. 39:22folder,
  1093. 39:23a special folder called Delta Log.
  1094. 39:26Okay?
  1095. 39:28Delta Log. This Delta Log is the heart
  1096. 39:32of this entire Delta Lake because this
  1097. 39:34stores all of the transactions, all of
  1098. 39:37the information about transactions, all
  1099. 39:40of the metadata.
  1100. 39:42And because of this particular Delta
  1101. 39:44Log, we also get an amazing feature
  1102. 39:46which is called
  1103. 39:48schema on write.
  1104. 39:51What is schema on write? Schema on write
  1105. 39:53means schema will be tested and
  1106. 39:56validated before it writes your data.
  1107. 39:59But with basic raw parquet files, basic
  1108. 40:02raw data lake, we do not get this
  1109. 40:04feature. So we get everything when we
  1110. 40:07add this Delta Log on top of it. And
  1111. 40:09within this Delta Log, if I just open
  1112. 40:11this Delta Log folder, what I see?
  1113. 40:13I see JSON files. Basically all of the
  1114. 40:16transactions will be written in the JSON
  1115. 40:18files.
  1116. 40:20There will be one more type of file, CRC
  1117. 40:21files. This is not directly related to
  1118. 40:23your Delta Lake, but it is a kind of you
  1119. 40:25can say another type of file that we
  1120. 40:27get. It is called I think cyclic
  1121. 40:29redundant checkpoint file, something
  1122. 40:30like that, okay? So this is for that
  1123. 40:32particular purpose. The major file is
  1124. 40:34JSON file where we store our all of the
  1125. 40:36metadata, all of the schema, all of the
  1126. 40:39transactions, data which is added, data
  1127. 40:42which is deleted, everything within this
  1128. 40:43particular JSON file, okay? And we keep
  1129. 40:46on adding JSON files as our transactions
  1130. 40:48grow, simple.
  1131. 40:50Simple? Very good. So this is the
  1132. 40:51concept of Delta Table. So let's try to
  1133. 40:53see this thing practically as well.
  1134. 40:55That is how you learn by doing it. And
  1135. 40:58that is why I created your free
  1136. 41:00Databricks account. Okay? Cool. So now
  1137. 41:02what I will do
  1138. 41:04I will create a new schema. Let's try to
  1139. 41:07or let's use default schema. It's fine.
  1140. 41:09Let's use default schema. Click on this
  1141. 41:10default schema
  1142. 41:12and click on create. And this time do
  1143. 41:14not pick volume, pick table.
  1144. 41:16Okay?
  1145. 41:17And here it will ask me that you can
  1146. 41:19even dump your
  1147. 41:21local file
  1148. 41:23which is one way. Second, you can even
  1149. 41:26pick data from the volume. The third is
  1150. 41:28you can even connect your Databricks to
  1151. 41:30AWS S3 to upload the data. But just for
  1152. 41:33the simplicity
  1153. 41:35I will just upload this file. It's
  1154. 41:37called orders. And do not worry. I will
  1155. 41:39just provide all of the data that I'm
  1156. 41:41just using with this tutorial in my
  1157. 41:44GitHub repo link. Do not need to worry.
  1158. 41:45But
  1159. 41:47you can use any file. Okay? Here I've
  1160. 41:49just used orders file. You can just use
  1161. 41:50any file. Okay? And as you can see this
  1162. 41:53preview is here. And I can see the data
  1163. 41:55looks fine. Perfect.
  1164. 41:57And then it will simply ask me to pick
  1165. 41:59the catalog name. I want to create this
  1166. 42:01table in the demo catalog.
  1167. 42:03And schema name I want to pick is
  1168. 42:05default. I can even create a new schema
  1169. 42:07right here as well if I want to. But I
  1170. 42:09want to keep
  1171. 42:11it under default. I'm good with that.
  1172. 42:12Okay? Cool. Then I can click on create
  1173. 42:14table.
  1174. 42:16So do you know what will happen?
  1175. 42:18Now my CSV file that I uploaded is of
  1176. 42:22CSV format. Right?
  1177. 42:24This will be automatically converted
  1178. 42:26into a Delta table.
  1179. 42:28Automatically. Yes.
  1180. 42:29Automatically. And the data type, like
  1181. 42:33basically the file type
  1182. 42:35will be of Parquet because in the Delta
  1183. 42:37Lake we always store our data in the
  1184. 42:39Parquet file along with the
  1185. 42:42that Delta log.
  1186. 42:43Make sense? Very good. So this is my
  1187. 42:46data. I think this is ready and I can
  1188. 42:48see under the tables I have orders
  1189. 42:49table. And if I just scroll down I can
  1190. 42:51see the data source is delta.
  1191. 42:54I told you, right? Because this is a
  1192. 42:57delta table. This is not a CSV table.
  1193. 43:00Very good. And this is a managed table
  1194. 43:02because I am not storing my data in a
  1195. 43:05separate cloud account. I am literally
  1196. 43:07dumping the data within the Databricks.
  1197. 43:09Cool?
  1198. 43:10Very good.
  1199. 43:11That is all.
  1200. 43:12That is all. Now if you just want to
  1201. 43:14query this data, you can even come here,
  1202. 43:16click on sample data just to see the
  1203. 43:18sample of your entire file. It will just
  1204. 43:21show you like this.
  1205. 43:22If you want to query it using SQL, you
  1206. 43:24can even go to SQL editor or you can
  1207. 43:26even go to notebook and you can just
  1208. 43:28query this thing. It's very simple. You
  1209. 43:30can, let say, click on workspace. Let's
  1210. 43:32try to do it and let me just delete all
  1211. 43:35the stuff that I have here.
  1212. 43:38What what do you want, bro? Do you want
  1213. 43:41Perform actions for bulk action. Right
  1214. 43:43click on the items. Wow.
  1215. 43:46They keep on just changing this UI
  1216. 43:47stuff. I don't know why.
  1217. 43:49So now let me just create a new folder
  1218. 43:50where I'll be just putting everything
  1219. 43:52that I'm just using here. So let say
  1220. 43:55um
  1221. 43:57demo. Okay.
  1222. 43:59And I will also attach one special file
  1223. 44:02which is called
  1224. 44:05dot
  1225. 44:06DBC file.
  1226. 44:08You cannot open this file by literally
  1227. 44:10double clicking on it. A lot of people
  1228. 44:11say, um Ansh, you uploaded dot DBC file.
  1229. 44:14I am not able to open that file because
  1230. 44:16that file will be opened only by
  1231. 44:19Databricks. So how you can just um take
  1232. 44:21advantage of that file?
  1233. 44:22So you can come here
  1234. 44:24and then you can just click on, let say,
  1235. 44:27upload. Um
  1236. 44:30where is my folder first of all? Okay,
  1237. 44:31this is my folder, demo folder.
  1238. 44:33And then you can just click on these
  1239. 44:34three dots. Then you can just click on
  1240. 44:35import and then you can add that file.
  1241. 44:38What will what will happen after that?
  1242. 44:40You will see all of the resources like
  1243. 44:42notebooks, scripts, anything that I will
  1244. 44:44have in that file will automatically be
  1245. 44:47imported here. Okay? But do not try to
  1246. 44:48double click on it and open it.
  1247. 44:50So let me just create a new notebook
  1248. 44:52here. Click on new notebook and that's
  1249. 44:54it.
  1250. 44:55And let me just rename it. Let me say
  1251. 44:58query.
  1252. 45:00One query and let's say if I just want
  1253. 45:02to query the data, I will simply select
  1254. 45:04asterisk from because I can just use SQL
  1255. 45:06as well here. I will simply say um demo
  1256. 45:12demo dot default dot orders.
  1257. 45:14Remember I have to use three level
  1258. 45:17namespace, right? Catalog name, schema
  1259. 45:19name and then table name.
  1260. 45:21Simple.
  1261. 45:22You can just run like this
  1262. 45:24and it will just show me all of the
  1263. 45:25things and it will automatically use the
  1264. 45:28serverless compute as you can see here.
  1265. 45:30It has automatically picked this thing
  1266. 45:31because with the Databricks free edition
  1267. 45:33we always get one free serverless
  1268. 45:35compute that we can use to run our
  1269. 45:37queries.
  1270. 45:38Cool. You do not need to create one
  1271. 45:40because it is already there so you can
  1272. 45:41just take advantage of it. So I think
  1273. 45:44the task is done and I can see the data
  1274. 45:46is here. That's how you can just query
  1275. 45:47it,
  1276. 45:48right? And if you just want to see much
  1277. 45:51more details about um delta table, you
  1278. 45:54can simply write
  1279. 45:56describe
  1280. 45:58and then table name. Let's say
  1281. 46:00demo
  1282. 46:02dot
  1283. 46:04default dot orders.
  1284. 46:08And let me just write percentage SQL.
  1285. 46:12Cool. So this will simply describe the
  1286. 46:14table and that's it. That this is my
  1287. 46:16table name, this is everything and I can
  1288. 46:17even say describe
  1289. 46:20um
  1290. 46:21detail and then it will get me some more
  1291. 46:25information about like okay what um like
  1292. 46:27how it was created, some description,
  1293. 46:29everything. Okay?
  1294. 46:31I can even run one more command which is
  1295. 46:34history. It will tell me like what
  1296. 46:36actually happened with all of the
  1297. 46:38versions. So it will simply display like
  1298. 46:39version zero table created. If I add
  1299. 46:42more data into it, it will create
  1300. 46:43version one. If I just let say delete
  1301. 46:45anything, it will create version two. So
  1302. 46:47that's how it keeps on creating the
  1303. 46:49versions within my table which helps me
  1304. 46:51to perform time traveling on top of my
  1305. 46:53data.
  1306. 46:54Oh, yeah. So you never you never lose
  1307. 46:58any version until and unless you
  1308. 47:00intentionally want to, but you can
  1309. 47:02anytime time travel back to any specific
  1310. 47:05version of the table.
  1311. 47:07Makes sense? That is the biggest
  1312. 47:08advantage of the Delta table.
  1313. 47:10I hope it makes sense.
  1314. 47:12Very good. So this is all about Delta
  1315. 47:14tables and I hope this concept is
  1316. 47:16crystal crystal
  1317. 47:18crystal clear. Okay.
  1318. 47:20So what is the next concept that we need
  1319. 47:23to understand? That is a very good
  1320. 47:24point.
  1321. 47:25So what should be covered? Let me just
  1322. 47:27see my list. So the next topic, next
  1323. 47:30concept that we are just trying to
  1324. 47:32understand is Lake Flow Connect.
  1325. 47:34And you know what? This is so important.
  1326. 47:37Why? Why so important? And first of all,
  1327. 47:39what is this Lake Flow Connect?
  1328. 47:41Lake Flow Connect is the way to ingest
  1329. 47:45your data to
  1330. 47:47Databricks. Not to basically,
  1331. 47:50you can say yeah, kind of to because now
  1332. 47:52you can even store the data as well in
  1333. 47:53the Databricks because Databricks has
  1334. 47:55their own managed storage accounts. So
  1335. 47:57let's say you have
  1336. 47:59data in
  1337. 48:01PostgreSQL database.
  1338. 48:02Just for an example.
  1339. 48:04Let's say you have the data in the S3
  1340. 48:06bucket. Just for an example. Let's say
  1341. 48:09you have data in any kind of message
  1342. 48:11queue, let's say Kafka.
  1343. 48:14Just for an example. So you have so many
  1344. 48:17sources, right? So many sources.
  1345. 48:19How will you ingest the data in the
  1346. 48:21Databricks?
  1347. 48:23That is the point. That is the point.
  1348. 48:26Now when Databricks, I told you
  1349. 48:29initially Databricks was only about
  1350. 48:31managed Apache Spark. So how people were
  1351. 48:34ingesting the data?
  1352. 48:35People were ingesting the data using the
  1353. 48:37Spark APIs, basically Spark connectors,
  1354. 48:39raw Apache Spark connectors.
  1355. 48:41People still use that option. For
  1356. 48:43example, if they want to ingest the data
  1357. 48:45using PostgreSQL, they create the JDBC
  1358. 48:47connection.
  1359. 48:48If they want to pull the data from AWS
  1360. 48:50S3, they still use the, you can say
  1361. 48:52Spark API to read the data. If they just
  1362. 48:55want to pull the data from Kafka, they
  1363. 48:57still just create that particular
  1364. 48:58connection. But
  1365. 49:00but
  1366. 49:01with the course of time, Databricks also
  1367. 49:04created some kind of managed connectors
  1368. 49:06that you can leverage along with the
  1369. 49:09code.
  1370. 49:10Databricks is not saying that you do not
  1371. 49:11need to use code. You can still use
  1372. 49:13code, but Databricks created an umbrella
  1373. 49:16of lake flow connect
  1374. 49:18where you have your code and your
  1375. 49:20managed connectors as well.
  1376. 49:22Why? Because see,
  1377. 49:24if you have used any good integration
  1378. 49:27tool, and let me just take an example of
  1379. 49:29Azure ecosystem. So Azure has a very
  1380. 49:31good data integration tool which is
  1381. 49:34called Azure Data Factory.
  1382. 49:36They provide you managed services to
  1383. 49:38integrate the data from hundreds of
  1384. 49:40sources.
  1385. 49:41Data bricks in the beginning was not
  1386. 49:44very mature enough to provide this
  1387. 49:45service. So Databricks actually welcomed
  1388. 49:49one service called Five Tran.
  1389. 49:52I do not have logo for that. So Five
  1390. 49:54Tran was very very active on Databricks
  1391. 49:56platform where Five Tran Five Tran is
  1392. 49:58another very popular data integration
  1393. 50:00service where you can connect to the
  1394. 50:02hundreds of sources, right? So Five Tran
  1395. 50:05was acting as a kind of layer for that.
  1396. 50:07But now Databricks has created their own
  1397. 50:10layer as well and they have introduced
  1398. 50:12so many connectors and they are keep on
  1399. 50:13adding more and more and more.
  1400. 50:15I know you are really really excited. So
  1401. 50:16let me just give you a glimpse of it.
  1402. 50:18Then I will just go deeper inside this
  1403. 50:20topic because this is very very very
  1404. 50:22important. So let me just show you.
  1405. 50:25So this is my Databricks account
  1406. 50:27and here you can go to let's say data
  1407. 50:30ingestion. Here if you do not see this
  1408. 50:32data engineering tab, do not worry.
  1409. 50:34Simply click on plus new and here you
  1410. 50:36will just see more and then you will
  1411. 50:38just find the data engineering here as
  1412. 50:39well. Do not worry.
  1413. 50:41So let me just click on data engineering
  1414. 50:42and then data ingestion.
  1415. 50:44See?
  1416. 50:45So here I have some files option
  1417. 50:48which we have already seen how to create
  1418. 50:50a table using file. We can upload the
  1419. 50:52file. We used this thing just now,
  1420. 50:54right? So this is one of the connectors.
  1421. 50:56We can even upload data directly to the
  1422. 50:58volume, another kind of connector. But
  1423. 51:00I'm talking about these data bricks
  1424. 51:02connectors. See, I have so many
  1425. 51:05connectors available that I can use.
  1426. 51:07Some are in preview, some are generally
  1427. 51:10available and now they are just keep on
  1428. 51:12adding more and more and more. All of
  1429. 51:14the major or most popular, see Apache
  1430. 51:17Kafka is already there now. So all of
  1431. 51:20the popular
  1432. 51:21sources are there
  1433. 51:23that you can just use to pull your data.
  1434. 51:25Wow, the list is really really big now
  1435. 51:26because last time when I just saw it was
  1436. 51:28like
  1437. 51:29uh I would say half of it. Obviously
  1438. 51:31like there were so many in preview, but
  1439. 51:32they have removed the preview tag from
  1440. 51:35so many services. Earlier I remember
  1441. 51:37only 1 2 3 4 5 6 or 7 8 services were
  1442. 51:42without preview, but now they are just
  1443. 51:44testing it and they are just improving
  1444. 51:46it. So all of these services, all of
  1445. 51:48these connectors are there.
  1446. 51:50Makes sense? And now if I just scroll
  1447. 51:51down, these are the community and the
  1448. 51:54custom connectors. These are either
  1449. 51:56developed by community or maybe
  1450. 51:58third-party services like FiveTran,
  1451. 52:00right? So these are uh FiveTran
  1452. 52:02connectors are here, partner connectors.
  1453. 52:04See, FiveTran integration. Earlier
  1454. 52:06FiveTran had a dedicated tab here. So
  1455. 52:09let me just click on it and you will see
  1456. 52:11a long list, but now obviously they have
  1457. 52:13just
  1458. 52:14deprioritized it because now they have
  1459. 52:16just their own thing. So let me just go
  1460. 52:18here, data integration integration.
  1461. 52:20Perfect. So these are all of the
  1462. 52:22services. Now you do not need to write
  1463. 52:24the code from scratch to pull the data
  1464. 52:26from these sources and you can directly
  1465. 52:28start loading the data from these
  1466. 52:30services. S3, foreign catalog, open
  1467. 52:32sharing, Salesforce, SQL Server,
  1468. 52:34everything is there. Let me just show
  1469. 52:36you one simple example that you can use.
  1470. 52:37Okay, let's say SQL Server.
  1471. 52:40So here I already have some connection
  1472. 52:42because I was just working with these
  1473. 52:44this particular data bricks integration
  1474. 52:45to create my projects, right? Data
  1475. 52:47engineering projects for obviously
  1476. 52:48YouTube. So I just created one with AWS
  1477. 52:52and one with agent database. So yeah. So
  1478. 52:54what you can do, let me just show you
  1479. 52:56one quickly. So you can just create a
  1480. 52:57connection and what you need to do.
  1481. 52:59First of all, it will ask you how you
  1482. 53:01want to authenticate yourself.
  1483. 53:04I usually pick username and password
  1484. 53:05whenever I'm just building the quick
  1485. 53:07tutorial. So you can here pick the
  1486. 53:08connection name. Let's say test.
  1487. 53:11Host is obviously the server where your
  1488. 53:14SQL server is hosted. So you can simply
  1489. 53:17type here, let's say XYZ, username,
  1490. 53:20password, right? And port usually
  1491. 53:23whenever you are just connecting to SQL
  1492. 53:24server, it is like 1433. Then create
  1493. 53:27connection or let's say test connection.
  1494. 53:29You can say advanced settings and then
  1495. 53:30create connection.
  1496. 53:31It will create the connection for you.
  1497. 53:33See test. It is there.
  1498. 53:35That is so so so easy.
  1499. 53:38Then what you can do with that?
  1500. 53:40You can
  1501. 53:41start ingesting your data directly.
  1502. 53:44Really? Yeah.
  1503. 53:45You can just um click on data ingestion,
  1504. 53:48which is here, right? And then let's say
  1505. 53:50if I just want to use AWS connection
  1506. 53:53because I know this is like the legit
  1507. 53:55one. So here you can see the URL for
  1508. 53:57that, host for that, and everything is
  1509. 53:59there.
  1510. 54:00Oh, and now if I just want to create the
  1511. 54:02ingestion pipeline with that, ingestion
  1512. 54:04pipeline means if I want to ingest the
  1513. 54:05data, I can directly click here
  1514. 54:07and then it will simply ask me what type
  1515. 54:10of ingestion you want to perform. These
  1516. 54:12are some advanced top that I will be
  1517. 54:14just discussing right now. Okay? So
  1518. 54:16let's try to talk about it. So we got
  1519. 54:19some taste of Lake Flow Connect. Lake
  1520. 54:21Flow Connect is the area which we use to
  1521. 54:24ingest the data within our data bricks.
  1522. 54:26Simple, very good.
  1523. 54:28Now
  1524. 54:29let's talk about some inner areas which
  1525. 54:31comes under Lake Flow Connect, but
  1526. 54:33I like to talk about it independently
  1527. 54:35because these are like very detailed
  1528. 54:36ones.
  1529. 54:37First of all, we have database
  1530. 54:39connectors.
  1531. 54:42Okay.
  1532. 54:43What are database connectors? As we just
  1533. 54:45saw, we have popular popular databases
  1534. 54:47like MySQL, MS SQL, PostgreSQL,
  1535. 54:51anything.
  1536. 54:52Now the beauty of these connectors is
  1537. 54:54why I just created a different category
  1538. 54:56of concept for this because you need to
  1539. 54:58understand one concept. Let's say let
  1540. 55:01let's pick um MS SQL server.
  1541. 55:04Do we have MS SQL server? Uh yeah.
  1542. 55:08Let's say this is SQL database.
  1543. 55:09So whenever we perform any data
  1544. 55:11engineering task on top of a database,
  1545. 55:14we perform one thing which is
  1546. 55:17non-negotiable.
  1547. 55:19This is incremental loading.
  1548. 55:23Okay.
  1549. 55:24Incremental loading.
  1550. 55:27Or you can say incremental ingestion. If
  1551. 55:28we want to perform incremental loading
  1552. 55:30or incremental ingestion,
  1553. 55:32we have to
  1554. 55:34take care of the CDC manually. CDC means
  1555. 55:37change data capture. Because what
  1556. 55:39happens is let's say you are just keep
  1557. 55:41on incrementally loading the data, but
  1558. 55:43now
  1559. 55:45there are
  1560. 55:46not only the you can say
  1561. 55:48new data,
  1562. 55:49some previous data can also be updated.
  1563. 55:53So you need to make sure that your data
  1564. 55:55is fully updated.
  1565. 55:57Either it is an append
  1566. 55:59or update, anything, I want fully
  1567. 56:02updated data.
  1568. 56:03If let's say I have new record with ID
  1569. 56:05let's say 10, I want 10 here
  1570. 56:08immediately.
  1571. 56:09If I have an ID
  1572. 56:11nine which was already there, but now it
  1573. 56:14is updated. So let's say green, this is
  1574. 56:16updated. I want this updated here as
  1575. 56:19well.
  1576. 56:20So all of these things require a lot of
  1577. 56:23manual and boilerplate code and I can
  1578. 56:26say that it would require at least
  1579. 56:27hundreds of lines of code at least,
  1580. 56:29okay? Because you need to write a lot of
  1581. 56:31try-except statements whenever you are
  1582. 56:33building this thing. Hundreds of lines
  1583. 56:35of code. But now
  1584. 56:37with the help of database connectors,
  1585. 56:38let's say if I'm just picking database
  1586. 56:40connector, I automatically get the
  1587. 56:42feature called change data capture.
  1588. 56:44I can literally pick this thing
  1589. 56:46and whenever I am ingesting the data, if
  1590. 56:49my data source is changed, let say if I
  1591. 56:51get a new get some new data, if my
  1592. 56:53existing data is updated, I will get all
  1593. 56:55of those changes. Wow.
  1594. 56:57What is this query-based capture? So
  1595. 57:00very good question. Let me just tell you
  1596. 57:01what is this thing.
  1597. 57:03CDC is clear? Very good.
  1598. 57:05This query-based capture is nothing but
  1599. 57:07the lightweight version of CDC.
  1600. 57:10Why saying this thing? Because see,
  1601. 57:12whenever I'm just ingesting the data
  1602. 57:14with the changes, I have to enable CDC
  1603. 57:17on the source tables and in order to
  1604. 57:19perform this thing, you need to involve
  1605. 57:22a DBA because in bigger organizations,
  1606. 57:24in any organization, you will see that
  1607. 57:26databases are governed and owned by the
  1608. 57:29DBAs. Data engineers cannot directly
  1609. 57:32change anything on the source side. No,
  1610. 57:34it is not allowed.
  1611. 57:36I don't think so it is allowed. It is
  1612. 57:37allowed, but
  1613. 57:39in smaller organizations, in startups,
  1614. 57:41obviously one person wears so many hats,
  1615. 57:43so that person can change it. But it is
  1616. 57:46a mess. You first raise a ticket, then
  1617. 57:48the ticket will go to DBA. That DBA will
  1618. 57:50first change the thing in QA, you will
  1619. 57:52test it, then it will do that thing in
  1620. 57:54production. So it takes a lot of time.
  1621. 57:56So this query-based capture is what we
  1622. 57:58data engineers have been doing since the
  1623. 58:00start because I am not also not a big
  1624. 58:02fan of change data capture. I always
  1625. 58:04prefer this thing. So what we do here,
  1626. 58:07we pick a CT, change tracking column.
  1627. 58:12That change tracking column can be a
  1628. 58:13date. In most of the scenarios, it could
  1629. 58:15be a date column. So what we do, we
  1630. 58:17simply take that date column and we keep
  1631. 58:20on adding or appending the new data
  1632. 58:24according to that last updated date. And
  1633. 58:26obviously we handle the update update of
  1634. 58:28that data as well.
  1635. 58:30If we see any kind of changes happening,
  1636. 58:33we use the same change tracking column
  1637. 58:35there as well. But in order to perform
  1638. 58:37this thing, we have to write a lot of
  1639. 58:38PySpark code. But that is fine. That's
  1640. 58:39how we were just doing the stuff. But
  1641. 58:41now Data Bricks has introduced this this
  1642. 58:44QBC, query-based capture as well, and it
  1643. 58:47does exactly the same thing. When this
  1644. 58:49feature was newly launched, I was just
  1645. 58:51like looking at some
  1646. 58:52internal things. Obviously, not the
  1647. 58:54entire script is
  1648. 58:55publicly available. But when I was just
  1649. 58:57looking at the behavior, I was like,
  1650. 58:59wow, this is the exact thing that we
  1651. 59:00data engineers have been doing. So this
  1652. 59:02is the managed solution for it.
  1653. 59:04Makes sense? So in short, you will get
  1654. 59:06the most updated data every time you run
  1655. 59:08the pipeline. Simple.
  1656. 59:10This is all about the database
  1657. 59:12connectors. I hope it is clear. I hope
  1658. 59:14it makes sense.
  1659. 59:16Very good.
  1660. 59:17The second thing that we have here is
  1661. 59:19SAS connectors. SAS connectors is very
  1662. 59:21very important
  1663. 59:23if you are working with
  1664. 59:26a domain where they have data coming
  1665. 59:29from so many sources.
  1666. 59:31It can be a SharePoint. Do we have the
  1667. 59:34SharePoint logo?
  1668. 59:36No? No. Let's use this one. So let say
  1669. 59:39you have the SharePoint, you have Teams,
  1670. 59:42you have Outlook, you have so many those
  1671. 59:44those things, right? Let me just use
  1672. 59:46this particular
  1673. 59:47Databricks.
  1674. 59:48With this here I can see that particular
  1675. 59:50thing. So let me just go to Data
  1676. 59:53Injection.
  1677. 59:55Cool.
  1678. 59:56And if I go to SQL Server, just to
  1679. 59:57delete this thing that I created for
  1680. 59:59you.
  1681. 1:00:00Perfect. So if I just go to Data
  1682. 1:00:01Injection, all of these Salesforce,
  1683. 1:00:03Workday, SAP, Google, right? These are
  1684. 1:00:06all the SAS connectors.
  1685. 1:00:07And to be honest,
  1686. 1:00:09those non-technical managers use data
  1687. 1:00:12from these sources for sure. And
  1688. 1:00:14especially if you're working within the
  1689. 1:00:15finance domain, you will ingest the data
  1690. 1:00:18from these sources. And
  1691. 1:00:20if you need to find the code to connect
  1692. 1:00:23to these things, it is a mess because
  1693. 1:00:25obviously they keep on changing the
  1694. 1:00:27connectors, they keep on changing the
  1695. 1:00:29APIs. But now you do not need to worry
  1696. 1:00:31about it.
  1697. 1:00:32Cool?
  1698. 1:00:33Very good.
  1699. 1:00:34Then third thing,
  1700. 1:00:36my personal favorite,
  1701. 1:00:37file connectors.
  1702. 1:00:39This is the thing that a lot of
  1703. 1:00:41developers, lot of data engineers
  1704. 1:00:43currently work with. What is this file
  1705. 1:00:45connectors? So let say you have the data
  1706. 1:00:48sitting in S3.
  1707. 1:00:49You have data sitting in let say ADLS
  1708. 1:00:52Gen2,
  1709. 1:00:53any cloud storage usually. So you use
  1710. 1:00:56file connectors.
  1711. 1:00:57Okay. Basically you you just want to
  1712. 1:00:59read the data from the object storage
  1713. 1:01:01and you just want to
  1714. 1:01:03leverage the Databricks.
  1715. 1:01:05Now I know your question. Do we have the
  1716. 1:01:07managed service for this as well? The
  1717. 1:01:09answer is yes or no. What what is this
  1718. 1:01:11answer yes or no? Let let just explain.
  1719. 1:01:14So the answer there is no
  1720. 1:01:17there is yes okay okay wait.
  1721. 1:01:19Let me frame the answer.
  1722. 1:01:21So there the best way to perform the
  1723. 1:01:24data ingestion from the file connectors
  1724. 1:01:26is using
  1725. 1:01:28PySpark code
  1726. 1:01:30that is my recommendation. Okay.
  1727. 1:01:33Let let me just come on to the point
  1728. 1:01:34don't worry.
  1729. 1:01:35PySpark code is the best way to fetch
  1730. 1:01:37the data from the file connectors. First
  1731. 1:01:39thing
  1732. 1:01:40first thing.
  1733. 1:01:41Second thing do we have no code solution
  1734. 1:01:44available where we can just directly run
  1735. 1:01:46the pipelines and it will just simply
  1736. 1:01:48fetch the data. Yes, we have that as
  1737. 1:01:49well. Let me show you. If you just go
  1738. 1:01:51here in the data bricks you will find it
  1739. 1:01:53let's say Amazon S3
  1740. 1:01:55there will be like ADLS Gen 2 as well.
  1741. 1:01:57Let me just find it for you.
  1742. 1:01:59Like you can just
  1743. 1:02:01write it in the search bar
  1744. 1:02:04ADLS
  1745. 1:02:06Azure Data Lake
  1746. 1:02:08they do not have it for ADLS Gen 2 for
  1747. 1:02:10now because I I told you coding is the
  1748. 1:02:12best one for file connectors. Okay, but
  1749. 1:02:14you can just pick let's say this one
  1750. 1:02:17Amazon S3 and Data Bricks simple.
  1751. 1:02:19What it will do? It will simply fetch
  1752. 1:02:21the data from the S3 and it will load
  1753. 1:02:23the data into your staging table. That's
  1754. 1:02:26it. Why I am saying that it is
  1755. 1:02:29not very very good as compared to
  1756. 1:02:30PySpark code. It is my personal
  1757. 1:02:32experience first of all.
  1758. 1:02:33When you write the PySpark code to
  1759. 1:02:35connect to the files, connect to the
  1760. 1:02:36object storage, you can perform a lot of
  1761. 1:02:39schema modification, you can do some
  1762. 1:02:41filtering as well before loading the
  1763. 1:02:43data in the staging layer. So it is my
  1764. 1:02:45personal recommendation.
  1765. 1:02:47And now let me come on to the point.
  1766. 1:02:48Point when I say PySpark code, I'm not
  1767. 1:02:50saying that you need to write the raw
  1768. 1:02:53code again and again. Or really yes.
  1769. 1:02:55Here we get a feature within the data
  1770. 1:02:57bricks that where you write PySpark code
  1771. 1:02:59for sure, but
  1772. 1:03:01they provide you a lot of features where
  1773. 1:03:03you do not need to write the code for
  1774. 1:03:07every small thing and for the complex
  1775. 1:03:10things.
  1776. 1:03:11What do I mean? So let's say
  1777. 1:03:13you have AWS S3 right and you want to
  1778. 1:03:17perform let's
  1779. 1:03:19data ingestion for the files.
  1780. 1:03:21Let's say you have some parquet files,
  1781. 1:03:23so you have one file, two file, three
  1782. 1:03:24file.
  1783. 1:03:25So you will keep on adding these files
  1784. 1:03:27within your source, right?
  1785. 1:03:29Keep on adding.
  1786. 1:03:31Now, if you want to incrementally load
  1787. 1:03:34the files,
  1788. 1:03:35you have to write the logic for that.
  1789. 1:03:36But Databricks says,
  1790. 1:03:38I know that you love coding. Let me just
  1791. 1:03:41give you an option to perform the
  1792. 1:03:43coding, but with the managed approach.
  1793. 1:03:45Here Databricks will say, I have
  1794. 1:03:48copy into
  1795. 1:03:50command which will incrementally load
  1796. 1:03:53the data, incrementally.
  1797. 1:03:56Which is one of the managed solutions
  1798. 1:03:58with code, not without code, with code.
  1799. 1:04:01Simple. So that's how we just ingest the
  1800. 1:04:03data using this thing. So let's say if I
  1801. 1:04:05have if if we have like a lot of data.
  1802. 1:04:08Do not worry. We will just talk about
  1803. 1:04:10how to ingest this thing, okay? In the
  1804. 1:04:12next concept, which is our streaming
  1805. 1:04:14connectors, basically how to perform
  1806. 1:04:15streaming, okay? Which is very very
  1807. 1:04:17important. So do not worry about that
  1808. 1:04:19about that for now because you first
  1809. 1:04:20need to understand the concept.
  1810. 1:04:22Cool? So this is all about the
  1811. 1:04:25connectors or you can say Lake Flow
  1812. 1:04:26Connect that we have.
  1813. 1:04:28Makes sense?
  1814. 1:04:29Now let me just talk about a very
  1815. 1:04:33important concept in the world of
  1816. 1:04:34streaming because I just used the word
  1817. 1:04:36streaming.
  1818. 1:04:37It's called auto
  1819. 1:04:40loader.
  1820. 1:04:41What is this auto loader?
  1821. 1:04:43What is this auto loader?
  1822. 1:04:45So now
  1823. 1:04:46with the rise of data,
  1824. 1:04:48managers, non-technical people, all
  1825. 1:04:51those leaders,
  1826. 1:04:53everyone wants to take data-driven
  1827. 1:04:56decisions as soon as possible, as soon
  1828. 1:04:58as data arrives in the cloud.
  1829. 1:05:00They want to see that data in the
  1830. 1:05:02dashboard. And I don't know what they do
  1831. 1:05:04with that data, but they want to see the
  1832. 1:05:05dashboard immediately refreshed, okay?
  1833. 1:05:08Immediately.
  1834. 1:05:09Immediately. Data is dropped at let's
  1835. 1:05:11say
  1836. 1:05:127:30 p.m. They want to see that data at
  1837. 1:05:147:30 p.m.
  1838. 1:05:16Okay?
  1839. 1:05:17And they they won't do anything like
  1840. 1:05:19until next day of 7:30 p.m., they want
  1841. 1:05:21to see the data in their dashboard being
  1842. 1:05:23refreshed. So, now you being a
  1843. 1:05:25developer, we cannot argue with them.
  1844. 1:05:26Obviously, you will say, okay, let me
  1845. 1:05:28just provide the data to you, bro, and
  1846. 1:05:29then do whatever you want to do. So,
  1847. 1:05:31auto loader, this is one of the
  1848. 1:05:35best things that they have added. So,
  1849. 1:05:36let's say
  1850. 1:05:38let's take this scenario. This scenario
  1851. 1:05:39is a very good scenario.
  1852. 1:05:41So, let's say you have the AWS S3 and
  1853. 1:05:44you have data,
  1854. 1:05:45okay, with these files.
  1855. 1:05:47Now, you want to
  1856. 1:05:50fetch the data and you want to
  1857. 1:05:53use this data as soon as possible. So,
  1858. 1:05:55what you will
  1859. 1:05:56usually perform? What you will perform?
  1860. 1:05:59You can perform, let's say,
  1861. 1:06:01um streaming,
  1862. 1:06:04Spark streaming. So, here we just
  1863. 1:06:05perform something called a streaming.
  1864. 1:06:07So, whenever we are just performing
  1865. 1:06:08streaming, we have to take care of the
  1866. 1:06:10idempotency. We have to take care of the
  1867. 1:06:12checkpoints. We have to take care of all
  1868. 1:06:14of the offsets, everything, right?
  1869. 1:06:17But Spark structured streaming
  1870. 1:06:20I know is already very good, but it is
  1871. 1:06:22not managed.
  1872. 1:06:24We do not have built-in capabilities to,
  1873. 1:06:27let say, efficiently manage the
  1874. 1:06:29end-to-end solution. But
  1875. 1:06:32with auto loader, auto loader is
  1876. 1:06:34basically a kind of managed Spark
  1877. 1:06:36structured streaming solution for you
  1878. 1:06:38created by Databricks.
  1879. 1:06:40So, they say that you can use
  1880. 1:06:42auto loader to stream your files, let's
  1881. 1:06:45say from here
  1882. 1:06:46to here.
  1883. 1:06:48Okay.
  1884. 1:06:49If let's say a new file arrives
  1885. 1:06:53a new file arrives
  1886. 1:06:54this will be automatically
  1887. 1:06:58be like go here
  1888. 1:07:00with idempotency, with all the
  1889. 1:07:01checkpoints, with even the schema
  1890. 1:07:04evolution as well.
  1891. 1:07:07Here Databricks provides you
  1892. 1:07:10some concepts called schema evolution
  1893. 1:07:13and we get two to three options. First
  1894. 1:07:15of all, if you want to update the
  1895. 1:07:17destination table with the new schema,
  1896. 1:07:18you can do that.
  1897. 1:07:20If you want to, let say
  1898. 1:07:22do not want if you do not want to
  1899. 1:07:23include the new schema or if you do not
  1900. 1:07:25want to update the schema, you can keep
  1901. 1:07:27on just having that particular same
  1902. 1:07:30schema after the
  1903. 1:07:32the after this new injection as well.
  1904. 1:07:34All of these things come under auto
  1905. 1:07:36loader.
  1906. 1:07:38Auto loader is very very important and
  1907. 1:07:40you need to understand this thing deep
  1908. 1:07:43um into an example.
  1909. 1:07:45Makes sense? I hope that you got some
  1910. 1:07:47taste of like auto loader like what
  1911. 1:07:48exactly is auto loader.
  1912. 1:07:50I hope so.
  1913. 1:07:52Concept is very simple.
  1914. 1:07:54Just a kind of streaming um managed
  1915. 1:07:57streaming solution for you and that's
  1916. 1:07:58it.
  1917. 1:07:59That is it. Nothing else, nothing else.
  1918. 1:08:02And yes, it is like mostly used with um
  1919. 1:08:05files, mostly, but yes, you can just use
  1920. 1:08:08it with multiple sources as well. This
  1921. 1:08:10is like
  1922. 1:08:11my personal experience. I have just used
  1923. 1:08:13mostly with the file. So that's what I'm
  1924. 1:08:14just telling you.
  1925. 1:08:17Makes sense?
  1926. 1:08:18I hope it makes sense. Now how we can
  1927. 1:08:19just use this particular um option. So
  1928. 1:08:23you can either use PySpark code as well
  1929. 1:08:25and you can even use Spark SQL as well.
  1930. 1:08:27Both the options are there. So you are
  1931. 1:08:28good with that. So I personally use
  1932. 1:08:31PySpark code more than Spark SQL code
  1933. 1:08:33whenever whenever I'm just doing
  1934. 1:08:34anything. So this is like up to you if
  1935. 1:08:36you just want to use anything.
  1936. 1:08:38Cool.
  1937. 1:08:40Now I know that you also want to see
  1938. 1:08:41like how it will work. So let me take an
  1939. 1:08:43example. Let's try to perform one very
  1940. 1:08:45simple example with this auto loader so
  1941. 1:08:46that you also understand this thing.
  1942. 1:08:48Let's see. So now because we will be
  1943. 1:08:49just performing a lot of examples and we
  1944. 1:08:52also need to see this example as well,
  1945. 1:08:54data injection, data connections,
  1946. 1:08:56everything. So I would need one cloud
  1947. 1:08:58account for that and the best one is
  1948. 1:09:01like which can be easily created. You
  1949. 1:09:03can just create AWS
  1950. 1:09:05free account because you get I think six
  1951. 1:09:07months of free access for that. So you
  1952. 1:09:09can just click here. If you already have
  1953. 1:09:11cloud account, very good. If you do not
  1954. 1:09:13have, click on create account and make
  1955. 1:09:15sure that you have the AWS cloud
  1956. 1:09:17account. I already have one cloud
  1957. 1:09:19account that I just use for the
  1958. 1:09:20tutorial. So let me just quickly sign
  1959. 1:09:22in. If you already have one, let's say
  1960. 1:09:24you just created this thing with this
  1961. 1:09:25particular thing.
  1962. 1:09:26Then you can click on sign in to console
  1963. 1:09:28and then it will take you to the sign in
  1964. 1:09:30page. Let me just do this for me.
  1965. 1:09:32So as you can see this is the sign in
  1966. 1:09:34page and for the first time
  1967. 1:09:36you will not have or you will not
  1968. 1:09:38remember your account ID or alias. In
  1969. 1:09:40that particular scenario you can just
  1970. 1:09:42click on sign in using root user email.
  1971. 1:09:45Then you just need to put your
  1972. 1:09:49root user which is the email ID that you
  1973. 1:09:51just picked to create your account and
  1974. 1:09:52then password and that's it. But if you
  1975. 1:09:54are if you have one IAM user, IAM user
  1976. 1:09:57is nothing but basically the cloud user
  1977. 1:09:59that you create within your parent
  1978. 1:10:01account. I already have that, but if you
  1979. 1:10:03do not have that, simply click on root
  1980. 1:10:04user. Okay?
  1981. 1:10:06So let me just log in into my AWS
  1982. 1:10:07account and I hope that you will also
  1983. 1:10:09log in nicely and
  1984. 1:10:11I think everyone should know how to log
  1985. 1:10:13in to AWS account or any cloud account.
  1986. 1:10:16Simple, create the account and then
  1987. 1:10:18click on sign in, put the ID and
  1988. 1:10:19password and that's it. So let me just
  1989. 1:10:21put my credentials and let me just take
  1990. 1:10:23you to my AWS account and let's try to
  1991. 1:10:25proceed then. Okay?
  1992. 1:10:26So I'm here in my AWS account and in
  1993. 1:10:29your case you will also see something
  1994. 1:10:31like that. And if you already know how
  1995. 1:10:33to use AWS then it's so easy. If you do
  1996. 1:10:35not know, nothing to worry because we
  1997. 1:10:37are not doing anything special with AWS,
  1998. 1:10:39nothing. So what we need to do? We just
  1999. 1:10:41need to create one S3 account which is a
  2000. 1:10:43data lake and that's it. Okay?
  2001. 1:10:45How you can just create one? Simply go
  2002. 1:10:47to search bar and search S3.
  2003. 1:10:49And click on S3.
  2004. 1:10:51And it will open up
  2005. 1:10:53oh wow, this nice UI with a lot of
  2006. 1:10:57unnecessary stuff. Click on create
  2007. 1:10:58bucket.
  2008. 1:10:59And that's it. So here are some things,
  2009. 1:11:01general purpose or directory. You can
  2010. 1:11:03simply say general purpose and bucket
  2011. 1:11:05name, let's pick the bucket name as
  2012. 1:11:10data bricks demo. Okay?
  2013. 1:11:12Then account regional namespace.
  2014. 1:11:16I will simply go with global namespace.
  2015. 1:11:17This is like you can just pick the same
  2016. 1:11:19name within the
  2017. 1:11:21like across the accounts, but I am just
  2018. 1:11:23good with that data bricks demo.
  2019. 1:11:25And ACL is disabled. Yeah, that is fine.
  2020. 1:11:29And then
  2021. 1:11:31bucket versioning. I don't need bucket
  2022. 1:11:33versioning. This is just for the if you
  2023. 1:11:35just want to, let's say
  2024. 1:11:37perform the time traveling, but that's
  2025. 1:11:38this is fine. And I think everything is
  2026. 1:11:40good. I will simply say create bucket.
  2027. 1:11:43This name is already taken. Wow. I will
  2028. 1:11:44simply say Onsh. Onsh is not
  2029. 1:11:47like Onsh is available. So
  2030. 1:11:51so this is my bucket, as you can see,
  2031. 1:11:52Databricks demo Onsh, and this is my
  2032. 1:11:55empty bucket, empty S3 bucket, empty
  2033. 1:11:57data. Like I do not have anything,
  2034. 1:11:58right? So what I will do, I will create
  2035. 1:12:00one folder within this
  2036. 1:12:02and I will simply say
  2037. 1:12:04raw. Raw means let's say raw data
  2038. 1:12:07and click on create folder. So this is
  2039. 1:12:09my folder name which is empty. Now I
  2040. 1:12:11will upload some data. I'll click on
  2041. 1:12:13upload and what I will do, I will simply
  2042. 1:12:16upload the same orders file that I just
  2043. 1:12:17uploaded before. Okay? So I have just
  2044. 1:12:21dragged it here. It is called orders.csv
  2045. 1:12:23and it is good. Cool.
  2046. 1:12:25Let's say upload.
  2047. 1:12:27This data is uploaded. Now the point is
  2048. 1:12:30this data
  2049. 1:12:32this data resides in AWS, right? This
  2050. 1:12:35this is my AWS.
  2051. 1:12:37So AWS is different entity. Databricks
  2052. 1:12:40is a different entity. How these two
  2053. 1:12:42entities will talk to each other?
  2054. 1:12:44This is the concept of external
  2055. 1:12:46location. Remember we just talked about
  2056. 1:12:48external location which comes under
  2057. 1:12:49Unity Metastore in the beginning. So
  2058. 1:12:51this is the exact thing that we need to
  2059. 1:12:54configure now.
  2060. 1:12:55That is why I have just added a lot of
  2061. 1:12:57practical demos within this tutorial so
  2062. 1:12:58that you actually understand the
  2063. 1:13:00concepts by doing it. Okay? I know this
  2064. 1:13:03is a concepts video, but still I want
  2065. 1:13:05you to understand it. So let me just
  2066. 1:13:07open my Databricks. So how you can just
  2067. 1:13:09create this connection? There are so
  2068. 1:13:11many ways you can directly create the
  2069. 1:13:12connection from here as well, but let me
  2070. 1:13:14just show you the recommended approach.
  2071. 1:13:16Click on catalog
  2072. 1:13:17and here then click on plus and here you
  2073. 1:13:20will see something called as external
  2074. 1:13:22location. Okay? You can click on this as
  2075. 1:13:24well. You can even create the credential
  2076. 1:13:26as well. Both are good, but I will
  2077. 1:13:27simply go with create an external
  2078. 1:13:29location. Okay?
  2079. 1:13:30So let me just click on plus button and
  2080. 1:13:33click on create an external location.
  2081. 1:13:35So now it will ask me, do you want the
  2082. 1:13:38manual setup or you want to set up your
  2083. 1:13:41external location automatically? So
  2084. 1:13:43here's the thing, whenever you are
  2085. 1:13:45working in AWS, you can just go with AWS
  2086. 1:13:47automatic setup. It is actually very
  2087. 1:13:49good and it saves a lot of time.
  2088. 1:13:51But with Azure, we do not have this
  2089. 1:13:53option. Whenever I work with Azure, I
  2090. 1:13:56always create the credential manually,
  2091. 1:13:58which is called database
  2092. 1:14:00Databricks connector ID from the cloud
  2093. 1:14:03account and then I wrap that
  2094. 1:14:06you can say credential Databricks
  2095. 1:14:08connector into a credential within the
  2096. 1:14:10Databricks and then I just create the
  2097. 1:14:12external location. So this is like
  2098. 1:14:13multi-step process. Let me just explain
  2099. 1:14:15this thing. First of all, you create the
  2100. 1:14:17credential. And what is that credential?
  2101. 1:14:19Credential is nothing but the Databricks
  2102. 1:14:21connector.
  2103. 1:14:23Databricks
  2104. 1:14:25Wow.
  2105. 1:14:26Databricks
  2106. 1:14:27connector. Okay. That Databricks
  2107. 1:14:29connector get wrapped inside something
  2108. 1:14:32called as credential.
  2109. 1:14:35Cool. And that credential will be used
  2110. 1:14:37to create your external location.
  2111. 1:14:41And that external location is used to
  2112. 1:14:43access your data. But all of these three
  2113. 1:14:46steps are automatically handled by
  2114. 1:14:48Databricks if you select this thing in
  2115. 1:14:50AWS only. Okay. So I will simply say
  2116. 1:14:52next.
  2117. 1:14:54Then it will say what should be the
  2118. 1:14:55external location name. I will simply
  2119. 1:14:57say
  2120. 1:14:58S3
  2121. 1:15:00in just you can just pick any name. Now
  2122. 1:15:03it wants the bucket name. So I will
  2123. 1:15:05simply say S3, which is a kind of
  2124. 1:15:07protocol that we use and then the bucket
  2125. 1:15:09name. The bucket name is I think let me
  2126. 1:15:12just check.
  2127. 1:15:13The bucket name is
  2128. 1:15:16Databricks demo
  2129. 1:15:18So I just need to provide that.
  2130. 1:15:21Databricks demo
  2131. 1:15:24punch. Cool.
  2132. 1:15:26And log in to AWS because it needs to
  2133. 1:15:29verify that okay, you are the authorized
  2134. 1:15:31one to access this Databricks this
  2135. 1:15:33particular data lake obviously. So let
  2136. 1:15:35me just click here.
  2137. 1:15:37And IAM storage role. So what it will
  2138. 1:15:39do? It will automatically create this
  2139. 1:15:41role as well, IAM storage role because
  2140. 1:15:44obviously for in order to access your
  2141. 1:15:47data from the data lake, you need the
  2142. 1:15:49right
  2143. 1:15:51role as well, right? Which is the
  2144. 1:15:53concept of role. So whenever you want to
  2145. 1:15:55access any resource from the AWS, we
  2146. 1:15:58always create the roles, right? Let me
  2147. 1:16:00just show you that as well so that you
  2148. 1:16:02understand what's going on. Nothing is a
  2149. 1:16:04black box for you. So you simply go to
  2150. 1:16:06IAM
  2151. 1:16:08in the AWS and here you go to roles
  2152. 1:16:11here.
  2153. 1:16:12And if you just want to let say read S3
  2154. 1:16:15bucket,
  2155. 1:16:16you can say I have so many roles data
  2156. 1:16:18bricks because I just keep on just using
  2157. 1:16:20that data bricks S3 automatic way of
  2158. 1:16:22this thing. So let's say S3
  2159. 1:16:26read
  2160. 1:16:28where is that role? I think there's no
  2161. 1:16:30role for that. That is fine. But if you
  2162. 1:16:32just want to create a new role, let's
  2163. 1:16:34say I just want to read the S3. So I
  2164. 1:16:36simply say read S3 and I can just create
  2165. 1:16:39a role because it doesn't exist. Then it
  2166. 1:16:41will say
  2167. 1:16:43trusted entity type AWS service,
  2168. 1:16:45account, web entity and blah blah blah
  2169. 1:16:48blah. I will simply say AWS service that
  2170. 1:16:49is fine because I will be accessing this
  2171. 1:16:52thing through a kind of AWS service.
  2172. 1:16:54Then service or use case I want to use
  2173. 1:16:57S3.
  2174. 1:16:58Simply say S3 and then click on next.
  2175. 1:17:01And here I just need to pick the right
  2176. 1:17:05you can say
  2177. 1:17:07role, not role basically the access or
  2178. 1:17:10basically the permissions.
  2179. 1:17:11I can say S3 access if I have or let say
  2180. 1:17:14read data lake something like that I can
  2181. 1:17:17just search it if I have that. So here I
  2182. 1:17:20have S3 Amazon S3 full access. I can
  2183. 1:17:23just pick that as well. If I have S3
  2184. 1:17:26files full access if you just want to
  2185. 1:17:28access files read only. So this way I
  2186. 1:17:30have all of these things. This is the
  2187. 1:17:32manual way of doing it, but this data
  2188. 1:17:34bricks will do everything for me. So let
  2189. 1:17:36me just click on initiate and let's wait
  2190. 1:17:39for it. So it has automatically opened
  2191. 1:17:41this window for me. Let me just read it
  2192. 1:17:43and let's say allow access. So this will
  2193. 1:17:46automatically created this thing for me.
  2194. 1:17:48But but but you need to wait for it
  2195. 1:17:50because it takes some time to create
  2196. 1:17:52this thing and in the back end it can
  2197. 1:17:54take I would say a few minutes because
  2198. 1:17:56it will create some functions for you as
  2199. 1:17:59well so that you can easily access the
  2200. 1:18:01data. And let me just show you if we can
  2201. 1:18:04see that particular progress. So let me
  2202. 1:18:05just go to IAM or not even IAM.
  2203. 1:18:09Let's go to S3 directly.
  2204. 1:18:12And here I have this data
  2205. 1:18:14bricks demo on very good. So this is my
  2206. 1:18:17raw folder. Everything is good on this
  2207. 1:18:18side. So let's wait for a moment and
  2208. 1:18:21then I can just show you if we have any
  2209. 1:18:23kind of progress on the back end files.
  2210. 1:18:25Okay. So a few minutes are passed. So
  2211. 1:18:28now let me just go to Databricks and if
  2212. 1:18:30I just go to let's say
  2213. 1:18:32plus icon, create an external location.
  2214. 1:18:34You can even click here or you can click
  2215. 1:18:35on go on or connect as well. Click on
  2216. 1:18:37external locations. This way you will
  2217. 1:18:38see all of the external locations.
  2218. 1:18:41So I can see that I created this
  2219. 1:18:43external location called S3 ingest and
  2220. 1:18:46this external location is here. That
  2221. 1:18:48means it is created.
  2222. 1:18:50If you have not waited for at least a
  2223. 1:18:52few minutes, you will only see pending
  2224. 1:18:54locations instead of existing locations.
  2225. 1:18:57So in pending locations, you will see
  2226. 1:18:59the message that please wait for a few
  2227. 1:19:01minutes because some back end working is
  2228. 1:19:03being done. Once it is done, you will
  2229. 1:19:05see the existing locations. Otherwise
  2230. 1:19:07you will only see pending locations. So
  2231. 1:19:09make sure that you are waiting for the
  2232. 1:19:12right amount of time.
  2233. 1:19:13If I just go to credentials, it has
  2234. 1:19:15created this credential automatically
  2235. 1:19:16for me. Databricks UC blah blah blah. So
  2236. 1:19:19this is the
  2237. 1:19:20credential automatically created for me.
  2238. 1:19:22I didn't create anything. Cool. What is
  2239. 1:19:24the advantage now? Because this external
  2240. 1:19:26location now exist, I can read the data
  2241. 1:19:29from the
  2242. 1:19:31external location. Really? Let's test
  2243. 1:19:32it.
  2244. 1:19:33Simply go to workspace, click on demo
  2245. 1:19:35and let's create a new notebook. Let's
  2246. 1:19:38call it as
  2247. 1:19:40second
  2248. 1:19:43S3. Okay. So now let me just create the
  2249. 1:19:45data frame quickly. So let's say DF
  2250. 1:19:47equals spark dot read dot format format
  2251. 1:19:52is CSV.
  2252. 1:19:53Then
  2253. 1:19:55let's say dot option
  2254. 1:19:57header
  2255. 1:19:58true
  2256. 1:20:00and then let's say
  2257. 1:20:01dot load load. Yeah.
  2258. 1:20:04Let's provide the location. Location
  2259. 1:20:06will be like your bucket location.
  2260. 1:20:08Databricks
  2261. 1:20:10demo on
  2262. 1:20:11then raw.
  2263. 1:20:13Then if I just want to display the data
  2264. 1:20:14frame, I can simply say display DF.
  2265. 1:20:16This will read the data
  2266. 1:20:18and then it will display the data as
  2267. 1:20:20well. Now because my external location
  2268. 1:20:22exists
  2269. 1:20:23if I will know if I would not have
  2270. 1:20:25created that external location, this
  2271. 1:20:27read
  2272. 1:20:28would have thrown the error that I do
  2273. 1:20:30not have permission to read the data
  2274. 1:20:32from this S3 lake because this data this
  2275. 1:20:35this data lake is totally different
  2276. 1:20:37thing, right? But now because our
  2277. 1:20:39Databricks is attached to it, now we can
  2278. 1:20:41just read this thing. I hope it makes
  2279. 1:20:42sense. That's how you can just perform
  2280. 1:20:44the data ingestion. Okay. This is the
  2281. 1:20:46very basic, very standard thing that we
  2282. 1:20:48just perform. Cool. So I hope you
  2283. 1:20:51understand this thing and now
  2284. 1:20:53we will see how we can just perform the
  2285. 1:20:56streaming with the auto loader. Okay,
  2286. 1:20:57let's see. So now for that, let's
  2287. 1:20:59prepare our first of all the data
  2288. 1:21:00source. So I will simply go to S3
  2289. 1:21:04uh let's click on this bucket and let's
  2290. 1:21:08create a new folder.
  2291. 1:21:10Let's say
  2292. 1:21:11um stream. Okay, stream, simple.
  2293. 1:21:15And within this, I will
  2294. 1:21:17upload some data and I have prepared
  2295. 1:21:20some data for you as well that you can
  2296. 1:21:21also use. I will just drop this file as
  2297. 1:21:23well. So this is a kind of JSON file
  2298. 1:21:27where we have got the day one audits.
  2299. 1:21:29Okay.
  2300. 1:21:30And we will ingest this data using the
  2301. 1:21:32auto loader and then we will add the
  2302. 1:21:35another day data
  2303. 1:21:37and then we will run our pipeline again.
  2304. 1:21:39And it will not load the data which is
  2305. 1:21:42already loaded. Okay? It will only load
  2306. 1:21:44the new data, which is called like
  2307. 1:21:45streaming. Okay?
  2308. 1:21:47So it will handle all of the things,
  2309. 1:21:48idempotency.
  2310. 1:21:50Idempotency is like exactly once
  2311. 1:21:52behavior. We'll just talk about it. So
  2312. 1:21:53let's try to see how we can just set up
  2313. 1:21:55this thing.
  2314. 1:21:56So let me just go to Databricks
  2315. 1:21:58workspace and let me just create a new
  2316. 1:22:00file here.
  2317. 1:22:02And let me just call it as
  2318. 1:22:06three
  2319. 1:22:08auto
  2320. 1:22:10loader.
  2321. 1:22:11Now
  2322. 1:22:12if you just want to create this auto
  2323. 1:22:15loader, you can say injection, you first
  2324. 1:22:17of all need to understand that we work
  2325. 1:22:19with something called as
  2326. 1:22:21streaming.
  2327. 1:22:23So here I will also be using streaming
  2328. 1:22:25instead of Spark. So if I just show you
  2329. 1:22:27the second notebook, you can see that I
  2330. 1:22:29have just used spark.read here.
  2331. 1:22:31But when we just perform the streaming,
  2332. 1:22:33we use read stream. Okay? This is the
  2333. 1:22:35very fundamental of Apache Spark. So
  2334. 1:22:37this is the first thing that you need to
  2335. 1:22:38consider.
  2336. 1:22:40Second thing is whenever we work with
  2337. 1:22:42the streaming concept, we also create
  2338. 1:22:44something called as checkpoint location.
  2339. 1:22:47Oh, really? Yeah, checkpoint location.
  2340. 1:22:49So we will just create that as well. So
  2341. 1:22:50you do not need to worry.
  2342. 1:22:51So let me just show you. First of all, I
  2343. 1:22:53will read
  2344. 1:22:54the data which is here.
  2345. 1:22:56df equals spark.readStream.
  2346. 1:23:02Okay? readStream.format.
  2347. 1:23:04Here, what will be the format? You will
  2348. 1:23:07say JSON. No. Here the format will
  2349. 1:23:09become cloud files. Why? Because in auto
  2350. 1:23:12loader, we define all of the formats at
  2351. 1:23:15as cloud files.
  2352. 1:23:16Then we define what is the format of
  2353. 1:23:19that cloud files, which is nothing but
  2354. 1:23:21JSON.
  2355. 1:23:22Okay? This is one thing that we always
  2356. 1:23:23perform. So let's say
  2357. 1:23:25cloud files
  2358. 1:23:26and then I will simply go to next line
  2359. 1:23:28and then here I can write option
  2360. 1:23:32and within the option I can write cloud
  2361. 1:23:34files.format is JSON.
  2362. 1:23:38I hope it makes sense. Very good.
  2363. 1:23:40Now we need to provide the checkpoint
  2364. 1:23:45Okay, what is that checkpoint location?
  2365. 1:23:46Basically,
  2366. 1:23:49checkpoint is the folder
  2367. 1:23:51which Databricks auto loader will manage
  2368. 1:23:55for us where it will write all of
  2369. 1:23:58things. Just you you you just tell me.
  2370. 1:23:59Let me just show you the diagram.
  2371. 1:24:02You tell me
  2372. 1:24:03how Databricks will know that
  2373. 1:24:06these four files are already processed
  2374. 1:24:10and this is the new file. How? How
  2375. 1:24:12Databricks knows this thing? So it know
  2376. 1:24:15it needs to maintain that particular
  2377. 1:24:17information somewhere. So that
  2378. 1:24:19information is nothing but a special
  2379. 1:24:21folder
  2380. 1:24:22that it maintains. It's called
  2381. 1:24:24checkpoint location.
  2382. 1:24:27Okay, and within that it has something
  2383. 1:24:29called as RocksDB where you just see all
  2384. 1:24:31of that stuff created. Checkpoint
  2385. 1:24:33location. Because in that checkpoint all
  2386. 1:24:36of this information will be written
  2387. 1:24:38for streaming
  2388. 1:24:39and only then this file will be loaded
  2389. 1:24:41which is the new file.
  2390. 1:24:42Right? Okay, I hope it makes sense. So
  2391. 1:24:45now let's quickly create our checkpoint
  2392. 1:24:48location as well within here. Now a very
  2393. 1:24:50good question that you can ask is where
  2394. 1:24:52should we create our checkpoint
  2395. 1:24:54location?
  2396. 1:24:55That's a very good thing. You can even
  2397. 1:24:56create
  2398. 1:24:58checkpoint location anywhere, but
  2399. 1:24:59usually how we create is we create
  2400. 1:25:02something called as first of all the
  2401. 1:25:04output folder. So let's
  2402. 1:25:06quickly create the output folder.
  2403. 1:25:10Or you can just stream output.
  2404. 1:25:13Stream
  2405. 1:25:15output. Cool.
  2406. 1:25:17Click on create folder. Within the
  2407. 1:25:19stream output folder, we create two
  2408. 1:25:21folders. One is checkpoint,
  2409. 1:25:24right? And second one is data.
  2410. 1:25:27Create folder and then click on data.
  2411. 1:25:31So now I have two folders. So one folder
  2412. 1:25:33I will use it for the streaming data.
  2413. 1:25:35One will be for checkpoint.
  2414. 1:25:37Make sense? Very good. I can click here
  2415. 1:25:39and I can just copy the S3 URI if I want
  2416. 1:25:41to and let me just click on actions.
  2417. 1:25:45Copy S3 URI.
  2418. 1:25:47Oh man, me just go here
  2419. 1:25:50and go here, go here, buckets and this
  2420. 1:25:53is the bucket stream output.
  2421. 1:25:56Okay, so this is the checkpoint. Okay,
  2422. 1:25:57makes sense. I can just copy this
  2423. 1:25:58particular thing. So
  2424. 1:26:00cool. Let me just go to this particular
  2425. 1:26:02thing. So here I will write
  2426. 1:26:05dot option
  2427. 1:26:08and here I will simply write the schema
  2428. 1:26:09location. Cloud files dot schema
  2429. 1:26:12location and then I need to provide the
  2430. 1:26:14checkpoint location, right? So here let
  2431. 1:26:17me just provide the checkpoint location
  2432. 1:26:18F
  2433. 1:26:20and I will simply create the checkpoint
  2434. 1:26:22path. That is it. That is it.
  2435. 1:26:25Now let's create the variable for it
  2436. 1:26:27because we do not have the variable. So
  2437. 1:26:29I'll simply say checkpoint
  2438. 1:26:32path equals
  2439. 1:26:34this is the one streaming output and
  2440. 1:26:36then within that checkpoint.
  2441. 1:26:38Cool. So this is my checkpoint path that
  2442. 1:26:40I have just created.
  2443. 1:26:41Now you will say Anshul, what is this
  2444. 1:26:43schema location? So whenever we just
  2445. 1:26:46work with auto loader,
  2446. 1:26:48it tracks the schema of the data
  2447. 1:26:51somewhere. Somewhere where? In the
  2448. 1:26:53checkpoint as well. So this is like
  2449. 1:26:55purely end-to-end managed Spark
  2450. 1:26:58structured streaming service available
  2451. 1:27:00whenever we use the auto loader.
  2452. 1:27:02Make sense? Very good. So my schema
  2453. 1:27:04location is already good.
  2454. 1:27:07Very good.
  2455. 1:27:08After that, I can just provide the mode,
  2456. 1:27:11the rescue mode or basically the schema
  2457. 1:27:14evolution mode for my files.
  2458. 1:27:16Okay. By default, if I do not provide
  2459. 1:27:18this thing, this is not mandatory first
  2460. 1:27:20of all. By default, it will just use the
  2461. 1:27:23um add columns. Basically, whenever you
  2462. 1:27:25just add anything new within your source
  2463. 1:27:28data, it will simply update that thing.
  2464. 1:27:30But usually we do not add this thing. I
  2465. 1:27:32always like to have rescue column
  2466. 1:27:35because in the rescue it will not break
  2467. 1:27:37my pipeline. It will simply store all of
  2468. 1:27:39the new columns within the rescue
  2469. 1:27:41columns. Okay. Very good. Then I just
  2470. 1:27:43want to load it and I want to load this
  2471. 1:27:46data from here.
  2472. 1:27:48Let's say let me copy this path.
  2473. 1:27:51I think it is just stream.
  2474. 1:27:54Perfect.
  2475. 1:27:55So this is my streaming read location,
  2476. 1:27:59right?
  2477. 1:28:00That is it. But now I also want to just
  2478. 1:28:03write this thing somewhere else, right?
  2479. 1:28:05You can say this instead of display I
  2480. 1:28:07just want to write it somewhere.
  2481. 1:28:09So now if I just want to write it, I
  2482. 1:28:11have two options. I can either
  2483. 1:28:13create a table as well if I want to. But
  2484. 1:28:16if I just want to write it to a location
  2485. 1:28:18that is also available, that is also
  2486. 1:28:19fine. And I just like to stream to a
  2487. 1:28:21folder instead of creating a table. So
  2488. 1:28:23okay.
  2489. 1:28:24So let's try to do that. df.
  2490. 1:28:27write stream. So similarly when we have
  2491. 1:28:28read stream, we also have write stream.
  2492. 1:28:30Okay. And I want to create a delta table
  2493. 1:28:33instead of like creating a CSV or
  2494. 1:28:35parquet, I just want to create a delta
  2495. 1:28:37streaming table. Okay. So I will simply
  2496. 1:28:38say delta.
  2497. 1:28:40And then I will say dot option.
  2498. 1:28:43And in the option I can pick checkpoint
  2499. 1:28:45path. Perfect. And this is my checkpoint
  2500. 1:28:48path. Cool.
  2501. 1:28:50And then I can also say
  2502. 1:28:53trigger mode because this is very
  2503. 1:28:54important whenever we are using the
  2504. 1:28:56serverless compute. So you cannot have
  2505. 1:29:00you can say your continuous mode with
  2506. 1:29:02serverless compute because serverless
  2507. 1:29:03compute cannot be used for continuous
  2508. 1:29:06running of pipeline. Here we all only
  2509. 1:29:08use once equals to true or available now
  2510. 1:29:10equals to true. Okay. So you can even
  2511. 1:29:12use once equals to true or available now
  2512. 1:29:14equals to true. It's fine.
  2513. 1:29:16Then I will simply say dot start.
  2514. 1:29:18And in the start you just need to define
  2515. 1:29:19where you want to push the data. That is
  2516. 1:29:21it. So I'll simply say I want to push
  2517. 1:29:24the data to stream output and then
  2518. 1:29:27data.
  2519. 1:29:28Cool. I hope it makes sense.
  2520. 1:29:31Okay.
  2521. 1:29:32Let's try to run this cell. Let's see
  2522. 1:29:34what do we get.
  2523. 1:29:37And I can also see C performance.
  2524. 1:29:40And let's wait. Okay. I can see stream
  2525. 1:29:42initializing. That means Spark structure
  2526. 1:29:44streaming is initialized. Okay.
  2527. 1:29:46It will also show me some graph,
  2528. 1:29:48basically some charts. I I it. Very
  2529. 1:29:51good. So I think this is done.
  2530. 1:29:53And if I just go to my S3,
  2531. 1:29:55if I just go to my data tab, perfect. I
  2532. 1:29:58can see my delta data being loaded. And
  2533. 1:30:02as I just mentioned in the very
  2534. 1:30:03beginning that how delta tables are
  2535. 1:30:05created. So this is my parquet file and
  2536. 1:30:08this is my delta log.
  2537. 1:30:09This is the parquet file. Everyone knows
  2538. 1:30:11this thing, but this is the delta log.
  2539. 1:30:12Remember I told you that we have two
  2540. 1:30:14types of files, JSON and CRC files. So
  2541. 1:30:16this is your delta log.
  2542. 1:30:19Wow. This is your delta log.
  2543. 1:30:22That means this data is fine. This data
  2544. 1:30:25is amazing.
  2545. 1:30:26Now I can even query this data. Really?
  2546. 1:30:29Yes. Let me just show you. Let's say if
  2547. 1:30:31I want to query this data,
  2548. 1:30:33DF equals spark dot read dot format and
  2549. 1:30:36this time because I'm reading delta
  2550. 1:30:38table delta
  2551. 1:30:40dot load
  2552. 1:30:42and this is my
  2553. 1:30:44path.
  2554. 1:30:45This is my path, right?
  2555. 1:30:46Then I can say
  2556. 1:30:48display DF. Let's see what do we get.
  2557. 1:30:51I should see that data nicely created in
  2558. 1:30:54my delta table.
  2559. 1:30:55Cool.
  2560. 1:30:56So I have this rescue data and I have
  2561. 1:30:59this key value and everything, order ID,
  2562. 1:31:01timestamp, custom data. Obviously
  2563. 1:31:03because all of the columns were like
  2564. 1:31:05created under this thing and I didn't
  2565. 1:31:06pass any kind of schema here and that is
  2566. 1:31:09why I didn't see anything. I can even
  2567. 1:31:11infer the schema if I want to, but I
  2568. 1:31:13didn't write that statement. That is why
  2569. 1:31:15I'm just seeing this thing. Otherwise if
  2570. 1:31:17you just want to infer the schema, you
  2571. 1:31:18can also infer the schema. Nothing is
  2572. 1:31:20like you can say wrong in that
  2573. 1:31:22particular thing. Okay. But yeah,
  2574. 1:31:23because I didn't write any infer schema
  2575. 1:31:25because I didn't want to infer the
  2576. 1:31:27schema, that is why I'm seeing this
  2577. 1:31:29thing.
  2578. 1:31:30Okay. But if you just want to, you can
  2579. 1:31:31even write that thing.
  2580. 1:31:33Let's say dot option
  2581. 1:31:36cloud files
  2582. 1:31:38dot infer schema um
  2583. 1:31:42infer schema and then just make it true.
  2584. 1:31:45Let me also check the documentation. Um
  2585. 1:31:49schema let me just write autoloader
  2586. 1:31:53infer schema perfect.
  2587. 1:31:56So so so so so where is that auto
  2588. 1:31:59loader? This is amazing browser.
  2589. 1:32:02So configure schema inference and
  2590. 1:32:03evolution very good. So we have
  2591. 1:32:07schema location okay. I want infer
  2592. 1:32:09schema.
  2593. 1:32:11Where is that infer schema?
  2594. 1:32:14Let me let me check schema hints I want
  2595. 1:32:16schema hints and
  2596. 1:32:20let me just search it for you. Let's use
  2597. 1:32:22the same one that we just used it. It's
  2598. 1:32:23not a big deal. Um so
  2599. 1:32:27now
  2600. 1:32:28the point that I just want to make here
  2601. 1:32:29is
  2602. 1:32:31we have just loaded this data. That is
  2603. 1:32:33fine. That is fine and you can like
  2604. 1:32:35usually what we do before just dumping
  2605. 1:32:37this data into into the delta lake we
  2606. 1:32:38also obviously
  2607. 1:32:40deserialize this JSON and then we just
  2608. 1:32:42perform some data cleaning to convert
  2609. 1:32:45this JSON into nice nice looking columns
  2610. 1:32:47but that is a different thing.
  2611. 1:32:49Now the main thing that I just want to
  2612. 1:32:50make is here you can just see that I
  2613. 1:32:53have order ID 1001 right cool. Now now
  2614. 1:32:58if I just upload
  2615. 1:33:00another file here in the stream what
  2616. 1:33:03will happen then? Let me just upload it.
  2617. 1:33:06Let me just upload day two JSON.
  2618. 1:33:10So now I have day two JSON as well. Let
  2619. 1:33:13me just upload. Do you know what will
  2620. 1:33:14happen?
  2621. 1:33:15This time
  2622. 1:33:17because of checkpoint folder
  2623. 1:33:20this will only load this new file which
  2624. 1:33:22is day two dot JSON and it will not
  2625. 1:33:24touch the previous file.
  2626. 1:33:26Let see if it works right because we
  2627. 1:33:28want to test it. So let me I will not do
  2628. 1:33:30anything. I will simply run this cell
  2629. 1:33:32again without changing anything. Again
  2630. 1:33:35the stream will initialize
  2631. 1:33:37and after some time I should see the
  2632. 1:33:39results and that's it. Very good.
  2633. 1:33:42Now if I just run this cell for one more
  2634. 1:33:44time
  2635. 1:33:45what do I see let's see.
  2636. 1:33:47Perfect I only have a new order 1002. I
  2637. 1:33:50do not have a duplicate order 1001
  2638. 1:33:53again.
  2639. 1:33:54Oh but how it happened? It due to this
  2640. 1:33:58checkpoint location. And where is that
  2641. 1:34:00checkpoint location?
  2642. 1:34:02The checkpoint location is here in the
  2643. 1:34:04stream output
  2644. 1:34:06in the checkpoint folder. Wow, we have
  2645. 1:34:08so many folders, right? But not all the
  2646. 1:34:11folders are for checkpoint. One folder
  2647. 1:34:13is also for schema location. Okay, so
  2648. 1:34:15this folder has the schemas. This
  2649. 1:34:18metadata has some metadata information
  2650. 1:34:19and obviously some offsets, some
  2651. 1:34:21sources, everything. So in the sources
  2652. 1:34:23we have this option
  2653. 1:34:24and then in the offsets we have the
  2654. 1:34:27offsets available. If I go to metadata,
  2655. 1:34:30I will see some metadata information for
  2656. 1:34:32this particular stream.
  2657. 1:34:34And if I go to commits, I will see some
  2658. 1:34:36commits and if I just go to schemas,
  2659. 1:34:38then obviously some schema information
  2660. 1:34:40is there. All the files are visible to
  2661. 1:34:41you. Do you know why? Because you own
  2662. 1:34:43this external location. That is why it
  2663. 1:34:46is available to you.
  2664. 1:34:48Oh, makes sense.
  2665. 1:34:50Now
  2666. 1:34:51let me also show you the folder that I
  2667. 1:34:52just um
  2668. 1:34:54took name in the beginning, Rocks DB,
  2669. 1:34:56because Rocks DB is one of the major
  2670. 1:34:58folder. Obviously every folder is like
  2671. 1:35:00important, but Rocks DB is that folder
  2672. 1:35:02which holds the state of your stream.
  2673. 1:35:05So let me just go to sources, click on
  2674. 1:35:07the zero and within that you will see
  2675. 1:35:08Rocks DB. Rocks DB will have all of the
  2676. 1:35:11information like, okay, this data was
  2677. 1:35:12processed, this data is new and
  2678. 1:35:14everything.
  2679. 1:35:15Everything is being managed by Data
  2680. 1:35:17Bricks just for you
  2681. 1:35:19using Auto Loader.
  2682. 1:35:20This is the power of Auto Loader.
  2683. 1:35:23Now because we use the trigger type as
  2684. 1:35:25once equals to true, that means whenever
  2685. 1:35:27the stream was completed, it turned off
  2686. 1:35:30the pipeline.
  2687. 1:35:32But if you want to keep on running this
  2688. 1:35:34pipeline, what you can do? You can
  2689. 1:35:35simply pick a new trigger type, let's
  2690. 1:35:37say processing time equals to 10
  2691. 1:35:39seconds, 5 seconds, 3 seconds. And now I
  2692. 1:35:42think Data Bricks has even um um you can
  2693. 1:35:44say initialize something called as
  2694. 1:35:46real-time mode. So it depends like how
  2695. 1:35:48frequently you want to run the pipeline.
  2696. 1:35:50Because we are using the free edition,
  2697. 1:35:51obviously they will not provide us the
  2698. 1:35:53compute that we can just run 24/7,
  2699. 1:35:55obviously. But if you just want to, you
  2700. 1:35:57can just pick the trigger type here
  2701. 1:35:59well.
  2702. 1:36:00This, let me just tell you, this is
  2703. 1:36:02actually one of the like complex
  2704. 1:36:04concepts. If you understood it very
  2705. 1:36:06well, very well done. If not, that is
  2706. 1:36:08fine. You can just rewatch this part.
  2707. 1:36:11Why? Because that's how you learn.
  2708. 1:36:13That's how you learn, right?
  2709. 1:36:14So this is one of the end-to-end example
  2710. 1:36:17of how streaming works, how data
  2711. 1:36:19ingestion works, how Databricks lake
  2712. 1:36:21flow connect works with examples. I hope
  2713. 1:36:24this entire part is crystal clear.
  2714. 1:36:27I hope so. Very well done. So now the
  2715. 1:36:29next concept that you need to learn is
  2716. 1:36:32DB utils. What is what what are DB
  2717. 1:36:34utils? And what is this DB utils
  2718. 1:36:37module or concept that you need to
  2719. 1:36:38learn? So first of all,
  2720. 1:36:40DB utils is basically a package of
  2721. 1:36:42modules that Databricks has created for
  2722. 1:36:45you or for all of the developers. So
  2723. 1:36:48let's say we all are using Databricks
  2724. 1:36:51and obviously we need to perform so many
  2725. 1:36:54stuff and we can do everything on our
  2726. 1:36:56own. We have APIs, we have SDKs, we have
  2727. 1:36:59literally everything, right?
  2728. 1:37:01But sometimes we need some helper
  2729. 1:37:03functions, helper modules so that we can
  2730. 1:37:06efficiently work with Databricks. And
  2731. 1:37:09here the core thing is using the code.
  2732. 1:37:13Let's say we just want to perform
  2733. 1:37:15everything using our code within our
  2734. 1:37:17notebooks, anything.
  2735. 1:37:18Okay.
  2736. 1:37:19So these are some of the utilities that
  2737. 1:37:21are created by the Databricks.
  2738. 1:37:23Have you ever worked with something
  2739. 1:37:25called as OS module in Python? Now
  2740. 1:37:28everyone knows that if we want to work
  2741. 1:37:30with let's say file management or
  2742. 1:37:32anything within the programming
  2743. 1:37:34language, we can do it via so many ways.
  2744. 1:37:37But when we just use these packages,
  2745. 1:37:39these modules like OS,
  2746. 1:37:41we see our work
  2747. 1:37:43efficiency is boosted, right? Similarly,
  2748. 1:37:46if we just talk about Databricks, we
  2749. 1:37:48also have the similar
  2750. 1:37:50component within Databricks within DB
  2751. 1:37:52utils. It's called
  2752. 1:37:54DB utils dot FS. Okay. FS means like the
  2753. 1:37:58short form for file systems. So it is
  2754. 1:37:59very similar to that. So similarly,
  2755. 1:38:02similar to this, we have so many other
  2756. 1:38:05utilities like dbutils.fs,
  2757. 1:38:08then dbutils.widget,
  2758. 1:38:10dbutils.
  2759. 1:38:13um jobs,
  2760. 1:38:15so many stuff. And I think they have
  2761. 1:38:16recently introduced one new one as well.
  2762. 1:38:19It is in experimental zone. It's called
  2763. 1:38:21data.
  2764. 1:38:22Okay.
  2765. 1:38:23So these are so many dbutils that we
  2766. 1:38:25have. And just to tell you, 80% of the
  2767. 1:38:29time you will be interacting with this
  2768. 1:38:31particular module because this is so so
  2769. 1:38:34so efficient. If you want to let say
  2770. 1:38:36list the files of a of any particular
  2771. 1:38:40bucket, of any particular folder, how
  2772. 1:38:42will you do that? Obviously, there are
  2773. 1:38:44multiple ways. You can just run a loop,
  2774. 1:38:46you can just send the API request to the
  2775. 1:38:48folder to list the components directly
  2776. 1:38:50via the SDK. But
  2777. 1:38:52when you connect
  2778. 1:38:54the cloud with Databricks, you literally
  2779. 1:38:56can use dbutils module to directly fetch
  2780. 1:39:00the details of all the content that we
  2781. 1:39:02have within any folder.
  2782. 1:39:04This is just a very simple example of
  2783. 1:39:06it.
  2784. 1:39:07Cool. So if you are a Databricks
  2785. 1:39:09developer and if you are just trying to
  2786. 1:39:11become one, this package, this module is
  2787. 1:39:14non-negotiable for you. Okay. So now
  2788. 1:39:16let's try to actually see it with some
  2789. 1:39:19hands-on examples. So let me just bring
  2790. 1:39:21my Databricks workspace here so that you
  2791. 1:39:25can also see these things. So let's go
  2792. 1:39:27to our demo folder that we just created
  2793. 1:39:30and let's create a new notebook
  2794. 1:39:32and let's name it as Did I create
  2795. 1:39:35notebook? Yeah, yeah, perfect. So this
  2796. 1:39:37is my notebook.
  2797. 1:39:38Perfect. And here I can say
  2798. 1:39:43db
  2799. 1:39:44utils. Cool. So this is my dbutils
  2800. 1:39:46notebook. And as you know that we have
  2801. 1:39:50already connected our Databricks
  2802. 1:39:52workspace to our S3 bucket, right? That
  2803. 1:39:54means we can access it via this
  2804. 1:39:56Databricks. We all know that. But let's
  2805. 1:39:58see how we can just use the dbutils
  2806. 1:40:00module. Okay.
  2807. 1:40:01So first of all, you do not even need to
  2808. 1:40:03import dbutils like this. Like you can
  2809. 1:40:05write this thing, but by default, when
  2810. 1:40:07you just run the Databricks notebooks,
  2811. 1:40:09it is automatically
  2812. 1:40:11imported here. So that is why you will
  2813. 1:40:13see something like
  2814. 1:40:14module not found error, no module called
  2815. 1:40:17DBUtils.
  2816. 1:40:18So do not just try to import it, okay?
  2817. 1:40:21Because I have seen like people import
  2818. 1:40:23from DBUtils import this, import DBUtils
  2819. 1:40:25something blah blah blah. So you do not
  2820. 1:40:27even need to import it like this. It is
  2821. 1:40:29already
  2822. 1:40:30integrated within your Databricks
  2823. 1:40:31workspace.
  2824. 1:40:32So first of all, if you want to see all
  2825. 1:40:34of the options available within DBUtils,
  2826. 1:40:37you first need to run this command
  2827. 1:40:39DBUtils.
  2828. 1:40:41help.
  2829. 1:40:42Then what will happen?
  2830. 1:40:43DB
  2831. 1:40:45Utils DB
  2832. 1:40:48Utils. help.
  2833. 1:40:50So it is saying bound method and let me
  2834. 1:40:51just write this DBUtils. help. So
  2835. 1:40:54perfect. So these are all of the
  2836. 1:40:56packages, mini mini packages or you can
  2837. 1:40:59say mini mini modules created within the
  2838. 1:41:01DBUtils.
  2839. 1:41:02So we have credentials, we have data, we
  2840. 1:41:05have See, I told you that this is the
  2841. 1:41:07new one and it is in the experimental
  2842. 1:41:08phase.
  2843. 1:41:09Then FS, this is the most important one
  2844. 1:41:12that you need to
  2845. 1:41:14learn. Then we have jobs. This is used
  2846. 1:41:17whenever we want to work with the
  2847. 1:41:19Databricks jobs and do not worry, we
  2848. 1:41:20will just talk about Databricks jobs as
  2849. 1:41:22well. That is obviously a very important
  2850. 1:41:24area for orchestration.
  2851. 1:41:26Then we have some library meta. This is
  2852. 1:41:28also new one. This is like recently
  2853. 1:41:30added. Then we have Notebook Utils, this
  2854. 1:41:32one, DBUtils. notebook.
  2855. 1:41:35The previous method or you can say to
  2856. 1:41:37use this thing was DBUtils, but Notebook
  2857. 1:41:40Utils, but Notebook Utils like is there
  2858. 1:41:42I think since so long, so it is still in
  2859. 1:41:44the experimental, but we have this thing
  2860. 1:41:46whenever we just want to fetch anything
  2861. 1:41:47from the notebook, we just use this
  2862. 1:41:49thing. Then we have preview, then we
  2863. 1:41:51have secret. Secret is very important.
  2864. 1:41:52This is used when you are working with
  2865. 1:41:54let's say key vaults, when you are
  2866. 1:41:55working with the secrets and you do not
  2867. 1:41:57want to expose the sensitive data within
  2868. 1:42:00the notebooks. So what you do? You do
  2869. 1:42:02not hard code any API credential or any
  2870. 1:42:05kind of key vault. You simply create the
  2871. 1:42:07secret for that. Cool. And then finally
  2872. 1:42:10you have widgets.
  2873. 1:42:12This is basically used for the
  2874. 1:42:13parameterization. So whenever you want
  2875. 1:42:15to see the list of DB utils, always run
  2876. 1:42:17dbutils.help first of all. Cool.
  2877. 1:42:19Now let's try to see some more examples.
  2878. 1:42:21So let's say now I want to
  2879. 1:42:24um explore dbutils.fs command. So what I
  2880. 1:42:26can do? I can simply say dbutils
  2881. 1:42:29.fs and if I just want to learn more
  2882. 1:42:32about this FS module, FS um you can say
  2883. 1:42:35component within DB utils module, then I
  2884. 1:42:37can simply say help. And I will see all
  2885. 1:42:40of the options available that I have
  2886. 1:42:42within this particular module.
  2887. 1:42:44So first of all, I have this particular
  2888. 1:42:45information. Cool. Then I have some
  2889. 1:42:48commands that I can just use. CP.
  2890. 1:42:50CP is a short form for copy. If I want
  2891. 1:42:53to move the data, or not just move
  2892. 1:42:55basically, if I just want to copy the
  2893. 1:42:57data from one place to another,
  2894. 1:42:59I do not even need to write any code for
  2895. 1:43:02let say moving data from one place to
  2896. 1:43:04another. No ETL is required. You can
  2897. 1:43:07literally use CP method and the data
  2898. 1:43:08will be moved. Okay? Moved means like it
  2899. 1:43:10will be copied.
  2900. 1:43:12Then head if you just want to return
  2901. 1:43:14some top records, then LS.
  2902. 1:43:17LS is um you can say most of the time
  2903. 1:43:19used with the list comprehensions. If
  2904. 1:43:21you just want to see what do I have
  2905. 1:43:23within my folder, um I want to fetch
  2906. 1:43:26only the parquet files out of so many
  2907. 1:43:28files. So these this particular
  2908. 1:43:29component is used. Then mkdirs, which is
  2909. 1:43:31very similar to the one that we just use
  2910. 1:43:34within the Windows or any particular OS
  2911. 1:43:36to create the directories. Then mount.
  2912. 1:43:39Mount was used very frequently in the
  2913. 1:43:42early days when we didn't have the Unity
  2914. 1:43:44catalog. But when we have Unity catalog,
  2915. 1:43:46we hardly use mount. But yeah, you can
  2916. 1:43:48still use mount. Okay?
  2917. 1:43:49Then we have move. If you want to move
  2918. 1:43:51the data, then we have put. If you want
  2919. 1:43:52to create the file, then we have remove.
  2920. 1:43:55Let say if you want to remove any folder
  2921. 1:43:56and all of these things. Okay? So this
  2922. 1:43:58is very similar to OS module that we
  2923. 1:44:01have within the Python. Cool. So let's
  2924. 1:44:03say I want to I know that I have this
  2925. 1:44:06folder, right? Um which folder? Um this
  2926. 1:44:08one. So I have this
  2927. 1:44:11Let's say I want to list what do I have
  2928. 1:44:13inside this folder. So what I can do
  2929. 1:44:15dbutils. fs. ls and then I can just
  2930. 1:44:19provide the path.
  2931. 1:44:20And let's see what do I get.
  2932. 1:44:22It will return everything within the
  2933. 1:44:24list. So this is the list and in the
  2934. 1:44:26list I will have the
  2935. 1:44:28you can say different different
  2936. 1:44:29components. First of all file info.
  2937. 1:44:31File info is this. So I have the path.
  2938. 1:44:34Okay. I have the path. This is the path
  2939. 1:44:36and name is metadata. Metadata means
  2940. 1:44:39this is the component that I have within
  2941. 1:44:41that. Okay. Then size and then this.
  2942. 1:44:43Then I have file info. Then I have
  2943. 1:44:45schemas folder. Then I have this folder
  2944. 1:44:47commits offset sources. Very good.
  2945. 1:44:50That's how you can just
  2946. 1:44:53identify anything that you have within
  2947. 1:44:54the folder. So how we use it? Let me
  2948. 1:44:56show you.
  2949. 1:44:58So we can let say
  2950. 1:45:00create the path like this and then I can
  2951. 1:45:03just run the loop
  2952. 1:45:05in this particular thing and then I can
  2953. 1:45:06say print or not even print. Let's use
  2954. 1:45:09the list comprehension. So I can say
  2955. 1:45:13my list equals
  2956. 1:45:15and then I want to run i. let's say path
  2957. 1:45:19for i in
  2958. 1:45:22there.
  2959. 1:45:23Cool. And then if I just print my list
  2960. 1:45:26then I should see only the path. So
  2961. 1:45:28that's how we just create the automation
  2962. 1:45:31whenever you want to let say
  2963. 1:45:33push the data to a specific location or
  2964. 1:45:36pull the data from a specific location.
  2965. 1:45:38We just use these kinds of list
  2966. 1:45:39comprehensions and this way you have
  2967. 1:45:41already seen that I have literally
  2968. 1:45:43fetched all of the file paths. I can
  2969. 1:45:45even just write some conditions here.
  2970. 1:45:46Let's say if
  2971. 1:45:49i.
  2972. 1:45:50file path or i. path
  2973. 1:45:52equals equals or let's say anything. If
  2974. 1:45:55if I just let say I want to fetch only
  2975. 1:45:57the metadata path. Okay. Because it can
  2976. 1:45:59be the condition. Right? So let's I just
  2977. 1:46:01want to
  2978. 1:46:02write this thing checkpoint and then
  2979. 1:46:04after that
  2980. 1:46:05not
  2981. 1:46:06committed I will simply say schemas.
  2982. 1:46:11You can even perform some, you can say
  2983. 1:46:15I do not have this thing. Wow. So, let
  2984. 1:46:17me just write this thing.
  2985. 1:46:21Uh
  2986. 1:46:23Checkpoint schemas.
  2987. 1:46:27Obviously, I will not see this thing.
  2988. 1:46:28So, let me just comment it out.
  2989. 1:46:31Just to see what do I have. So, I have
  2990. 1:46:34the schemas. Okay. Got it. So, I have
  2991. 1:46:36one more slash
  2992. 1:46:40schemas and then slash.
  2993. 1:46:42So, this way you can perform some, you
  2994. 1:46:44can say character regex to fetch only
  2995. 1:46:47the specific folders, only the specific
  2996. 1:46:49files from the folder. So, this is the
  2997. 1:46:52automated way to perform anything
  2998. 1:46:53related to that. Makes sense? Very good.
  2999. 1:46:56So, now let's try to use more utilities.
  3000. 1:46:58Let see what more folders do we have. I
  3001. 1:47:01think we also have the data, right? So,
  3002. 1:47:04let's do one thing. Let's try to copy
  3003. 1:47:05this data
  3004. 1:47:07to a different one. Okay. And I will
  3005. 1:47:09simply use db utils dot
  3006. 1:47:12fs dot mkdirs because I want to create
  3007. 1:47:15the folder. And I will create the
  3008. 1:47:17folder, let's say stream output. And I
  3009. 1:47:19will say um db util data. db utils data.
  3010. 1:47:23So, this will create the folder like
  3011. 1:47:24this. Cool. My folder is created. Now
  3012. 1:47:27what I will do? I will simply say db
  3013. 1:47:29utils dot fs dot cp. cp means copy. And
  3014. 1:47:34what I want to copy? I will simply write
  3015. 1:47:36this path. So, I want to copy
  3016. 1:47:39this particular folder
  3017. 1:47:41to
  3018. 1:47:42this particular folder. And this folder
  3019. 1:47:44is db utils
  3020. 1:47:47data. Makes sense? Cool. Um uh I was
  3021. 1:47:51just like expecting this particular
  3022. 1:47:53error because we have the directory
  3023. 1:47:55within this. Like we have the delta log
  3024. 1:47:57as well. So, that is why it is saying
  3025. 1:47:58that cannot copy directory
  3026. 1:48:01unless recurse is set to true. So, I can
  3027. 1:48:03literally write here um recurse is true.
  3028. 1:48:07Then it can just keep on copying
  3029. 1:48:09everything, everything, everything to
  3030. 1:48:10the new folder.
  3031. 1:48:11So, perfect. It is done. Are you
  3032. 1:48:13serious? Yes.
  3033. 1:48:14Yes, I'm serious. I can even show you.
  3034. 1:48:17So DBUTL obviously, you can just go to
  3035. 1:48:18the S3 account and you can just confirm
  3036. 1:48:20this thing, but I do not need to,
  3037. 1:48:21because I have everything everything I
  3038. 1:48:24have access to everything within my
  3039. 1:48:25Databricks itself. So I will simply say
  3040. 1:48:26DBUTL.
  3041. 1:48:28fs.ls
  3042. 1:48:30and here I will simply write
  3043. 1:48:32DBUTL data folder and let's see what do
  3044. 1:48:35I have inside this folder. Perfect. I
  3045. 1:48:36have three things.
  3046. 1:48:38First parquet file, second parquet file
  3047. 1:48:40and third is this delta log and that I
  3048. 1:48:42know this thing.
  3049. 1:48:43That means I
  3050. 1:48:45do not even need to write any ETL code,
  3051. 1:48:48any kind of script, nothing. I can
  3052. 1:48:50literally perform this CP.
  3053. 1:48:52This is efficient when you just want to
  3054. 1:48:54perform one time copy or you are just
  3055. 1:48:57literally dumping the data from one
  3056. 1:48:59location to another. This is a very
  3057. 1:49:01useful command and to be honest, when
  3058. 1:49:03you are just building the automations,
  3059. 1:49:05you might need to move some data as
  3060. 1:49:07well. Let's say you just process some
  3061. 1:49:09data and let me just tell you one thing.
  3062. 1:49:11All of these managed thing like this
  3063. 1:49:14auto loader and all of these things, if
  3064. 1:49:16you just try to think about it like how
  3065. 1:49:17these things are built, under the hood
  3066. 1:49:20they are literally using these things.
  3067. 1:49:21How? See, let's say you just process
  3068. 1:49:24some data, right? And you do not want to
  3069. 1:49:26process the same data. You can literally
  3070. 1:49:28move the existing copied data to a
  3071. 1:49:30different folder using the move command
  3072. 1:49:32and then obviously the target folder
  3073. 1:49:33will be empty. So you can just compare
  3074. 1:49:35what files are copied or not and that's
  3075. 1:49:37it. So these are some internal things
  3076. 1:49:38that you can even build by yourself, but
  3077. 1:49:40obviously because these things are
  3078. 1:49:42already built with
  3079. 1:49:43considering all of the edge cases, you
  3080. 1:49:45do not even need to worry about all of
  3081. 1:49:47the edge cases, any failures, nothing
  3082. 1:49:49because everything is tested. So then
  3083. 1:49:52you just use these managed tools. But it
  3084. 1:49:54is not like you cannot build by your by
  3085. 1:49:56your own, right? Cool. So that's how you
  3086. 1:49:59can just use DBUTL module and I hope
  3087. 1:50:01this module will be very very helpful
  3088. 1:50:03for you and now I want to just tell you
  3089. 1:50:05a little bit more about one more thing
  3090. 1:50:08which is DBUTL.
  3091. 1:50:11So now let's say I want to create the
  3092. 1:50:12parameters for my notebook. I'm not
  3093. 1:50:15talking about variables. I'm talking
  3094. 1:50:16about parameters. Parameters and
  3095. 1:50:18variables are two different things. We
  3096. 1:50:20create variables if we want to, let's
  3097. 1:50:23say use dynamic
  3098. 1:50:26text, dynamic numbers, anything within
  3099. 1:50:28my code.
  3100. 1:50:29We use parameters
  3101. 1:50:31and we change the value for the
  3102. 1:50:33parameters at the runtime.
  3103. 1:50:35Makes sense? So let's say I have the let
  3104. 1:50:38me just show you the example. Let's say
  3105. 1:50:40I'm just doing something within my
  3106. 1:50:41notebook and I have something like this.
  3107. 1:50:43Let's say
  3108. 1:50:45print
  3109. 1:50:47data is loaded from or let say
  3110. 1:50:52data is loaded for
  3111. 1:50:55date. Okay, I do not know for which
  3112. 1:50:58date. Let's say in this notebook I have
  3113. 1:51:00just built the pipeline to fetch the
  3114. 1:51:01data from somewhere and then load it
  3115. 1:51:04somewhere. Cool? And every day I need to
  3116. 1:51:07run this notebook on a daily basis.
  3117. 1:51:09Obviously, then what I can do, every day
  3118. 1:51:12I can provide a new date parameter so
  3119. 1:51:14that every time I am fetching the data,
  3120. 1:51:17it will only load the data greater than
  3121. 1:51:19that particular date. That means I can
  3122. 1:51:21supply the last load date.
  3123. 1:51:23Makes sense? So like I can even write
  3124. 1:51:25last load date. And this is a very
  3125. 1:51:27classic and very traditional example how
  3126. 1:51:30we used to perform the incremental data
  3127. 1:51:32loading.
  3128. 1:51:33Makes sense? So you can just imagine
  3129. 1:51:35that I have just written some code to
  3130. 1:51:37fetch the data from SQL. I can even
  3131. 1:51:39write the query for you if you just want
  3132. 1:51:40to. So let's say
  3133. 1:51:43select asterisk from let say from your
  3134. 1:51:46orders table
  3135. 1:51:47where
  3136. 1:51:50order date
  3137. 1:51:53greater than
  3138. 1:51:54last load date. Simple. I'm just
  3139. 1:51:55printing it because I do not have the
  3140. 1:51:57SQL connection right now. So I am just
  3141. 1:51:59printing this thing. But you can imagine
  3142. 1:52:00I'm I am not printing it printing this
  3143. 1:52:02thing. I am literally executing this
  3144. 1:52:04thing, right? So now what will happen?
  3145. 1:52:06Every day if I just run this particular
  3146. 1:52:08notebook, every time it will fetch all
  3147. 1:52:11of the orders greater than last load
  3148. 1:52:13date. So let's say today is seventh of
  3149. 1:52:17today seventh or yeah, today is seventh
  3150. 1:52:18of November. So now what I can do? Today
  3151. 1:52:21is 7th of November. So let's imagine
  3152. 1:52:24that I have loaded the data
  3153. 1:52:26for 1st of November, okay? Till 5th of
  3154. 1:52:30November.
  3155. 1:52:31So till 5th of November my data is
  3156. 1:52:33loaded, okay? Now today on 7th I want to
  3157. 1:52:38load the data greater than what?
  3158. 1:52:41Greater than 5th
  3159. 1:52:42obviously so that I can just get all of
  3160. 1:52:45the data after 5th. I will get the data
  3161. 1:52:46for 6th and um 7th as well, not the
  3162. 1:52:49entire day but yeah for
  3163. 1:52:51few hours. So this is the date, this 5th
  3164. 1:52:53November should be passed every time to
  3165. 1:52:56this particular notebook.
  3166. 1:52:57And now let's say once this particular
  3167. 1:53:00notebook is notebook run is completed,
  3168. 1:53:03then let's say next day or let's say on
  3169. 1:53:05Monday you want to rerun this particular
  3170. 1:53:08notebook, then what date you will
  3171. 1:53:09provide? Let's say 7th November.
  3172. 1:53:12Makes sense? So every time this date is
  3173. 1:53:14being changed, right? This particular
  3174. 1:53:16thing needs to be addressed here and how
  3175. 1:53:18we can just address this thing? We just
  3176. 1:53:20create the widgets.
  3177. 1:53:21So I will simply say DB utils dot
  3178. 1:53:25widgets dot
  3179. 1:53:27set
  3180. 1:53:28and here I can literally set any name,
  3181. 1:53:31let's say last load date and I just
  3182. 1:53:32provided a default value because we need
  3183. 1:53:34to provide default value which is a good
  3184. 1:53:36practice. You can even ignore the
  3185. 1:53:37default value, it's fine but I usually
  3186. 1:53:39just try to keep it. And what we
  3187. 1:53:41provide? 1900 01 01. Why do we just
  3188. 1:53:45provide this date? This is called
  3189. 1:53:47initial load. This is called full load.
  3190. 1:53:49Let's say we want to load all the data
  3191. 1:53:52and when we do not have any kind of
  3192. 1:53:53date, it will literally load all of the
  3193. 1:53:55data that we have so far. So if I just
  3194. 1:53:57run this thing
  3195. 1:53:58um set widgets dot
  3196. 1:54:02set what? Widgets dot set or get?
  3197. 1:54:06I think widgets dot set it was widgets
  3198. 1:54:09dot set or get because get is used to
  3199. 1:54:10get the get the thing.
  3200. 1:54:12Widgets dot set
  3201. 1:54:15data text.
  3202. 1:54:19Oh, it's not set, it's text, sorry.
  3203. 1:54:21Because I was just confused between set
  3204. 1:54:22and get. So it is text.
  3205. 1:54:25So now what will happen? This will
  3206. 1:54:27create this particular box for me. And
  3207. 1:54:29now what I can do, I can literally
  3208. 1:54:31override this parameter within my
  3209. 1:54:33notebook as well when I am running this
  3210. 1:54:35within my development environment. when
  3211. 1:54:37we just do it in the you can say
  3212. 1:54:39orchestration in the form of job, we
  3213. 1:54:41override this parameter directly via the
  3214. 1:54:43Databricks jobs. And we will just talk
  3215. 1:54:45about Databricks jobs very very soon. So
  3216. 1:54:46do not worry about that. First you need
  3217. 1:54:48to understand that this state now can be
  3218. 1:54:50overridden. And now how we use this
  3219. 1:54:52thing, let's say this is there, but how
  3220. 1:54:54we use it? Let me show you. So we use a
  3221. 1:54:57special kind of module and that's where
  3222. 1:54:59I was just confused. dbutils.widgets.get
  3223. 1:55:03and here I just need to provide the name
  3224. 1:55:05of it.
  3225. 1:55:06That is it. And I can store this value
  3226. 1:55:09in the variable
  3227. 1:55:11like this. Oh. So now if I run this
  3228. 1:55:14thing,
  3229. 1:55:16this will get the print statement like
  3230. 1:55:17this. Last load date wow. Let me just
  3231. 1:55:19try a test string here.
  3232. 1:55:22Perfect.
  3233. 1:55:24Um last load date is not found. Very
  3234. 1:55:26good because we had last load
  3235. 1:55:28variable.
  3236. 1:55:30Cool. Now you can see that it is
  3237. 1:55:31printing 19000101.
  3238. 1:55:33Now if I just override this thing, let's
  3239. 1:55:35say
  3240. 1:55:36um
  3241. 1:55:372026
  3242. 1:55:3911 05
  3243. 1:55:41if I just
  3244. 1:55:43run this thing now, it will show me this
  3245. 1:55:44date. So we override this date using
  3246. 1:55:47this particular module like this.
  3247. 1:55:50Makes sense? And when you are just
  3248. 1:55:51developing this thing in the development
  3249. 1:55:52environment, you just do it directly via
  3250. 1:55:54this notebook. But when you are
  3251. 1:55:57orchestrating this notebook, you are
  3252. 1:55:58done with the development and you know
  3253. 1:55:59you just need to orchestrate it, you
  3254. 1:56:01override this parameter directly via the
  3255. 1:56:04jobs.
  3256. 1:56:05We will just look at it. Do not worry.
  3257. 1:56:06So this is the way we just use the
  3258. 1:56:08dbutils command.
  3259. 1:56:09I hope this makes you um you can say
  3260. 1:56:13aware about this module very well so
  3261. 1:56:15that you can just explore more and you
  3262. 1:56:16can just learn more. But to be honest,
  3263. 1:56:1880% of the time we just use FS and
  3264. 1:56:21widgets commands, but obviously
  3265. 1:56:23sometimes using secrets as well. So
  3266. 1:56:24yeah, that's it. Makes sense? Very good.
  3267. 1:56:27So now let's talk about this amazing
  3268. 1:56:29thing and you might feel like is it
  3269. 1:56:32related to Databricks only? Um not
  3270. 1:56:34actually because this is a kind of
  3271. 1:56:35design thing that we just built. But you
  3272. 1:56:37know what? Databricks was one of the
  3273. 1:56:40earliest, you can say, creators of
  3274. 1:56:43medallion architecture because they just
  3275. 1:56:45came up with the lakehouse architecture
  3276. 1:56:47and this medallion thing was also be
  3277. 1:56:49like very popular into that particular
  3278. 1:56:51um structure.
  3279. 1:56:52Do not worry about lakehouse, okay?
  3280. 1:56:54Because lakehouse is nothing but when
  3281. 1:56:56you just put your data in the data lake
  3282. 1:56:57and you just query the data using your
  3283. 1:56:59um you can say engine on top of it. So
  3284. 1:57:02it is totally fine. You do not need to
  3285. 1:57:03worry about lakehouse, data lake,
  3286. 1:57:05warehouse. These are the architecture
  3287. 1:57:07things. We are talking about Databricks
  3288. 1:57:10and medallion architecture is the thing
  3289. 1:57:12which is not actually a kind of
  3290. 1:57:15data architecture.
  3291. 1:57:17This is a kind of strategy that we use
  3292. 1:57:20to build our final data architecture.
  3293. 1:57:22Let me just make it clear.
  3294. 1:57:24So first of all,
  3295. 1:57:25when we talk about data architecture, we
  3296. 1:57:27talk about lambda architecture, kappa
  3297. 1:57:29architecture, lakehouse architecture,
  3298. 1:57:31data mesh, data fabric. These are the
  3299. 1:57:32pure data architecture things.
  3300. 1:57:34Medallion architecture is the journey of
  3301. 1:57:37the data. Let me just tell you. So for
  3302. 1:57:39example, let's say
  3303. 1:57:40um I want to use Databricks, right?
  3304. 1:57:43for the entire data lifecycle. Cool.
  3305. 1:57:46Very good.
  3306. 1:57:47Now obviously there can be some sources.
  3307. 1:57:49Um sources can be let say S3, which is
  3308. 1:57:52very popular one, data lake,
  3309. 1:57:54database,
  3310. 1:57:56database, um database, okay?
  3311. 1:58:00Then you can also have maybe Kafka. Like
  3312. 1:58:02you can just imagine anything. Let's say
  3313. 1:58:03Event Hub. Let's bring some Azure stuff
  3314. 1:58:06as well. So let's say Event Hub. These
  3315. 1:58:08are some of the very popular popular
  3316. 1:58:10sources that we data engineers deal with
  3317. 1:58:12a lot of times, right? Simple.
  3318. 1:58:15And the end goal is to
  3319. 1:58:18store this data or you can say
  3320. 1:58:21not store, basically represent. We want
  3321. 1:58:24to build the presentation layer, the
  3322. 1:58:26final layer, the serving layer
  3323. 1:58:28into the Databricks.
  3324. 1:58:30Now obviously, Databricks does not hold
  3325. 1:58:32your data. It will be attached to the
  3326. 1:58:34data like under the hood. That is like
  3327. 1:58:36non-negotiable. We know that thing. But
  3328. 1:58:38you need to understand this thing that
  3329. 1:58:39at the end we will be using Databricks
  3330. 1:58:42to just build reports, let's say. I want
  3331. 1:58:45to build reports, let's say
  3332. 1:58:48Power BI, okay, um Tableau, blah blah
  3333. 1:58:51blah. I don't know who is using Tableau
  3334. 1:58:53nowadays. Angela, a lot of people are
  3335. 1:58:55using. Yeah, yeah. I don't know why they
  3336. 1:58:56are still using because
  3337. 1:58:59outdated stuff. So Power BI is there,
  3338. 1:59:01right? You can have, let say, some data
  3339. 1:59:03scientists, data science people, AI
  3340. 1:59:05engineers, anything because AI is also
  3341. 1:59:07built on top of the final data. Let's
  3342. 1:59:08say we have some agents as well, right?
  3343. 1:59:10Nowadays
  3344. 1:59:11agents are the most popular stakeholders
  3345. 1:59:14for all the data. So let's say agents
  3346. 1:59:16are using this data. Perfect, makes
  3347. 1:59:18sense.
  3348. 1:59:19Now you think, you think that it is just
  3349. 1:59:23point A to point B journey. It is not
  3350. 1:59:26the reality. There are some, you can
  3351. 1:59:28say, checkpoints in the between. There
  3352. 1:59:30are some, you can say,
  3353. 1:59:33small small
  3354. 1:59:35destinations that you just need to
  3355. 1:59:37actually see. So what are these
  3356. 1:59:39destinations? Let me just tell you. The
  3357. 1:59:40first of all, you will see the very
  3358. 1:59:43first thing which is nothing but
  3359. 1:59:46a layer. This is the layer
  3360. 1:59:49that we use
  3361. 1:59:50to literally dump our data in as it is
  3362. 1:59:54form. What do I mean? If I'm just
  3363. 1:59:56ingesting the data from AWS S3,
  3364. 1:59:58I will have one layer, I will have one
  3365. 2:00:00stop where I will literally create the
  3366. 2:00:03replica of the data. Why do I do that?
  3367. 2:00:05So that I also own the data which is
  3368. 2:00:08available on the source side.
  3369. 2:00:11Cool. We just use it and we just call
  3370. 2:00:13this thing as
  3371. 2:00:15bronze layer. Okay? Bronze.
  3372. 2:00:17Then we perform some cleaning. We
  3373. 2:00:21perform some transformation. We perform
  3374. 2:00:23some, you can say,
  3375. 2:00:26some kind of manipulation, right? This
  3376. 2:00:29is called transformation and this layer
  3377. 2:00:30is called silver layer.
  3378. 2:00:32Here the data will be cleaned, first of
  3379. 2:00:34all. Data will be deduplicated.
  3380. 2:00:37Data will be
  3381. 2:00:38joined. Okay? Data will be created in a
  3382. 2:00:41kind of a separate structure that we
  3383. 2:00:44want to use it, our organizations want
  3384. 2:00:46to use. In some scenarios, we might
  3385. 2:00:48create the entities as well, like
  3386. 2:00:50totally different entities out of the
  3387. 2:00:52data that we have the bronze layer.
  3388. 2:00:54In short, data will be cleaned.
  3389. 2:00:57Simple? Very good.
  3390. 2:00:58The third thing that we have is the
  3391. 2:01:00final thing, which is the gold layer.
  3392. 2:01:02Okay?
  3393. 2:01:03In the gold layer, data will be
  3394. 2:01:05available
  3395. 2:01:07in the
  3396. 2:01:08final, you can say
  3397. 2:01:12layer or you can say in the final
  3398. 2:01:13structure. Like this data is the final
  3399. 2:01:15one.
  3400. 2:01:16Here you create the models, dimensional
  3401. 2:01:18data models, fact tables,
  3402. 2:01:20dimension tables. If you are working
  3403. 2:01:22with data vault, you will create
  3404. 2:01:23satellite links, all of these things.
  3405. 2:01:26Make sense? This is the gold layer. In
  3406. 2:01:28some scenarios, you might also create
  3407. 2:01:29OBD, which is one big table.
  3408. 2:01:31So in short, gold layer is just to serve
  3409. 2:01:33our data. So in short, we can say that
  3410. 2:01:35we connect our data to this gold layer.
  3411. 2:01:38Oh, yes. But we also have B and S as
  3412. 2:01:41well.
  3413. 2:01:43Okay? Bronze, silver, gold. This is the
  3414. 2:01:45entire medallion architecture.
  3415. 2:01:47It is not a structure, it is not an
  3416. 2:01:49architecture, it is not a design. It is
  3417. 2:01:51just a journey of the data which says
  3418. 2:01:54that
  3419. 2:01:55data will be much more clean and
  3420. 2:01:58reliable as it moves forward the line.
  3421. 2:02:01Simple. Because you can less rely on
  3422. 2:02:03this data because it is literally raw
  3423. 2:02:04data. You can rely more on this data
  3424. 2:02:06because it is at least clean,
  3425. 2:02:08deduplicated and blah blah blah. You can
  3426. 2:02:10most rely on this data because this is
  3427. 2:02:12the final data that we are representing.
  3428. 2:02:15I hope it makes sense. This is the
  3429. 2:02:16medallion architecture.
  3430. 2:02:18Okay?
  3431. 2:02:19Now let's try to see this thing with the
  3432. 2:02:21help of an example. We will create three
  3433. 2:02:23notebooks. The first one, I will simply
  3434. 2:02:25ingest the data. In the second one, we
  3435. 2:02:27might perform some transformation,
  3436. 2:02:28simple transformation, because obviously
  3437. 2:02:30we're not mastering PySpark here.
  3438. 2:02:32PySpark, we know that we need to master
  3439. 2:02:34PySpark for Databricks. And if you just
  3440. 2:02:36want to learn PySpark, you can literally
  3441. 2:02:38refer to a dedicated PySpark resource.
  3442. 2:02:39And I also have created the PySpark
  3443. 2:02:41course. You can literally go through
  3444. 2:02:42that particular one. And I hope that you
  3445. 2:02:44might have some PySpark experience.
  3446. 2:02:46Only then you are just learning
  3447. 2:02:47Databricks, right? So we will be just
  3448. 2:02:49using PySpark and then I will just show
  3449. 2:02:51you that how we can just serve our
  3450. 2:02:53table. We can even create the aggregated
  3451. 2:02:54views. The
  3452. 2:02:57and you can say
  3453. 2:02:59the motive here is not to just show you
  3454. 2:03:01how you can just master PySpark. The
  3455. 2:03:02motive is how you can just learn the
  3456. 2:03:04Medallion architecture. Like what is the
  3457. 2:03:06intention behind it? Okay, so we'll just
  3458. 2:03:08perform very very simple simple you can
  3459. 2:03:09say transformations. And then
  3460. 2:03:12the next topic is directly linked to it,
  3461. 2:03:14which is Databricks jobs. Then we will
  3462. 2:03:16see how we can orchestrate our
  3463. 2:03:18notebooks, orchestrate our resources,
  3464. 2:03:19everything. Cool. So let's try to
  3465. 2:03:21perform this thing. And let me just
  3466. 2:03:23bring my Databricks workspace.
  3467. 2:03:25So this is my Databricks workspace.
  3468. 2:03:27Let me just create a new notebook. Let
  3469. 2:03:29me just click on this folder. Let me
  3470. 2:03:31just say create and new notebook.
  3471. 2:03:34Perfect. So this notebook will be called
  3472. 2:03:36as fifth
  3473. 2:03:38bronze.
  3474. 2:03:39I can even create everything within the
  3475. 2:03:41same notebook, but I want you to feel
  3476. 2:03:43the real world taste as well. So that is
  3477. 2:03:45why I have just created this new
  3478. 2:03:46notebook. And in this notebook, first of
  3479. 2:03:48all, I will ingest the data. And we know
  3480. 2:03:50that we have data in the orders table,
  3481. 2:03:52if you remember.
  3482. 2:03:54You I think we just dumped some data in
  3483. 2:03:57the S3, right? Let me just open my AWS
  3484. 2:04:00account as well in parallel so that we
  3485. 2:04:01can just see what do we have.
  3486. 2:04:03So I have opened my AWS account and let
  3487. 2:04:06me just click on S3
  3488. 2:04:08just to see what do we have. So we have
  3489. 2:04:09this particular lake and we have this
  3490. 2:04:11raw data, right?
  3491. 2:04:13So what we're going to do, we will open
  3492. 2:04:14this raw table, okay, or basically raw
  3493. 2:04:16folder. And then we will let me just
  3494. 2:04:20dump more data if I have more data. Let
  3495. 2:04:22me just see it here.
  3496. 2:04:25So
  3497. 2:04:27yeah, I think I have more data.
  3498. 2:04:29So let me just dump at least one to two
  3499. 2:04:31more files. And yeah, so let me just
  3500. 2:04:34upload.
  3501. 2:04:35Um, I have products as well.
  3502. 2:04:38So let's upload products.
  3503. 2:04:41And should we upload order items as
  3504. 2:04:44well? Order items, yes. And then we can
  3505. 2:04:46also
  3506. 2:04:48import employees. Perfect. So I have
  3507. 2:04:51uploaded these three files as well. And
  3508. 2:04:53now all of this data is in my S3.
  3509. 2:04:56Now you can imagine that this is our
  3510. 2:04:58source and not imagine like this is our
  3511. 2:05:00source and within the source we have
  3512. 2:05:02these these files. Okay? And this is
  3513. 2:05:03sitting in the S3. This is our source.
  3514. 2:05:06Now
  3515. 2:05:07this is a kind of you can say OLTP style
  3516. 2:05:10data where we have orders, order items,
  3517. 2:05:12products, employees, all of these
  3518. 2:05:13things, right? So now what I will do in
  3519. 2:05:15the very first notebook, I will ingest
  3520. 2:05:18this data.
  3521. 2:05:19Where? In my um bronze layer, right? And
  3522. 2:05:23in order to create the bronze layer, I
  3523. 2:05:25can also have the dedicated schemas for
  3524. 2:05:28that like bronze, silver, gold. I can
  3525. 2:05:30just have this thing as well if I want
  3526. 2:05:32to. So what I will do, I will simply say
  3527. 2:05:34create schema
  3528. 2:05:36if not exists.
  3529. 2:05:39And the schema name will be um catalog
  3530. 2:05:41name. What is my catalog name? Let me
  3531. 2:05:43just check. So catalog name is demo.
  3532. 2:05:46I'll simply say demo dot
  3533. 2:05:48bronze. Let me just run this thing.
  3534. 2:05:50So here I will truly create the schema.
  3535. 2:05:52That's it. Cool.
  3536. 2:05:54Very good. So once the schema is here,
  3537. 2:05:56then what I will do, I will simply
  3538. 2:05:57ingest the data one by one. And what I
  3539. 2:06:00need to do? Nothing.
  3540. 2:06:02Simply dump the data in as it is form,
  3541. 2:06:05in as it is. Yes, you can only do one
  3542. 2:06:08thing which is like very obvious. You
  3543. 2:06:09can just change the format of the data
  3544. 2:06:11because what we do usually, we do not
  3545. 2:06:14want to keep our data in the CSV format.
  3546. 2:06:16We want to have the data at least in the
  3547. 2:06:18delta format, right? So what you can do,
  3548. 2:06:20you do not need to transform anything,
  3549. 2:06:22but you can ingest the data in the delta
  3550. 2:06:25tables or basically in the delta format.
  3551. 2:06:28Makes sense? How you can just do that?
  3552. 2:06:29Let me just show you very basics of
  3553. 2:06:31PySpark. So first of all, you will just
  3554. 2:06:33perform this thing. DF equals spark dot
  3555. 2:06:36read dot format format is CSV, right?
  3556. 2:06:40And here you will simply write your
  3557. 2:06:41option.
  3558. 2:06:43Option is header
  3559. 2:06:45true, then one more
  3560. 2:06:48which is inverse schema because by
  3561. 2:06:50default we do not get these schema in a
  3562. 2:06:52CSV file. CSV is just a text file. I'll
  3563. 2:06:54simply say true and
  3564. 2:06:56finally I'll simply say load. Now this
  3565. 2:06:59thing is very very
  3566. 2:07:00good for you as well being a developer.
  3567. 2:07:01So now as you just saw that we have
  3568. 2:07:03multiple files in my S3 bucket. I do not
  3569. 2:07:07like to ingest the data one by one
  3570. 2:07:09duplicating my code. No.
  3571. 2:07:12I always promote modular coding. You
  3572. 2:07:14need to be a programmer where you can
  3573. 2:07:16just literally
  3574. 2:07:17perform the things
  3575. 2:07:19efficiently. So what I will do? I will
  3576. 2:07:20literally I will literally run the loop.
  3577. 2:07:22I'll simply say for I in
  3578. 2:07:26db utils dot fl dot ls. Remember I just
  3579. 2:07:29talked about this thing. You can
  3580. 2:07:30literally fetch everything. So here I
  3581. 2:07:32will get the path of this file.
  3582. 2:07:35I'll simply say copy URI
  3583. 2:07:37copy S3 URI.
  3584. 2:07:38Why do we have this button if it is
  3585. 2:07:40grayed out?
  3586. 2:07:42Bro, S3 AWS what are you doing?
  3587. 2:07:46So this is the folder. Cool. So I want
  3588. 2:07:49to run the loop over here and this is my
  3589. 2:07:53you can say df. So now what I will do? I
  3590. 2:07:55will literally have this particular I
  3591. 2:07:58and just to show you first of all we
  3592. 2:08:01need to see what do we have it here. So
  3593. 2:08:03I'll simply say print I
  3594. 2:08:05just to see what exact thing exact keys
  3595. 2:08:07that we have within this loop within
  3596. 2:08:08this list. So we have the entire path.
  3597. 2:08:11See?
  3598. 2:08:12So that means I can use I dot path if I
  3599. 2:08:15just write I dot path
  3600. 2:08:18to see the data frames.
  3601. 2:08:19Right? So what I will do? I will simply
  3602. 2:08:21write the code here and here I will
  3603. 2:08:24write I dot path. Now it will happen it
  3604. 2:08:27will load the data frame one by one of
  3605. 2:08:29each file. Wow.
  3606. 2:08:31But I do not just want to load the data
  3607. 2:08:33frame. I also want to create the delta
  3608. 2:08:35table. So I will say
  3609. 2:08:37df dot
  3610. 2:08:39write dot format, right? And here I can
  3611. 2:08:42do?
  3612. 2:08:43I can say I want to just save in the
  3613. 2:08:45data format.
  3614. 2:08:47And here I want to perform option. Um,
  3615. 2:08:51no. I just want to perform directly mode
  3616. 2:08:53and I want to perform let say
  3617. 2:08:55append.
  3618. 2:08:56Append.
  3619. 2:08:57I can perform append. I can even perform
  3620. 2:08:59overwrite, but let say append.
  3621. 2:09:01Cool. Then I will simply say dot save as
  3622. 2:09:03table.
  3623. 2:09:05What?
  3624. 2:09:07[laughter]
  3625. 2:09:08Save as table and then
  3626. 2:09:10I will simply say demo dot and bronze
  3627. 2:09:14dot. Now here is a tricky thing.
  3628. 2:09:17Now if you just look at this thing, I
  3629. 2:09:19have I have
  3630. 2:09:21this table name. Now obviously I cannot
  3631. 2:09:23pick the um you can say static name for
  3632. 2:09:27all the tables because it will literally
  3633. 2:09:29create the bug because I cannot have the
  3634. 2:09:32table name same for all the tables. So
  3635. 2:09:34how I can just dynamically fetch the
  3636. 2:09:36names out of it? So I can do a lot of
  3637. 2:09:38things here. So the best thing I think
  3638. 2:09:40is we can just use um
  3639. 2:09:43employees dot csv. Do we have the file
  3640. 2:09:46name here? So I would have to use I
  3641. 2:09:48think regex.
  3642. 2:09:49So
  3643. 2:09:50um yeah. So I think employees dot csv.
  3644. 2:09:56So let me just see if we get the file
  3645. 2:09:58name separately as well because if we
  3646. 2:10:00have the file name
  3647. 2:10:02then I can literally ignore regex,
  3648. 2:10:04otherwise I have to use it. So we have
  3649. 2:10:06file info, we have file path. Yes, we
  3650. 2:10:08have name. So we have the name because I
  3651. 2:10:10was thinking like we get a lot of
  3652. 2:10:11metadata. So I can use here i dot name
  3653. 2:10:15dot
  3654. 2:10:17i dot name. But here is one thing. I
  3655. 2:10:19cannot directly use i dot name because
  3656. 2:10:21in the name I have employees dot csv as
  3657. 2:10:23well. So here I would need to remove
  3658. 2:10:26this dot csv from my i dot name because
  3659. 2:10:29I do not want to include dot csv. So
  3660. 2:10:31what I can do here I can literally
  3661. 2:10:33perform this thing.
  3662. 2:10:36So let say
  3663. 2:10:38table name
  3664. 2:10:40equals i dot name. Okay? And then can
  3665. 2:10:44say table name
  3666. 2:10:46equals
  3667. 2:10:48table name. Or let's say first of all
  3668. 2:10:50file name because this is the
  3669. 2:10:52file name
  3670. 2:10:53just to make it like more readable. And
  3671. 2:10:55then table name
  3672. 2:10:57equals file name
  3673. 2:11:00dot split and I want to split it on dot
  3674. 2:11:04and then I just want to fetch the zeroth
  3675. 2:11:06index which is the very first index.
  3676. 2:11:07And then I can write here
  3677. 2:11:10table name. I hope it makes sense.
  3678. 2:11:13Nothing fancy, just basics. And now if I
  3679. 2:11:16just run this particular code, now what
  3680. 2:11:18it should do it should create all of the
  3681. 2:11:20tables dynamically
  3682. 2:11:22in the loop. I do not need to hard code
  3683. 2:11:24that particular same code again and
  3684. 2:11:26again.
  3685. 2:11:28This will just do my work. Okay. I hope
  3686. 2:11:30so if there are no little little small
  3687. 2:11:32small bugs. And let's wait. Let's wait
  3688. 2:11:35for it to complete and let's see our all
  3689. 2:11:37the bronze tables if we have it ready.
  3690. 2:11:39And if we have it ready then boom.
  3691. 2:11:45I think four five. Okay. So now I think
  3692. 2:11:48all of the tasks are completed. Cool. So
  3693. 2:11:50this says it is completed. So now if I
  3694. 2:11:54just
  3695. 2:11:55run this thing.
  3696. 2:11:57So I should have used override but it is
  3697. 2:12:00fine. It is fine. It is fine. It is
  3698. 2:12:02fine. So if I just show you my tables,
  3699. 2:12:04let me just expand this thing. So I have
  3700. 2:12:06this bronze schema.
  3701. 2:12:07And within that I have these tables. See
  3702. 2:12:09employees, order items, orders,
  3703. 2:12:10products. All of these tables are
  3704. 2:12:12created using this particular modular
  3705. 2:12:14code. I hope it makes sense. Simple.
  3706. 2:12:16And I can even query anything. Let's say
  3707. 2:12:18select asterisk from
  3708. 2:12:21demo. bronze. orders.
  3709. 2:12:25Cool. So this should just display data
  3710. 2:12:27because it is in the delta format.
  3711. 2:12:29And all of these tables are not CSV
  3712. 2:12:31tables. These are the delta tables.
  3713. 2:12:34Cool. And yes, we can directly create
  3714. 2:12:37the table using dot save as table
  3715. 2:12:39method. We do not even need to write
  3716. 2:12:40create table table name. No. When we are
  3717. 2:12:43using PySpark we just use this method.
  3718. 2:12:45Cool. So this is done. My bronze
  3719. 2:12:48notebook is completed and I cannot and I
  3720. 2:12:51should not perform any kind of
  3721. 2:12:53transformation. Now I will simply go to
  3722. 2:12:54my new notebook.
  3723. 2:12:56And this note will be silver. So let's
  3724. 2:12:58say oh not a file. I don't want to
  3725. 2:13:01create a new file because I'm not
  3726. 2:13:03writing any py code.
  3727. 2:13:05You can even create py file as well.
  3728. 2:13:07Same thing but
  3729. 2:13:09notebooks are very good for PySpark
  3730. 2:13:11developers.
  3731. 2:13:12So let's say
  3732. 2:13:13six silver.
  3733. 2:13:15Cool. So this is my
  3734. 2:13:17notebook, silver notebook. So what I
  3735. 2:13:19need to do now? I need to perform the
  3736. 2:13:21transformation on the independent table.
  3737. 2:13:24So what we do? We always try to perform
  3738. 2:13:26some transformation. And here as I just
  3739. 2:13:28mentioned, we are not mastering PySpark.
  3740. 2:13:30So we will not be performing a lot of
  3741. 2:13:31PySpark transformations, right? We will
  3742. 2:13:33simply simulate that we are transforming
  3743. 2:13:35our data and that's it.
  3744. 2:13:36So first of all, I will
  3745. 2:13:38read DF orders and then I'll simply say
  3746. 2:13:41spark dot read dot table because this
  3747. 2:13:44time we have the delta table.
  3748. 2:13:46I will simply say three level namespace
  3749. 2:13:48first of all. Demo dot
  3750. 2:13:50bronze dot
  3751. 2:13:53orders.
  3752. 2:13:54Cool. And then I can say display
  3753. 2:13:56DF orders.
  3754. 2:14:01Cool. Let's wait.
  3755. 2:14:03And this should display the orders.
  3756. 2:14:09Perfect.
  3757. 2:14:12So this particular DF is ready. Cool.
  3758. 2:14:14Now if you just want to
  3759. 2:14:16perform anything, any transformation,
  3760. 2:14:18you can just perform. And because we are
  3761. 2:14:20simulating this thing, so you can just
  3762. 2:14:21imagine that we have performed a lot of
  3763. 2:14:24transformations according to our use
  3764. 2:14:26case.
  3765. 2:14:27Simple.
  3766. 2:14:28Very good.
  3767. 2:14:29Now what I will do? I will literally
  3768. 2:14:32perform this thing.
  3769. 2:14:34I will literally load all of the other
  3770. 2:14:36tables as well. So I'll simply say DF
  3771. 2:14:39order items
  3772. 2:14:42equals let say
  3773. 2:14:44yeah perfect and then let's load
  3774. 2:14:47DF products.
  3775. 2:14:50We have products, we do not have
  3776. 2:14:51customers and all.
  3777. 2:14:53I think we have one more table which is
  3778. 2:14:56employees. Cool.
  3779. 2:14:58So let's say employees.
  3780. 2:15:03So we have all of the tables loaded.
  3781. 2:15:06And let me just check one of these.
  3782. 2:15:08Let's say ordered
  3783. 2:15:10items.
  3784. 2:15:13So we have just loaded all of the data
  3785. 2:15:15frames. Order items is not defined. Wow.
  3786. 2:15:18TF order items.
  3787. 2:15:23So cool. So I have all of this
  3788. 2:15:25information available. Now what I will
  3789. 2:15:26do, as I just mentioned, you can just
  3790. 2:15:28imagine that we have performed a lot of
  3791. 2:15:30transformations. So here I will
  3792. 2:15:32literally at the end, after performing
  3793. 2:15:34all the transformations because this
  3794. 2:15:35data is already cleaned, now I will
  3795. 2:15:37literally join these tables. Okay? So
  3796. 2:15:39how I can just join these tables? So
  3797. 2:15:40let's say DF join.
  3798. 2:15:42And I can write the code to join all of
  3799. 2:15:45these tables. Let's say DF orders
  3800. 2:15:49dot join then order items. And I want to
  3801. 2:15:52join it on the order ID.
  3802. 2:15:54Then let's say order ID and then I want
  3803. 2:15:57to perform inner join, but ideally I
  3804. 2:15:59should just perform left join, but it's
  3805. 2:16:00fine.
  3806. 2:16:01Cool. So that's how you can just perform
  3807. 2:16:03join. And if you just see
  3808. 2:16:05it is DF join, you will
  3809. 2:16:08see the table.
  3810. 2:16:11And now let's wait. So this is the join
  3811. 2:16:13data set where we have order and order
  3812. 2:16:15items.
  3813. 2:16:15So similarly you can just join this
  3814. 2:16:18particular Do we have order items?
  3815. 2:16:22DF order items.
  3816. 2:16:26I think Yeah, yeah. We have all of
  3817. 2:16:28things. So this is the way we can just
  3818. 2:16:30perform all of the joins. But now let me
  3819. 2:16:32just write the code to join all of the
  3820. 2:16:35data frames together. And here you can
  3821. 2:16:36even write the SQL query if you want to.
  3822. 2:16:38So it is fine. Okay?
  3823. 2:16:40So this is the code that I have just
  3824. 2:16:41used to join all of my data frames.
  3825. 2:16:44Nothing special, very fundamentals of
  3826. 2:16:46PySpark where we literally join the
  3827. 2:16:49like the same thing I have just written
  3828. 2:16:51multiple times and I literally delegated
  3829. 2:16:53this task to Jenny and Jenny just wrote
  3830. 2:16:55this particular code for me. Same
  3831. 2:16:57boilerplate stuff because you do not
  3832. 2:16:58need to write the boilerplate code again
  3833. 2:17:01and again repeatedly, right? Especially
  3834. 2:17:03in the AI era. So this is the code. Let
  3835. 2:17:05me just run it for you just to show you
  3836. 2:17:07again the results. Obviously I know like
  3837. 2:17:09this is working fine but still.
  3838. 2:17:11So this is the end data frame which is
  3839. 2:17:13cleaned, which is joined and this is now
  3840. 2:17:15serving as a kind of one big white table
  3841. 2:17:19that we just use in the silver layer.
  3842. 2:17:21Cool, very good. So this is all about
  3843. 2:17:23the silver layer that we have just
  3844. 2:17:24created. Now let's create the final
  3845. 2:17:27notebook which is our gold notebook,
  3846. 2:17:29right? So let's name it as
  3847. 2:17:32seven gold. And here what we do in the
  3848. 2:17:35gold notebook, we perform dimensional
  3849. 2:17:37modeling, we create fact tables,
  3850. 2:17:39dimension tables, we create aggregated
  3851. 2:17:40tables. It depends like what
  3852. 2:17:42stakeholders want. So let's imagine that
  3853. 2:17:44they want some aggregated views or
  3854. 2:17:46aggregated tables that we can just
  3855. 2:17:47create in the gold layer. Okay?
  3856. 2:17:49So first of all
  3857. 2:17:51you need to
  3858. 2:17:52read data frame.
  3859. 2:17:55So spark dot read dot
  3860. 2:17:57format or let's say table.
  3861. 2:18:00Because we have a table. Did we create
  3862. 2:18:02the table? I think no because it
  3863. 2:18:03literally joined the data frame. So
  3864. 2:18:05let me just write the table quickly.
  3865. 2:18:08So DF join
  3866. 2:18:10dot write dot format.
  3867. 2:18:13Format is let's say delta.
  3868. 2:18:15And then mode overwrite. Yeah, let's use
  3869. 2:18:18overwrite then dot save
  3870. 2:18:20as
  3871. 2:18:22table.
  3872. 2:18:24And table will be let's say demo silver
  3873. 2:18:26orders.
  3874. 2:18:27Orders OBT.
  3875. 2:18:30Cool. Nice strong this time.
  3876. 2:18:32And I'm just using overwrite that makes
  3877. 2:18:34sense. Demo dot silver cannot be found.
  3878. 2:18:36Yes, because we didn't create the
  3879. 2:18:38schema. So let me just quickly create
  3880. 2:18:40the schema here.
  3881. 2:18:42Create
  3882. 2:18:43schema if
  3883. 2:18:45not exists.
  3884. 2:18:48It's demo dot silver.
  3885. 2:18:50Cool.
  3886. 2:18:52That's okay. It's done. So now let me
  3887. 2:18:54just run this particular set.
  3888. 2:18:58Let's wait, let's wait, let's wait.
  3889. 2:19:02Hm cool so this is done and I'm also
  3890. 2:19:03planning to mark here as overwrite
  3891. 2:19:07instead of append
  3892. 2:19:08because we might run this thing multiple
  3893. 2:19:11times. So let me just run it one more
  3894. 2:19:12time.
  3895. 2:19:14And this is
  3896. 2:19:16why why it is append?
  3897. 2:19:18I just changed it to overwrite.
  3898. 2:19:22Oh
  3899. 2:19:23no worries at all. I can simply write
  3900. 2:19:25overwrite here.
  3901. 2:19:30Cool and I can just confirm this thing
  3902. 2:19:32if this is
  3903. 2:19:35yeah
  3904. 2:19:36select asterisks from
  3905. 2:19:39demo.bronze.
  3906. 2:19:42orders or I can write count here
  3907. 2:19:47just to confirm the mess that we have
  3908. 2:19:48created.
  3909. 2:19:50Okay 10,000 very good. So if I just run
  3910. 2:19:52this thing again and if I just again
  3911. 2:19:54count the things I should see 10,000 if
  3912. 2:19:56everything is fine otherwise something
  3913. 2:19:57is wrong.
  3914. 2:19:59So so so
  3915. 2:20:02cool
  3916. 2:20:06yes perfect everything is fine. I can
  3917. 2:20:07see 10,000. So that means our table are
  3918. 2:20:09good. Tables are good because we might
  3919. 2:20:11run it multiple times via a job so it is
  3920. 2:20:13fine. So this is done this is created.
  3921. 2:20:15Now let me just try it
  3922. 2:20:17silver um
  3923. 2:20:20demo
  3924. 2:20:22dot
  3925. 2:20:25silver
  3926. 2:20:27then orders OBT. Cool.
  3927. 2:20:31So this is my data frame and let me just
  3928. 2:20:33quickly create create schema if not
  3929. 2:20:37exists
  3930. 2:20:40demo.
  3931. 2:20:42gold.
  3932. 2:20:44So this is display
  3933. 2:20:47DF
  3934. 2:20:48and let's see what do we have in the
  3935. 2:20:50data frame.
  3936. 2:20:52And let's try to create one aggregated
  3937. 2:20:54view and the very simple aggregated view
  3938. 2:20:55that you can just expect from any
  3939. 2:20:58stakeholder is so let's take a real
  3940. 2:21:00world requirement that you as a
  3941. 2:21:02developer or you as a data engineer
  3942. 2:21:04would receive most probably. Let's say
  3943. 2:21:07the store or store owner, store manager
  3944. 2:21:10or let's say any analytics manager,
  3945. 2:21:11anyone who is just trying to figure out
  3946. 2:21:13some KPIs to help the store grow because
  3947. 2:21:16there can be like multiple stores for
  3948. 2:21:18that particular store chain. As you can
  3949. 2:21:20see we also have like multiple stores,
  3950. 2:21:21store ID, blah blah blah.
  3951. 2:21:23So let's say
  3952. 2:21:24manager wants to see which store is
  3953. 2:21:26performing good. First of all on the
  3954. 2:21:28basis of number of orders, second is on
  3955. 2:21:30the basis of number of customers. So
  3956. 2:21:32that
  3957. 2:21:34manager or analytics manager or anyone
  3958. 2:21:36who is performing the analytics can
  3959. 2:21:37better determine what things do they
  3960. 2:21:39need. Do they need more staff because
  3961. 2:21:42the orders are more or do they need some
  3962. 2:21:44more you can say people on the floor
  3963. 2:21:46because there are more number of
  3964. 2:21:47customers so that they can help or they
  3965. 2:21:48can just assist the customers better,
  3966. 2:21:50right? So let's try to build this
  3967. 2:21:52particular kind of view. So how you can
  3968. 2:21:54just create that or let's say aggregated
  3969. 2:21:55table as well. It's not a big deal.
  3970. 2:21:57First of all let's write the code for
  3971. 2:21:59that. So let's say
  3972. 2:22:02DF join, not join, let's say DF
  3973. 2:22:04aggregated.
  3974. 2:22:06Cool and then I will simply say DF dot
  3975. 2:22:09group by and I want to group by on store
  3976. 2:22:12ID again fundamental supply spark.
  3977. 2:22:15And after that
  3978. 2:22:17I will simply say dot agg and then let's
  3979. 2:22:19use count, count on order ID.
  3980. 2:22:24Cool and then I will simply agg as as
  3981. 2:22:26agg
  3982. 2:22:27as this as total orders, cool.
  3983. 2:22:30And let's import the functions quickly
  3984. 2:22:32from PySpark dot SQL dot functions
  3985. 2:22:35import as F.
  3986. 2:22:38Cool. So we have loaded all the
  3987. 2:22:40functions and let's also perform one
  3988. 2:22:41more you can say aggregation which is
  3989. 2:22:45let's go on the next line. Let's say
  3990. 2:22:48count of customer ID
  3991. 2:22:52total dot total customers
  3992. 2:22:54and let's use here comma. Cool.
  3993. 2:22:58I think it looks good so let's see what
  3994. 2:23:00do we have displayed df.
  3995. 2:23:04Uh, let see our aggregated version. So
  3996. 2:23:06that looks good. Just to make it
  3997. 2:23:09look like better, let's me just sort
  3998. 2:23:12this particular data. Let's say df.
  3999. 2:23:15Sort and then let's sort on order ID,
  4000. 2:23:18store ID.
  4001. 2:23:20Cool.
  4002. 2:23:21So perfect. We have all of these things.
  4003. 2:23:23We have total orders.
  4004. 2:23:25Why we are seeing the same numbers? Why
  4005. 2:23:28why why? So each store has these many
  4006. 2:23:31total orders or these many customer IDs.
  4007. 2:23:34Why why why? Oh, I see.
  4008. 2:23:36Because obviously we need to apply the
  4009. 2:23:38distinct as well because here we have
  4010. 2:23:41the customer ID as just the count and we
  4011. 2:23:43need the distinct count. But order is
  4012. 2:23:45fine because I think order ID is the you
  4013. 2:23:47can say primary key, but still we can
  4014. 2:23:49just use the distinct key word.
  4015. 2:23:52So let's use count
  4016. 2:23:55distinct.
  4017. 2:23:57Perfect here as well. Count distinct.
  4018. 2:24:01Perfect.
  4019. 2:24:03Now let's wait. Let's wait. Let's wait.
  4020. 2:24:05Let wait and now now it is good. I was
  4021. 2:24:08like why we have like exact total number
  4022. 2:24:10of orders as exact total number of
  4023. 2:24:11customers. So this is the aggregated
  4024. 2:24:13version of our data frame. That means we
  4025. 2:24:15can literally see the performance of
  4026. 2:24:17each store directly within our view.
  4027. 2:24:19Perfect basically the data frame.
  4028. 2:24:21Now it's our choice if we want to create
  4029. 2:24:22the view, we can even create the view.
  4030. 2:24:24If we want to create the tables, we can
  4031. 2:24:25even create the tables.
  4032. 2:24:27So now let's finally try to create the
  4033. 2:24:28gold table, aggregated table for us. So
  4034. 2:24:31I'll simply say df.
  4035. 2:24:34or df agg. write.
  4036. 2:24:36format
  4037. 2:24:39and let's
  4038. 2:24:39write the write it in the delta format.
  4039. 2:24:43Then let's say dot mode mode let's say
  4040. 2:24:46overwrite.
  4041. 2:24:47Perfect.
  4042. 2:24:49And we do not need to overwrite schema
  4043. 2:24:50because schema will not evolve so it's
  4044. 2:24:52fine. So let's say
  4045. 2:24:54dot save as table.
  4046. 2:24:57And let's say it as demo. gold.
  4047. 2:25:01dot
  4048. 2:25:02orders 80. Cool. So this is my thought
  4049. 2:25:05data frame, which is just the aggregated
  4050. 2:25:07portion of it. Simple.
  4051. 2:25:08So we can even see it if you want to.
  4052. 2:25:11Let's say select a from demo . gold .
  4053. 2:25:17orders
  4054. 2:25:19So this is our final data which will be
  4055. 2:25:22used to
  4056. 2:25:23which will be used for the data
  4057. 2:25:24reporting, analytics, anything, right?
  4058. 2:25:27And we have all the information for each
  4059. 2:25:28store.
  4060. 2:25:29Now, if anyone wants to analyze this
  4061. 2:25:31data, now let's talk about this thing as
  4062. 2:25:33well. This is also the part of
  4063. 2:25:34Databricks concept, on the fly concept.
  4064. 2:25:36So if let's say you just want to allow
  4065. 2:25:39some managers to use this notebook, do
  4066. 2:25:41not worry, they will not edit your
  4067. 2:25:42notebook, but they can do what? They can
  4068. 2:25:44just use the visualizations which are
  4069. 2:25:46created within the notebook itself. How
  4070. 2:25:48we can just do that? Let me show you.
  4071. 2:25:50Click on this plus button. Here you will
  4072. 2:25:52see visualization.
  4073. 2:25:53Here you can use the
  4074. 2:25:55use like literally anything, like if you
  4075. 2:25:58just want to use the
  4076. 2:26:00data which is there, which is let's say
  4077. 2:26:01for
  4078. 2:26:03these particular stores. So if you just
  4079. 2:26:04want to pick the store for like one and
  4080. 2:26:06then pick the total number of orders,
  4081. 2:26:09then total number of customers,
  4082. 2:26:10anything. Okay. So this is your source
  4083. 2:26:12of data.
  4084. 2:26:13Then you can pick any particular, let's
  4085. 2:26:15say bar chart, pie chart, histogram,
  4086. 2:26:18anything. It depends like what exactly
  4087. 2:26:19you want to do. Let's say bar chart.
  4088. 2:26:22You can just pick the column. Let say I
  4089. 2:26:23just want to pick X as store ID. Then Y
  4090. 2:26:27columns is let's say
  4091. 2:26:29total number of orders. So this way I
  4092. 2:26:31will see okay, store number one as
  4093. 2:26:33403 then 366 and like this. And then I
  4094. 2:26:37can also pick some count, same thing
  4095. 2:26:39because you already have the data.
  4096. 2:26:41So you can just pick the count, okay,
  4097. 2:26:42like sum.
  4098. 2:26:44So this is the way you can just build
  4099. 2:26:46the visualization directly within the
  4100. 2:26:47notebook and you can even save it.
  4101. 2:26:49Oh wow. Yes, you can even save it. You
  4102. 2:26:51can even edit these things. You can even
  4103. 2:26:52change the color, blah blah blah.
  4104. 2:26:54Everything is here. So you can just pick
  4105. 2:26:56it. Let say you just want this color,
  4106. 2:26:57you can just pick this color. If you
  4107. 2:26:59want to pick let's say pie chart, this
  4108. 2:27:00is the pie chart according to the store
  4109. 2:27:02IDs. Obviously we do not pick pie chart
  4110. 2:27:04if we let say more than 10 values. That
  4111. 2:27:06that is like kind of standard rule, but
  4112. 2:27:09yeah, you have the options.
  4113. 2:27:10So you can even pick let say histogram,
  4114. 2:27:12you can even pick let say heat map, you
  4115. 2:27:15can even pick let say
  4116. 2:27:16bubble,
  4117. 2:27:17which is not a very good thing, but
  4118. 2:27:19yeah, you have all of these things let
  4119. 2:27:20say cohort, everything.
  4120. 2:27:22Cool? But the very simple and the very
  4121. 2:27:24basic one is your
  4122. 2:27:27bar chart. So this way you can even
  4123. 2:27:28perform or build the visualization
  4124. 2:27:30directly within the notebook as well.
  4125. 2:27:31And you can even save it. Just click on
  4126. 2:27:33save, it will be appearing here and
  4127. 2:27:34that's it because by default you just
  4128. 2:27:36get the table.
  4129. 2:27:38Cool? This is another feature. So this
  4130. 2:27:40is all about your medallion
  4131. 2:27:41architecture. Now your medallion
  4132. 2:27:43architecture, medallion notebooks are
  4133. 2:27:45there. Now we need to understand the
  4134. 2:27:47next concept to completely a kind of you
  4135. 2:27:50can say run this particular thing in
  4136. 2:27:51production. Okay? Let's see. And for
  4137. 2:27:53that we need to understand lake flow
  4138. 2:27:55jobs. And this is yes the one of the
  4139. 2:27:58most important areas for medallion
  4140. 2:28:00architecture. This is not the part of
  4141. 2:28:02medallion architecture first of all, but
  4142. 2:28:05this actually completes the medallion
  4143. 2:28:07architecture. Why? Because have you ever
  4144. 2:28:10heard the word called or term called
  4145. 2:28:13data orchestration?
  4146. 2:28:16If yes, then data
  4147. 2:28:18orchestration in Databricks
  4148. 2:28:20is achieved via lake flow jobs. Oh, as
  4149. 2:28:23the name suggest, this is responsible to
  4150. 2:28:25build the data jobs. And we always build
  4151. 2:28:28jobs for the orchestration.
  4152. 2:28:30What is orchestration? When you want to
  4153. 2:28:33run the specific components of your um
  4154. 2:28:36you can say
  4155. 2:28:38medallion architecture, anything of your
  4156. 2:28:40code, of your solution in a specific
  4157. 2:28:42order. Makes sense?
  4158. 2:28:44So data orchestration is specifically
  4159. 2:28:46done via lake flow jobs. Those
  4160. 2:28:48components, those things, those um you
  4161. 2:28:52can say order is decided by lake flow
  4162. 2:28:53jobs. Lake flow job is a you can say new
  4163. 2:28:56feature relatively.
  4164. 2:28:58It was not there before. So what we were
  4165. 2:29:00using before when we didn't have the
  4166. 2:29:02lake flow jobs, we were using
  4167. 2:29:04the data factory
  4168. 2:29:07via Azure if you are if you were using
  4169. 2:29:10Databricks via Azure which was or which
  4170. 2:29:13is the most popular way okay like using
  4171. 2:29:16Databricks with Azure. So this was like
  4172. 2:29:18one solution. The other solution was
  4173. 2:29:22obviously the airflow
  4174. 2:29:25Apache airflow where you was triggering
  4175. 2:29:27the jobs manually via Apache airflow
  4176. 2:29:31orchestrating the notebooks directly via
  4177. 2:29:33the Apache airflow. So these were like
  4178. 2:29:35two very very popular frameworks
  4179. 2:29:37solutions available for data
  4180. 2:29:39orchestration for our Databricks
  4181. 2:29:40notebooks. But then Databricks created
  4182. 2:29:43its own lake flow jobs because obviously
  4183. 2:29:46Databricks is a complete AI and data
  4184. 2:29:48solution. So obviously they do not want
  4185. 2:29:50the users to go on a different platform
  4186. 2:29:52just to perform the orchestration. So
  4187. 2:29:54they built this orchestration solution
  4188. 2:29:57within the Databricks.
  4189. 2:29:58That makes sense. That makes sense.
  4190. 2:30:00So this is nothing but just the
  4191. 2:30:02orchestration okay like how you run the
  4192. 2:30:03pieces, how you schedule the pieces, how
  4193. 2:30:06you even let say monitor the jobs
  4194. 2:30:08because obviously if you want to monitor
  4195. 2:30:10the things like how the things are
  4196. 2:30:11failing, how the things are going, how
  4197. 2:30:13you are getting the alerts during the
  4198. 2:30:15midnight. So all of these things are
  4199. 2:30:17directly available now in Databricks
  4200. 2:30:20directly.
  4201. 2:30:21Let me just show you quickly within my
  4202. 2:30:23Databricks as well.
  4203. 2:30:25So let's go to home and not even home
  4204. 2:30:28let's say
  4205. 2:30:30click on the menu button click on home
  4206. 2:30:32from here.
  4207. 2:30:33So here
  4208. 2:30:34if you do not see this option jobs and
  4209. 2:30:35pipelines click on plus new you will
  4210. 2:30:37just find it here okay so do not worry.
  4211. 2:30:39So let's say jobs and pipelines.
  4212. 2:30:41So this is the area that we can just see
  4213. 2:30:44and I already have one job so do not
  4214. 2:30:46need to worry. So you can just ignore
  4215. 2:30:48this thing. So this is the area where we
  4216. 2:30:50create jobs and pipelines. Now let me
  4217. 2:30:53just tell you jobs are different,
  4218. 2:30:55pipelines are different. We will just
  4219. 2:30:56talk about pipelines very very soon but
  4220. 2:30:59currently we are just talking about jobs
  4221. 2:31:01lake flow jobs.
  4222. 2:31:02So lake flow jobs means when you are
  4223. 2:31:05orchestrating the things right. So here
  4224. 2:31:07if you just want to create a job you can
  4225. 2:31:09click on jobs here, or you can just
  4226. 2:31:10click here as well, or you can even
  4227. 2:31:12click on create and then job. There are
  4228. 2:31:13multiple options. Let me just click
  4229. 2:31:15here, job.
  4230. 2:31:17So you will see this kind of interface.
  4231. 2:31:19Nothing fancy. This is very very simple.
  4232. 2:31:21The first thing is you first need to
  4233. 2:31:23rename your job. Let say
  4234. 2:31:26I am just renaming it as medallion
  4235. 2:31:29job. This is my job name.
  4236. 2:31:31Then it asks us to pick the tasks
  4237. 2:31:35because obviously within the job
  4238. 2:31:38we need to pick the task,
  4239. 2:31:40right? We need to orchestrate the pieces
  4240. 2:31:42and in our the pieces are notebooks, but
  4241. 2:31:44it can be Python files, it can be SQL
  4242. 2:31:46scripts, it can be anything, but in our
  4243. 2:31:48case it is just notebooks and in most of
  4244. 2:31:49the cases it will be just notebooks,
  4245. 2:31:50okay?
  4246. 2:31:51So let me just add it and you can
  4247. 2:31:53directly click here as well, but let me
  4248. 2:31:54just show you the long list. We have all
  4249. 2:31:56of these tasks available. We have DBT
  4250. 2:31:58tasks available natively in with
  4251. 2:32:00directly in the Databricks because
  4252. 2:32:01obviously DBT is well integrated with
  4253. 2:32:03Databricks nowadays. So they have just
  4254. 2:32:05created this thing as well and this
  4255. 2:32:08Databricks Lakeflow jobs is not a simple
  4256. 2:32:10orchestration. You can even run the
  4257. 2:32:12control flow, if else condition, for
  4258. 2:32:14loops, everything,
  4259. 2:32:16everything. This is like very well
  4260. 2:32:18written for Databricks, very well
  4261. 2:32:20written. So you can just perform all of
  4262. 2:32:22these things and yes, AI things are also
  4263. 2:32:24possible now, document parsing,
  4264. 2:32:25classification.
  4265. 2:32:27By the way, classification is like very
  4266. 2:32:29similar to your JEF model that you can
  4267. 2:32:31just perform, okay?
  4268. 2:32:33So all of these things are available
  4269. 2:32:35directly within the um Lakeflow jobs,
  4270. 2:32:37okay? So job is just like orchestration,
  4271. 2:32:39similar to Apache Airflow. Very straight
  4272. 2:32:42forward one liner definition,
  4273. 2:32:44alternative of Apache Airflow, simple,
  4274. 2:32:46simple.
  4275. 2:32:47So let me just click on the notebook
  4276. 2:32:49and here I can just name it. Let say I
  4277. 2:32:52want to name it as bronze
  4278. 2:32:54and here I can pick the notebook as
  4279. 2:32:56type, source is this one, path. Here I
  4280. 2:32:58need to just pick the um let me just
  4281. 2:33:01bring it. So it is I think in the
  4282. 2:33:05recents, no. Let me just go here.
  4283. 2:33:09Where is my folder?
  4284. 2:33:10Where is my folder?
  4285. 2:33:12Um my folder is I think in the repos
  4286. 2:33:15recents.
  4287. 2:33:16Yeah, let me just open it from recents.
  4288. 2:33:18So this is the notebook that I just want
  4289. 2:33:20to pick. So it is here, users and this
  4290. 2:33:24email and the demo and bronze. So this
  4291. 2:33:26is my path of this notebook and I want
  4292. 2:33:28to use the compute as serverless compute
  4293. 2:33:30because it will automatically scale up
  4294. 2:33:31as per the load. Then environment and
  4295. 2:33:34libraries. If I want to add any specific
  4296. 2:33:36environment to my data bricks, I can do
  4297. 2:33:38that. But I do not have any specific
  4298. 2:33:40environment, so that is fine. And if I
  4299. 2:33:42want to add the libraries, I do not have
  4300. 2:33:43any libraries, so that is also good. And
  4301. 2:33:46then if you have some environment
  4302. 2:33:47variables, no, I do not have. So you can
  4303. 2:33:49simply ignore. If you have some
  4304. 2:33:50parameters, remember the widgets part,
  4305. 2:33:52you can just override it here as well,
  4306. 2:33:54but we do not have it. So simply say
  4307. 2:33:55create task.
  4308. 2:33:57Now this task is completed, which is
  4309. 2:33:58bronze. Now I want to add another task.
  4310. 2:34:00Let's say I want to run another
  4311. 2:34:03notebook, which is
  4312. 2:34:04silver.
  4313. 2:34:05And what is the path of this one? So the
  4314. 2:34:07path of this one is let's say this
  4315. 2:34:09silver.
  4316. 2:34:10And everything else is same. Simply say
  4317. 2:34:12create task. And after that, I want to
  4318. 2:34:14create another notebook task, which is
  4319. 2:34:16for gold layer.
  4320. 2:34:20Simple. And then let me just pick the
  4321. 2:34:22notebook.
  4322. 2:34:23The notebook is there.
  4323. 2:34:25Cool.
  4324. 2:34:26So this job is created. Now what will
  4325. 2:34:28happen? I can literally
  4326. 2:34:31click on save.
  4327. 2:34:33Um, I think it is automatically saved,
  4328. 2:34:34so it is fine. I can even say run now if
  4329. 2:34:36I want to run. I can even schedule it.
  4330. 2:34:38Let's say if I want to run this
  4331. 2:34:40particular job every day at 8:00 a.m.,
  4332. 2:34:429:00 a.m. or let's say 1:00 a.m., 2:00
  4333. 2:34:44a.m. just to disturb the developers. So
  4334. 2:34:47I can even schedule this particular
  4335. 2:34:50job
  4336. 2:34:51anytime. Okay? I can even provide the
  4337. 2:34:53job parameters, which will be just just
  4338. 2:34:56just overridden for this particular job.
  4339. 2:34:58I can even swap the compute, but I do
  4340. 2:35:00not want to. It is fine. And some health
  4341. 2:35:02checks are also there and this is good.
  4342. 2:35:04Cool. And some permissions, obviously
  4343. 2:35:05I'm just running it as an owner, but if
  4344. 2:35:07I want to just run it via service
  4345. 2:35:08principal, I can also do that. Not a big
  4346. 2:35:10deal. Cool. So I can even go to jobs and
  4347. 2:35:13pipelines now and if I just refresh, I
  4348. 2:35:15should see that job created. See,
  4349. 2:35:18medallion job is here. Currently, we do
  4350. 2:35:19not have any kind of runs. So, if you
  4351. 2:35:21just want to run it, you can just click
  4352. 2:35:22on this particular run now button and
  4353. 2:35:24this will start running my job. You can
  4354. 2:35:25click on view run from here just to see
  4355. 2:35:28how it performs as as you can see it is
  4356. 2:35:30just now running the first task. Once
  4357. 2:35:32the first task is completed, then only
  4358. 2:35:34it will move to the second task. Once
  4359. 2:35:35the second task is completed, then it
  4360. 2:35:37will move to the third task.
  4361. 2:35:39This is called orchestration.
  4362. 2:35:41This is called dependency between the
  4363. 2:35:43task within the orchestration. Simple.
  4364. 2:35:47Okay? With the right example, with the
  4365. 2:35:49right demo.
  4366. 2:35:50Straightforward, simple. So now let's
  4367. 2:35:52wait for it to complete and once it is
  4368. 2:35:54done, I will just show you the results.
  4369. 2:35:56So I can see that this job is completed
  4370. 2:35:58and our task bronze, silver, gold all
  4371. 2:36:01are completed and it took around 1
  4372. 2:36:03minute 25 seconds and that is good.
  4373. 2:36:06I can also see it in the form of
  4374. 2:36:07timeline if you just want to compare.
  4375. 2:36:10I also have the option of list as well,
  4376. 2:36:11but graph is the best.
  4377. 2:36:13This is everything about this particular
  4378. 2:36:15job and you can even see all of the runs
  4379. 2:36:17that you will have in your case as well
  4380. 2:36:19and again the task as well if you just
  4381. 2:36:21want to edit this then. You can edit
  4382. 2:36:23this job anytime. Just click on these
  4383. 2:36:25three dots and edit as YAML if you have
  4384. 2:36:27the YAML file, otherwise you can even
  4385. 2:36:29keep on adding the tasks here as well.
  4386. 2:36:31You have both the options.
  4387. 2:36:33Cool.
  4388. 2:36:34Very good. So this is all about jobs and
  4389. 2:36:36pipelines. Now yes, jobs is not
  4390. 2:36:39something which is very very complex,
  4391. 2:36:41but when you are just building the
  4392. 2:36:43complex dependency structure for your
  4393. 2:36:45orchestration, then yes, you need to
  4394. 2:36:47master jobs in detail and the only way
  4395. 2:36:50to master it by building more and more
  4396. 2:36:52jobs. Simple. Simple. Very
  4397. 2:36:54straightforward.
  4398. 2:36:55Build more and more. Just think about
  4399. 2:36:57some things like okay, let's have this
  4400. 2:36:58orchestration,
  4401. 2:37:00build some projects and then just build
  4402. 2:37:02this thing. This is all about the lake
  4403. 2:37:04flow jobs available in the Databricks.
  4404. 2:37:07I hope it makes sense. Very good.
  4405. 2:37:10So now let's talk about another concept
  4406. 2:37:12which is becoming the most important
  4407. 2:37:14concept in Databricks and I personally
  4408. 2:37:15love it a It's called lake
  4409. 2:37:19pipelines.
  4410. 2:37:21A lot of people can be confused between
  4411. 2:37:24pipeline and a job, but both are totally
  4412. 2:37:27different concepts, totally different
  4413. 2:37:29concepts. Okay?
  4414. 2:37:31Yes, there are some you can say
  4415. 2:37:34siding part between both, but both are
  4416. 2:37:37totally different. First of all, let's
  4417. 2:37:38try to understand what is lake flow
  4418. 2:37:39pipeline. Then I will compare it with
  4419. 2:37:41the job as well. Okay?
  4420. 2:37:43So first of all, lake flow pipeline
  4421. 2:37:45was
  4422. 2:37:47earlier known as DLT, Delta Live Tables.
  4423. 2:37:52If you have worked with DLT, you would
  4424. 2:37:54know that this is the very popular
  4425. 2:37:55framework back then as well. And now
  4426. 2:37:56with LDP, they have just improved a lot
  4427. 2:37:58of things and they have just changed a
  4428. 2:38:00lot of code syntaxes as well. Breaking
  4429. 2:38:02changes, yes, breaking changes.
  4430. 2:38:04So yeah, this is all about the history
  4431. 2:38:06of it. So now it is referred to as LDB,
  4432. 2:38:10lake flow declarative pipelines, but
  4433. 2:38:11usually we just call it as lake flow
  4434. 2:38:13pipelines and it it it works very well
  4435. 2:38:16with the jargons.
  4436. 2:38:17So lake flow pipelines is created by
  4437. 2:38:20Databricks.
  4438. 2:38:22Okay? Directly,
  4439. 2:38:23directly.
  4440. 2:38:25Listen to me. Okay? It is created by
  4441. 2:38:27Databricks.
  4442. 2:38:28Then
  4443. 2:38:29in Apache Spark 4.1, I guess, or 4.0. I
  4444. 2:38:34think 4.1.
  4445. 2:38:35They contributed
  4446. 2:38:37this particular thing to open source
  4447. 2:38:40Apache Spark as well. And this became
  4448. 2:38:43even bigger thing because they
  4449. 2:38:45contributed it to the open source Apache
  4450. 2:38:47Spark.
  4451. 2:38:49That means lake flow pipelines is now
  4452. 2:38:52not like just integrated within the
  4453. 2:38:55Databricks itself. It can be or it is
  4454. 2:38:57now integrated across so many different
  4455. 2:39:00different platforms who are managing
  4456. 2:39:02data who are managing Apache Spark.
  4457. 2:39:05But in Apache Spark, it is not called as
  4458. 2:39:07lake flow pipelines or lake flow
  4459. 2:39:09declarative pipelines. It is called as
  4460. 2:39:11SDP,
  4461. 2:39:13Spark declarative pipelines because it
  4462. 2:39:15is on Spark side. When it is on the lake
  4463. 2:39:18flow side on Databricks side, it is
  4464. 2:39:20called lake flow declarative pipelines.
  4465. 2:39:21Okay, remember these two terms.
  4466. 2:39:23Very good. So now, what is a lake flow
  4467. 2:39:26pipeline? What is a lake flow pipeline?
  4468. 2:39:29So when lake flow pipeline was not
  4469. 2:39:31there, we developers
  4470. 2:39:35were writing all of the code by
  4471. 2:39:38ourselves.
  4472. 2:39:39And we were writing
  4473. 2:39:41imperative code.
  4474. 2:39:43What is this imperative code?
  4475. 2:39:45Imperative code means you have to just
  4476. 2:39:47take care of
  4477. 2:39:49each step, small step, big step, read,
  4478. 2:39:52write, transformation, everything. That
  4479. 2:39:54is called imperative coding or
  4480. 2:39:56imperative style of building pipelines.
  4481. 2:39:58Cool? Or basically code any solution.
  4482. 2:40:01But after this particular lake flow
  4483. 2:40:03pipelines, we got something called as
  4484. 2:40:08declarative
  4485. 2:40:10declarative approach. What is
  4486. 2:40:11declarative approach?
  4487. 2:40:13Declarative approach says you just need
  4488. 2:40:16to declare
  4489. 2:40:18what you want
  4490. 2:40:19without worrying
  4491. 2:40:22how it will be achieved.
  4492. 2:40:24You need to just focus on this
  4493. 2:40:27what.
  4494. 2:40:28That's it.
  4495. 2:40:29Do not focus on
  4496. 2:40:31how.
  4497. 2:40:33This is the simplest definition for
  4498. 2:40:35declarative approach.
  4499. 2:40:37Here you just define
  4500. 2:40:39how your end table or end data frame
  4501. 2:40:43data set should look like. These are
  4502. 2:40:46transformations you need and that is it.
  4503. 2:40:48Everything will be managed by
  4504. 2:40:51LDP or basically declarative pipeline.
  4505. 2:40:54Makes sense?
  4506. 2:40:55Not just this, like just the
  4507. 2:40:57transformation,
  4508. 2:40:58it also takes care of the
  4509. 2:41:01execution order as well.
  4510. 2:41:03Dependencies. If you want to let say run
  4511. 2:41:06one piece of code, let's say this is a
  4512. 2:41:09task number one.
  4513. 2:41:11Okay, let me just draw it. Let's say
  4514. 2:41:13this is a task number one.
  4515. 2:41:15And you want to run another task after
  4516. 2:41:17this.
  4517. 2:41:18Let's say you want to run this task.
  4518. 2:41:21And then you want run
  4519. 2:41:23another task.
  4520. 2:41:25Right?
  4521. 2:41:26You do not even need to define this
  4522. 2:41:28dependency. Okay? You
  4523. 2:41:31Let's say you have some parallel task as
  4524. 2:41:33well which do not have any kind of
  4525. 2:41:34dependency. That will run in parallel
  4526. 2:41:36automatically.
  4527. 2:41:37Wow.
  4528. 2:41:38So everything will be taken care by
  4529. 2:41:42your LDP. Everything.
  4530. 2:41:46Not just this. Not just this.
  4531. 2:41:49With the course of time, Data Bricks
  4532. 2:41:51added some amazing amazing components,
  4533. 2:41:54amazing amazing packages within the LDP.
  4534. 2:41:57Now
  4535. 2:41:58let me just give you a very quick
  4536. 2:41:59example.
  4537. 2:42:01There's a concept if you know in data
  4538. 2:42:02engineering, it's called SCD
  4539. 2:42:05type two.
  4540. 2:42:07Slowly changing dimension type two.
  4541. 2:42:09Where we build the dimensions of type
  4542. 2:42:11two. And it takes at least at least
  4543. 2:42:14I would say 80 to 100 lines of code to
  4544. 2:42:18apply or to implement the logic for SCD
  4545. 2:42:21in PySpark. At least 80 to 100 lines of
  4546. 2:42:23code. Easily.
  4547. 2:42:26With LDP,
  4548. 2:42:27we can literally use something called as
  4549. 2:42:29Auto CDC. And that's it.
  4550. 2:42:32Auto CDC is basically a decorator which
  4551. 2:42:34is created for us. We just need to
  4552. 2:42:36define that we want SCD type two and
  4553. 2:42:38some parameters and that's it.
  4554. 2:42:39That will automatically handle
  4555. 2:42:41everything.
  4556. 2:42:43This will automatically handle
  4557. 2:42:44incremental injection as well.
  4558. 2:42:47Wow. You do not even need to write the
  4559. 2:42:48logic for incremental data loading. So
  4560. 2:42:50they keep on keep on adding these kinds
  4561. 2:42:53of features so that you developers can
  4562. 2:42:55easily build all of these things.
  4563. 2:42:59Now one more thing.
  4564. 2:43:00In this AI era,
  4565. 2:43:03LDP is even more popular. Why?
  4566. 2:43:06Because just think about it. Let's say
  4567. 2:43:08you are integrating AI LLM within your
  4568. 2:43:11solution and you're using the LLM to
  4569. 2:43:13generate the code.
  4570. 2:43:15Now LLM will generate hundreds of lines
  4571. 2:43:18of code for traditional PySpark coding.
  4572. 2:43:20And now same model, same LLM will
  4573. 2:43:23generate almost almost let say 20 to 30%
  4574. 2:43:26of the code code because obviously the
  4575. 2:43:29number of lines of code in lake flow
  4576. 2:43:30pipelines is like very very less.
  4577. 2:43:32So you are directly saving 50 to 70% of
  4578. 2:43:36the tokens cost as well for your
  4579. 2:43:38organization. Just think about it.
  4580. 2:43:41So that is why it is even more popular
  4581. 2:43:43in this AI era lake flow declarative
  4582. 2:43:44pipelines because it generates less um
  4583. 2:43:48codes less tokens.
  4584. 2:43:50Make sense?
  4585. 2:43:52This is an amazing framework which is
  4586. 2:43:54added and now I can say that since it is
  4587. 2:43:56added
  4588. 2:43:58all of the organizations who are using
  4589. 2:44:00Databricks are directly or indirectly
  4590. 2:44:03integrating this particular framework in
  4591. 2:44:05their solutions.
  4592. 2:44:06If they are building something new, they
  4593. 2:44:08are trying it, they are testing it, they
  4594. 2:44:09are
  4595. 2:44:10um relying on it. If they already had
  4596. 2:44:13some solution, they are just comparing
  4597. 2:44:14it with this particular thing.
  4598. 2:44:16Obviously they need to just test a lot
  4599. 2:44:17of things, they need to just um look at
  4600. 2:44:19some benchmarks, everything, but yeah,
  4601. 2:44:22organizations have started touching this
  4602. 2:44:24particular framework.
  4603. 2:44:25Make sense?
  4604. 2:44:26So this is all about it and the best way
  4605. 2:44:29to learn LDP is just to build some lake
  4606. 2:44:31flow declarative pipelines and let me
  4607. 2:44:33just tell you I also have a dedicated
  4608. 2:44:34video just on the lake flow pipelines or
  4609. 2:44:37I think Databricks pipelines. You can
  4610. 2:44:39just search it. I can just show you if I
  4611. 2:44:41I can just find it. Let me just bring
  4612. 2:44:42the
  4613. 2:44:44Let me just write Databricks um
  4614. 2:44:47pipelines on Slamba.
  4615. 2:44:50Um I just created this video. Where's
  4616. 2:44:52that?
  4617. 2:44:53Do we have um this browser by the way is
  4618. 2:44:56like very very good. That's why I am
  4619. 2:44:58just seeing this particular thing. But
  4620. 2:44:59if you just search this thing on
  4621. 2:45:00YouTube, you you will just find the
  4622. 2:45:01video. I'm just so sure about it. So you
  4623. 2:45:04can just learn about lake flow pipelines
  4624. 2:45:06in detail if you want to because it is
  4625. 2:45:08that particular skill that
  4626. 2:45:10is not attained by everyone right now,
  4627. 2:45:13all of the data engineers as well. But
  4628. 2:45:15if you have, then obviously it is a kind
  4629. 2:45:17of outlier that you can just add in your
  4630. 2:45:18resume and it will help you a lot a lot.
  4631. 2:45:22Okay.
  4632. 2:45:22Let's try to create a very simple
  4633. 2:45:24pipeline in Databricks so that you can
  4634. 2:45:26also learn how it works and it's very
  4635. 2:45:27very easy. So let me just open my data
  4636. 2:45:31bricks. This is my data bricks. So let's
  4637. 2:45:33try to see it. Where is my home button?
  4638. 2:45:36Perfect. So how you can just create the
  4639. 2:45:37pipeline? First of all, click here jobs
  4640. 2:45:39and pipelines and then click on ETL
  4641. 2:45:40pipeline or click on create and then ETL
  4642. 2:45:42pipeline. Both are same thing. Let me
  4643. 2:45:45just click here. And yes, one more
  4644. 2:45:46thing, very small thing. The major
  4645. 2:45:48advantage of this particular lake flow
  4646. 2:45:50pipeline is you can either use SQL or
  4647. 2:45:52Python. You have both the options. Both
  4648. 2:45:54the options. If you are more into SQL,
  4649. 2:45:57go with SQL. If you are more into
  4650. 2:45:58PySpark, then Python is the way for you
  4651. 2:46:01because in Python you literally write
  4652. 2:46:02PySpark code. Okay.
  4653. 2:46:04So let me just click here and let's try
  4654. 2:46:06to see how it works. So this will open a
  4655. 2:46:08completely different interface because
  4656. 2:46:10when you want to build the lake flow
  4657. 2:46:13declarative pipeline, you build the
  4658. 2:46:14entire package. Okay. So yes, it is a
  4659. 2:46:17kind of different thing which is a new
  4660. 2:46:19thing, but do not worry. I am here with
  4661. 2:46:21you. Do not worry at all. Let me just
  4662. 2:46:23give you a very quick overview of this
  4663. 2:46:25entire thing.
  4664. 2:46:26And I love this particular interface to
  4665. 2:46:29be honest because they have recently
  4666. 2:46:30added this thing. Earlier we used to
  4667. 2:46:32write all of the lake flow pipelines
  4668. 2:46:34code in the notebook when the DLT era
  4669. 2:46:36was there. But then they introduced lake
  4670. 2:46:38flow and then they also introduced this
  4671. 2:46:40thing and this is amazing. This is
  4672. 2:46:42amazing.
  4673. 2:46:43And yeah, so first of all, you have to
  4674. 2:46:45rename this pipeline. Okay. Let me just
  4675. 2:46:47do it for you. Let's say
  4676. 2:46:49um first LDP. Cool.
  4677. 2:46:53Let's say rename.
  4678. 2:46:54So this pipeline is renamed and perfect.
  4679. 2:46:57First LDP is here. Now the thing is by
  4680. 2:46:59default this pipeline will be created in
  4681. 2:47:01the root folder. Okay. Now you will say
  4682. 2:47:04what's the big deal? I can easily move
  4683. 2:47:06the pipeline directly from the home
  4684. 2:47:07button. You should never do it. Why?
  4685. 2:47:10Because see
  4686. 2:47:11whenever you just change the um you can
  4687. 2:47:13say location of your pipeline, it will
  4688. 2:47:15fail because it works on the YAML, like
  4689. 2:47:19where you have stored the pipeline.
  4690. 2:47:20Everything is written here. So you
  4691. 2:47:22cannot touch directly these things from
  4692. 2:47:24the root location. You have to do
  4693. 2:47:25everything from here. So let me show you
  4694. 2:47:27how you do it. Just click on these three
  4695. 2:47:28dots. If you just want to move this
  4696. 2:47:30particular pipeline, click on move. And
  4697. 2:47:32this is also written in their official
  4698. 2:47:34documentation that you should always
  4699. 2:47:36move the stuff from this interface.
  4700. 2:47:39And then you can just go to demo because
  4701. 2:47:40see, by default it created at the root
  4702. 2:47:43location. So I just want to move this
  4703. 2:47:44inside this demo folder. So I'll click
  4704. 2:47:46on this demo and then I will click on
  4705. 2:47:48move.
  4706. 2:47:49So now this particular pipeline is moved
  4707. 2:47:51to my demo folder. That's how it works.
  4708. 2:47:54Cool. Very good.
  4709. 2:47:55Now that is all about the root location
  4710. 2:47:58of this particular pipeline. Now
  4711. 2:48:01whatever we need to create in this
  4712. 2:48:03particular lake flow pipeline,
  4713. 2:48:05we can write all of the things here in
  4714. 2:48:08the transformations folder. See, by
  4715. 2:48:10default we get this particular empty
  4716. 2:48:13file which is called my transformation
  4717. 2:48:14dot py, but I can just rename it or I
  4718. 2:48:16can even delete it. Not a big deal. Let
  4719. 2:48:18me just move to trash.
  4720. 2:48:20So now you can just create your Python
  4721. 2:48:24file, right? You can even create mix
  4722. 2:48:28match of Python and SQL both. Let's say
  4723. 2:48:30you just want to create some pieces in
  4724. 2:48:31Python, some pieces in SQL, both works.
  4725. 2:48:34Third thing, you can even
  4726. 2:48:37segregate your code in multiple files.
  4727. 2:48:39You do not need to write everything
  4728. 2:48:40within one single file. No.
  4729. 2:48:43All the files created, listen to me
  4730. 2:48:45carefully, all the files created under
  4731. 2:48:47this transformations folder will be
  4732. 2:48:49considered as the components of your
  4733. 2:48:52pipeline.
  4734. 2:48:53So if you have 10 files, all of the 10
  4735. 2:48:56files will contribute towards the same
  4736. 2:48:58LDP, same pipeline. Remember? Very good.
  4737. 2:49:02So now let me just create one Python
  4738. 2:49:04file. Let me just click on test and it
  4739. 2:49:06will just create this test particular
  4740. 2:49:08file. So let me just save it as let's
  4741. 2:49:11say
  4742. 2:49:13um
  4743. 2:49:15LDP code dot py.
  4744. 2:49:19Makes sense? So let's wait. Let's wait.
  4745. 2:49:21Let wait. Let wait. And this is my
  4746. 2:49:23transformation folder.
  4747. 2:49:25And where is this file created? Let me
  4748. 2:49:26just create it inside this thing. Create
  4749. 2:49:28file. Perfect. Not a Python
  4750. 2:49:31I Python notebook. This is a Python
  4751. 2:49:33file. Okay? So you have to create the
  4752. 2:49:34Python file. You can even create the
  4753. 2:49:36notebook as well, but we usually create
  4754. 2:49:37the Python files.
  4755. 2:49:39So simply say
  4756. 2:49:40LDP code dot py.
  4757. 2:49:42You can even create multiple multiple
  4758. 2:49:44files like LDP code blah blah blah.
  4759. 2:49:47Everything works. Okay. So let me just
  4760. 2:49:49show you if you want to let say ingest
  4761. 2:49:52or blah blah blah. So this is my ingest
  4762. 2:49:53dot py. So now if you just want to
  4763. 2:49:56ingest the data,
  4764. 2:49:57you can have ingestion done from
  4765. 2:50:00directly from the S3 bucket as well. You
  4766. 2:50:01can use auto loader for that.
  4767. 2:50:04You can even ingest the data from the
  4768. 2:50:05delta tables. Everything works fine.
  4769. 2:50:07It's not a big deal. But let's say we
  4770. 2:50:09just want to ingest the data from the
  4771. 2:50:11bronze table because we already have
  4772. 2:50:12that bronze table within our delta lake
  4773. 2:50:15within our catalog and we can just reuse
  4774. 2:50:17that particular thing. We do not need to
  4775. 2:50:19again create the new table or new
  4776. 2:50:21source. Okay.
  4777. 2:50:22So how you can just import this thing?
  4778. 2:50:24There are multiple ways and let me just
  4779. 2:50:25tell you the previous method still work.
  4780. 2:50:27If you just want to import the DLT, it
  4781. 2:50:29still works. Okay. It's not like it they
  4782. 2:50:31have literally
  4783. 2:50:34reduced the use case of this thing. No.
  4784. 2:50:36But the modern way is this one from
  4785. 2:50:38PySpark dot
  4786. 2:50:40pipelines or I think from PySpark
  4787. 2:50:44import
  4788. 2:50:46pipelines as
  4789. 2:50:48DP DP or LDP. It's up to you, but I just
  4790. 2:50:51use DP because we used to import
  4791. 2:50:54import DLT as DT or something. So it's
  4792. 2:50:57fine. Let's say import pipelines as DP.
  4793. 2:51:00Now there are some decorators. There are
  4794. 2:51:02some functions that we can use within
  4795. 2:51:04this particular
  4796. 2:51:06package. So we have three major things
  4797. 2:51:09within this. The very first is
  4798. 2:51:12materialized views.
  4799. 2:51:15Okay. The second thing we have is
  4800. 2:51:17streaming tables.
  4801. 2:51:20Streaming
  4802. 2:51:23tables.
  4803. 2:51:24Third thing we have is normal views.
  4804. 2:51:29Cool.
  4805. 2:51:30So if you just want to create the
  4806. 2:51:34tables. Okay. Where you can just perform
  4807. 2:51:36batch processing.
  4808. 2:51:37You can simply go with mat views,
  4809. 2:51:39materialized views. If you want to
  4810. 2:51:41perform streaming, if you want to build
  4811. 2:51:43the streaming tables, then you should go
  4812. 2:51:44with the streaming tables. If you just
  4813. 2:51:46want to create the views, then obviously
  4814. 2:51:47you should just go with the views. So if
  4815. 2:51:49you just want to create the normal batch
  4816. 2:51:51processing, do not go with streaming
  4817. 2:51:52tables, okay? Simply go with the mat
  4818. 2:51:54views. Mat views behave like you can say
  4819. 2:51:56incremental data injection
  4820. 2:51:58for your batch tables.
  4821. 2:52:00Makes sense?
  4822. 2:52:01Very good. So how you can just use it?
  4823. 2:52:03There are decorators. Let's say I'll
  4824. 2:52:04simply say dp dot um you can even write
  4825. 2:52:08dp dot um streaming, something like
  4826. 2:52:10that. So it's not like you have to have
  4827. 2:52:12to um write this dp here. Let me just
  4828. 2:52:15tell you I'm just writing dp here just
  4829. 2:52:17because I am importing this package as
  4830. 2:52:20dp. If you are importing this package as
  4831. 2:52:22let say sdp, you have to write sdp. Just
  4832. 2:52:25make sure this thing. This is like a
  4833. 2:52:26very small thing but
  4834. 2:52:27okay, like this. So it's up to you how
  4835. 2:52:29you are importing this thing.
  4836. 2:52:31I hope it makes sense. Now if let's say
  4837. 2:52:33I'm just I I just want to create the
  4838. 2:52:34materialized view. I'll simply say dp
  4839. 2:52:36dot materialized
  4840. 2:52:39materialized view.
  4841. 2:52:41I'm not getting any recommendation but
  4842. 2:52:42it's fine. So this is the thing, at the
  4843. 2:52:44rate dp dot materialized view.
  4844. 2:52:46Then I need to define my function.
  4845. 2:52:49What function? Function will have all of
  4846. 2:52:52my code. For example, let's say I want
  4847. 2:52:54to create the table as LDP
  4848. 2:52:57um bronze.
  4849. 2:53:00Let's say LDP bronze.
  4850. 2:53:02So here in the LDP bronze I will
  4851. 2:53:04literally write
  4852. 2:53:06this thing and then I can just read the
  4853. 2:53:07table normally spark dot read dot table
  4854. 2:53:12and the table name will be let say demo
  4855. 2:53:15dot
  4856. 2:53:16bronze
  4857. 2:53:19dot orders.
  4858. 2:53:20Cool, this is my table name
  4859. 2:53:22and I will simply say return here. What
  4860. 2:53:23it will do? It will literally take my
  4861. 2:53:25transformations here. I'm not performing
  4862. 2:53:27any transformations. I'm literally
  4863. 2:53:29reading this table and I'm returning
  4864. 2:53:31this dataframe. Whatever thing I return
  4865. 2:53:34will become my dataset. Oh really? Yeah,
  4866. 2:53:36will become my dataset, simple.
  4867. 2:53:38Whatever thing I'm returning, it will
  4868. 2:53:39become my table.
  4869. 2:53:41So if I just write let say DF something
  4870. 2:53:43something, it will become something
  4871. 2:53:44something. So
  4872. 2:53:45it is my returned DF. So this DF will
  4873. 2:53:47become my data frame.
  4874. 2:53:49I hope it makes sense.
  4875. 2:53:50Now
  4876. 2:53:52you need to understand how materialized
  4877. 2:53:53view works because if you understood
  4878. 2:53:55this thing, your entire concept
  4879. 2:53:58of you can say LDP will be crystal
  4880. 2:54:01clear. Why? Because you will be able to
  4881. 2:54:02understand how things are working.
  4882. 2:54:04And if you do not understand this thing,
  4883. 2:54:05you will feel like this thing is working
  4884. 2:54:08in a black box. No, we need to open this
  4885. 2:54:10box. Let's try to open this box. So
  4886. 2:54:12first of all,
  4887. 2:54:13what is a materialized view? View is at
  4888. 2:54:16the end of the day is just a view. And
  4889. 2:54:19view is what? Let's say this is my view.
  4890. 2:54:21View is just holding the query and
  4891. 2:54:24that's it, right? What is the query
  4892. 2:54:26here?
  4893. 2:54:27Query is this one, like whatever things
  4894. 2:54:29I'm writing here.
  4895. 2:54:30I'm reading the table.
  4896. 2:54:32If I want to perform some
  4897. 2:54:33transformations, that will become the
  4898. 2:54:34part of query as well, but this is my
  4899. 2:54:36query for now, right? So this is the
  4900. 2:54:38query that my view is referring.
  4901. 2:54:41Now materialized view is different from
  4902. 2:54:44a traditional view in this manner
  4903. 2:54:46because a materialized view
  4904. 2:54:49let say this is materialized view.
  4905. 2:54:51Materialized view will cache the result
  4906. 2:54:54as well in its memory.
  4907. 2:54:57Oh, cache the results.
  4908. 2:55:01Oh.
  4909. 2:55:03It will work on the query. It will run
  4910. 2:55:05the query, but this time it will cache
  4911. 2:55:07the result as well. And every time it
  4912. 2:55:09will run the query, it will not
  4913. 2:55:11reprocess the entire query again and
  4914. 2:55:13again. It will only process the new
  4915. 2:55:15data.
  4916. 2:55:17Only process the new data. So how it
  4917. 2:55:19does know how how it knows like um it is
  4918. 2:55:23the new data and it is not the new data?
  4919. 2:55:24Because in the view we need to rerun the
  4920. 2:55:26same query again and again, simple and
  4921. 2:55:27sorted. But in the materialized view,
  4922. 2:55:30okay, we just cache the data. But this
  4923. 2:55:33time let's say I am just reading this
  4924. 2:55:34table and all of the data orders rows
  4925. 2:55:37will come here.
  4926. 2:55:39Perfect. 10,000 rows will come here.
  4927. 2:55:41If I rerun this particular pipeline,
  4928. 2:55:44it will not process any record if I do
  4929. 2:55:46not have any new data. Let's imagine we
  4930. 2:55:48do not have any new data.
  4931. 2:55:49Then it will only process zero records.
  4932. 2:55:51Why? Because there is no new data and it
  4933. 2:55:54will keep on using the same cached
  4934. 2:55:56results which will be much faster than
  4935. 2:55:58rerunning the entire query.
  4936. 2:56:00If I have let's say 10 new records,
  4937. 2:56:02let's say 10 new records, it will not
  4938. 2:56:05process all the rows again. It will only
  4939. 2:56:07process the 10 records. Why? Because it
  4940. 2:56:10maintains that state
  4941. 2:56:12internally. You do not have access to
  4942. 2:56:14it. Do not worry. I will just show you
  4943. 2:56:15the documentation as well where
  4944. 2:56:17everything is written here because when
  4945. 2:56:18you have that particular confidence
  4946. 2:56:20whatever I'm saying, I know you trust
  4947. 2:56:21me. I know but I still want to show you
  4948. 2:56:23the documentation
  4949. 2:56:25because it is a good practice to refer
  4950. 2:56:27it whenever you want to, especially for
  4951. 2:56:28the new things where you do not have
  4952. 2:56:30much sources available. So when you have
  4953. 2:56:32less sources available, you should rely
  4954. 2:56:33on the official documentation and that's
  4955. 2:56:35it. Okay? I know you rely on me. I know
  4956. 2:56:37you trust me. I know I know but still
  4957. 2:56:39I just want you to have a good practice
  4958. 2:56:41and that's it.
  4959. 2:56:43Cool. So that's how it works and let me
  4960. 2:56:44just bring and let me just try to search
  4961. 2:56:46if I just find it because they keep on
  4962. 2:56:47updating the page.
  4963. 2:56:50Materialized views. Yeah, I think I got
  4964. 2:56:52it. They updated it on October 15, 2026.
  4965. 2:56:54Very good. Very good. Keep on updating
  4966. 2:56:56every day
  4967. 2:56:57because we will just keep on coming and
  4968. 2:56:58by the way, they they didn't update
  4969. 2:56:59every single page. They just mention
  4970. 2:57:01like what area was updated. So first of
  4971. 2:57:03all, this is the official documentation,
  4972. 2:57:05okay, for LDP and especially for the
  4973. 2:57:07materialized views. First of all, let's
  4974. 2:57:08try to read it what is written here.
  4975. 2:57:10They are saying
  4976. 2:57:12um like standard views materialized
  4977. 2:57:14views are the results of a query that
  4978. 2:57:15you access them the same way you would
  4979. 2:57:17like a table. Unlike standard
  4980. 2:57:19Yeah, I think this is the same thing
  4981. 2:57:20which is written here. So that is fine.
  4982. 2:57:21Now let me just show you the main thing.
  4983. 2:57:23How they compute this thing.
  4984. 2:57:26First of all, it is written that a
  4985. 2:57:27materialized view is a declarative
  4986. 2:57:30pipeline object. We know that. It
  4987. 2:57:31includes a query. We know this as well.
  4988. 2:57:34We have a flow. Flow is nothing but just
  4989. 2:57:36the pipeline that we are creating and
  4990. 2:57:38the cached results for fast access.
  4991. 2:57:41A materialized view tracks changes in
  4992. 2:57:43the upstream data. Upstream data means a
  4993. 2:57:45source data. It will keep on tracking
  4994. 2:57:47the changes.
  4995. 2:57:49And whenever we trigger our pipeline, it
  4996. 2:57:50will incrementally process the changed
  4997. 2:57:53data, not the entire data.
  4998. 2:57:56good.
  4999. 2:57:57now
  5000. 2:57:59more thing important written here in the
  5001. 2:58:00virtual lock condition, they are saying
  5002. 2:58:02they are often incremental. Anshul
  5003. 2:58:04Lamba, what do you mean?
  5004. 2:58:06You said that they are always processing
  5005. 2:58:08the new data. Yes.
  5006. 2:58:10So whenever they want to compute the
  5007. 2:58:11data, the data will be incremental for
  5008. 2:58:14sure, but the way it is processed is
  5009. 2:58:16different or can be different.
  5010. 2:58:17Because Databricks is managing the how
  5011. 2:58:20part. So let's say if you want to
  5012. 2:58:22incrementally ingest the data. Okay? You
  5013. 2:58:24want to incrementally ingest the data
  5014. 2:58:26and your table has, let's say, only 1000
  5015. 2:58:28records. Okay? Only 1000 records. And
  5016. 2:58:30you got only 10 new records.
  5017. 2:58:32Now obviously it makes sense to
  5018. 2:58:35reprocess the entire table because the
  5019. 2:58:37number of records are so less.
  5020. 2:58:39And when you will be just performing the
  5021. 2:58:40incremental data ingestion, it might
  5022. 2:58:42take more compute. So it is just a
  5023. 2:58:44balance. It is just a pick between these
  5024. 2:58:45two approaches. But you do not need to
  5025. 2:58:47worry about this thing.
  5026. 2:58:48Makes sense? So that is why they are
  5027. 2:58:50saying they are often incremental. Most
  5028. 2:58:52of the times it will be incremental, but
  5029. 2:58:54sometimes it can be full load as well.
  5030. 2:58:56But your number of records will be in
  5031. 2:58:58sync. But the processing nature will be
  5032. 2:59:01different.
  5033. 2:59:02Makes sense? Now the main thing,
  5034. 2:59:05how they know that the data is changed?
  5035. 2:59:07Again,
  5036. 2:59:09it will track the source and all of the
  5037. 2:59:11information of the source will be
  5038. 2:59:13written in this hidden table
  5039. 2:59:16which is created inside this catalog,
  5040. 2:59:17system.information_schema.tables.
  5041. 2:59:21Oh oh.
  5042. 2:59:22And these are not visible in catalog
  5043. 2:59:23explorer explorer, but it was visible
  5044. 2:59:26earlier then
  5045. 2:59:27when we were just working with Delta
  5046. 2:59:29live tables, it was visible. And you can
  5047. 2:59:31even see the Databricks internal catalog
  5048. 2:59:33if you have access to this thing because
  5049. 2:59:35it stores all of these things. See,
  5050. 2:59:37Databricks uses Unity Catalog to store
  5051. 2:59:38metadata. We know that. And including
  5052. 2:59:41the query and additional system view for
  5053. 2:59:42incremental updates, Databricks
  5054. 2:59:44materializes the cached data in the
  5055. 2:59:45cloud storage. Yes, because whenever we
  5056. 2:59:47are just storing the cache, it needs to
  5057. 2:59:49materialize it somewhere. So it keeps on
  5058. 2:59:52maintaining everything within the this
  5059. 2:59:54particular catalog, which is Databricks
  5060. 2:59:55stores some backing data in Databricks
  5061. 2:59:57internal catalog. You might have access
  5062. 2:59:59to this particular catalog. You might
  5063. 3:00:01not have access to this particular
  5064. 3:00:02catalog depending upon your permissions
  5065. 3:00:03and the Databricks version you are
  5066. 3:00:05using.
  5067. 3:00:07If you're using a your hosted one, you
  5068. 3:00:08might see it. If you're using free
  5069. 3:00:10edition, I am not sure. And I am not
  5070. 3:00:12even sure if you see this and you can
  5071. 3:00:14access it or not because you are using
  5072. 3:00:15the free edition. So you can just check
  5073. 3:00:17it. But
  5074. 3:00:18you should not
  5075. 3:00:19play with these catalogs because these
  5076. 3:00:21are just maintaining your
  5077. 3:00:23checkpoints. These are maintaining your
  5078. 3:00:25last load information, everything. And
  5079. 3:00:27do you know what? Earlier everyone was
  5080. 3:00:29having the access to these particular
  5081. 3:00:31catalogs, these particular tables. Then
  5082. 3:00:32people started
  5083. 3:00:34touching those tables and playing around
  5084. 3:00:35it. And then they were just literally
  5085. 3:00:38breaking the code and then they were
  5086. 3:00:39just complaining Databricks, hey, my
  5087. 3:00:41database is not synced, blah blah blah.
  5088. 3:00:44Then they just made it like private.
  5089. 3:00:45Okay. So this is the way I hope now you
  5090. 3:00:47understood how materialized views are
  5091. 3:00:50created and how materialized views are
  5092. 3:00:52actually
  5093. 3:00:53used. I hope it makes sense. Okay. So
  5094. 3:00:55this is my materialized table. Very
  5095. 3:00:57good. So let's say I have this
  5096. 3:00:59materialized table and similarly I can
  5097. 3:01:01just create the streaming table as well.
  5098. 3:01:03Um streaming table is same thing that we
  5099. 3:01:05have just um saw in the Spark structured
  5100. 3:01:08streaming phase. So it is just like a
  5101. 3:01:10table
  5102. 3:01:11created on Spark structured streaming
  5103. 3:01:12table and that's it. Simple, very
  5104. 3:01:14simple.
  5105. 3:01:15Materialized view is different, is new.
  5106. 3:01:17That is why I'm just telling now talking
  5107. 3:01:18about this thing in detail. Okay.
  5108. 3:01:20Very simple, very good. And you do not
  5109. 3:01:22use
  5110. 3:01:23you do not use the streaming table for
  5111. 3:01:25all of the sources. You can only use the
  5112. 3:01:28streaming tables for the streaming
  5113. 3:01:29sources like Kafka, like Event Hub, like
  5114. 3:01:32Delta streaming tables, all of these
  5115. 3:01:34things. Okay. But we are just focusing
  5116. 3:01:36on the materialized views here. And if
  5117. 3:01:37you just want to learn
  5118. 3:01:39like LDP in detail, obviously I have
  5119. 3:01:41just already mentioned the source for
  5120. 3:01:44for this particular uh topic. Okay.
  5121. 3:01:46So now let's try to complete this
  5122. 3:01:49particular LDP. Let's say I just want to
  5123. 3:01:50create another materialized view and
  5124. 3:01:52this time I will be just creating the
  5125. 3:01:54silver task and I will read
  5126. 3:01:57from where? I will read it from the from
  5127. 3:01:59this table, LDP bronze. And the good
  5128. 3:02:01thing is I do not even need to refer it
  5129. 3:02:04like this demo.silver.orders. I can
  5130. 3:02:06literally say
  5131. 3:02:07LDP bronze.
  5132. 3:02:09Now how it will know that this LDP
  5133. 3:02:11bronze is already created here? This is
  5134. 3:02:13called dependency.
  5135. 3:02:15This is called dependency in the LDP. It
  5136. 3:02:17will automatically fetch that do I have
  5137. 3:02:20this table created here or not? Because
  5138. 3:02:22whatever I am writing here
  5139. 3:02:24it will automatically
  5140. 3:02:26populate the fields called catalog and
  5141. 3:02:28schema directly from here. Whatever I am
  5142. 3:02:30just mentioning here. I can click here
  5143. 3:02:32on the workspace. Workspace is my demo
  5144. 3:02:35which is the catalog. Schema I will
  5145. 3:02:37create a new schema for it and I will
  5146. 3:02:38simply say LDP. Okay? And let's say
  5147. 3:02:40create. So every time I am just writing
  5148. 3:02:43LDP bronze here, it will automatically
  5149. 3:02:46automatically
  5150. 3:02:48it will automatically change this
  5151. 3:02:51particular
  5152. 3:02:52thing to this catalog and then this
  5153. 3:02:54particular schema. Okay?
  5154. 3:02:56And I saw one thing file or notebook not
  5155. 3:02:58found. Source code is this one. Let me
  5156. 3:02:59just see configure paths
  5157. 3:03:02and
  5158. 3:03:03let's see the bronze. Let's see demo. We
  5159. 3:03:07have first LDP. We have transformations.
  5160. 3:03:08Let's say select.
  5161. 3:03:10Perfect.
  5162. 3:03:11So
  5163. 3:03:12this is done. It was like saying like
  5164. 3:03:15why we do not have that particular LDP.
  5165. 3:03:17So now I have just simply picked it. So
  5166. 3:03:19it is fine.
  5167. 3:03:20Cool cool cool. Very good. So what is
  5168. 3:03:22this thing tests? So I think it just
  5169. 3:03:24created this particular folder. Let me
  5170. 3:03:25just move it to trash and we have files
  5171. 3:03:28external to pipeline folder.
  5172. 3:03:30And perfect I think yeah perfect. So
  5173. 3:03:32this is my silver layer. This is my
  5174. 3:03:34bronze layer and let's create the some
  5175. 3:03:37transformations as well. Let's say I
  5176. 3:03:38just want to add one column. So I simply
  5177. 3:03:40say df equals df dot with column.
  5178. 3:03:44And here I will create the column let
  5179. 3:03:46say
  5180. 3:03:47current
  5181. 3:03:48timestamp. Okay?
  5182. 3:03:50And here I can just pick, let say, um,
  5183. 3:03:53get now? Not get now. Let's say current
  5184. 3:03:56timestamp.
  5185. 3:03:59Cool.
  5186. 3:04:00Very good.
  5187. 3:04:01So we can just use this thing.
  5188. 3:04:04And I can simply say return DF. This is
  5189. 3:04:06my silver table.
  5190. 3:04:07Now if I just want to create the gold
  5191. 3:04:09table,
  5192. 3:04:11I simply say LDP silver and let's
  5193. 3:04:13perform some aggregation. Can simply say
  5194. 3:04:15order, price and total. Perfect. Do we
  5195. 3:04:18have price? Um, I doubt. So let's use
  5196. 3:04:20count.
  5197. 3:04:22Or I will say
  5198. 3:04:23order ID.
  5199. 3:04:26And not order ID, let's say
  5200. 3:04:28customers.
  5201. 3:04:30Simple and let's perform this
  5202. 3:04:31aggregation on store
  5203. 3:04:33as we performed earlier. So let's say
  5204. 3:04:35customer
  5205. 3:04:37ID and then let's say total customers.
  5206. 3:04:40I hope it makes sense. So this is our
  5207. 3:04:41simple pipeline, three step pipeline
  5208. 3:04:43that we are just creating for this
  5209. 3:04:44particular task. Now
  5210. 3:04:46in LDB, one of the biggest advantage
  5211. 3:04:49that we get is um, you can say dry run.
  5212. 3:04:52So if before even running the pipeline,
  5213. 3:04:54we can even perform dry run. Dry run
  5214. 3:04:55will literally test
  5215. 3:04:57and will assess our code. If everything
  5216. 3:05:00is fine, nothing is broken. If yes, it
  5217. 3:05:02will tell us beforehand. And if
  5218. 3:05:04everything is fine, it will give us the
  5219. 3:05:06pipeline graph just to show that
  5220. 3:05:08dependency.
  5221. 3:05:09And I do not even need to perform any
  5222. 3:05:11kind of dependency. It will
  5223. 3:05:12automatically build the dependency graph
  5224. 3:05:14on the basis of the dependency. Just
  5225. 3:05:16look at it.
  5226. 3:05:17This is the independent task. So it will
  5227. 3:05:20create it at first. Then this is
  5228. 3:05:22dependent on this particular one, as you
  5229. 3:05:23can see.
  5230. 3:05:24Then this is dependent on this
  5231. 3:05:26particular one. So that's how it just
  5232. 3:05:28keeps on creating this particular
  5233. 3:05:29dependency graph.
  5234. 3:05:30Now it is saying current timestamp is
  5235. 3:05:31not defined. This is not depend. Yes,
  5236. 3:05:33because we didn't import the packages.
  5237. 3:05:35So let me just import it
  5238. 3:05:37from PySpark. SQL. functions
  5239. 3:05:41import as DF.
  5240. 3:05:43Perfect.
  5241. 3:05:44So now let's perform the
  5242. 3:05:46dry run again. Let's see if it works or
  5243. 3:05:48not.
  5244. 3:05:51Let's wait for a bit.
  5245. 3:05:53And yeah, you can also perform the tried
  5246. 3:05:54on if you want to. I think this is good.
  5247. 3:05:57I can click on pipeline graph just to
  5248. 3:05:58see it. So
  5249. 3:06:01perfect. I have this source delta, which
  5250. 3:06:04is my source table, as you can see.
  5251. 3:06:07Cool.
  5252. 3:06:08And this is my materialized view, which
  5253. 3:06:10is incremental, as you can see. Then I
  5254. 3:06:12have this full recompute
  5255. 3:06:14for LDP silver, and then I have
  5256. 3:06:16materialized view incremental, as you
  5257. 3:06:18can see.
  5258. 3:06:19Wow. So this is the entire lineage
  5259. 3:06:21automatically created using my LDP. I
  5260. 3:06:23didn't touch anything. I literally
  5261. 3:06:25didn't touch anything.
  5262. 3:06:27That's how it works.
  5263. 3:06:29You can even click on this I button if
  5264. 3:06:30you just want to.
  5265. 3:06:32And if you can just read it, you can
  5266. 3:06:33just do it like this. So let's do one
  5267. 3:06:35thing. Let's try to now run this
  5268. 3:06:37particular pipeline and click on run
  5269. 3:06:39pipeline. This will run this pipeline
  5270. 3:06:41within this canvas.
  5271. 3:06:43And you will see all of the number of
  5272. 3:06:44records processed, all of the things
  5273. 3:06:47processed, everything, all of the
  5274. 3:06:49information will be here within this
  5275. 3:06:50particular canvas. So let's wait, and I
  5276. 3:06:52think this is running this particular
  5277. 3:06:53thing. So let's click on pipeline graph
  5278. 3:06:56just to see it. So I can see that output
  5279. 3:06:59records are 10,000. That means it
  5280. 3:07:01ingested 10,000
  5281. 3:07:03records,
  5282. 3:07:04and it
  5283. 3:07:05processed or transformed 10,000 records,
  5284. 3:07:08and at the end I got 25 records because
  5285. 3:07:10I only have the, you can say obviously,
  5286. 3:07:1325 store IDs. Simple.
  5287. 3:07:15Now the good thing is this is done. This
  5288. 3:07:17is ingested. If I just go to, let's say
  5289. 3:07:19my catalog, I can just duplicate this
  5290. 3:07:22tab.
  5291. 3:07:23So if I just duplicate this tab, let me
  5292. 3:07:25just show you
  5293. 3:07:26catalog.
  5294. 3:07:28And I should see the schema LDP. Yes, I
  5295. 3:07:30have. And all of these things are here.
  5296. 3:07:32LDP bronze, LDP gold, LDP silver.
  5297. 3:07:35All of the three tables are created with
  5298. 3:07:36data.
  5299. 3:07:37And I also have information schema, I
  5300. 3:07:39told you. And within the information
  5301. 3:07:40schema, we get all of these things, and
  5302. 3:07:43we do not have access to it, as we just
  5303. 3:07:44read. Simple. Very good.
  5304. 3:07:47So you cannot see that catalog here that
  5305. 3:07:49you just were seeing database internals.
  5306. 3:07:51But if you are just using Azure hosted
  5307. 3:07:53or hosted Databricks workspace, I think
  5308. 3:07:55you might see that. Good.
  5309. 3:07:57Very good.
  5310. 3:07:58Now the good thing is, if I just go to
  5311. 3:08:00pipelines, if I now click on run
  5312. 3:08:02pipeline for one more time, do you know
  5313. 3:08:03what will happen?
  5314. 3:08:05Obviously it will run my pipeline, but
  5315. 3:08:07this time it will not process or I can
  5316. 3:08:10say it should not process any new
  5317. 3:08:13records because there are no new
  5318. 3:08:14records. That is why you are seeing no
  5319. 3:08:17change.
  5320. 3:08:18Output records is this one. Let me just
  5321. 3:08:20refresh. No change, full recompute and
  5322. 3:08:23then no change. Let's wait.
  5323. 3:08:25Incremental.
  5324. 3:08:28Let's wait. Let's wait.
  5325. 3:08:31For it to complete. Yeah.
  5326. 3:08:33Obviously it will show 25 just as the
  5327. 3:08:36output records because we have the
  5328. 3:08:37output as 20 10,000.
  5329. 3:08:40But it says no change. Why no change?
  5330. 3:08:43Why no change? You tell me.
  5331. 3:08:45Because we do not have any kind of
  5332. 3:08:48change on the source side.
  5333. 3:08:51We do not have any kind of change.
  5334. 3:08:53We just read the data from the orders
  5335. 3:08:56from the bronze schema and we returned
  5336. 3:08:57it.
  5337. 3:08:58This is our bronze materialized view.
  5338. 3:09:00This is called LDP bronze.
  5339. 3:09:02And it has output records at 10,000 with
  5340. 3:09:04with no change. We do not have any kind
  5341. 3:09:06of change. And if we just go to
  5342. 3:09:07performance, we might see this thing
  5343. 3:09:09here as well. Rows read zero.
  5344. 3:09:12Read zero.
  5345. 3:09:14Zero. See, LDP bronze is zero.
  5346. 3:09:17Oh, see.
  5347. 3:09:19This read
  5348. 3:09:2110,000 rows read and this read 20,000.
  5349. 3:09:24This one.
  5350. 3:09:26The very first task row like very first
  5351. 3:09:28task read only zero rows. Why? Because
  5352. 3:09:31source was not changed.
  5353. 3:09:35Makes sense?
  5354. 3:09:36You can even monitor this thing. If you
  5355. 3:09:38just go to let's say here
  5356. 3:09:40and if you just go to pipelines, you
  5357. 3:09:41will see forced LDP.
  5358. 3:09:43And this is an ETL pipeline. That is why
  5359. 3:09:45you are seeing this ETL pipeline. If I
  5360. 3:09:47click here,
  5361. 3:09:48you will see a tab called runs and these
  5362. 3:09:50are all the runs here.
  5363. 3:09:52And all of the same information is here
  5364. 3:09:54as well. And if you just want to edit
  5365. 3:09:55it, you can click on pencil icon. You
  5366. 3:09:57will land on that particular page where
  5367. 3:09:59we are just doing all of this stuff.
  5368. 3:10:01Make sense? But everything is
  5369. 3:10:03visible here as well.
  5370. 3:10:06Wow, everything.
  5371. 3:10:08Make sense? Even if you just want to
  5372. 3:10:09schedule this pipeline so that it can
  5373. 3:10:11just run let's say every single day, you
  5374. 3:10:14can just schedule this. Let's say run
  5375. 3:10:15pipeline
  5376. 3:10:17again just to run it and if you just
  5377. 3:10:18want to schedule it you can just click
  5378. 3:10:19on this particular button this one
  5379. 3:10:21schedule and it will schedule it simple.
  5380. 3:10:24Cool and because we just ran it let's
  5381. 3:10:26see
  5382. 3:10:27and we should see the exact same stuff
  5383. 3:10:29because it is no changed then fully
  5384. 3:10:31compute and then this will be like
  5385. 3:10:33incremental
  5386. 3:10:34because this is just an aggregation.
  5387. 3:10:36Now why it just picked full recompute
  5388. 3:10:38because I told you often times you will
  5389. 3:10:40see is see it as incremental but
  5390. 3:10:42sometimes if the processing is a
  5391. 3:10:44processing compute is better with full
  5392. 3:10:47full recompute instead of incremental it
  5393. 3:10:48will simply go with recompute
  5394. 3:10:50full recompute instead of incremental
  5395. 3:10:52simple.
  5396. 3:10:53Make sense? Very good.
  5397. 3:10:55So this is all about LDB. Now
  5398. 3:10:58what is the difference between this LDB
  5399. 3:11:01and this particular job?
  5400. 3:11:04This is a very good question.
  5401. 3:11:05Now the thing is pipeline is built for a
  5402. 3:11:08specific purpose
  5403. 3:11:11specific you can say task.
  5404. 3:11:13But
  5405. 3:11:14Data Bricks job or basically
  5406. 3:11:17any kind of orchestration job
  5407. 3:11:19performs a lot of similar similar tasks
  5408. 3:11:22bro
  5409. 3:11:23a lot of tasks.
  5410. 3:11:25For example let's say this is your one
  5411. 3:11:27LDB.
  5412. 3:11:28Okay?
  5413. 3:11:30After this LDB or let say along with
  5414. 3:11:32this LDB you should have one more LDB,
  5415. 3:11:34you should have one more LDB and once
  5416. 3:11:37all of these LDBs are completed you
  5417. 3:11:39should run one more LDB
  5418. 3:11:42but after completing all of these LDBs
  5419. 3:11:45that means all of these pipelines
  5420. 3:11:47and after running all of these pipelines
  5421. 3:11:49you should run let's say
  5422. 3:11:54three
  5423. 3:11:55PySpark notebooks let's say
  5424. 3:11:57one two three.
  5425. 3:12:00Now you tell me
  5426. 3:12:02can you handle this
  5427. 3:12:04without a job? No. Here you have to use
  5428. 3:12:08lake flow job where you can even
  5429. 3:12:10orchestrate the LDP pipeline. Oh.
  5430. 3:12:15You can even orchestrate this thing as
  5431. 3:12:17well. So that is why if you just go to
  5432. 3:12:19Databricks jobs
  5433. 3:12:21if you just click on job and let's say
  5434. 3:12:23if you have this medallion job and if
  5435. 3:12:25you just want to go to tasks and if you
  5436. 3:12:27want to add that lake flow job after
  5437. 3:12:29this gold you can click on add task and
  5438. 3:12:32you will have a task called ETL
  5439. 3:12:34pipeline. You can even scroll down and
  5440. 3:12:36you will find ETL pipeline. Here you can
  5441. 3:12:38just say
  5442. 3:12:39LDP and pipeline. You need to pick the
  5443. 3:12:42pipeline.
  5444. 3:12:43Pipeline is this one and that's it. Save
  5445. 3:12:45task.
  5446. 3:12:46Wow. This way you can even orchestrate
  5447. 3:12:50the pipeline as well.
  5448. 3:12:52So job is like the orchestration.
  5449. 3:12:56Pipeline is achieving a task
  5450. 3:13:00or you can better
  5451. 3:13:01phrase it like
  5452. 3:13:03pipeline is like you can say a kind of
  5453. 3:13:06small job
  5454. 3:13:08for a specific task.
  5455. 3:13:10Just for the understanding, okay? Just
  5456. 3:13:12for the understanding I'm just giving
  5457. 3:13:13you this definition.
  5458. 3:13:14It is a kind of flow
  5459. 3:13:17for that particular task only.
  5460. 3:13:20That is why
  5461. 3:13:21they both are interconnected but both
  5462. 3:13:24are not same.
  5463. 3:13:25Job is for orchestration. Pipeline is
  5464. 3:13:28the execution order for that particular
  5465. 3:13:31task only.
  5466. 3:13:33You should not build 100 things within
  5467. 3:13:35one single pipeline. No.
  5468. 3:13:37Why? It will be a nightmare to debug any
  5469. 3:13:41pipeline if you see any error at 2:00
  5470. 3:13:43a.m.
  5471. 3:13:43Because most of the pipelines of the
  5472. 3:13:47organizations run during the midnight.
  5473. 3:13:49If you see any error who will fix that?
  5474. 3:13:51Who will fix that? And how you will fix
  5475. 3:13:53that? It's not a piece of cake. But when
  5476. 3:13:55you have small small pipelines for
  5477. 3:13:57dedicated tasks you can easily debug it.
  5478. 3:14:00And in order to orchestrate those small
  5479. 3:14:01small pieces you have the job.
  5480. 3:14:04I hope now it makes sense. Now I hope
  5481. 3:14:06all the dots are connected.
  5482. 3:14:09With example, obviously because I wanted
  5483. 3:14:11to just show you everything with
  5484. 3:14:12examples.
  5485. 3:14:14Make sense?
  5486. 3:14:15good.
  5487. 3:14:16This is all about lake flows, jobs, lake
  5488. 3:14:18flow pipelines, and let me just tell you
  5489. 3:14:22your 80% of the concepts are crystal
  5490. 3:14:24clear, really yeah, because the the
  5491. 3:14:26these are the
  5492. 3:14:27major things that you need to
  5493. 3:14:29understand.
  5494. 3:14:30These are the major things.
  5495. 3:14:33Cool. Let's see what topic we need to
  5496. 3:14:35cover next.
  5497. 3:14:36So now let's talk about this topic DAB.
  5498. 3:14:41Data bricks asset bundles or declarative
  5499. 3:14:43automation bundles because recently they
  5500. 3:14:45just change the name and they just pick
  5501. 3:14:47the name as declarative automation
  5502. 3:14:49bundles. What is this thing? What is
  5503. 3:14:51this thing?
  5504. 3:14:52So this is nothing but a very useful
  5505. 3:14:54package to deploy your data bricks
  5506. 3:14:57packages.
  5507. 3:14:59Data bricks modules, data bricks
  5508. 3:15:01pipelines, data bricks, everything.
  5509. 3:15:03Because whatever we are building so far,
  5510. 3:15:05whatever we have built so far,
  5511. 3:15:07pipelines, jobs, notebooks, everything,
  5512. 3:15:10you are doing it within your workspace
  5513. 3:15:12or you can say within your
  5514. 3:15:14account
  5515. 3:15:15workspace.
  5516. 3:15:17So
  5517. 3:15:18this is good,
  5518. 3:15:19but this is just the one side of it. You
  5519. 3:15:22also need to learn how to deploy it to
  5520. 3:15:25multiple platforms.
  5521. 3:15:27Let's say this is your data bricks dev,
  5522. 3:15:29you need to deploy it to QA
  5523. 3:15:33and then ultimately to
  5524. 3:15:35prod as well.
  5525. 3:15:36Oh, so in order to deploy this thing,
  5526. 3:15:39you need a framework.
  5527. 3:15:41There are multiple ways to be honest.
  5528. 3:15:43You can use Terraform, you can use so
  5529. 3:15:46many ways, right? So many ways, there
  5530. 3:15:47are so many ways, Azure Bicep, so many
  5531. 3:15:50ways. But data bricks created a package
  5532. 3:15:52called asset bundles or automation
  5533. 3:15:54bundles
  5534. 3:15:55where they say that we will make your
  5535. 3:15:57deployment much, much, much easier and
  5536. 3:15:59very, very simple.
  5537. 3:16:01Very simple.
  5538. 3:16:03Okay.
  5539. 3:16:04What is the simple thing? So what we
  5540. 3:16:06Whatever you build here, we create a
  5541. 3:16:09kind of package.
  5542. 3:16:13Oh, we create a package
  5543. 3:16:15and then we deploy this bundle, this
  5544. 3:16:17package. We just called as bundle.
  5545. 3:16:19That's why it is called as automation
  5546. 3:16:21bundle or asset bundle. So, we create
  5547. 3:16:23this package, okay? And we deploy it to
  5548. 3:16:25QA
  5549. 3:16:26and same package will ultimately go to
  5550. 3:16:28production as well.
  5551. 3:16:30Cool? This is the concept.
  5552. 3:16:32But how to bundle it? How to bundle it?
  5553. 3:16:35There are multiple ways. There are
  5554. 3:16:36multiple ways. So, what we do? Let's say
  5555. 3:16:38you have built notebooks, you have um
  5556. 3:16:41created jobs, you have created
  5557. 3:16:43pipelines.
  5558. 3:16:44Everything that you have created,
  5559. 3:16:46everything
  5560. 3:16:48behind the scenes, behind the UI, you
  5561. 3:16:51will see something called as YAML.
  5562. 3:16:55YAML. And YAML, you should know that
  5563. 3:16:58this is the standard for DevOps, okay?
  5564. 3:17:01Every DevOps software, technology,
  5565. 3:17:03framework uses YAML and not just DevOps.
  5566. 3:17:06YAML is becoming standard for literally
  5567. 3:17:07everything. Okay? Even Docker. Docker
  5568. 3:17:10compose file is full of YAML. So, YAML
  5569. 3:17:11is literally everywhere.
  5570. 3:17:13And now in the world of AI,
  5571. 3:17:16it is the first choice. Why? Because
  5572. 3:17:17when you just write the JSON code or
  5573. 3:17:19JSON syntax, you waste a lot of tokens
  5574. 3:17:22by writing curly braces and blah blah
  5575. 3:17:24double quotes.
  5576. 3:17:25In YAML, we do not have curly braces, we
  5577. 3:17:27do not have quotes. So, it saves a lot
  5578. 3:17:28of tokens because it's all about tokens
  5579. 3:17:30now. Literally, it's all about tokens.
  5580. 3:17:33So, YAML is just a good way to replace
  5581. 3:17:35JSON. Um it is used for configurations,
  5582. 3:17:38it is used for um you can say defining
  5583. 3:17:40hierarchies, key-value pairs, but
  5584. 3:17:42without those curly braces and without
  5585. 3:17:43those um double quotes. Simple? This is
  5586. 3:17:46the best answer that I can just give
  5587. 3:17:48what is YAML. Similar thing, but we we
  5588. 3:17:50just use it like like it it we just
  5589. 3:17:52write it like this. Let's say we just
  5590. 3:17:53have a key, then key will have a colon,
  5591. 3:17:55then let's say this is the value.
  5592. 3:17:57Simple. No curly braces, no double
  5593. 3:17:59quotes, nothing. Simple.
  5594. 3:18:02Okay? So, this is YAML. So, whatever we
  5595. 3:18:03are creating, jobs, pipelines, um
  5596. 3:18:07notebooks, everything,
  5597. 3:18:08under the hood,
  5598. 3:18:09these are just YAML files. So what we
  5599. 3:18:12do?
  5600. 3:18:13We simply say that we will provide you
  5601. 3:18:15one parent YAML file. Listen to me
  5602. 3:18:17carefully. Parent YAML file. So this
  5603. 3:18:19will be my parent YAML file. Let's say.
  5604. 3:18:23And within this parent YAML file, I will
  5605. 3:18:25have small small
  5606. 3:18:28connecting YAML files.
  5607. 3:18:30Let's say this YAML file will be for
  5608. 3:18:32job.
  5609. 3:18:33This YAML file will be for pipelines.
  5610. 3:18:37And blah blah blah. So I will connect
  5611. 3:18:39these these or I will include these
  5612. 3:18:41these
  5613. 3:18:43YAML
  5614. 3:18:45to this parent YAML file. And I will
  5615. 3:18:47create a package out of it.
  5616. 3:18:49Okay?
  5617. 3:18:51I will create a package, basically a
  5618. 3:18:52bundle out of it. And that bundle is
  5619. 3:18:54nothing but this one. And it is also
  5620. 3:18:56called as dot bundle. When you just
  5621. 3:18:58deploy it, it gets deployed with this
  5622. 3:18:59particular extension, dot bundle.
  5623. 3:19:01And this dot bundle will go to QA and
  5624. 3:19:04will ultimately go to production. This
  5625. 3:19:07is your automation bundle.
  5626. 3:19:09Oh, yes. This is your automation bundle.
  5627. 3:19:11Let me show you.
  5628. 3:19:13If you just go to your Databricks, if I
  5629. 3:19:15just click on let say pipelines, if I
  5630. 3:19:16click on anything, let say job,
  5631. 3:19:19you will see in the three dots, edit as
  5632. 3:19:21YAML. So this is the YAML written for
  5633. 3:19:24this particular job. Oh. So this UI is
  5634. 3:19:27just for you.
  5635. 3:19:28But for machine,
  5636. 3:19:30for Databricks internal code, for
  5637. 3:19:32backend, this is the thing they want.
  5638. 3:19:34Simple.
  5639. 3:19:36Simple.
  5640. 3:19:37This is the YAML. So they have
  5641. 3:19:39resources, they have jobs, job name,
  5642. 3:19:41medallion task, each task, and where is
  5643. 3:19:44the notebook for each thing, everything.
  5644. 3:19:46So this is the job. This is just the UI.
  5645. 3:19:49This is just the UI. But the resource is
  5646. 3:19:51this one.
  5647. 3:19:52So what we do? We bundle this job,
  5648. 3:19:55everything, and then when we deploy this
  5649. 3:19:58bundle to QA, this exact job will be
  5650. 3:20:01deployed to QA. So when that dot bundle
  5651. 3:20:04folder will be taken to the QA
  5652. 3:20:07workspace, will have this job. Why?
  5653. 3:20:09Because we have this particular
  5654. 3:20:12job created
  5655. 3:20:14under dot bundle.
  5656. 3:20:15Oh, because Databricks understands this.
  5657. 3:20:20Make sense? Very good. How we can just
  5658. 3:20:22create this thing? Let me show you. So
  5659. 3:20:24you can literally go to workspace,
  5660. 3:20:26right? And you can let's say create a
  5661. 3:20:29new folder. Let me just remove this
  5662. 3:20:31forced LDB as well from here.
  5663. 3:20:33Let's say move to trash. So if you just
  5664. 3:20:35want to create this thing, you can
  5665. 3:20:37create one new folder within this as
  5666. 3:20:39well.
  5667. 3:20:40So let's say I want to create bundle.
  5668. 3:20:43Open a git folder. We do not want to
  5669. 3:20:45create git folder. It's fine. So let's
  5670. 3:20:46say folder.
  5671. 3:20:48So we will just talk about git folder
  5672. 3:20:49don't worry. It's very simple. So let
  5673. 3:20:52say this is my
  5674. 3:20:53dab folder. Let's say it's called as
  5675. 3:20:55dab.
  5676. 3:20:56Okay. And this is the folder I want to
  5677. 3:20:58use for all of the YAML, all of the
  5678. 3:20:59deployments, everything, right? So how
  5679. 3:21:01you can just create this thing? You need
  5680. 3:21:02to open one terminal, web terminal. Yes,
  5681. 3:21:05we get the web terminal as well within
  5682. 3:21:06the Databricks. In order to open it, you
  5683. 3:21:08need to have at least one notebook
  5684. 3:21:10because only then it will open it
  5685. 3:21:11because it needs to use a compute. So
  5686. 3:21:13just for that purpose, I'm just creating
  5687. 3:21:14a demo notebook which is not linked to
  5688. 3:21:16any kind of deployment, but just for
  5689. 3:21:19using the compute. Let me just close all
  5690. 3:21:21the
  5691. 3:21:22unused files. Cool. So when we just get
  5692. 3:21:25into this particular notebook, I will
  5693. 3:21:27see one terminal here on the bottom
  5694. 3:21:29side. Okay. Click on this logs and this
  5695. 3:21:32terminal will be
  5696. 3:21:33open and it will simply say requires
  5697. 3:21:35cluster to be attached. So simply click
  5698. 3:21:36on serverless compute and it will attach
  5699. 3:21:38this compute.
  5700. 3:21:40Now it will open the terminal.
  5701. 3:21:42And this is my terminal. You can even
  5702. 3:21:43click on this button to open it in the
  5703. 3:21:46new window like this.
  5704. 3:21:49So this is my terminal and now I can
  5705. 3:21:51just literally write anything I want. So
  5706. 3:21:53here I will first of all initialize the
  5707. 3:21:55bundle.
  5708. 3:21:56You can write
  5709. 3:21:57Databricks bundle init. Hit enter. It
  5710. 3:22:00will simply say installing the CLI
  5711. 3:22:02because behind the scenes we first need
  5712. 3:22:04to install the CLI. So in the web
  5713. 3:22:06terminal, it will automatically install
  5714. 3:22:07the CLI. Okay. Then it will simply say
  5715. 3:22:09do you want default Python? Simply say
  5716. 3:22:11yes. And unique name for the project,
  5717. 3:22:13let's say
  5718. 3:22:15dab
  5719. 3:22:16project. Include a job that runs a
  5720. 3:22:18notebook. Yeah, because this will just
  5721. 3:22:19show you how the things works. Simply
  5722. 3:22:21create a demo notebook, um demo job.
  5723. 3:22:23Yes. Include ETL, yes.
  5724. 3:22:26Include a sample Python package.
  5725. 3:22:28We'll
  5726. 3:22:29Yeah, just keep it. Fine.
  5727. 3:22:31Use serverless compute, yes. Serverless
  5728. 3:22:32compute and now default catalog for any
  5729. 3:22:34table, literally say demo.
  5730. 3:22:37Um yes.
  5731. 3:22:40After answering these simple simple
  5732. 3:22:42questions, your package will be
  5733. 3:22:44initialized, your bundle will be
  5734. 3:22:45initialized, and I think it has done the
  5735. 3:22:46work.
  5736. 3:22:47Let me just check and let me just open
  5737. 3:22:50it.
  5738. 3:22:51Demo dab project. Perfect. As I can see,
  5739. 3:22:54everything is here. Let me just close
  5740. 3:22:55this terminal. It is not required now.
  5741. 3:22:57So within the dab project, like as you
  5742. 3:22:59can as you can see, inside the dab I
  5743. 3:23:01have this demo notebook which I created
  5744. 3:23:02just for this particular purpose to open
  5745. 3:23:05this terminal, but I can just close it
  5746. 3:23:06now. I can even delete it. It's not
  5747. 3:23:07required.
  5748. 3:23:09Within that particular folder, it
  5749. 3:23:10created this particular folder for me.
  5750. 3:23:13Wow.
  5751. 3:23:14Yes. It created this folder for me. And
  5752. 3:23:16within this folder, I have some things.
  5753. 3:23:18First of all, fixtures, ignore this
  5754. 3:23:19thing. Resources, I will just talk about
  5755. 3:23:21this thing. Source and tests. These are
  5756. 3:23:24demo demo things.
  5757. 3:23:25Okay. Ignore everything because the main
  5758. 3:23:27thing here is databricks.yml file. This
  5759. 3:23:30is the major parent YAML file that I
  5760. 3:23:33just talked about. Okay. This is the
  5761. 3:23:34parent YAML file. Okay.
  5762. 3:23:37Within this parent YAML file, we get
  5763. 3:23:38some things. First of all, the project
  5764. 3:23:40name, which is this one, dab project. It
  5765. 3:23:42says include resources.yml. Remember I
  5766. 3:23:46told you that we attach the small small
  5767. 3:23:48components YAML files to it. So it
  5768. 3:23:50simply says this is my parent YAML and
  5769. 3:23:53anything which is created inside the
  5770. 3:23:55resources folder, like any YAML file,
  5771. 3:23:57should also be the part of this parent
  5772. 3:23:59YAML file. and let me just open this
  5773. 3:24:01YAML file, like resources folder, you
  5774. 3:24:03will see two YAML files. First of all,
  5775. 3:24:05sample job and this is a sample ETL. If
  5776. 3:24:07I open this particular file, you will
  5777. 3:24:09see the
  5778. 3:24:10sample job, sample job YAML. See?
  5779. 3:24:14Oh, wow.
  5780. 3:24:15Everything is here.
  5781. 3:24:17And if I just open the ETL pipeline,
  5782. 3:24:18this is the YAML for the ETL. Again,
  5783. 3:24:20sample.
  5784. 3:24:22Oh, so these two YAML file
  5785. 3:24:24are now the part of this parent YAML
  5786. 3:24:27file.
  5787. 3:24:28Wow. And then we have some artifacts. If
  5788. 3:24:30you just want to include some, you can
  5789. 3:24:32say internal artifacts like Python wheel
  5790. 3:24:34file. So it has already created that
  5791. 3:24:35thing. Python wheel, type wheel, UV
  5792. 3:24:36build wheel. That's it.
  5793. 3:24:39But you can just ignore it. It's not a
  5794. 3:24:40big deal. It is only
  5795. 3:24:42it is only required when you have like
  5796. 3:24:44some packages within your source folder
  5797. 3:24:46and you just want to include it within
  5798. 3:24:48your
  5799. 3:24:49Python build if you just want to build
  5800. 3:24:51it during the deployment. So it is for
  5801. 3:24:53that particular purpose. But usually if
  5802. 3:24:54you just want to use the wheel, you like
  5803. 3:24:57it's my personal opinion. You can just
  5804. 3:24:59put the wheel file directly instead of
  5805. 3:25:00rebuilding it. But you can just do it as
  5806. 3:25:02well. It's not a big deal. Okay.
  5807. 3:25:04And then inside the source folder we
  5808. 3:25:05have the project. We have this main
  5809. 3:25:07taxes or TY sample thing, DAP project
  5810. 3:25:10ETL, some project ETL. But now here's
  5811. 3:25:12the thing.
  5812. 3:25:14When you have
  5813. 3:25:15first of all the
  5814. 3:25:18ETL file like
  5815. 3:25:20you can say job forget about ETL just
  5816. 3:25:22the job.
  5817. 3:25:23If you just talk about job, if I just go
  5818. 3:25:25here in the resources and if I just go
  5819. 3:25:27to sample job,
  5820. 3:25:28you will see that we have sample
  5821. 3:25:30notebook as well. Oh, because in the job
  5822. 3:25:32we are orchestrating the components, but
  5823. 3:25:34we also need to include the component as
  5824. 3:25:36well within this.
  5825. 3:25:38So it says
  5826. 3:25:39here is the component. So this is the
  5827. 3:25:41thing that you need to remember whenever
  5828. 3:25:42you are deploying the stuff, whenever
  5829. 3:25:44you are deploying the package, you need
  5830. 3:25:45to include YAML. Yes, but you also need
  5831. 3:25:48to include the dependent like dependent
  5832. 3:25:49files.
  5833. 3:25:50I know it is like very common thing, but
  5834. 3:25:52I still want to tell you
  5835. 3:25:54that you need to include notebooks,
  5836. 3:25:57scripts, Python files, everything within
  5837. 3:25:59the
  5838. 3:26:00bundle. Now it is not required that you
  5839. 3:26:03have to have to create this source
  5840. 3:26:04folder, but it is a good practice just
  5841. 3:26:06to put all of the modules within the
  5842. 3:26:08source folder.
  5843. 3:26:09Cool. Very good.
  5844. 3:26:11Similar to ETL. Now whenever we just
  5845. 3:26:13create the ETL, we put all of the files
  5846. 3:26:15inside transformations folder I told
  5847. 3:26:17you. So see it is the same thing here as
  5848. 3:26:19well. If I open this thing inside the
  5849. 3:26:21transformation, I have these two files.
  5850. 3:26:24And if I just open the ETL YAML for it,
  5851. 3:26:26you will find all of the things here.
  5852. 3:26:28See, I have root path here and I want to
  5853. 3:26:31include everything that I have inside
  5854. 3:26:33the transformations folder.
  5855. 3:26:36That means these are the YAML files.
  5856. 3:26:38These are just the building block. This
  5857. 3:26:40is just the blueprint, but the raw
  5858. 3:26:42material is sitting inside the source
  5859. 3:26:44folder.
  5860. 3:26:46And that should be the part of the
  5861. 3:26:47deployment package as well. I hope it
  5862. 3:26:49makes sense.
  5863. 3:26:51So that's how we just create the
  5864. 3:26:52package. And if you just want to deploy
  5865. 3:26:53it, we can simply write bundle deploy
  5866. 3:26:55and that's it. It will simply create a
  5867. 3:26:56dot bundle folder and it will be there
  5868. 3:26:58in your workspace. That is obviously now
  5869. 3:27:00some people say that hey, do data
  5870. 3:27:03engineers need to know about these
  5871. 3:27:04things? This is just a DevOps things.
  5872. 3:27:06No.
  5873. 3:27:07You need to know because see, there are
  5874. 3:27:08two things.
  5875. 3:27:09Um let me just tell you.
  5876. 3:27:11First of all,
  5877. 3:27:12data brick CICD
  5878. 3:27:16for
  5879. 3:27:17bundle.
  5880. 3:27:19This part needs to be mastered by data
  5881. 3:27:21engineers because you will be the one
  5882. 3:27:24who know what is inside transformations
  5883. 3:27:27and what should be there inside
  5884. 3:27:28transformations folder. How you can just
  5885. 3:27:30expect this thing from a DevOps engineer
  5886. 3:27:32that they will know what is LDP? How how
  5887. 3:27:35how how do they know?
  5888. 3:27:37You need to master this thing. You need
  5889. 3:27:39to understand how bundle works. Now then
  5890. 3:27:42where DevOps team come in? Let me just
  5891. 3:27:44tell you that as well. Once you created
  5892. 3:27:46the dot bundle
  5893. 3:27:48folder, okay, let's say once you just
  5894. 3:27:51created this bundle, now this bundle
  5895. 3:27:54needs to go to QA,
  5896. 3:27:56needs to go to prod.
  5897. 3:27:59And this bundle creation should also be
  5898. 3:28:01automated because there can be like
  5899. 3:28:02let's say developer one created this
  5900. 3:28:04bundle, developer two created this
  5901. 3:28:06bundle. So all the quality checks here,
  5902. 3:28:08let's say some test cases should also
  5903. 3:28:10run. So this part, this part, this part
  5904. 3:28:14will be handled by DevOps team. They
  5905. 3:28:16will just create the pipeline CICD
  5906. 3:28:18pipeline in Azure DevOps, let's say in
  5907. 3:28:20most of the cases in Azure DevOps. So
  5908. 3:28:22they will just automate this thing. They
  5909. 3:28:24will just write the job there, let's say
  5910. 3:28:26trigger
  5911. 3:28:28trigger this job on this particular
  5912. 3:28:30thing and if anyone creates a pull
  5913. 3:28:31request, simply create a bundle folder,
  5914. 3:28:34then just take that dot bundle folder,
  5915. 3:28:36deploy it to QA, run the test cases. If
  5916. 3:28:39everything is fine, you can even include
  5917. 3:28:41some senior folks in the pipeline and
  5918. 3:28:43then approve it, then go to production.
  5919. 3:28:45This entire automation will be handled
  5920. 3:28:47by the DevOps team
  5921. 3:28:49or in today's era, a senior data
  5922. 3:28:51engineer can also handle this thing.
  5923. 3:28:54But this is the DevOps part. This is not
  5924. 3:28:56the DevOps part. This is not the DevOps
  5925. 3:28:58part. This is the data engineering
  5926. 3:28:59development part. This is not a DevOps
  5927. 3:29:02part
  5928. 3:29:03because you you literally like start
  5929. 3:29:05shouting,
  5930. 3:29:06CI CD is all about DevOps, why do we
  5931. 3:29:08need to learn it? No.
  5932. 3:29:09How can you expect this thing from a
  5933. 3:29:11DevOps person to know about LDP,
  5934. 3:29:15materialized views, Spark structured
  5935. 3:29:17streaming, ETL? How how can you just
  5936. 3:29:19expect this thing? No.
  5937. 3:29:21You need to perform this thing.
  5938. 3:29:24Make sense? Make sense? Very good.
  5939. 3:29:26So this is all about asset bundles and I
  5940. 3:29:28hope this will give you a very clear
  5941. 3:29:29understanding of it. And yeah, this is
  5942. 3:29:31all.
  5943. 3:29:32Nothing fancy, nothing difficult as
  5944. 3:29:35well. So this was all about DAPP.
  5945. 3:29:37Now let's talk about the Git folders
  5946. 3:29:40because we just talked about it. So
  5947. 3:29:41let's say
  5948. 3:29:43Git folder. So let's say Databricks
  5949. 3:29:46Git folders.
  5950. 3:29:47So what is Databricks Git folder? So
  5951. 3:29:49let's say on the same Databricks
  5952. 3:29:52workspace,
  5953. 3:29:54multiple developers
  5954. 3:29:56multiple developers are working. Let's
  5955. 3:29:58say this developer is working, this
  5956. 3:29:59developer is working, multiple
  5957. 3:30:00developers are working, right?
  5958. 3:30:02This decent developer is also working.
  5959. 3:30:06So now these all are working, right? All
  5960. 3:30:08can create conflict. All can just mess
  5961. 3:30:11up with each other's development,
  5962. 3:30:12obviously, because there's just one
  5963. 3:30:13workspace. So the solution is simply
  5964. 3:30:17involve
  5965. 3:30:19one
  5966. 3:30:20version control or basically a system
  5967. 3:30:23which can isolate each other's
  5968. 3:30:25development. So here we involve Git.
  5969. 3:30:29Here you can just use GitHub, Azure
  5970. 3:30:31DevOps, any repository if you want to,
  5971. 3:30:33but software will be Git.
  5972. 3:30:35So here you include Git and everyone
  5973. 3:30:38creates their own branch using Git and
  5974. 3:30:40this Data Bricks is also connected to
  5975. 3:30:43this Git.
  5976. 3:30:44So what will happen? So everything will
  5977. 3:30:46be
  5978. 3:30:48connected to this Git and this Git will
  5979. 3:30:49be connected to Data Bricks. Now
  5980. 3:30:51everyone is contributing to Data Bricks,
  5981. 3:30:52yes, but via Git.
  5982. 3:30:54Cool?
  5983. 3:30:56Let me show you how you can just create
  5984. 3:30:57it. It's very simple. Simply go to home
  5985. 3:30:59and then go to workspace and then click
  5986. 3:31:02on create or let's go to demo
  5987. 3:31:04first of all and then click on create,
  5988. 3:31:06click on Git folder. So this is the Git
  5989. 3:31:07folder, but whenever you want to create
  5990. 3:31:09a Git folder, you need to create the
  5991. 3:31:10GitHub repository or Git repository.
  5992. 3:31:13You can just connect it via GitHub, you
  5993. 3:31:15can also connect it via Azure DevOps. It
  5994. 3:31:17is not a big deal and in most of the
  5995. 3:31:18scenarios you will get this thing done
  5996. 3:31:22on your workspace by a senior folk, but
  5997. 3:31:24if you know this thing, it's good.
  5998. 3:31:26It's really good.
  5999. 3:31:28I hope it makes sense. Okay, okay, okay,
  6000. 3:31:30okay.
  6001. 3:31:31So this is all about Git and this is a
  6002. 3:31:33very fundamental thing. I hope that you
  6003. 3:31:35all would already know, but
  6004. 3:31:37like you would know about Git, but Data
  6005. 3:31:38Bricks Git folder is a different thing,
  6006. 3:31:40right? Like now you also know that as
  6007. 3:31:41well.
  6008. 3:31:42So this is all about Data Bricks Git
  6009. 3:31:44folders.
  6010. 3:31:46Makes sense?
  6011. 3:31:47Now let's talk about Data Bricks SQL.
  6012. 3:31:49Now what is this thing? Data Bricks SQL.
  6013. 3:31:52Do we just need to write SQL? It is Data
  6014. 3:31:53Bricks SQL? No. It is totally a
  6015. 3:31:56different thing. Really?
  6016. 3:31:59Now it is [clears throat] also called as
  6017. 3:32:00SQL warehouse, Data Bricks SQL
  6018. 3:32:01warehouse. But what is this thing? Data
  6019. 3:32:02Bricks SQL, Data Bricks SQL warehouse.
  6020. 3:32:05So basically whatever we have done being
  6021. 3:32:08a data engineer
  6022. 3:32:09in Data Bricks, we used all purpose
  6023. 3:32:10compute, we used serverless SQL compute,
  6024. 3:32:13we use all of these things, right?
  6025. 3:32:15These computes are very good
  6026. 3:32:18whenever you want to perform data
  6027. 3:32:19engineering task, ingestion,
  6028. 3:32:21transformation, storage, blah blah blah.
  6029. 3:32:24But when we want our bricks
  6030. 3:32:29to be connected
  6031. 3:32:30to
  6032. 3:32:31tools like Power BI, any reporting tool,
  6033. 3:32:35we do not
  6034. 3:32:37connect those tools via all purpose
  6035. 3:32:40compute or the compute that we use for
  6036. 3:32:42data engineering. No.
  6037. 3:32:44We have a special type of compute called
  6038. 3:32:45SQL warehouse.
  6039. 3:32:47Oh, because these are the optimized
  6040. 3:32:49compute to perform the SQL workloads or
  6041. 3:32:51basically reporting workloads.
  6042. 3:32:55This area comes under Databricks SQL.
  6043. 3:32:58This is one thing. Second,
  6044. 3:33:01obviously you have built amazing amazing
  6045. 3:33:02things. Now, who will use them?
  6046. 3:33:06Stakeholders. Not stakeholders only. You
  6047. 3:33:08will also use that data. You also might
  6048. 3:33:10need to query that data. You might also
  6049. 3:33:12need to look at some you can say might
  6050. 3:33:14numbers anything.
  6051. 3:33:16So how will you just take care of all of
  6052. 3:33:18these things? Let me just show you. So
  6053. 3:33:19let me show you
  6054. 3:33:21because this area has a dedicated space
  6055. 3:33:23within the data bricks. So simply come
  6056. 3:33:25to data bricks and then oh to SQL. So if
  6057. 3:33:28it is like collapsed, you can just
  6058. 3:33:29expand it or you can even go to plus
  6059. 3:33:31new.
  6060. 3:33:32So this is the SQL area where they have
  6061. 3:33:34put all of the things. SQL warehouses,
  6062. 3:33:36alerts, SQL editor as well because they
  6063. 3:33:38have just created this integrate SQL
  6064. 3:33:40editor where you can write the queries
  6065. 3:33:42and you will get the results back.
  6066. 3:33:44You can even store the queries and
  6067. 3:33:47very popular option dashboards is also
  6068. 3:33:49here. You can even create the
  6069. 3:33:51dashboards. You do not even need to go
  6070. 3:33:52to Power BI. And if you just take my
  6071. 3:33:54advice,
  6072. 3:33:55I think in the very very very
  6073. 3:33:59not very, I would say I do not know the
  6074. 3:34:02exact timing, but you will see a change
  6075. 3:34:05that
  6076. 3:34:06people might not use the traditional
  6077. 3:34:08dashboards. Now people be using the
  6078. 3:34:10integrated dashboard. That's why
  6079. 3:34:13Databricks dashboards
  6080. 3:34:14are becoming more popular.
  6081. 3:34:16Dashboards within the AI chatbots are
  6082. 3:34:19becoming more popular, but I think that
  6083. 3:34:21will take a lot of time because not
  6084. 3:34:23every organization would
  6085. 3:34:24trust it blindly to just hand over all
  6086. 3:34:26the data and then just ask the
  6087. 3:34:27questions. But integrated dashboards
  6088. 3:34:30like Databricks dashboards will become
  6089. 3:34:31very popular.
  6090. 3:34:33Power BI will obviously will be there
  6091. 3:34:34because Power BI has been there since so
  6092. 3:34:36long and organization has created like
  6093. 3:34:38thousands of dashboards and it is not a
  6094. 3:34:40piece of cake to migrate all of them. It
  6095. 3:34:42takes years, okay? It takes years, but
  6096. 3:34:45Power BI will be there, but you will see
  6097. 3:34:46a rise of these kinds of dashboards as
  6098. 3:34:48well. Okay?
  6099. 3:34:49So first of all, let's click on the SQL
  6100. 3:34:50warehouse. Let's see what do we have. So
  6101. 3:34:52by default in the free edition, we get
  6102. 3:34:54serverless starter warehouse and this is
  6103. 3:34:56a type of compute that we use to connect
  6104. 3:35:00to SQL workloads, to connect to
  6105. 3:35:02reporting workloads, everything. Okay?
  6106. 3:35:04You can even create one
  6107. 3:35:06if you have the hosted version. If you
  6108. 3:35:07are on free version, you can even they
  6109. 3:35:09like you can just only use this one and
  6110. 3:35:11that's it.
  6111. 3:35:12Cool, very good. You can just turn it
  6112. 3:35:14on. It is also serverless, so it will be
  6113. 3:35:16just automatically scaling up and down
  6114. 3:35:18depending upon the workloads and the
  6115. 3:35:19size is 2x small, which is the cluster
  6116. 3:35:21size. Okay? We have 2x small, x small,
  6117. 3:35:24and then small, large, extra large,
  6118. 3:35:26these kinds of sizes.
  6119. 3:35:27Right? So this is my compute. Let's say
  6120. 3:35:29if I want to look at my data, I can go
  6121. 3:35:31to SQL editor.
  6122. 3:35:33Cool. And let me just open the query
  6123. 3:35:36and this is a new tab.
  6124. 3:35:38Here you can just open the catalog on
  6125. 3:35:40the left. Here you can let's say click
  6126. 3:35:43on SQL query
  6127. 3:35:44and you can just query anything the same
  6128. 3:35:46way you query your SQL um database.
  6129. 3:35:50Let's say select asterisks from
  6130. 3:35:53orders. And I can just decide what
  6131. 3:35:57I have within my workspace. So let's say
  6132. 3:35:59demo and then let's say bronze. Okay?
  6133. 3:36:02So if I just click on run all,
  6134. 3:36:04it will simply run this session and this
  6135. 3:36:06will be my
  6136. 3:36:08just SQL workload area.
  6137. 3:36:11No data injection, nothing I can perform
  6138. 3:36:13because this is obviously a SQL workload
  6139. 3:36:15area, but here we just perform some
  6140. 3:36:17quick analysis, ad hoc analysis and all
  6141. 3:36:18of these things.
  6142. 3:36:19Cool.
  6143. 3:36:20If you have written some special queries
  6144. 3:36:23that you just want to save it, you can
  6145. 3:36:24even save it using this particular
  6146. 3:36:25button.
  6147. 3:36:26And that is not everything.
  6148. 3:36:29Databricks has recently created
  6149. 3:36:31something called as parameterized
  6150. 3:36:32queries. So let say you just want to
  6151. 3:36:35perform parameterization as well within
  6152. 3:36:37your query. You can perform let's say
  6153. 3:36:39where um store ID
  6154. 3:36:41okay
  6155. 3:36:42equals
  6156. 3:36:44colon let's say this um store ID.
  6157. 3:36:47Okay? You can just add it like this as
  6158. 3:36:49well or you can even use this UI because
  6159. 3:36:52I just created it. You can just click
  6160. 3:36:53here as well add parameter and parameter
  6161. 3:36:56one can be anything and you can even
  6162. 3:36:58rename it let's say
  6163. 3:37:00param store.
  6164. 3:37:02Either way you can directly code it
  6165. 3:37:03because I remember this particular colon
  6166. 3:37:05thing so yeah. So now what happened?
  6167. 3:37:07This has become my query
  6168. 3:37:10parameterized query. Wow.
  6169. 3:37:12Wow. Literally wow. So I can just remove
  6170. 3:37:14this thing parameter store. Now what
  6171. 3:37:16will happen? I can just literally
  6172. 3:37:17provide some value let's say 10. Now I
  6173. 3:37:19can click on run all.
  6174. 3:37:21Now this will just show me all of the
  6175. 3:37:24things for just store ID equals to 10.
  6176. 3:37:27Let's say I just want to see any other
  6177. 3:37:29thing let's say 11. If I let's say click
  6178. 3:37:31on run all, I will see only the store ID
  6179. 3:37:33equals to 11. What is the advantage of
  6180. 3:37:35it?
  6181. 3:37:36Let's say you are a technical person
  6182. 3:37:39and you have created a very long query
  6183. 3:37:42let's say 50 lines of query.
  6184. 3:37:45Now you ran it once or let's say your
  6185. 3:37:47stakeholder ran it once. Cool. Now next
  6186. 3:37:50day they want to check the same result
  6187. 3:37:52but for a different store
  6188. 3:37:55right? Now it is so risky to change the
  6189. 3:37:58things directly within the query because
  6190. 3:38:00this is a very simple query and in real
  6191. 3:38:02world we write like sub queries, sub
  6192. 3:38:04queries within sub query, sub queries
  6193. 3:38:06within sub queries and you know that we
  6194. 3:38:08use CTEs, we use sub queries so it
  6195. 3:38:10becomes a mess when you have 50 to 60 to
  6196. 3:38:1270 lines of queries right?
  6197. 3:38:15So you cannot miss any single thing
  6198. 3:38:17otherwise result will be wrong. But
  6199. 3:38:19let's say you created one query, you
  6200. 3:38:21tested it end to end and everything is
  6201. 3:38:23working fine. Now what you can do you
  6202. 3:38:25can create parameters within your
  6203. 3:38:26queries and you can just change those
  6204. 3:38:28parameters and you can just get the
  6205. 3:38:30dynamic results every time whenever you
  6206. 3:38:32are just running that query.
  6207. 3:38:34It will help the technical people as
  6208. 3:38:35well because you do not need to touch
  6209. 3:38:37the query again and again. It will be a
  6210. 3:38:39gold for non-technical people because
  6211. 3:38:42they do not need to touch the query
  6212. 3:38:44because obviously if they touch the
  6213. 3:38:46query they will break it.
  6214. 3:38:48So what you can do? You can literally
  6215. 3:38:49save this query and you can just only
  6216. 3:38:51allow the read access and they can only
  6217. 3:38:53change the parameters and that's it.
  6218. 3:38:55That way they will not break the code.
  6219. 3:38:57They will only put something garbage in
  6220. 3:38:59the parameters at the in in the worst
  6221. 3:39:01case scenario and that's it. That will
  6222. 3:39:02not do anything harmful to your code, to
  6223. 3:39:05your resources, right?
  6224. 3:39:08This way you can perform the like I
  6225. 3:39:10really like love this feature like
  6226. 3:39:11parameterization of queries.
  6227. 3:39:13Simple
  6228. 3:39:14because earlier people were just
  6229. 3:39:16creating the functions, the procedures
  6230. 3:39:18just for performing all of these things.
  6231. 3:39:20But now you do not need to create that.
  6232. 3:39:22Simply save the queries,
  6233. 3:39:23parameterization and that's it.
  6234. 3:39:25Cool.
  6235. 3:39:27This is like very important and then
  6236. 3:39:29whatever queries you save it will be
  6237. 3:39:31saved under queries but I do not want to
  6238. 3:39:32save it so I'm not saving it and that's
  6239. 3:39:34it.
  6240. 3:39:34And if you just want to create the
  6241. 3:39:36alerts as well you can even create the
  6242. 3:39:37alerts. Let's say
  6243. 3:39:39you want to notify your manager if
  6244. 3:39:42any customer has just purchased
  6245. 3:39:44something more than xyz amount, right?
  6246. 3:39:47So you can even create the alerts that
  6247. 3:39:49way by clicking here alerts. So all of
  6248. 3:39:52these things come under Databricks SQL.
  6249. 3:39:53Databricks SQL is not just like I am
  6250. 3:39:56using SQL in Databricks, it is
  6251. 3:39:57Databricks SQL. I am using SQL in
  6252. 3:39:59Databricks and I know how to use SQL. I
  6253. 3:40:02am a Databricks developer because I am
  6254. 3:40:04using SQL and Databricks also use SQL.
  6255. 3:40:06What?
  6256. 3:40:08What? What is this?
  6257. 3:40:11Bro, yes, SQL is the base for Databricks
  6258. 3:40:15as well but
  6259. 3:40:18do you write this query in your SQL? No.
  6260. 3:40:22Then it is different.
  6261. 3:40:25Yes, SQL is a fundamental but who will
  6262. 3:40:28learn the technology?
  6263. 3:40:30Who?
  6264. 3:40:31No, no, no, no. We know SQL, we know
  6265. 3:40:33everything. We know the entire data
  6266. 3:40:35engineering because we know SQL.
  6267. 3:40:37Very good, very good, very good But do
  6268. 3:40:39not worry, because if you are my data
  6269. 3:40:41fam, it's my responsibility to tell you
  6270. 3:40:43what is actually required to become a
  6271. 3:40:46data engineer, what is actually required
  6272. 3:40:49to become an AI data engineer or
  6273. 3:40:51anything which is relevant into this
  6274. 3:40:53domain. Make sense? Make sense?
  6275. 3:40:56This is all about Databricks SQL. Let's
  6276. 3:40:58jump onto the next topic. Now let's talk
  6277. 3:41:00about Databricks Genie. And Databricks
  6278. 3:41:03Genie is like so so so popular and it is
  6279. 3:41:06actually very good. Let me just see if I
  6280. 3:41:08have the logo for it.
  6281. 3:41:11Databricks. No.
  6282. 3:41:13It's fine.
  6283. 3:41:14So yeah, Databricks Genie. What is
  6284. 3:41:15Databricks Genie? Databricks Genie is
  6285. 3:41:16nothing but the AI agent built by
  6286. 3:41:19Databricks
  6287. 3:41:20for Databricks,
  6288. 3:41:22inside Databricks. Oh really? Yeah.
  6289. 3:41:25All of these things.
  6290. 3:41:26And this is not just another AI agent.
  6291. 3:41:28It is actually agentic AI agent. What
  6292. 3:41:31what is the difference? See,
  6293. 3:41:33one AI agent can be the one
  6294. 3:41:36which can answer your questions.
  6295. 3:41:38That is an AI agent.
  6296. 3:41:40But when that AI agent can also perform
  6297. 3:41:43the tasks in the form of workflows, in
  6298. 3:41:46the form of like multi-step tasks, then
  6299. 3:41:48that agent is not just an AI agent. It
  6300. 3:41:50is an agentic AI agent
  6301. 3:41:52that can perform the tool calls,
  6302. 3:41:53everything. Okay. I know at the end of
  6303. 3:41:56the day it is still an agent, but it
  6304. 3:41:57matters a lot because now it is able to
  6305. 3:42:00perform the agentic things, agentic
  6306. 3:42:01things.
  6307. 3:42:03Hmm. That is a Databricks Genie.
  6308. 3:42:05And Databricks Genie has actually
  6309. 3:42:08boosted the
  6310. 3:42:10efficiency,
  6311. 3:42:11speed, productivity to the next level.
  6312. 3:42:14Really? Yeah.
  6313. 3:42:15And you also get Databricks Genie for
  6314. 3:42:16free, like in the free edition. Let me
  6315. 3:42:18just show you.
  6316. 3:42:19Let me just open this particular thing.
  6317. 3:42:22And if you just want to open Genie,
  6318. 3:42:23there are like multiple areas. You can
  6319. 3:42:25even go to dedicated notebook. You will
  6320. 3:42:27find Genie there. Let me just show you
  6321. 3:42:28first of all that thing. So if you just
  6322. 3:42:30let say go to demo. Why do I have
  6323. 3:42:32drafts? Oh, because I just I didn't save
  6324. 3:42:34the queries. Let me just drop it.
  6325. 3:42:36I can just drop this as well. Perfect.
  6326. 3:42:38So if I just open this one and if have
  6327. 3:42:40let say any notebook, let say
  6328. 3:42:43Okay?
  6329. 3:42:44And if I'm just performing any kind of
  6330. 3:42:46data injection, data transformation,
  6331. 3:42:49data loading, anything, and if I want
  6332. 3:42:51any help, okay?
  6333. 3:42:52If I want any help in the dedicated
  6334. 3:42:54cell, I can open this Jenny right away.
  6335. 3:42:57This is a kind of inline code help by
  6336. 3:43:00Jenny.
  6337. 3:43:01Oh, yes.
  6338. 3:43:03If I do not want an inline code help, I
  6339. 3:43:06want the help for the entire notebook.
  6340. 3:43:09I might need to ask something else. Then
  6341. 3:43:11I can click on this button here.
  6342. 3:43:14This will open the interactive AI agent
  6343. 3:43:17session, and it will take this notebook
  6344. 3:43:20as a context.
  6345. 3:43:21It doesn't mean that it cannot take
  6346. 3:43:23context of any other notebook, but this
  6347. 3:43:24will be the primary source of the
  6348. 3:43:26context.
  6349. 3:43:27Makes sense? So, let's say
  6350. 3:43:29I want to take some help. Okay? Let me
  6351. 3:43:31just click here. Jenny. So, this is the
  6352. 3:43:34new chat for me.
  6353. 3:43:36I can just ask anything. I can say let
  6354. 3:43:38say um I want to
  6355. 3:43:42fetch
  6356. 3:43:44only or let say I want to
  6357. 3:43:48This is my orders, right? Demo default
  6358. 3:43:49orders. Yeah.
  6359. 3:43:50I want to fetch
  6360. 3:43:53orders
  6361. 3:43:54only from store
  6362. 3:43:58ID equals
  6363. 3:43:5910. Let's say if I hit enter, just
  6364. 3:44:02natural language and that's it.
  6365. 3:44:04What it will do? It will first of all
  6366. 3:44:06look at your current
  6367. 3:44:07notebook, which is one query, right? It
  6368. 3:44:10has said that I will add a SQL cell to
  6369. 3:44:12fetch those orders and run it. And it
  6370. 3:44:14has edited my query notebook, and it is
  6371. 3:44:16simply saying connected to compute
  6372. 3:44:17because it is verifying that
  6373. 3:44:20is the query right or wrong that it has
  6374. 3:44:22written. Okay? And I would also see one
  6375. 3:44:25cell if it has created for me for now.
  6376. 3:44:26Yeah. So, this is the cell created by
  6377. 3:44:29Jenny. It is also running it for me just
  6378. 3:44:31to confirm it is fine or not. Once it is
  6379. 3:44:33there, then it will give me the final
  6380. 3:44:35answer. So, let's wait.
  6381. 3:44:37And I didn't write this query. Jenny has
  6382. 3:44:39written it for me. Okay? I just used the
  6383. 3:44:41natural language.
  6384. 3:44:42This is very similar to having Claude
  6385. 3:44:45code within your Databricks.
  6386. 3:44:48Even better than that because Claude
  6387. 3:44:50code doesn't have all of the internal
  6388. 3:44:51knowledge of Databricks this has. All of
  6389. 3:44:54the package information this has, right?
  6390. 3:44:56So if you are good with all of the
  6391. 3:44:58changes, you can accept it. If you are
  6392. 3:44:59not happy, you can simply say reject
  6393. 3:45:01all. Oh, yes.
  6394. 3:45:03It's totally in your control. It's not
  6395. 3:45:05like you ask something and now it is not
  6396. 3:45:06in your control. If I want to accept it,
  6397. 3:45:08simply say accept all and that's it.
  6398. 3:45:10That is done. If you want to ask
  6399. 3:45:11something more, you can just ask more.
  6400. 3:45:13If you want to attach something else,
  6401. 3:45:15you can click on plus button. You can
  6402. 3:45:16just add some files, connectors,
  6403. 3:45:18anything and even add some context.
  6404. 3:45:20If you want to initialize another
  6405. 3:45:22session, new chat, you can click here
  6406. 3:45:24and all of the previous things will be
  6407. 3:45:25gone because you do not need to keep
  6408. 3:45:27everything. And if you just want to see
  6409. 3:45:29the history, all of the chat history
  6410. 3:45:31that you have so far within your
  6411. 3:45:32workspace, everything will be here.
  6412. 3:45:34I will be having so many, so that is why
  6413. 3:45:36I'm not opening it.
  6414. 3:45:37Obviously you need to just delegate all
  6415. 3:45:39of the tasks to AI now.
  6416. 3:45:41Makes sense? Cool. But you need to have
  6417. 3:45:43the overlook. You need to have to you
  6418. 3:45:45you you need to monitor what it is
  6419. 3:45:47doing. You need to accept it, right? It
  6420. 3:45:49will be you who will be just accepting
  6421. 3:45:51the changes. Makes sense? Cool. That is
  6422. 3:45:53why knowledge is important, but yeah,
  6423. 3:45:55you also need to delegate the repetitive
  6424. 3:45:58boilerplate code to AI now. Cool. So
  6425. 3:46:01this is Jenny code. Like the very simple
  6426. 3:46:03use case of Jenny when you have the
  6427. 3:46:05inline code help, when you have the code
  6428. 3:46:07help within your session.
  6429. 3:46:09There is a dedicated space for Jenny as
  6430. 3:46:12well. Let me just show you.
  6431. 3:46:13If you click on this particular Jenny,
  6432. 3:46:15this is Jenny code, like that is also
  6433. 3:46:17Jenny code, but this is a dedicated
  6434. 3:46:19space for it. Let me just open it.
  6435. 3:46:22And this will just simply open this
  6436. 3:46:23particular window right here.
  6437. 3:46:25What is the benefit of it?
  6438. 3:46:26You can literally ask anything
  6439. 3:46:28within this particular Databricks
  6440. 3:46:30workspace. Oh, really? Yeah. Let's say
  6441. 3:46:32um I want you to
  6442. 3:46:35summarize
  6443. 3:46:37about
  6444. 3:46:39what I have
  6445. 3:46:42inside
  6446. 3:46:44my
  6447. 3:46:46demo catalog.
  6448. 3:46:49I just asked any random question related
  6449. 3:46:51to this particular workspace. I just
  6450. 3:46:53simply said that please check my catalog
  6451. 3:46:55and that's it.
  6452. 3:46:56It will automatically read the catalog.
  6453. 3:46:58It will read the schema. All of the
  6454. 3:46:59schemas are read automatically. It will
  6455. 3:47:02list the columns, everything. I am
  6456. 3:47:04expecting a brief summary of what I have
  6457. 3:47:07inside my catalog.
  6458. 3:47:09This is so useful. Let's say you are
  6459. 3:47:12deployed deployed. Like you are let's
  6460. 3:47:15say
  6461. 3:47:18on a project and you do not have any
  6462. 3:47:20knowledge about that project, then
  6463. 3:47:21obviously you need some context. So the
  6464. 3:47:23in in the traditional days you would be
  6465. 3:47:25just looking at each thing by yourself
  6466. 3:47:27and you would need to just
  6467. 3:47:29understand what is going on in this
  6468. 3:47:30catalog. But now you can literally ask
  6469. 3:47:33all of these things from the AI, from
  6470. 3:47:35the GenAI code. Okay, just explain me
  6471. 3:47:37this thing. Okay, okay, how this thing
  6472. 3:47:38is happening, everything.
  6473. 3:47:39See, it has just given me a very quick
  6474. 3:47:42summary
  6475. 3:47:43and I have bronze schema. I have four
  6476. 3:47:45row managed table. These are the table
  6477. 3:47:46names. Then I have silver. I have one
  6478. 3:47:48white table, one gold, one aggregated
  6479. 3:47:50table, one LDP schema, one default and
  6480. 3:47:52information schema, simple. In short,
  6481. 3:47:54raw detail in bronze, everything
  6482. 3:47:58everything. I can literally ask anything
  6483. 3:48:00from this GenAI code here. And if I just
  6484. 3:48:02want to expand it, I can click on this
  6485. 3:48:04particular button. It will simply open
  6486. 3:48:05this particular
  6487. 3:48:08dedicated space.
  6488. 3:48:10Simple.
  6489. 3:48:11Simple, simple, simple.
  6490. 3:48:13Very good. And these are like some of my
  6491. 3:48:15previous sessions and I just told you
  6492. 3:48:16that I just used GenAI code to join the
  6493. 3:48:18data frames. So this is also stored
  6494. 3:48:20here. I can even remove it. It's not
  6495. 3:48:21something like you can just not ignore
  6496. 3:48:24remove. And one thing which is so good,
  6497. 3:48:27schedules. This is actually inspired by
  6498. 3:48:30obviously the popular frameworks that we
  6499. 3:48:31have. You can even schedule any chat or
  6500. 3:48:34anything that you want to. Let's say you
  6501. 3:48:35just want to ingest something. Okay, and
  6502. 3:48:37you just asked it from GenAI code and
  6503. 3:48:39you do not want to schedule it every
  6504. 3:48:41morning. So you can even do that.
  6505. 3:48:44Makes sense? And if you just want to
  6506. 3:48:45delete anything, you can simply delete
  6507. 3:48:46it. Let's say delete this.
  6508. 3:48:48Delete this. You just delete it. Like
  6509. 3:48:50it's very easy.
  6510. 3:48:51So everything is here in front of you.
  6511. 3:48:53This is Jenny code.
  6512. 3:48:56Make sense?
  6513. 3:48:57Now Jenny code can be integrated within
  6514. 3:48:59the dashboards, within the you can say
  6515. 3:49:02anything because Jenny code can perform
  6516. 3:49:04the task for you.
  6517. 3:49:05So now that means you do not even need
  6518. 3:49:09to integrate Databricks to your local
  6519. 3:49:11system to work with cloud code because
  6520. 3:49:13you do not even need cloud code. You
  6521. 3:49:15have Jenny code
  6522. 3:49:17for you.
  6523. 3:49:18Databricks has provided a better cloud
  6524. 3:49:21code for you because Jenny code
  6525. 3:49:23understands the internal things of
  6526. 3:49:24Databricks. They have created it. They
  6527. 3:49:26have just trained it and obviously they
  6528. 3:49:28would have just trained it on some
  6529. 3:49:29things that you even or no one knows
  6530. 3:49:31because these are these would be the
  6531. 3:49:33internals of Databricks. So this is very
  6532. 3:49:34very good.
  6533. 3:49:35The Jenny code actually understands your
  6534. 3:49:37workspace, how to change the things, how
  6535. 3:49:39to fix the things, everything.
  6536. 3:49:42Of and
  6537. 3:49:43the best thing
  6538. 3:49:45if you just talk about the tokens cost,
  6539. 3:49:47everything, everything is optimized
  6540. 3:49:50here.
  6541. 3:49:51Make sense? Because obviously when you
  6542. 3:49:53are just using cloud code, you do not
  6543. 3:49:55even need to
  6544. 3:49:57worry about
  6545. 3:49:58how you will just how how you will be
  6546. 3:49:59just telling everything to cloud code
  6547. 3:50:01because when you are just using cloud
  6548. 3:50:02code,
  6549. 3:50:03you need to first of all attach the
  6550. 3:50:04MCPs, you first of all need to attach
  6551. 3:50:06the skills, you first of all need to
  6552. 3:50:08connect your Databricks and then just
  6553. 3:50:09share some credentials which can be
  6554. 3:50:11risky. But here everything is going to
  6555. 3:50:14Databricks.
  6556. 3:50:15Simple. So it is secure as well as
  6557. 3:50:17compared to other things. Obviously you
  6558. 3:50:19can just use anything, but I'm just
  6559. 3:50:20telling you the comparison.
  6560. 3:50:23This is all about Jenny code and I hope
  6561. 3:50:25that you that you would love and you
  6562. 3:50:26would just use Jenny code more and more.
  6563. 3:50:28Okay? And let's see the next topic. So
  6564. 3:50:31now let's talk about the Databricks
  6565. 3:50:33visual prep which is one of the most
  6566. 3:50:35recent additions within the Databricks
  6567. 3:50:38workspace that we have bought.
  6568. 3:50:40Databricks visual prep is like no code
  6569. 3:50:45ETL or basically no code
  6570. 3:50:48pipelines.
  6571. 3:50:49No code pipelines where you do even need
  6572. 3:50:51to write any code.
  6573. 3:50:54If you have used something called as
  6574. 3:50:56Azure data factory,
  6575. 3:50:57if you have used something called as AWS
  6576. 3:50:59glue, it is very similar to that but for
  6577. 3:51:02data bricks.
  6578. 3:51:04Because there are so many people who do
  6579. 3:51:05not like to write code and let me just
  6580. 3:51:07tell you first of all,
  6581. 3:51:09if you are building the complex, the
  6582. 3:51:11real world end to end data engineering
  6583. 3:51:13pipelines, you still use all of the
  6584. 3:51:15stuff that we have discussed.
  6585. 3:51:17This area is for those you can say mini
  6586. 3:51:20mini pipelines or you can say some add
  6587. 3:51:22hoc pipelines that you can just build or
  6588. 3:51:25some people can build who do not
  6589. 3:51:26understand the code very well.
  6590. 3:51:28So understand the difference.
  6591. 3:51:30Data bricks visual prep is not the
  6592. 3:51:31replacement for what we have just
  6593. 3:51:33discussed so far. No. This is just for
  6594. 3:51:35like mini mini add hoc quick pipelines.
  6595. 3:51:37Okay.
  6596. 3:51:38This is for that particular thing but it
  6597. 3:51:39has a great potential. It has a great
  6598. 3:51:41potential but I'm just telling you the
  6599. 3:51:43difference. Okay. If you have like very
  6600. 3:51:45very complex pipelines, you want a very
  6601. 3:51:47you can say dedicated support for
  6602. 3:51:50customization everything, then obviously
  6603. 3:51:52you can just go with code but if you do
  6604. 3:51:53not want to write the code from scratch
  6605. 3:51:55everything, then you can just go with no
  6606. 3:51:56code pipelines. And yes, the good thing
  6607. 3:51:58is it is even available within the free
  6608. 3:52:00edition. So let me show you. So if you
  6609. 3:52:02just go here and you will just see under
  6610. 3:52:04data engineering, it's called visual
  6611. 3:52:06data prep. Click here.
  6612. 3:52:08And here you can just click on plus new
  6613. 3:52:10because it is also called as lake flow
  6614. 3:52:12designer. This is another name if you
  6615. 3:52:14want to know. Let me just write it here.
  6616. 3:52:17Lake flow designer.
  6617. 3:52:23Cool. And it is also called a data
  6618. 3:52:24bricks visual prep.
  6619. 3:52:26Cool.
  6620. 3:52:27So if you just want to create plus new
  6621. 3:52:31and it will just open the canvas. This
  6622. 3:52:33canvas will be a little bit similar to
  6623. 3:52:37AWS glue if you have used. Okay. And if
  6624. 3:52:39you have not used, then do not worry.
  6625. 3:52:42This is the you can say
  6626. 3:52:44canvas. So what we do here, we have
  6627. 3:52:46multiple options. If you want to let say
  6628. 3:52:49use any source,
  6629. 3:52:50you can just pick source, import data
  6630. 3:52:52into designer. It will
  6631. 3:52:54automatically import it.
  6632. 3:52:55But sometimes you have the
  6633. 3:52:58local files.
  6634. 3:52:59You want to manually enter the data.
  6635. 3:53:01You can click here, enter data, and you
  6636. 3:53:02can just manually feed it, and you can
  6637. 3:53:04even drop the local files from here.
  6638. 3:53:06And you have all of the connectors here
  6639. 3:53:08as well that we just saw in the lake
  6640. 3:53:09flow connect. So you have a very good
  6641. 3:53:11list of um you can say connectors. Let
  6642. 3:53:13say I want to pick the source. And here
  6643. 3:53:15I want to pick let say orders data
  6644. 3:53:17because I already have this table. So
  6645. 3:53:19this will be picked automatically and
  6646. 3:53:20this will connect this thing here and
  6647. 3:53:22this is the canvas. I can do a lot of
  6648. 3:53:24stuff.
  6649. 3:53:25So this is my orders table. Let's wait
  6650. 3:53:26for it to load because it will run that
  6651. 3:53:28particular
  6652. 3:53:29query to show you the preview and
  6653. 3:53:31everything. Cool. So this is the preview
  6654. 3:53:33I can see.
  6655. 3:53:34Let me have some space and this is my
  6656. 3:53:37output.
  6657. 3:53:38Now let's say I want to filter some
  6658. 3:53:41records.
  6659. 3:53:42I can do that, right?
  6660. 3:53:44So what I can do? I I will simply click
  6661. 3:53:46here in the filter and I will put what
  6662. 3:53:50condition I want.
  6663. 3:53:51Let's say
  6664. 3:53:52first condition, first condition is
  6665. 3:53:53let's say store ID
  6666. 3:53:55is equal to let's say 10. I can even
  6667. 3:53:58click on drop down just to see what
  6668. 3:53:59values I have. Let's say one. Okay. You
  6669. 3:54:01will say why are you just picking again
  6670. 3:54:02again 10?
  6671. 3:54:04So this is one way. If you want to put
  6672. 3:54:06some customization using code, you can
  6673. 3:54:08click here as well and here you can just
  6674. 3:54:10write the expression. Either way it will
  6675. 3:54:11work.
  6676. 3:54:12Click on apply
  6677. 3:54:14and it will apply this transformation
  6678. 3:54:16without writing any code just by
  6679. 3:54:18selecting the things and I can just see
  6680. 3:54:20it here. See?
  6681. 3:54:22I have this particular thing. So let me
  6682. 3:54:23just click here, just here and that's
  6683. 3:54:26it. So this is my preview.
  6684. 3:54:29Now let's look at the preview. I have
  6685. 3:54:31this particular preview and I only have
  6686. 3:54:3336 rows
  6687. 3:54:34in the output. Why?
  6688. 3:54:36Because
  6689. 3:54:37out of 1,000 rows, out of 1,000 rows and
  6690. 3:54:40obviously these are like just 4,000 rows
  6691. 3:54:42out of 10,000 rows,
  6692. 3:54:44I just have 36 records for store equals
  6693. 3:54:47to one.
  6694. 3:54:48Did I write any kind of code? No.
  6695. 3:54:50Everything is automatically done.
  6696. 3:54:52Wow.
  6697. 3:54:53This way you can perform all of the
  6698. 3:54:55transformations select, limit, sort, you
  6699. 3:54:58can even combine, join, you can even
  6700. 3:55:02perform
  6701. 3:55:03AI functions as well, like all of the
  6702. 3:55:05things like collect not collect like
  6703. 3:55:07parse information everything, all of the
  6704. 3:55:09AI functions that Databricks has,
  6705. 3:55:11data parsing, everything.
  6706. 3:55:14Then you can even perform some
  6707. 3:55:17notification as well.
  6708. 3:55:19This is amazing. If you just want to
  6709. 3:55:21send any notification to yourself, to
  6710. 3:55:23your let's say email, to your Slack,
  6711. 3:55:25Messenger, anything, so you can just do
  6712. 3:55:27that as well.
  6713. 3:55:28And the most important thing,
  6714. 3:55:32if let's say
  6715. 3:55:34obviously you can just perform drag and
  6716. 3:55:35drop. It is amazing, it is very
  6717. 3:55:37convenient. If let's say
  6718. 3:55:39you do not even need to perform drag and
  6719. 3:55:41drop, then what you can do? You can ask
  6720. 3:55:43this particular thing. This is nothing
  6721. 3:55:45but a kind of Databricks Gen code. You
  6722. 3:55:48can simply say
  6723. 3:55:50I want to change my filter
  6724. 3:55:53and I want
  6725. 3:55:55to filter
  6726. 3:55:56store ID
  6727. 3:55:57equals
  6728. 3:55:5910.
  6729. 3:56:00Now this will look at my
  6730. 3:56:04workflow and it will
  6731. 3:56:05enable auto proof. Yes, enable.
  6732. 3:56:08It will automatically change everything.
  6733. 3:56:09You can even ask it to build more and
  6734. 3:56:11more transformation, more and more
  6735. 3:56:12steps, or you can even ask it to change
  6736. 3:56:14the existing step or anything.
  6737. 3:56:17And let's say allow because obviously it
  6738. 3:56:19would need to
  6739. 3:56:21just ask you before changing it. So it
  6740. 3:56:23is just equal it is changing this
  6741. 3:56:24particular thing.
  6742. 3:56:25And we will just see the result very
  6743. 3:56:27very soon once it is done.
  6744. 3:56:29So I can see that it is changed. Now I
  6745. 3:56:30can see all of the store IDs are 10.
  6746. 3:56:33Wow. [snorts] Now you do not even need
  6747. 3:56:34to perform drag and drop. You can rely
  6748. 3:56:36on this particular thing. But remember
  6749. 3:56:39this is just for the you can say
  6750. 3:56:42mini mini pipelines, mini mini ad hoc
  6751. 3:56:44pipelines that you can just build. And
  6752. 3:56:46anyone can build, but those who know how
  6753. 3:56:48to build the things, not anyone, like
  6754. 3:56:50who know how to build.
  6755. 3:56:52And this is very important for data
  6756. 3:56:53engineers as well. Why? Because
  6757. 3:56:54sometimes you just want to build a quick
  6758. 3:56:56POC pipeline just to provide it to
  6759. 3:56:58stakeholders that's it.
  6760. 3:57:00So it is a very good thing for data
  6761. 3:57:02engineers as well, not just like for non
  6762. 3:57:03data engineers or non technical people.
  6763. 3:57:05This is very important for data
  6764. 3:57:06engineers as well.
  6765. 3:57:07Makes sense? So this component is like
  6766. 3:57:09very recently added in Databricks very
  6767. 3:57:11very recently and I hope it makes sense.
  6768. 3:57:14Very good. Let's look at the last topic
  6769. 3:57:16for today. It's called Databricks
  6770. 3:57:19Lakehouse which is actually one of the
  6771. 3:57:23hottest topics right now. Why?
  6772. 3:57:25Because this has changed the dynamics
  6773. 3:57:28how people use databases nowadays. So
  6774. 3:57:31what is this Lakehouse?
  6775. 3:57:32First of all, let me just tell you
  6776. 3:57:33Lakehouse is nothing but
  6777. 3:57:35your PostgreSQL database. Really? Yeah.
  6778. 3:57:39PostgreSQL database but managed by
  6779. 3:57:42Databricks.
  6780. 3:57:43Really? Just managed? Not really much
  6781. 3:57:45more than that.
  6782. 3:57:46So what actually happened is
  6783. 3:57:48Databricks Lakehouse is actually a very
  6784. 3:57:51interesting concept and I created like
  6785. 3:57:52dedicated video on Databricks Lakehouse.
  6786. 3:57:55You can just search Databricks Lakehouse
  6787. 3:57:56and you will just find the video for
  6788. 3:57:57that. But I will still tell you. Let me
  6789. 3:57:59just show you first of all.
  6790. 3:58:01Databricks
  6791. 3:58:03Lakehouse
  6792. 3:58:07Yeah, this is the video Databricks
  6793. 3:58:09Lakehouse. I just created I think one
  6794. 3:58:10hour tutorial on it because it is like
  6795. 3:58:12very I created like I think three months
  6796. 3:58:14back when it was like newly newly
  6797. 3:58:17launched. So like not launched, it
  6798. 3:58:20gained popularity during that time.
  6799. 3:58:21Obviously it was just like like like
  6800. 3:58:23launched way back but yeah.
  6801. 3:58:25So what is this thing? So Databricks is
  6802. 3:58:28using PostgreSQL database under the hood
  6803. 3:58:29for sure, but that is not the only
  6804. 3:58:31thing.
  6805. 3:58:33They have used something called as you
  6806. 3:58:36can say decoupled architecture.
  6807. 3:58:38What does it mean? So let's say
  6808. 3:58:40in databases
  6809. 3:58:42we get two major things.
  6810. 3:58:44Two major things. I can also show you
  6811. 3:58:46the official documentation. Not official
  6812. 3:58:47documentation. They are just written
  6813. 3:58:48like a very good
  6814. 3:58:50blog on this. Oh, let's find it. Let's
  6815. 3:58:52try to find it. If I just find it
  6816. 3:58:54Databricks Lakehouse blog.
  6817. 3:58:58I think it was created by um
  6818. 3:59:03their senior member and I really like
  6819. 3:59:04that blog. Let me just find it.
  6820. 3:59:06So I just found this particular blog
  6821. 3:59:08finally because there are multiple
  6822. 3:59:10blogs, but I really like this blog by
  6823. 3:59:12Reynoldsen and this blog actually
  6824. 3:59:15explained the things very very well. So
  6825. 3:59:16basically
  6826. 3:59:18the traditional database has two major
  6827. 3:59:20things first of all wall and data bytes.
  6828. 3:59:23Wall write ahead logs and data bytes.
  6829. 3:59:26Wall is just for the metadata. Data
  6830. 3:59:28bytes are the real bytes that we just
  6831. 3:59:29write and that is why it is also called
  6832. 3:59:31as data and your logs.
  6833. 3:59:35Now this wall and data files were
  6834. 3:59:40you can say
  6835. 3:59:41hardly connected with this particular
  6836. 3:59:43database engine
  6837. 3:59:45in the traditional database.
  6838. 3:59:47But now in this lake base this is
  6839. 3:59:50decoupled. That means this engine will
  6840. 3:59:53be in a separate machine.
  6841. 3:59:55This wall
  6842. 3:59:56which they now call it as safe keeper is
  6843. 3:59:59created in a separate machine. Page
  6844. 4:00:02server
  6845. 4:00:03which is a real data
  6846. 4:00:05is also created in a separate machine.
  6847. 4:00:08Now this is decoupled.
  6848. 4:00:10Now this is not the only thing because
  6849. 4:00:12obviously decoupled architectures are
  6850. 4:00:14there, but the major thing that they
  6851. 4:00:15have done is this one.
  6852. 4:00:18Object storage.
  6853. 4:00:19They have internally or you can say they
  6854. 4:00:23are internally converting your page
  6855. 4:00:25server basically real pages into the
  6856. 4:00:28object storage in the form of parquet
  6857. 4:00:31files so that you can use let say Spark
  6858. 4:00:35or any engine to directly access the
  6859. 4:00:37data.
  6860. 4:00:39And this way
  6861. 4:00:41your data lives in the cloud object
  6862. 4:00:43storage.
  6863. 4:00:45You do not even need to create multiple
  6864. 4:00:47you can say replicas of the data.
  6865. 4:00:49You do not even need to move the data.
  6866. 4:00:51You just need to change the engine. If
  6867. 4:00:53you want to use the database database
  6868. 4:00:55engine you just use Postgres. If you
  6869. 4:00:57just want to use Spark you can just use
  6870. 4:00:58Spark. Simple.
  6871. 4:01:00There'll be just one copy of the data.
  6872. 4:01:02This concept is very very very very like
  6873. 4:01:06you can say important and it is changing
  6874. 4:01:08the dynamics of the databases nowadays.
  6875. 4:01:10Especially for data engineering,
  6876. 4:01:12especially for data engineering because
  6877. 4:01:14now what you can do, you can literally
  6878. 4:01:16access these databases via the Unity
  6879. 4:01:18catalog. You can even access the you can
  6880. 4:01:21say
  6881. 4:01:23you can even convert these tables or you
  6882. 4:01:25can say also sync these tables to the
  6883. 4:01:27Unity catalog tables or basically your
  6884. 4:01:30traditional Delta tables. You can sync
  6885. 4:01:32these things.
  6886. 4:01:33Really yeah. You can even sync these
  6887. 4:01:35things. There are like built-in
  6888. 4:01:36pipelines that you can just use.
  6889. 4:01:39Oh yes.
  6890. 4:01:41Everything is there. Everything is
  6891. 4:01:43there.
  6892. 4:01:46This is actually very good.
  6893. 4:01:47And you can also just read this article
  6894. 4:01:49if you want to, but the major thing that
  6895. 4:01:51is discussed in this particular entire
  6896. 4:01:53entire article is the one that I just
  6897. 4:01:55told you like the decoupled architecture
  6898. 4:01:56and that
  6899. 4:01:57you can say
  6900. 4:02:00the this particular thing object
  6901. 4:02:01storage. And this gave rise to a new
  6902. 4:02:03concept
  6903. 4:02:05called
  6904. 4:02:06Delta
  6905. 4:02:07Lake Transactional Analytical Processing
  6906. 4:02:09because before that
  6907. 4:02:11we were using OLTP
  6908. 4:02:13or OLAP.
  6909. 4:02:16And yes, there was like one more concept
  6910. 4:02:17that came in the middle which was
  6911. 4:02:20HTAP, Hybrid Transactional Analytical
  6912. 4:02:23Processing.
  6913. 4:02:24But yeah, it was like not very very
  6914. 4:02:25popular
  6915. 4:02:26because in there you would need to
  6916. 4:02:27create the replica still, but here you
  6917. 4:02:29do not need to create the replica.
  6918. 4:02:32This is the concept of Data Bricks Lake
  6919. 4:02:34Base and yes, in the free edition you
  6920. 4:02:36get database Lake Base as well. Wow.
  6921. 4:02:38They have literally invested so much
  6922. 4:02:41to provide these features for free. And
  6923. 4:02:44to be honest, that's how people learn,
  6924. 4:02:45that's how people use more. So it is
  6925. 4:02:47like directly related to their sales as
  6926. 4:02:49well, but that is fine. So if you just
  6927. 4:02:50want to create this thing, you can click
  6928. 4:02:52on Compute and here you will see Lake
  6929. 4:02:54Base and then you can just click on Lake
  6930. 4:02:56Base.
  6931. 4:02:56Postgre, they have created dedicated
  6932. 4:02:58space as well. Now it like it was there
  6933. 4:03:00indicated here before, but now they have
  6934. 4:03:03just created a dedicated space. It's
  6935. 4:03:04called Lake Base Postgre.
  6936. 4:03:06And there you can just go, explore, and
  6937. 4:03:08just create. I already have one this
  6938. 4:03:10particular thing. Lake base demo. I just
  6939. 4:03:12created this thing three months back.
  6940. 4:03:14And if you just want to learn Databricks
  6941. 4:03:16Lake base alone in detail, you can just
  6942. 4:03:18watch that video that I just showed. And
  6943. 4:03:20that's how you can just
  6944. 4:03:22managed Databricks Lake base, database,
  6945. 4:03:25branches, everything.
  6946. 4:03:27Everything.
  6947. 4:03:29Make sense? Make sense? Make sense?
  6948. 4:03:31This is all about our Databricks
  6949. 4:03:34concepts that we have just covered in
  6950. 4:03:37this particular video. And I think we
  6951. 4:03:39have covered 20 plus concepts. I think
  6952. 4:03:4020 21 concepts. And I think that is
  6953. 4:03:42good.
  6954. 4:03:43And we learned a lot of a lot a lot of
  6955. 4:03:46things. And I hope that you also learned
  6956. 4:03:48and understood so many things. And I
  6957. 4:03:49hope now you can just become a better
  6958. 4:03:51Databricks data engineer, Databricks
  6959. 4:03:53developer, or any developer who wants to
  6960. 4:03:55learn Databricks, right?
  6961. 4:03:57So that's all for today's video. If you
  6962. 4:03:59loved the video, and I know you loved
  6963. 4:04:01the video, simply hit the subscribe
  6964. 4:04:02button and share your thoughts in the
  6965. 4:04:04comment section. And yes, share this
  6966. 4:04:05video with your friends so that they can
  6967. 4:04:06also learn and grow. And happy learning.

About this transcript

This page contains the full transcript of Databricks Was HARD Until I Learned These 21 CONCEPTS (Databricks Ansh Lamba) by Ansh Lamba, generated from the public captions YouTube serves with the video. The transcript has 42,215 words across 6,967 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 choose a caption track available on the video.

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, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.