Skip to content

Data Engineer Professional · Domain 9: Data Modeling · 5% of the exam

Task 9.1: Design scalable Delta/Iceberg table layouts for large data assets by mapping partitioning to data grain, aligning clustering to relationship access patterns, and maintaining balanced file sizes through compaction.

Partition grain and size limits, clustering on join and filter keys, target file sizes, compaction and auto compaction, and managed Iceberg tables.

Study it

  • Table layouts: partition grain, clustering keys and file sizes

    Partly covered by: Database Sharding

Sample questions

Try each one before opening the answer. Every option is explained, with the Databricks documentation page that proves it.

Question 1 · choose 1

An external Delta fact table, not maintained by predictive optimization, has grown from 2 TB to 12 TB over a year. Reports show that most of its files are still about 256 MB, although new files are near 1 GB. The team wants the whole table compacted to files of about 1 GB. What should the data engineer do?

  1. ARun VACUUM on the table to clear out the smaller files
  2. BSet autoOptimize.autoCompact to true on the table
  3. CCall coalesce(1) before each write to the table
  4. DSet delta.targetFileSize to 1gb, then OPTIMIZE
Show the answer and why
  • ARun VACUUM on the table to clear out the smaller files

    Incorrect

    VACUUM removes files no longer referenced by the table; it does not merge the current files.

  • BSet autoOptimize.autoCompact to true on the table

    Incorrect

    With true, auto compaction targets 128 MB files and does not rewrite older files.

  • CCall coalesce(1) before each write to the table

    Incorrect

    Forcing one output file per write slows writes and does not fix the existing files.

  • DSet delta.targetFileSize to 1gb, then OPTIMIZE

    Correct

    When the autotuned target grows, OPTIMIZE does not re-optimize existing files; a fixed target makes it compact them to that size.

Databricks autotunes target file size by table size, from 256 MB for smaller tables up to 1 GB above 10 TB. Existing files are not rewritten when the target grows, so a fixed targetFileSize is needed if all files must reach the larger size.

Question 2 · choose 2

Queries join an 8 TB fact table to small store and date dimensions and filter only on dimension attributes, such as region. The fact table is unpartitioned, and its scans read nearly every file. The team also runs MERGE statements on the fact table by store_id. Which TWO changes help dynamic file pruning skip fact files? (Choose TWO.)

  1. AUse liquid clustering on the fact table's join keys, such as store_id
  2. BPartition the fact table by store_id
  3. CCluster the small dimension tables by region
  4. DRun the queries and MERGE statements on Photon-enabled compute
  5. EAdd a BROADCAST hint for the dimension tables
Show the answer and why
  • AUse liquid clustering on the fact table's join keys, such as store_id

    Correct

    Clustering on the columns used in joins colocates matching rows, so dynamic file pruning can skip more files.

  • BPartition the fact table by store_id

    Incorrect

    Partitioning a large table by a high-cardinality key creates many small partitions and is not the recommended layout.

  • CCluster the small dimension tables by region

    Incorrect

    Pruning is applied to the scan of the large table, so the fact table's layout is what matters.

  • DRun the queries and MERGE statements on Photon-enabled compute

    Correct

    Dynamic file pruning in MERGE requires Photon, and Photon gives broader pruning for SELECT.

  • EAdd a BROADCAST hint for the dimension tables

    Incorrect

    Broadcasting changes the join strategy but does not make the fact layout prunable.

Dynamic file pruning pushes join filter results into the scan of the large Delta table at runtime. It works best when the join columns are clustered, and for MERGE, UPDATE and DELETE it requires Photon.

Question 3 · choose 1

Writes to a very narrow table, with only two small columns, fail because a data file would exceed the Parquet format's row limit. What does Databricks suggest?

  1. ARaise delta.targetFileSize to 10gb on the table
  2. BTurn off optimized writes for the narrow table
  3. CSet maxRecordsPerFile, as a Spark conf or a write option
  4. DPartition the table by both columns to spread the rows
