apache / apache/datafusion-sqlparser-rs
Format for Value renders incorrect escaping of quote characters in BigQuery
- Lingua principale
- Rust
- Stelle
- 3.5k
- Fork
- 772
- Merge medio
- 4g 9h
- PR unite (30g)
- 17
Descrizione
`impl fmt::Display for EscapeQuotedString` (which is used when formatting a Value expr) uses double quote character escaping (like `''` or `""`) which is a syntax error in BigQuery.
This was also reported in PRQL: https://github.com/PRQL/prql/issues/5099
To fix this, I think we need to make this method aware of the dialect. And potentially add a new supports rule (like supports_backslash_escaping?) If someone could chime in on the approach I can take a stab at it.
Here is a failing test case you can add to tests/sqlparser_bigquery.rs
```rs
#[test]
fn test_quote_escape() {
bigquery().verified_expr(r#"JSON '{"foo":"bar\'s"}'"#); // Wrong output: JSON '{"foo":"bar''s"}'
bigquery().verified_expr(r#"JSON "{\"foo\":\"bar's\"}""#); // Wrong output: JSON "{""foo"":""bar's""}"
}
```
Both of these are valid BigQuery syntax. They get parsed into the AST correctly but get formatted incorrectly.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia con impl fmt::Display for EscapeQuotedString e con i casi che falliscono in tests/sqlparser_bigquery.rs. Esegui o aggiungi test_quote_escape per confrontare l'output formattato di entrambe le stringhe BigQuery valide, quindi rendi la formattazione consapevole del dialetto in modo che entrambi i casi mantengano un escaping valido.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust, sql
- Ambito
- compilers, databases
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100