YouTube2Text

Delta Lake Interview Questions — Transcript

by DataBeli · 3,575 words · 498 segments · language en · Watch on YouTube

Full transcript

  1. 0:00Hi, in this video I'm going to cover the
  2. 0:03real interview questions about Delta
  3. 0:05Lake that I ask when I take interviews
  4. 0:08of data engineers and I have included
  5. 0:11the theoretical questions that confirms
  6. 0:13the in-depth knowledge of Delta Lake
  7. 0:15concepts. Also, I have included many
  8. 0:18practical questions that confirms that
  9. 0:20the person has actually worked on Delta
  10. 0:23Lake. And talking about myself, I'm
  11. 0:25Narendra Kumar. I have 12 years of
  12. 0:28experience in IT and data engineering. I
  13. 0:30have spent eight years now. I have
  14. 0:32completed these certifications also and
  15. 0:35taking interviews for data engineers. It
  16. 0:37is part of my daily job. So let's get
  17. 0:40started.
  18. 0:42So the first question that I ask it is
  19. 0:44uh let's say if we have created a data
  20. 0:46table or if we have stored the delta
  21. 0:49data in some particular location. If we
  22. 0:52go to that location, so what kind of
  23. 0:54files and folders do we see? So the
  24. 0:57answer to that is let's say if this is a
  25. 0:59sample table we have created. So there
  26. 1:02we will see some parquet files and a
  27. 1:05folder with the name delta log. This
  28. 1:08park file they really contain the actual
  29. 1:12data of the table and delta log these
  30. 1:15contain the transaction history and the
  31. 1:18transaction history it is contained in
  32. 1:19terms of these JSON log file and CRC
  33. 1:23these are the check sum files which
  34. 1:25ensure the consistency or completeness
  35. 1:28of these JSON files and after we keep
  36. 1:32writing multiple operation on delta log.
  37. 1:35So after some time this JSON will be
  38. 1:38combined and here also a park file will
  39. 1:41be created. So that is how the kind of
  40. 1:44files and folders we see. And in case
  41. 1:47our table if it is partitioned then what
  42. 1:50we see is we will see the data log in
  43. 1:53the similar way but instead of directly
  44. 1:55those uh park file we will see that
  45. 1:58partitioned folders. So here country is
  46. 2:01the partition column. These are the
  47. 2:03values and then again if there is
  48. 2:05further two-level partitioning then
  49. 2:08category is the partition column and
  50. 2:10clothing it is the actual partition or
  51. 2:12the value of that clothing category
  52. 2:14column and then we will see the actual
  53. 2:17park files. So that is how the folder
  54. 2:20structure is there for delta league and
  55. 2:23if the candidate is able to answer this
  56. 2:25correctly so that confirms that the
  57. 2:28candidate has actually gone to the
  58. 2:29location they know what kind of files
  59. 2:31and all are there.
  60. 2:34Now moving on to the next question there
  61. 2:36we ask like within the data log what
  62. 2:40kind of information is stored. So if I
  63. 2:43open any of the JSON file. So here we
  64. 2:46can see or what we shall tell is like
  65. 2:48each of the JSON it contains detailed
  66. 2:52information like what operation was
  67. 2:54performed. In this case it is the right
  68. 2:56operation and while performing the
  69. 2:58operation what other parameters were
  70. 3:00used which notebook was used which
  71. 3:03cluster was used everything in every
  72. 3:06information is stored and also how many
  73. 3:08files were impacted how many rows were
  74. 3:11written what was the size of the data
  75. 3:14that was written and along with that for
  76. 3:18each and every file. So in this case
  77. 3:20this was a new file that was written. So
  78. 3:23it is add otherwise if something is
  79. 3:25deleted it will show as a remove and for
  80. 3:28each file it contain like partition
  81. 3:31values, size and also it contains
  82. 3:34statistics. This states part it is very
  83. 3:37important because for each and every
  84. 3:40column it contains what is minimum value
  85. 3:43and what is maximum value. So those
  86. 3:46detail it contain for each and every
  87. 3:48column and this information it is very
  88. 3:51helpful when we retrieve the data.
  89. 3:54Now coming to the next question which is
  90. 3:57again a another practical question that
  91. 3:59I ask. Let's say if I'm fetching some
  92. 4:02data from a table and I apply a filter
  93. 4:05in in this case let's say if I mention
  94. 4:08select star from table where ID is
  95. 4:10greater than five then how does it
  96. 4:14utilize that filter internally to fetch
  97. 4:17the data efficiently.
  98. 4:19So the answer to that is uh because in
  99. 4:22data log the data is stored in terms of
  100. 4:25actual park file but it will not read
  101. 4:28all the file. What it will do is first
  102. 4:30it will come to these delta logs and
  103. 4:33from these logs it has this statistics
  104. 4:36for each and every file. For example in
  105. 4:38this case it knows that the uh in this
  106. 4:41particular file the value of ID is
  107. 4:44minimum is one maximum is three. And if
  108. 4:47I'm putting the condition that id is
  109. 4:49greater than five. So it knows from here
  110. 4:52that
  111. 4:53id greater than five values will not be
  112. 4:56there in this file. So it will not even
  113. 4:58check out this particular park file. So
  114. 5:01that is how based on this data logs it
  115. 5:04is able to identify which all files it
  116. 5:08shall go through to pick up that
  117. 5:09information. So then once it knows which
  118. 5:13files has the required columns based on
  119. 5:16that filter then it will go to those
  120. 5:18park file and within park also it will
  121. 5:20efficiently pick up only the required
  122. 5:23columns. So that is how internally
  123. 5:25things work in park. So that is how the
  124. 5:28filter works very efficiently in case of
  125. 5:31data tables.
  126. 5:33Now the next comes a theoretical
  127. 5:35question which is a generic question
  128. 5:37like tell me some of the features of
  129. 5:39Delta Lake. Then the features are that
  130. 5:42Delta Lake tables they support acid
  131. 5:45transactions. They support schema
  132. 5:47enforcement and evolution. We can even
  133. 5:50like automatically handle new column or
  134. 5:52deleted columns. It supports time
  135. 5:55travel. We can go back in time and fetch
  136. 5:57any previous version of the table. And
  137. 6:00it has very optimized metadata
  138. 6:02management which we just saw. And it
  139. 6:05supports unified batch and stream
  140. 6:08processing. Both kind of operations we
  141. 6:10can do on a single table. And it makes
  142. 6:13upsert, delete and other complex
  143. 6:15operations more efficient and uh those
  144. 6:19there we get to save lot of cost. So
  145. 6:22these are some of the features of delta
  146. 6:24league. Now the next follow-up question
  147. 6:27comes about these features. So let's say
  148. 6:30I ask like uh how does delta link it
  149. 6:33performs asset transaction or these
  150. 6:35absurd delete operation efficiently. So
  151. 6:38the answer how we can explain explain is
  152. 6:41let's say we have a table we want to
  153. 6:44delete some record and insert new data.
  154. 6:47So for new inserted data obviously it
  155. 6:49will create new file and for the data
  156. 6:51that we want to delete it will not
  157. 6:54rewrite those all those files or it will
  158. 6:57not delete those files immediately but
  159. 6:59it will create new file and in its log
  160. 7:03it will mention that the previous file
  161. 7:05shall be considered as removed and new
  162. 7:08file shall be considered as added. So
  163. 7:10without rewriting the entire data it
  164. 7:13will create new file and in the logs it
  165. 7:16maintain which file it shall refer and
  166. 7:18which file it shall not refer and using
  167. 7:21that log itself it can uh perform time
  168. 7:24travel that we can go back in time and
  169. 7:27then we can check previous version of
  170. 7:29the data. Now the next question comes
  171. 7:33about time travel like how exactly we
  172. 7:36can do time travel and what are the
  173. 7:38different options we can use while doing
  174. 7:41time travel
  175. 7:43and the answer to that is that we can
  176. 7:45use describe history to check what all
  177. 7:48versions are there for the given table
  178. 7:51and to perform the actual time travel
  179. 7:54what we can do is we get two option
  180. 7:56either using this version number column
  181. 7:59we can use like version is of and
  182. 8:03whatever version we specify from that
  183. 8:05previous version it will fetch the data
  184. 8:07in this case it is a select query second
  185. 8:10option we get let's say if we don't know
  186. 8:12the version and simply we want like I
  187. 8:15want the
  188. 8:16table where the uh date was like 18th of
  189. 8:21November so that till that time whatever
  190. 8:25data was there in the table that data I
  191. 8:28want in those cases we use time stamp is
  192. 8:31of. So whatever time stamp we specify
  193. 8:33that time whatever was the data in the
  194. 8:36table that will be returned. And here we
  195. 8:39can check out the data using the select
  196. 8:41query. And if we want to make this
  197. 8:44version as the latest version then
  198. 8:46simply we can do restore table operation
  199. 8:49and then the data will be restored from
  200. 8:51the time travel. So here is a s simple
  201. 8:55command. So this way we can restore the
  202. 8:57table.
  203. 8:59Now the next question comes like what is
  204. 9:02upsert operation and what is insert only
  205. 9:05merge operation. So what is upsert is
  206. 9:08like when we doing the merge operation
  207. 9:12when we compare based on some column if
  208. 9:15it is matching then we update the data
  209. 9:17if it is not matching it means it is new
  210. 9:20data then we insert the data. This is
  211. 9:23called as upsert operation. And if we
  212. 9:26simply remove this when matched let's
  213. 9:28say we don't want to update anything or
  214. 9:30we are expecting that the data that is
  215. 9:33incoming it will never be updated it
  216. 9:35will always be new only. So then we what
  217. 9:38we do is we do only when note match then
  218. 9:41we insert the data. If same data is
  219. 9:43coming in we are not expecting it to be
  220. 9:46updated. So we will not update it. So
  221. 9:49that is called as insert only merge.
  222. 9:53Now the next question comes about
  223. 9:55optimize and zorder. So what is
  224. 9:58optimize? It compacts small files and
  225. 10:01improve query performance. So let's say
  226. 10:04wherever the data is stored for our
  227. 10:06table, if the files are less than 1 GB.
  228. 10:09So whenever we run the optimize
  229. 10:11operation, it will combine the small
  230. 10:13files and it will create the files
  231. 10:15around size of 1 GB. So the size
  232. 10:18question can also be there like what is
  233. 10:20the size that it tries to create those
  234. 10:22table it is 1 GB and what is Z order. So
  235. 10:27when it is combining those small file or
  236. 10:30even if those are big file what it
  237. 10:33actually does it it colllocate related
  238. 10:35data. So in zorder command we provide a
  239. 10:39column name as well. So for example this
  240. 10:43is how we run a simple optimize command
  241. 10:46which combine the small uh files and it
  242. 10:50does it don't care about collocating any
  243. 10:52data but along with optimize if you
  244. 10:56specify any column let's say ID L is Z
  245. 11:00order then it what it will do is it will
  246. 11:04put the similar ids into same file for
  247. 11:08example let's say uh 0 to 100 ids it
  248. 11:11will put into one file then 100 to 200
  249. 11:13into another file. That's how it will
  250. 11:16put it. Some people they are confused.
  251. 11:18They think like think that for each ID
  252. 11:21it will create separate separate file.
  253. 11:23That is not the case. Uh it will put
  254. 11:26similar ids into same file and in zorder
  255. 11:30we can even specify more than one column
  256. 11:33as well. So in that case those based on
  257. 11:36those two column it will put similar
  258. 11:39data in in same file that is how it
  259. 11:42works.
  260. 11:44Now the next questions comes like as the
  261. 11:47data lake supports time travel so until
  262. 11:51when it keeps the history. So most of
  263. 11:54the people think that uh by default like
  264. 11:57it is 7 days. So after 7 days it is
  265. 11:59cleared out automatically.
  266. 12:02But in reality the data in our delta
  267. 12:05lake table it is never cleared out
  268. 12:07automatically unless we run any vacuum
  269. 12:10command. So if we don't specify any or
  270. 12:13specify or run any vacuum command then
  271. 12:16data is never cleared. But in recent uh
  272. 12:20datab bricks release what they have done
  273. 12:22is they are doing maintenance
  274. 12:24automatically. So in datab bricks
  275. 12:27environment specifically they run the
  276. 12:29vacuum command automatically after some
  277. 12:32certain duration then the data is
  278. 12:34cleared out but it is only when the
  279. 12:37command is run otherwise the data is not
  280. 12:39cleared out and to actually clear out
  281. 12:43the data we have this vacuum command and
  282. 12:46how much data it will clear uh so that
  283. 12:49that is controlled how that is also
  284. 12:52another question so that is are
  285. 12:55controlled using these two properties.
  286. 12:58Let's say log retention duration, how
  287. 13:01much of delta logs we want to retain and
  288. 13:05deleted file retention duration. So the
  289. 13:08actual data how much duration we want to
  290. 13:10retain. So in this case the park file
  291. 13:13the actual data it will retain let's say
  292. 13:15last 7 days and uh the other log file
  293. 13:20the delta logs that it stored those it
  294. 13:23will retain for 30 days. So for example
  295. 13:27if I run on a run a vacuum command on a
  296. 13:30table with these configurations. So what
  297. 13:33it will do is it doesn't mean that the
  298. 13:35data loaded earlier than 7 days will be
  299. 13:38deleted. What it means is in the table
  300. 13:42after writing the data if we do any
  301. 13:45delete operation or if we do any upsert
  302. 13:48operation or merge operation that time
  303. 13:50if some file are internally considered
  304. 13:53as removed in data log only those file
  305. 13:57it will delete. So that is again like
  306. 14:00some people I find they are confused
  307. 14:01they think they think like any data
  308. 14:04older than 7 days will be deleted that
  309. 14:06is not the case. If the files are
  310. 14:08required for the latest version of the
  311. 14:10table whether those are loaded years ago
  312. 14:14those will not be deleted when we run
  313. 14:16vacuum but if the file is considered
  314. 14:19deleted in latest version of data log
  315. 14:22then only it will be deleted. So that is
  316. 14:25where like uh this vacuum comes into
  317. 14:28picture and how we run vacuum it is
  318. 14:31simple like vacuum and then the table
  319. 14:33name and with vacuum there comes another
  320. 14:36option like we can do dry run also. So
  321. 14:40let's say this is also a question like
  322. 14:42how can we check what files will vacuum
  323. 14:45delete without actually running vacuum
  324. 14:47or deleting them. Then we specify this
  325. 14:50dry run operation. It will what it will
  326. 14:53do is it will actually not delete
  327. 14:55anything but it will simply put the list
  328. 14:57of files that it is it is going to
  329. 15:00delete if we run actual vacuum. So it is
  330. 15:03kind of a dry run with just provide the
  331. 15:05list.
  332. 15:07Now the next questions come about
  333. 15:09cloning. So what are the two types of
  334. 15:11cloning that we can use with Delta Lake?
  335. 15:14So the answer to that it is a shallow
  336. 15:18clone and deep clone. And the question
  337. 15:20again it is like what is difference
  338. 15:22between these two. So what cello clone
  339. 15:25does it it creates a quick copy that
  340. 15:28does not copy the actual data file. Uh
  341. 15:31it only created its own metadata but
  342. 15:34underlying data files it will refer to
  343. 15:37the original table wherein deep clone
  344. 15:39what it does it it create a totally
  345. 15:42separate metadata and it also copies
  346. 15:44over all the data files as well. So that
  347. 15:47it that it was what deep clone does.
  348. 15:51The next question about the same comes
  349. 15:53like when shall we use each of these. So
  350. 15:57if we want to do some quick testing or
  351. 16:00like try out some basic operation for a
  352. 16:03quick analysis then we shall create a
  353. 16:05shallow clone. But if we really want to
  354. 16:08create a copy of the table then we shall
  355. 16:10use deep clone. And uh also like we can
  356. 16:16I also ask like in case of shallow clone
  357. 16:18and deep clone if after cloning I delete
  358. 16:21the actual table then what happens? So
  359. 16:24then in case of shallow clone it will
  360. 16:26fail because the underlying data would
  361. 16:28have been deleted and deep clone it will
  362. 16:31work fine because the underlying data
  363. 16:33was copied fully and the same happens if
  364. 16:36you run vacuum as well. If you run
  365. 16:38vacuum then shalloc clone may fail if
  366. 16:41the underlying files are deleted but
  367. 16:43deep clone it will work fine. The next
  368. 16:46question it is like how exactly do we
  369. 16:49use these shallow and deep clone. So
  370. 16:51answer to that it is very simple. Let's
  371. 16:53say we do create or select table then
  372. 16:57shallow clone and then the original
  373. 16:59table. So it will take this table and
  374. 17:01create this new shallow clone of the
  375. 17:04table. In case of deep clone, we specify
  376. 17:07deep clone. That is how simple it is.
  377. 17:10Now the next question comes about
  378. 17:12partitioning and liquid clustering. So
  379. 17:15we can we normally ask like what is
  380. 17:17liquid clustering or what is the
  381. 17:19difference between partitioning and
  382. 17:21liquid clustering. So in case of
  383. 17:24partitioning it actually creates the
  384. 17:26folder or directories based on the
  385. 17:28provided column. And in case of liquid
  386. 17:31clustering what it does is it is similar
  387. 17:33to optimize and zorder. So it uh
  388. 17:37colllocates the similar data into same
  389. 17:40file but it don't create the actual
  390. 17:43directory and actual folder structure
  391. 17:45there. Now the next question comes how
  392. 17:48exactly do we use these two? So here is
  393. 17:51one example. So partitioning we specify
  394. 17:55partitioned by while creating the table
  395. 17:57or while writing the data. And in case
  396. 18:00of liquid clustering in instead of
  397. 18:03partitioned by we simply specify cluster
  398. 18:06by and the advantage of cluster by is
  399. 18:09that even after creating the table later
  400. 18:11on we can change the cluster columns but
  401. 18:14in case of partitioning we cannot change
  402. 18:17it. And why we can't change it? Because
  403. 18:21in case of partitioned it has actually
  404. 18:23created folders for each and every
  405. 18:26column. So it will not it will not be
  406. 18:28able to create the folders again. But in
  407. 18:31case of liquid clustering it simply
  408. 18:33rewrite these files into the same
  409. 18:35folder. So that is how it is able to do
  410. 18:38it. Now the follow-up question on liquid
  411. 18:40clustering is that does the clustering
  412. 18:44happens automatically while writing the
  413. 18:46data into table and the answer to that
  414. 18:49seems like yes but it is no while
  415. 18:52writing the data automatically it will
  416. 18:54not create those clusters. it will
  417. 18:57create or uh write those sim similar
  418. 19:00data into similar files only when we
  419. 19:02will run optimize command. That is when
  420. 19:05it will uh rewrite the data based on
  421. 19:08those clustering columns and that is
  422. 19:10where there will be some extra cost
  423. 19:12involved for when we use liquid
  424. 19:14clustering wherein in case of
  425. 19:17partitioning because the target data
  426. 19:19itself it is written in terms of
  427. 19:21folders. So while writing itself it will
  428. 19:24automatically write it write it into
  429. 19:26different different folders and no
  430. 19:28separate setup or step is required. So
  431. 19:31both has their pros and cons. And
  432. 19:34similarly
  433. 19:35partitioning we use when we have low
  434. 19:38cardality of the data. Low cardinality
  435. 19:41means like low or like less number of
  436. 19:43distinct values for the columns like
  437. 19:46year, country like that. And for
  438. 19:49clustering we normally use the high
  439. 19:51cardality columns like ID and other
  440. 19:54types of such columns.
  441. 19:57Now the next question or topic comes
  442. 19:59about change data feed. So we ask like
  443. 20:02what is change data feed? When shall we
  444. 20:05use it and how exactly we can use it. So
  445. 20:09what change data feed is? uh if we
  446. 20:11enable change data feed on any table
  447. 20:14then it provide a very detailed
  448. 20:17information about
  449. 20:19record level operation that are being
  450. 20:21performed. For example, this is our
  451. 20:25original table and on top of this table
  452. 20:27if one record we are updating one we are
  453. 20:30deleting and one um new record that we
  454. 20:34are inserting. So in change data feed uh
  455. 20:37it will say that this record is deleted
  456. 20:40this record is inserted and this record
  457. 20:43this is the data before changing it and
  458. 20:46this is the data after changing it. So
  459. 20:49detailed level change type and all the
  460. 20:52data and all the operation everything it
  461. 20:55provides in a very detailed logs manner.
  462. 20:59And when we enable change data feed then
  463. 21:03we ask like where exactly does it fetch
  464. 21:05that data or where exactly is this data
  465. 21:07stored. So along with delta log folder
  466. 21:11in the delta table it create another
  467. 21:14folder change data and that is when that
  468. 21:18is where in this park file it will store
  469. 21:21this information that is how internally
  470. 21:23it works. And the next question comes
  471. 21:26like how exactly we can use change data
  472. 21:29feed. So one option is that while
  473. 21:31creating the table itself we can specify
  474. 21:35this property delta dot enable change
  475. 21:38data feed equal to true then it will be
  476. 21:40enabled for this table or after creating
  477. 21:43the table later on also we can do alter
  478. 21:46table and then alter this property then
  479. 21:49also we can set it up. Now the next
  480. 21:52question comes let's say if we have
  481. 21:54created a table we inserted or did some
  482. 21:57operation then later on if we enable it
  483. 22:00then will it still uh showcase those
  484. 22:03changes in the CDF which was there
  485. 22:06before enabling the change data feed the
  486. 22:09answer to that it is no uh it start
  487. 22:12tracking those changes only after we
  488. 22:14enable this property so previous
  489. 22:16operations we can't fetch.
  490. 22:19So that covers all the questions on
  491. 22:21Delta Lake and I have created similar
  492. 22:24video on spark as well. You can go
  493. 22:26through that as well if you want and if
  494. 22:29you still have any doubts let me know
  495. 22:30and if you want to plan a mock interview
  496. 22:32with me the link is there in the
  497. 22:34description. That's all for now. Thank
  498. 22:37you. Bye-bye. Happy learning.

About this transcript

This page contains the full transcript of Delta Lake Interview Questions by DataBeli, generated from the public captions YouTube serves with the video. The transcript has 3,575 words across 498 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

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

Free YouTube transcript tool

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