apache / apache/datafusion-sqlparser-rs
Expected end of statement, found: COMMENT while parsing MySQL `CREATE TABLE` statement
- Dominant language
- Rust
- Stars
- 3.5k
- Forks
- 772
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 17
Description
Hi,
I'm using sqlparser = "0.38.0", trying to parse the below with
```
let result = Parser::parse_sql(dialect.as_ref(), &sql);
let ast: Vec = Vec::new();
match result {
Ok(value) => {
println!("Parse Ok");
let ast = value;
},
Err(err) => {
eprintln!("Error: {}", err);
std::process::exit(-1);
},
}
```
However it is failing with **sql parser error: Expected end of statement, found: COMMENT at Line: 1, Column 691**. Is there a way to ignore anything outside the parenthesis as that is irrelevant for my usecase however I suspect this is unintended behaviour?
```
CREATE TABLE `randoms_2` (
`first_name` varchar(64) NOT NULL,
`last_name` varchar(64) NOT NULL,
`home_phone` varchar(12) NOT NULL,
`email` varchar(64) NOT NULL,
`address` varchar(64) NOT NULL,
`city` varchar(32) NOT NULL,
`state` varchar(2) NOT NULL,
`zip` varchar(5) NOT NULL,
`date_of_birth` varchar(10) NOT NULL,
`ssn` varchar(9) NOT NULL,
`drivers_license` varchar(32) NOT NULL,
`drivers_license_state` varchar(2) NOT NULL,
`income_type` varchar(16) NOT NULL,
`account_type` varchar(16) NOT NULL,
`routing_number` varchar(32) NOT NULL,
`account_number` varchar(32) NOT NULL,
`bank_name` varchar(64) NOT NULL,
PRIMARY KEY (`ssn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='LOAD DATA LOCAL INFILE "random.csv" INTO TABLE randoms_2 COLUMNS TERMINATED BY '','' ENCLOSED BY ''"'' LINES TERMINATED BY ''\\r\\n'' IGNORE 1 LINES;';
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Parser::parse_sql entry point and reproduce the MySQL CREATE TABLE example, focusing on the trailing ENGINE, CHARSET, and COMMENT clauses. Determine the intended handling of this valid statement and verify that the reported input parses correctly with regression coverage for the trailing COMMENT clause.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, rust, sql
- Domain
- compilers, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100