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

"on" and "ON" are table aliases?

Open galenseilis opened this issue 1 year ago • 0 comments

I just ran this example, which is adjusted from one of the examples on the README.

# foo.py
from sql_metadata import Parser

parser = Parser(
    """
WITH
    database1.tableFromWith AS (SELECT aa.* FROM table3 as aa 
                                left join table4 on aa.col1=table4.col2),
    test as (SELECT * from table3)
SELECT
  "xxxxx"
FROM
  database1.[tableFromWith] alias
LEFT JOIN database2.table2 ON ("tt"."ttt"."fff" = "xx"."xxx")
"""
)

print(parser.tables_aliases)

I am getting this result:

> python foo.py
{'aa': 'table3', 'on': 'table4', 'alias': 'database1.[tableFromWith]', 'ON': 'database2.table2'} 
  • Is this intended behaviour?
  • If this behaviour is desired, please explain how to interpret it.

galenseilis avatar Dec 18 '24 18:12 galenseilis