Metacenta

Lineage integrity · rule sql-relation-written-twice

SQL tables written by more than one file

A Metacenta review checks this under the rule Each relation has one writer. Everything below applies whether or not you ever commission one.

What this rule checks

For SQL projects without dbt, this rule flags each table or view that two or more files write. A write is a create table, create view, insert, merge, update or delete. A query.sql with no explicit write, inside a <dataset>/<table>/ folder, counts as writing that table. Assertion files are not writers.

Why it matters

Whichever file runs last wins. The table's contents then depend on scheduling order rather than on either file.

How to fix it

Give each relation one writer. Keep one writer per table. If the files load different partitions on purpose, merge them into one parameterised file, or say so in each.

When it is fine to leave

Files that load different partitions or date ranges on purpose, such as a daily load beside a one-off backfill, are not competing. A cleanup script that deletes old rows also counts as a writer here. Say which applies in each file.

What we need to check it

The .sql files, read from your repository with read-only access or uploaded. We match relations by their last two name parts, such as dataset.table, so the finding is medium confidence.