Skip to content

dfs() does not generate the expected result #4958

New issue

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

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

Already on GitHub? Sign in to your account

Closed
snovik75 opened this issue Apr 8, 2025 · 1 comment
Closed

dfs() does not generate the expected result #4958

snovik75 opened this issue Apr 8, 2025 · 1 comment

Comments

@snovik75
Copy link
Contributor

snovik75 commented Apr 8, 2025

This code:

tree = parse_one("select a from b")

for n in tree.dsf():
    print(n, type(n))

outputs

SELECT a FROM b <class 'sqlglot.expressions.Select'>
a <class 'sqlglot.expressions.Column'>
a <class 'sqlglot.expressions.Identifier'>
FROM b <class 'sqlglot.expressions.From'>
b <class 'sqlglot.expressions.Table'>
b <class 'sqlglot.expressions.Identifier'>

There are 2 clear issues here:

  1. the tree itself comes as the first element while it should come last
  2. Identifier should always come before Column or Table because it is deeper in the tree (i.e. the order is wrong)
@georgesittas
Copy link
Collaborator

Relevant Slack discussion for context: https://tobiko-data.slack.com/archives/C0448SFS3PF/p1744101733575189.

@snovik75 snovik75 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 8, 2025
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

No branches or pull requests

2 participants