semantic: resolve table-qualified column refs over dynamic joins#6975
Closed
c-tonneslan wants to merge 1 commit into
Closed
semantic: resolve table-qualified column refs over dynamic joins#6975c-tonneslan wants to merge 1 commit into
c-tonneslan wants to merge 1 commit into
Conversation
… joins
A column reference like a.id is resolved unqualified-first: the leading
identifier is looked up as a column before being treated as a table
qualifier. For a join over dynamic inputs every name resolves as a
dynamic column, so joinScope.resolveUnqualified raises "join on dynamic
column ... requires table-qualified reference" for a.id and resolveExpr
returns that error before ever trying the qualified interpretation.
The result is that a query whose references are already table-qualified,
like
SELECT a.x FROM 'a.json' AS a JOIN 'b.json' AS b ON a.id = b.id
fails under -dynamic with an error claiming the references aren't
qualified. The same query works without -dynamic.
When unqualified resolution fails on a multi-element path, fall back to
resolving it as a qualified reference before surfacing the error. A
genuinely unqualified dynamic column in a join is a single-element path,
so it still reports the original error.
Closes brimdata#6974
Signed-off-by: Charlie Tonneslan <cst0520@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.
Closes #6974.
resolveExprresolves a column reference unqualified-first:path[0]is looked up as a column before being treated as a table qualifier. For a join over dynamic inputs, every name resolves as a dynamic column, sojoinScope.resolveUnqualifiedraisesjoin on dynamic column %q requires table-qualified referencefor the leading name ofa.id. That error is returned immediately, before the qualified (table.column) resolution further down ever runs.So a query whose references are already table-qualified fails under
-dynamicwith an error claiming they aren't:The same query works without
-dynamic.The fix: when unqualified resolution fails on a multi-element path, try resolving it as a qualified reference before surfacing the error. A genuinely unqualified dynamic column in a join is a single-element path (
ON id = id), so that case still reports the original error, andcompiler/ztests/sql/join-dynamic-err.yamlstill passes. Addedjoin-dynamic-qualified.yamlcovering the fixed case.