apache / datafusion-sqlparser-rs

Extensible SQL Lexer and Parser for Rust
Apache License 2.0
2.79k stars 538 forks source link

Can't parse escaped double quotes #800

Open DeadNumbers opened 1 year ago

DeadNumbers commented 1 year ago

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: TokenizerError("Expected close delimiter '\"' before EOF. at Line: 12920, Column 429")', src/main.rs:8:54

The line contains escaped double quotes:

'S-130, 190 , 290, 390 in 2005, 491 in 2012, 490 in 2017, L-180, 280, 380, WIMS Course, Wildfire Analyst Training, Misc. Ops and Plans Related Courses, Misc. \"I\" Courses.'

AugustoFKL commented 1 year ago

@DeadNumbers can you please post the query you're trying to run, please?

DeadNumbers commented 1 year ago

@AugustoFKL have no query, i'm read .sql file and try to parse from string. my goal is to convert all tables data from sql dump to csv.

Jefffrey commented 1 year ago

Will need more info on this to reproduce, as \" seems to parse just fine within a literal, e.g.

SELECT '\"test\"'
AugustoFKL commented 1 year ago

@DeadNumbers, can you give us the '.sql' you're trying to read?

Is that the line you're trying to parse?

'S-130, 190      , 290, 390 in 2005, 491 in 2012, 490 in 2017, L-180, 280, 380, WIMS Course, Wildfire Analyst Training, Misc. Ops and Plans Related Courses,       Misc. \"I\" Courses.'
DeadNumbers commented 1 year ago

@AugustoFKL yes, this line

appletreeisyellow commented 1 year ago

Just curious, @cobyge added support for backslash escape for MySQL in https://github.com/sqlparser-rs/sqlparser-rs/pull/844. Why not for all other SQL?

cobyge commented 1 year ago

Honestly I just had my specific use-case which was blocking my use, and I didn't have the time or setup to check and test every single database supported.

Each database needs it's own escape implementation.