Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STRING_AGG wrongly being converted to GROUP_CONCAT in parse_one #2331

Closed
SudarshanVS opened this issue Sep 27, 2023 · 0 comments
Closed

STRING_AGG wrongly being converted to GROUP_CONCAT in parse_one #2331

SudarshanVS opened this issue Sep 27, 2023 · 0 comments

Comments

@SudarshanVS
Copy link

SudarshanVS commented Sep 27, 2023

sqlglot==13.3.0

SELECT
  STRING_AGG(email, '') AS STRING_AGGROwner_Id_Email
FROM organizations

The above query gets converted to

SELECT
  GROUP_CONCAT(owner_id_email, '') AS emails
FROM organizations

When passed through the below code,

query = """SELECT
  STRING_AGG(email, '') AS emails
FROM organizations"""
expression_tree = parse_one(query, read='trino')

But GROUP_CONCAT is not a valid TRINO function (STRING_AGG is also not a valid TRINO function). The correct equivalent function is ARRAY_JOIN(ARRAY_AGG(email),',')

Can this be fixed?

@SudarshanVS SudarshanVS changed the title STRING_ STRING_AGG wrongly being converted to GROUP_CONCAT in parse_one Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant