sql-metadata icon indicating copy to clipboard operation
sql-metadata copied to clipboard

with_name marked as table

Open isadofschi opened this issue 2 years ago • 0 comments

Hi! Thank you, your package is very useful to us!

We encountered a minor issue with a query where some with_name is incorrectly marked as a table. I built this minimal example:

import sql_metadata

query = """
with
A as (
	with intermediate_query as (
		select
			id,
			some_column
		from table_one
	)
	select
	    id,
	    some_column
	from intermediate_query
),
B as (
	select
	    id,
	    other_column
	from table_two
)
select
	A.id,
	some_column,
	other_column
from A
inner join B
on A.id = B.id
"""
parser = sql_metadata.Parser(query)
parser.tables, parser.with_names

With version 2.8.0 I get (['table_one', 'B', 'table_two'], ['A', 'intermediate_table'])

isadofschi avatar Aug 18 '23 21:08 isadofschi