Skip to content

fix(sql): use LEFT JOIN in blame view to handle schema-only reverts#10976

Open
wucm667 wants to merge 1 commit into
dolthub:mainfrom
wucm667:fix/dolt-blame-after-schema-revert
Open

fix(sql): use LEFT JOIN in blame view to handle schema-only reverts#10976
wucm667 wants to merge 1 commit into
dolthub:mainfrom
wucm667:fix/dolt-blame-after-schema-revert

Conversation

@wucm667
Copy link
Copy Markdown

@wucm667 wucm667 commented May 1, 2026

Description

When a schema-only commit (involving DROP TABLE + RENAME TO) is reverted,
dolt_blame_<table> returns zero rows even though the table has live data.

Root Cause

The blame view used an implicit cross join (FROM a, b WHERE a.x = b.y) to
join sorted_diffs_by_pk with dolt_log. After a schema-only revert, the
to_commit hash from the diff table may not match any commit in dolt_log,
causing all rows to be filtered out.

Fix

Changed the blame view SQL to use a LEFT JOIN between sorted_diffs_by_pk
and dolt_log, so rows from the diff table are returned even when the commit
hash lookup in dolt_log doesn't find a match.

Fixes #10965

When a schema-only commit (involving DROP TABLE + RENAME TO) is reverted,
dolt_blame returns zero rows even though the table has live data. The blame
view used an implicit cross join with WHERE filtering, which excluded rows
when the to_commit hash from the diff table didn't match a commit in
dolt_log (e.g., after revert operations alter the commit history context).

Fix: change the blame view SQL to use a LEFT JOIN between
sorted_diffs_by_pk and dolt_log, so rows from the diff table are returned
even when the commit hash lookup in dolt_log doesn't find a match.

Fixes dolthub#10965

Signed-off-by: wucm667 <stevenwucongmin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dolt_blame returns no rows after schema-only dolt_revert

2 participants