apache / apache/datafusion-sqlparser-rs
Format for Value renders incorrect escaping of quote characters in BigQuery
- 主要言語
- Rust
- スター
- 3.5k
- フォーク
- 772
- 平均マージ
- 4日 9時間
- マージ済み PR(30日)
- 17
説明
`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.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
impl fmt::Display for EscapeQuotedString と tests/sqlparser_bigquery.rs の失敗しているケースから始めます。両方の有効な BigQuery 文字列のフォーマット後の出力を比較するために test_quote_escape を実行または追加し、その後、両方のケースで有効なエスケープが維持されるように、フォーマットを方言対応にします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rust, sql
- 領域
- compilers, databases
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100