Some aggregation functions need ORDER BY clause

Abierto
#4,383 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 4 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
38/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
rust, sql

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
10.9k
Forks
261
Merge medio
4 d 6 h
PR fusionados (30 d)
78

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PRQL/prql

Todos los issues de PRQL/prql

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.