1. A data engineering team partitions a Delta table by `year` and `month` for a dataset that spans 5 years of financial records. A common query pattern filters on both `month` and a non-partitioned column `account_category` (200 distinct values). The team considers adding Z-ORDER on `account_category`. After running `OPTIMIZE ... ZORDER BY (account_category)`, what behavior should the engineer expect?
- A. Z-ORDER clustering is applied globally across all partitions, reorganizing files across year/month boundaries to minimize the total number of files.
- B. Z-ORDER clustering is applied independently within each partition, co-locating rows with the same account_category values within the files of each year/month partition, enabling file skipping within a partition.✓ Correct
- C. Z-ORDER on account_category automatically adds it as a secondary partition column, creating nested partitions like year=2024/month=01/account_category=SAVINGS.
- D. Z-ORDER has no effect when partition columns are already defined, because partition pruning handles all filtering and Z-ORDER only works on non-partitioned tables.
Explanation
In Delta Lake, Z-ORDER operates within partition boundaries — it does not reorganize data across partitions. When a table is partitioned by year and month, running OPTIMIZE ZORDER BY (account_category) clusters files within each individual partition by account_category values. This allows the engine to skip files within a partition that don't contain the queried account_category values. Option A is incorrect — Z-ORDER never moves data across partition boundaries; partitioning and Z-ORDER are complementary, not conflicting. Option C is incorrect — Z-ORDER does not create nested partition directories; it is purely a file-level clustering mechanism within existing partitions. Option D is incorrect — Z-ORDER and partitioning work together effectively; partitioning handles coarse-grained filtering (year/month) while Z-ORDER handles fine-grained filtering (account_category) within each partition.