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.

The tables property is still having difficulties finding the tables in a CTAS

See original GitHub issue

I created 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 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.it_id = sub.it_id)
        order by table_a.name, table_a.age
        """
    parser = Parser(qry)
    assert set(parser.tables) == set(["xyz", "table_a", "table_b", "table_c", "internal_table"])

And the code is not able to pass it as is. It seems that it struggles with with created subqueries.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
tipanverellacommented, Jun 2, 2021

I am using AWS Athena, which is essentially Presto

1reaction
macbrecommented, Jun 3, 2021

BTW I didn’t see you in stargazers of sql-metadata, you know we fix only issues from people that help us to promote our library 😛 🤣

We should state that in our CONTRIBUTING.md 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Considerations and limitations for CTAS queries
Table, database, or column names for CTAS queries should not contain quotes or backticks. To ensure this, check that your table, database, or...
Read more >
CREATE TABLE AS SELECT (CTAS) - Azure Synapse Analytics
CTAS is a parallel operation that creates a new table based on the output of a SELECT statement. CTAS is the simplest and...
Read more >
Derived tables in Looker - Google Cloud
In Looker, a derived table is a query whose results are used as if it were an actual table in the database. For...
Read more >
CREATE TABLE AS SELECT does not work for external tables
Sounds like CTAS does not work with external tables. Any reasons why this should not be supported? We can contribute a patch if...
Read more >
Unable to create table from within package - Stack Overflow
Create a table in procedure is only alowed when you have "Create table" or "create any table" privilege but granted directly to user ......
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