Skip to content

SQLite, DuckDB: Support aggregate ORDER BY without arguments - #2660

Open
LucaCappelletti94 wants to merge 1 commit into
mainfrom
sqlite-aggregate-order-by-no-args
Open

LucaCappelletti94 wants to merge 1 commit into
mainfrom
sqlite-aggregate-order-by-no-args

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

SQLite and DuckDB accept an aggregate call whose only content is an ORDER BY clause, such as SELECT count(ORDER BY a) FROM t, but the parser failed with Expected: ), found: BY. SQLite documents ORDER BY inside aggregate calls (https://www.sqlite.org/lang_aggfunc.html#aggorderby) and so does DuckDB (https://duckdb.org/docs/current/sql/functions/aggregates#order-by-clause-in-aggregate-functions). SQLite 3.51.1 and DuckDB 1.4.4 both run count(ORDER BY a) and count(ORDER BY a ASC, b DESC) and both reject count(DISTINCT ORDER BY a). SQLite also accepts count(ALL ORDER BY a).

A new dialect method, supports_aggregate_order_by_with_empty_args, enables the form for SQLite, DuckDB and the generic dialect. DISTINCT still requires an argument. Tests now cover every dialect on both sides of the capability.

@codecov-commenter

codecov-commenter commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.29%. Comparing base (ada8314) to head (f168835).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2660   +/-   ##
=======================================
  Coverage   81.28%   81.29%           
=======================================
  Files          42       42           
  Lines       33920    33936   +16     
  Branches    33920    33936   +16     
=======================================
+ Hits        27571    27587   +16     
  Misses       2785     2785           
  Partials     3564     3564           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaCappelletti94
LucaCappelletti94 force-pushed the sqlite-aggregate-order-by-no-args branch from 77ce46a to f168835 Compare October 18, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DuckDB enhancement New feature or request SQLite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants