Refactor!: map duckdb LIST to ArrayAgg#7552
Merged
georgesittas merged 1 commit intomainfrom Apr 23, 2026
Merged
Conversation
Collaborator
Author
georgesittas
commented
Apr 23, 2026
| "JSON_ARRAY": lambda args: exp.JSONArray(expressions=args), | ||
| "JSON_EXTRACT_PATH": parser.build_extract_json_with_path(exp.JSONExtract), | ||
| "JSON_EXTRACT_STRING": parser.build_extract_json_with_path(exp.JSONExtractScalar), | ||
| "LIST": exp.ArrayAgg.from_arg_list, |
Collaborator
Author
There was a problem hiding this comment.
The advantage of this approach is that LIST is correctly identified as an AggFunc (because of ArrayAgg). The LIST function was added for Materializes' LIST function, which IIRC isn't an aggregate function. That's why I decided to change this.
Contributor
SQLGlot Integration Test ResultsComparing:
By Dialect
Overallmain: 113234 total, 112044 passed (pass rate: 98.9%), sqlglot version: sqlglot:jo/map_ddb_list_to_array_agg: 110925 total, 110027 passed (pass rate: 99.2%), sqlglot version: Transitions: Dialect pair changes: 0 previous results not found, 1 current results not found ✅ 34 test(s) passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is Copilot's response when I asked whether
LISTandARRAY_AGGare synonymous in DuckDB:«In DuckDB,
list(expr)andarray_agg(expr)are essentially the same kind of aggregate: both collect the grouped input values into a single LIST (array) value.Practical differences are mostly about name/compatibility and a few option/details, not the core semantics:
Purpose
array_aggis the more standard SQL / Postgres-style name.listis a shorter DuckDB-friendly alias/name for the same idea.Return type
Options
DISTINCT,FILTER, and oftenORDER BYwithin the aggregate (depending on DuckDB version).So: yes, for normal usage they’re interchangeable—use
array_aggif you want portability/readability for SQL folks, uselistif you prefer the concise DuckDB idiom.If you tell me your DuckDB version (or paste
SELECT version();), I can be precise about any version-specific differences (e.g., ordering guarantees/availability ofORDER BYwithin the aggregate).»Original PR: #7551