Schedule icon
WorkingDirectory icon
Queries icon
Fail icon
OutputValues icon
Log icon
Switch icon

Parquet Partition Day Alignment Audit with DuckDB

Audit a date-partitioned Parquet lake with DuckDB. Find files outside their day folder and the UTC offset or load date that explains them.

Categories
Data

Daily Parquet partitions are only as good as the code that chose the day. If a writer computed dt in local time from a UTC column, the folder dt=2026-09-02 holds events from the evening of Sep 1 to the afternoon of Sep 2, and every query that filters on dt is wrong by hours. This flow checks it from the file footers and tells you which offset would put the lake right.

How it works

  1. build_demo_lake writes a deterministic demo lake with DuckDB, unless lake_glob points at your own files. The default demo was partitioned in UTC+05:30.
  2. find_files, inspect_column and read_ranges stop the run with a BLOCKED_ message when the glob matches nothing, there is no dt= date folder, the column is missing or not a timestamp, or no file has an event time range.
  3. read_ranges gets the first and last event time of every file from its footer (method: FOOTER), or scans only that column (method: SCAN, for Spark INT96 files and exact row counts).
  4. audit marks each file ALIGNED, SPILLS_OVER, MISFILED or SPANS_DAYS, then tries every UTC offset from -24h to +24h in 15 minute steps and reports the one that fits the most files.
  5. A Switch routes ALIGNED, SHIFT_DETECTED and MISALIGNED.

What you get

  • A decision with a plain reason, such as "At UTC+05:30 32 of 32 would be inside".
  • A CSV of the misaligned files with the hours they stick out, and a CSV of the best offsets.
  • A rewrite statement for a shifted lake. Your files are never changed.

Who it's for

  • Data engineers who own date-partitioned Parquet lakes written by Spark, dbt, Python or DuckDB.
  • Teams whose daily totals differ between the lake and the source.

Why orchestrate this with Kestra

  • Inputs, guards, a Switch and a schedule in one declarative flow, with the reason in the execution.
  • on_findings: FAIL turns a new partition bug into a failed run that can alert.

Prerequisites

  • A Kestra instance with the DuckDB plugin and access to Parquet files in hive layout, such as dt=2026-09-02/.

Secrets

  • None for local files. Reading s3:// or gs:// paths needs DuckDB storage access that this flow does not set up.

Quick start

  1. Click Execute with the defaults: the demo ends SUCCESS with SHIFT_DETECTED at UTC+05:30.
  2. Execute again with demo_scenario: BACKFILL to see files in the wrong day that no offset explains.
  3. Set lake_glob, time_column and the offset your partitions should follow, then enable the daily trigger.

How to extend

  • Add a Slack or email task on the failure branch, or loop over several tables.
  • Rewrite the affected days with the statement from the result, then audit again.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.