We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
DuckDB doesn't use the WITHIN GROUP syntax to order a listagg output. Its instead added into the function call like listagg(col, sep ORDER BY col2)
WITHIN GROUP
listagg(col, sep ORDER BY col2)
Fully reproducible code snippet
snowsql = """ select col0, listagg(col1, ', ') within group (order by col2) from (values (1, 'a', 3), (2, 'b', 2), (3, 'c', 1) ) group by col0 """ ducksql = sqlglot.transpile(snowsql, read='snowflake', write='duckdb')[0] print(ducksql)
yields
SELECT col0, GROUP_CONCAT(col1, ', ') WITHIN GROUP (ORDER BY col2) FROM (VALUES (1, 'a', 3), (2, 'b', 2), (3, 'c', 1)) GROUP BY col0
which throws ParserException: Parser Error: Unknown ordered aggregate "GROUP_CONCAT".
ParserException: Parser Error: Unknown ordered aggregate "GROUP_CONCAT".
I would expect the transpiler to output this:
select col0, group_concat(col1, ', ' order by col2) from (values (1, 'a', 3), (1, 'b', 2), (1, 'c', 1) ) group by col0
Official Documentation
https://duckdb.org/docs/sql/aggregates https://docs.snowflake.com/en/sql-reference/functions/listagg
The text was updated successfully, but these errors were encountered:
VaggelisD
Successfully merging a pull request may close this issue.
DuckDB doesn't use the
WITHIN GROUP
syntax to order a listagg output. Its instead added into the function call likelistagg(col, sep ORDER BY col2)
Fully reproducible code snippet
yields
which throws
ParserException: Parser Error: Unknown ordered aggregate "GROUP_CONCAT".
I would expect the transpiler to output this:
Official Documentation
https://duckdb.org/docs/sql/aggregates
https://docs.snowflake.com/en/sql-reference/functions/listagg
The text was updated successfully, but these errors were encountered: