Repository navigation
fix: infer a column selected through a joined CTE from the source that has a wildcard - #6558
Merged
Merged
Conversation
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
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.
Selecting an inferred column from a CTE that joins two tables failed with
Table ["default_db", "x"] does not have wildcard.when only the second table had a wildcard. Since #5581,lineage_of_table_declreplaced a CTE input with its source tables during resolution, so every source shared the CTE's input name and inference charged the column to the first one (x). The CTE is now the input during resolution again, so inference goes from the CTE's own declaration to the source that has the wildcard (y), and the query compiles toSELECT zz FROM t.#5581's purpose,
debug lineagereporting source tables for CTE inputs, moves topl_to_lineage. That function now replaces each CTE input with its source tables, keeping the input'sidandname, and recurses through nested CTEs. The existing CTE lineage tests and thedebug_lineagesnapshots pass unchanged.When both joined tables have wildcards, the column is ambiguous. That case compiled on
mainby charging the first source, which is what makestest_column_inference_with_into(#4723) pass. The fix keeps that behaviour explicitly: inference charges the first wildcard source instead of raising the old "could be any of" error. The CTE selects all of each source's columns, so the SQL is the same. Without the CTE, the same query reportsAmbiguous name; whether the CTE form should report it too is left as is.The error messages in
infer_table_columnnow print the table asdefault_db.xrather than["default_db", "x"].Tests:
test_infer_column_through_joined_cteuses the query from the issue. It fails onmainwith the "does not have wildcard" error and passes with this change.test_nested_cte_lineage_traces_to_source_tablescovers recursion through a CTE built on another CTE.task prqlc:testpasses: 796 tests.Closes #6557 — automated triage