question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nested with statement causes confusion

See original GitHub issue

I wrote the following test:

def test_create_table_as_select_with_joins_with():
    qry = """
        CREATE table xyz as 
        with sub as (select it_id from internal_table)
        SELECT *
        from (
            with abc as (select * from other_table)
            select name, age, it_id
            from table_z
            join abc on (table_z.it_id = abc.it_id)
        ) as table_a
        join table_b on (table_a.name = table_b.name)
        left join table_c on (table_a.age = table_c.age)
        left join sub on (table_a.it_id = sub.it_id)
        order by table_a.name, table_a.age
        """
    parser = Parser(qry)
    assert set(parser.tables) == set(["xyz", "table_z", "table_b", "table_c", "internal_table", "other_table"])

which the code is unable to pass, as it thinks with in the following sub-query:

from (
  with abc as (select * from other_table)
  select name, age, it_id
  from table_z
  join abc on (table_z.it_id = abc.it_id)
)

is a table.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
collerekcommented, Jun 22, 2021

@tipanverella You just have to put that with everywhere, don’t you? 🤣

1reaction
collerekcommented, Jun 22, 2021

@tipanverella fix for this is already in a PR waiting for @macbre review.

You are already helping with those failing edge cases, thanks to you sql-metadata is becoming better and more universal☺️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Confusion of nested ifelse expression - Stack Overflow
This code aims to define a new column, Y in the data set x . The column Y will populate based on the...
Read more >
Getting a Nested With Clause error while creating a Table
Hello,. I am trying to create a table from a query. However I am getting the following error: ORA-32034: unsupported use of WITH...
Read more >
Confusion Between For Each and For All in Nested Quantifiers
This expression says that if students x and y are friends, and students x and z are friends, and furthermore, if y and...
Read more >
Nested conditionals (if/else/if) | AP CSP (article) | Khan Academy
The above structure can become confusing when we deal with nested conditionals. However, you can remember the general syntactic structure of an if-else ......
Read more >
Solved: Nested IF statement - Microsoft Power BI Community
Therefore, all your arguments after it are causing the error. I think you can remove the "SliderValue" argument, or use a SWITCH() function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found