fix(sql): use LEFT JOIN in blame view to handle schema-only reverts#10976
Open
wucm667 wants to merge 1 commit into
Open
fix(sql): use LEFT JOIN in blame view to handle schema-only reverts#10976wucm667 wants to merge 1 commit into
wucm667 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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) tojoin
sorted_diffs_by_pkwithdolt_log. After a schema-only revert, theto_commithash from the diff table may not match any commit indolt_log,causing all rows to be filtered out.
Fix
Changed the blame view SQL to use a
LEFT JOINbetweensorted_diffs_by_pkand
dolt_log, so rows from the diff table are returned even when the commithash lookup in
dolt_logdoesn't find a match.Fixes #10965