Allow any valid SQL query to be used as a table in a s-string
Los mantenedores suelen responder en 3 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
Línea de trabajo
The issue points to the s-string handling in prqlc/prqlc/src/sql/gen_query.rs, around line 508. Read that code and its related tests to see how table s-strings are validated and emitted, especially the current requirement that they start with SELECT . Done means a valid SQL query, including one beginning with a CTE, can be used as a table in an s-string while existing cases remain covered.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
I was wondering if there would be an easy way to allow any valid SQL query to be used as table.
Our use case it the following: We receive a source SQL query, and its content is out of our control. We then generate a PRQL pipeline applying to this query, compile it to SQL, and execute it on a target database. We have no control over the source query, and some of them can be pretty complex, and can include CTEs. An example would be
WITH Base AS (SELECT c.company_id, cc.name AS company_name, [...] a.value::JSONB AS json_data FROM sometable AS c LEFT JOIN other_table AS cc ON cc.foo = c.baz LEFT JOIN fizz AS s ON s.wee = c.woo LEFT JOIN CROSS JOIN LATERAL (SELECT EXTRACT(YEAR FROM d.d)::INTEGER AS blah FROM generate_series(date_trunc('year', a.start_date), date_trunc('year', a.end_date), INTERVAL '1 year'), other_cte AS ([...]) SELECT * FROM other_cte
Right now, this results in an error with s-strings representing a table must start with SELECT `, which seems to originate in https://github.com/PRQL/prql/blob/main/prqlc/prqlc/src/sql/gen_query.rs#L508 .
Would there be an easy way to allow such a query to be used in an s-string in a from statement ?
from (s""" <complex_sql_query_here> """) | select {this.a, this.b, this.c}
For now, I see an escape hatch, but it seems quite hacky:
- Instead of the real SQL query, use a magic value accepted by prql, so you get a prql query like
from (s""" SELECT __MY_MAGIC_VALUE__ """) | select {this.a, this.b, this.c} - Compile to SQL
- Replace
SELECT __MY_MAGIC_VALUE__with the actual sql query in the compiled SQL - Validate and format the final string with
sqlparser
Thank you for your help and your work on prql!
- Lenguaje dominante
- Rust
- Estrellas
- 10.9k
- Forks
- 261
- Merge medio
- 3 d 21 h
- PR fusionados (30 d)
- 84
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de PRQL/prql
-
Underscore does not work as expectedPosiblemente ocupada @prql-bot la tomó hace 1 día. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
PRQL/prql#6518 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
prqlc Debug Report HTML Does Not Escape Source File Name, Enabling Stored XSS via PRQLC_DEBUG_LOGAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
PRQL/prql#6502 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
Add `.prql` to linguistAbiertofriendliness integrations
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
PRQL/prql#1636 · 2 comentarios · 2 reacciones ·
Los mantenedores suelen responder en 3 días
-
Dificultad 4/5 1-2 días Aptitud para principiantes 12/100
PRQL/prql#6517 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
review-runs-tracking: 2026-11Abiertoreview-runs-tracking
Dificultad 3/5 Medio día Aptitud para principiantes 5/100
PRQL/prql#6513 · 1 comentario ·
Los mantenedores suelen responder en 3 días
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
riverqueue/river#1576 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
stadelmanma/fitparse-rs#64 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
zed-extensions/java#325 ·
-
Suggestion: full-band strip — mark the tuned frequency in magenta, with triangles on the edgesAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
dividebysandwich/sdroxide#769 ·
Los mantenedores suelen responder en 5 días