andialbrecht / sqlparse

A non-validating SQL parser module for Python
BSD 3-Clause "New" or "Revised" License
3.71k stars 693 forks source link

Expressions are being changed automatcally while parsing group by clause #760

Open hashir0981 opened 9 months ago

hashir0981 commented 9 months ago

Describe the bug It is hallucinating some expressions that include datetime. That should'nt be the expected result.

To Reproduce def strip_alias_from_group_by(group_by: str) -> str: sql = f""" SELECT {group_by.strip()} FROM TABLE1 """.strip() parsed_sql = parse_one(sql, dialect="databricks", read="databricks") return ", ".join(map(lambda i: f"{i.alias}" if i.alias else i.sql(), parsed_sql.expressions))

What's the concrete error / traceback.

Expected behavior A clear and concise description of what you expected to happen.

Versions (please complete the following information):

Additional context Add any other context about the problem here.

andialbrecht commented 9 months ago

Please provide more details about the error. How to reproduce it, the expected and actual output of any kind.