Skip to content

fix(vscode): support aliased references #4309

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

benfdking
Copy link
Contributor

No description provided.

Comment on lines +58 to +60
unaliased = table.copy()
if unaliased.args.get("alias") is not None:
unaliased.set("alias", None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's all sorts of modifiers that can be attach to an exp.Table, such as joins, tablesamples etc. You'd need to drop all of them except catalog, db and this or leverage existing helpers such as sqlmesh.core.dialect.find_tables which should do that for you.

However, looking into the whole function again, I don't think you need to find (or clean up) the references on your own, isn't that provided by model.depends_on?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the problem is that if there's an alias the depends_on check won't work correctly, though we still want to get a match. In all other cases you're right. find_tables could be a good suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also realised ... it was failing with an exception and if say there are more examples where this can happen, I think it's better we wrap it in a try catch.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants