Some aggregation functions need ORDER BY clause

Aperta
#4,383 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
38/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust, sql
Ambito
backend, databases

Direzione di ricerca

Start by tracing how PRQL represents sort and aggregation through its compiler, then find the SQL generation tests for aggregate functions. Check how ordering is preserved when a relation is passed to an aggregation; done means the example emits json_agg(month || ': ' || total ORDER BY total) and relevant tests pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

compiler
let json_agg = func arr -> s"json_agg({arr})"

from invoices
sort total
aggregate (json_agg f"{month}: {total}")

(intention: I want a single row that is a json array, which contains "month: total" entries, sorted by total)

I think this PRQL should produce the following SQL:

SELECT
  json_agg(month || ': ' || total ORDER BY total)
FROM invoices

The important bit is that json_agg has its column ORDERed BY total.

This is because from invoices | sort total produces a relation, ordered by total, so this ordering should be accounted by the aggregation function.

Lingua principale
Rust
Stelle
10.9k
Fork
261
Merge medio
3g 21h
PR unite (30g)
84

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PRQL/prql

Tutte le issue di PRQL/prql

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.