fix: add label() to qualified column names in JOIN SELECT to prevent ambiguous column errors #369
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.
Summary
Fixes remaining issues with reverse join and changelist processing after PR #368.
Changes
1. Fix ambiguous column errors in JOIN queries (commit 554f7bd)
Problem: JOIN queries generated qualified column names in SELECT (e.g.,
primary_meta_tbl.id) without aliases, causing "column reference 'id' is ambiguous" errors in WHERE clause.Solution: Added
.label(k)to all qualified columns in SELECT:Modified functions:
_build_reverse_meta_cte_build_reverse_data_cte_meta_data_sql_helper2. Use offset=0 for changelist with reverse join support (commits 0e5b668, cb495f2)
Problem: Initial approach (commit 5b1a19a) disabled offset optimization entirely by switching to v1, which broke reverse join functionality.
Solution: Use v2 (with reverse join support) but with
offset=0for all tables:changelist_modeflag inget_change_list_process_idsbuild_changed_idx_sql_v2checks this flag and usesoffset=0instead of saved offsetsref_meta_tblto_apply_sql_filterssql_apply_filters_idx_to_subqueryBenefits:
join_keysworks in changelist3. Add production test case (commit 43eaf2c)
Added comprehensive test reproducing the exact production scenario that caused the bug:
advertising_campaign_to_moderateid + ad_campaign_ididonlyTesting
✅ All changelist tests pass
✅ Offset optimization works correctly in
run_full✅ Reverse join with filters_idx works without errors
✅ Production case with composite join_keys passes