Skip to content

Invalid macro resolution for table identifiers #259

@izeigerman

Description

@izeigerman

Expression which include a table identifier resolved through a macro like:

FULL OUTER JOIN @SQL('@target') AS tgt

resolves into the following AST:

  (JOIN this:
    (TABLE this:
      (COLUMN this:
        (IDENTIFIER this: orders, quoted: False), table:
        (IDENTIFIER this: sushi, quoted: False)), alias:
      (TABLEALIAS this:
        (IDENTIFIER this: tgt, quoted: False))), side: FULL, kind: OUTER, on:
...

The TABLE node contains another COLUMN node instead of just IDENTIFIERS. For comparison here's the same AST, but with the value inserted directly instead of through a macro:

  (JOIN this:
    (TABLE this:
      (IDENTIFIER this: orders, quoted: False), db:
      (IDENTIFIER this: sushi, quoted: False), alias:
      (TABLEALIAS this:
        (IDENTIFIER this: tgt, quoted: False))), side: FULL, kind: OUTER, on:
...

Because of the invalid AST other sql-related functionality like eg. exp.replace_tables doesn't work correctly.

Metadata

Metadata

Assignees

Labels

BugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions