Skip to content

semantic: resolve table-qualified column refs over dynamic joins#6975

Closed
c-tonneslan wants to merge 1 commit into
brimdata:mainfrom
c-tonneslan:fix/dynamic-join-qualified-ref
Closed

semantic: resolve table-qualified column refs over dynamic joins#6975
c-tonneslan wants to merge 1 commit into
brimdata:mainfrom
c-tonneslan:fix/dynamic-join-qualified-ref

Conversation

@c-tonneslan
Copy link
Copy Markdown

Closes #6974.

resolveExpr resolves 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, so joinScope.resolveUnqualified raises join on dynamic column %q requires table-qualified reference for the leading name of a.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 -dynamic with an error claiming they aren't:

$ super -s -dynamic -c "SELECT a.x FROM 'a.json' AS a JOIN 'b.json' AS b ON a.id = b.id"
join on dynamic column "a" requires table-qualified reference at line 1, column 53:
...

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, and compiler/ztests/sql/join-dynamic-err.yaml still passes. Added join-dynamic-qualified.yaml covering the fixed case.

… 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>
@mattnibs mattnibs closed this May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error message inaccurately says query "requires table-qualified reference"

2 participants