Show the answer and why
  • ARaise delta.targetFileSize to 10gb on the table

    Incorrect

    Larger files hold even more rows.

  • BTurn off optimized writes for the narrow table

    Incorrect

    That changes file sizing but does not cap rows per file.

  • CSet maxRecordsPerFile, as a Spark conf or a write option

    Correct

    Capping records per file avoids the error; Databricks recommends it only when necessary.

  • DPartition the table by both columns to spread the rows

    Incorrect

    Partitioning a narrow table creates many tiny partitions.

Narrow tables can hit the Parquet limit on rows per file. Use spark.sql.files.maxRecordsPerFile or the DataFrameWriter option maxRecordsPerFile, which takes precedence, only when needed.

Question 4 · choose 1

A data engineer wants to confirm that auto compaction has been running on a table. Where can they see it?

  1. AIn the cluster event log, as COMPACTION events for each write
  2. BIn table history, as OPTIMIZE with operationParameters.auto true
  3. CIn SHOW TBLPROPERTIES, as a counter of the compactions that ran
  4. DIn the Spark UI's Storage tab for the writing cluster
Show the answer and why
  • AIn the cluster event log, as COMPACTION events for each write

    Incorrect

    Compaction is recorded in table history, not compute events.

  • BIn table history, as OPTIMIZE with operationParameters.auto true

    Correct

    Auto compaction appears as OPTIMIZE with auto true; a manual OPTIMIZE has auto false.

  • CIn SHOW TBLPROPERTIES, as a counter of the compactions that ran

    Incorrect

    Properties show settings, not operations.

  • DIn the Spark UI's Storage tab for the writing cluster

    Incorrect

    The Storage tab shows cached data.

Review table history to confirm auto compaction: it appears as an OPTIMIZE operation with operationParameters.auto set to true.

Question 5 · choose 1

A data engineer wonders which writes to an external Delta table already use optimized writes without any table or session setting. Which operation is one of them?

  1. AA streaming append with a processing-time trigger
  2. BA DataFrame write after coalesce(10)
  3. CCOPY INTO from a classic cluster
  4. DA MERGE INTO statement that upserts changes
Show the answer and why
  • AA streaming append with a processing-time trigger

    Incorrect

    Streaming appends are not in the default list.

  • BA DataFrame write after coalesce(10)

    Incorrect

    Databricks advises against coalesce or repartition before writes when optimized writes are used.

  • CCOPY INTO from a classic cluster

    Incorrect

    COPY INTO is not among the operations listed as enabled by default.

  • DA MERGE INTO statement that upserts changes

    Correct

    Optimized writes are enabled by default for MERGE, and for UPDATE and DELETE with subqueries.

Optimized writes shuffle data before writing to produce fewer, larger files. They are on by default for MERGE and for UPDATE and DELETE with subqueries, and for CTAS and INSERT on SQL warehouses.

Question 6 · choose 1

A legacy notebook that writes to a new Unity Catalog managed table still sets spark.databricks.delta.autoCompact.enabled in its Spark config. What does Databricks recommend?

  1. ARemove the setting so background auto compaction applies
  2. BSet it to legacy to keep the old fixed 128 MB file size
  3. CAdd autoOptimize.optimizeWrite = false to the table's properties
  4. DRun OPTIMIZE on the table after every write instead
Show the answer and why
  • ARemove the setting so background auto compaction applies

    Correct

    Background auto compaction is available for managed tables once the old Spark setting is removed.

  • BSet it to legacy to keep the old fixed 128 MB file size

    Incorrect

    Fixed legacy sizing works against automatic tuning.

  • CAdd autoOptimize.optimizeWrite = false to the table's properties

    Incorrect

    Turning off optimized writes does not enable background compaction.

  • DRun OPTIMIZE on the table after every write instead

    Incorrect

    Manual OPTIMIZE after every write adds cost.

Background auto compaction is available for Unity Catalog managed tables and does not need predictive optimization. When migrating, remove the autoCompact Spark configuration from cluster or notebook settings.

Practice domain 9 →Practice all domains →