apache / apache/datafusion-sqlparser-rs
Format for Value renders incorrect escaping of quote characters in BigQuery
- Ngôn ngữ chính
- Rust
- Star
- 3.5k
- Fork
- 772
- Merge trung bình
- 4 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 17
Mô tả
`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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu với impl fmt::Display for EscapeQuotedString và các trường hợp bị lỗi trong tests/sqlparser_bigquery.rs. Chạy hoặc thêm test_quote_escape để so sánh đầu ra đã được định dạng cho cả hai chuỗi BigQuery hợp lệ, sau đó làm cho việc định dạng nhận biết dialect để cả hai trường hợp đều giữ được việc escaping hợp lệ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- rust, sql
- Lĩnh vực
- compilers, databases
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100