iffyio commented on code in PR #1747:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/1747#discussion_r2011373382
##########
src/dialect/mysql.rs:
##########
@@ -141,6 +149,280 @@ impl Dialect for MySqlDialect {
fn supports_set_names(&self) -> bool {
true
}
+ /// Dialect-specific table/view option parser override
+ ///
+ /// This method is called to parse the next table/view option.
+ ///
+ /// If `None` is returned, falls back to the default behavior.
+ /// <https://dev.mysql.com/doc/refman/8.4/en/create-table.html>
+ fn parse_plain_option(&self, parser: &mut Parser) ->
Result<Option<SqlOption>, ParserError> {
+ //Some consts
+ const COMPRESSION_OPTS: [&str; 3] = ["ZLIB", "LZ4", "NONE"];
+ const INSERT_METHODS_OPTS: [&str; 3] = ["NO", "FIRST", "LAST"];
+
+ let keyword = match parser.parse_one_of_keywords(&[
Review Comment:
I think that behavior makes sense for the parser to mitigate, maybe we could
explicitly track the one word options and multiple keyword options to avoid
ambiguity? something like:
```rust
fn parse_plain_option(&self, parser) -> Result<Option<SqlOption>> {
if self.parse_keywords(START, TRANSACTION) {
return Ok(Some(SqlOption::Ident("START TRANSACTION")))
} // ...
let key = if self.parse_keywords(DEFAULT, CHARACTER, SET) {
Ident::new("DEFAULT CHARACTER SET")
} // ...
else {
self.parse_ident()?
};
let _ = self.consume_token('=')?;
let value = self.parse_expr()?;
Ok(Some(SqlOption::KeyValue {
key, value
}))
}
```
In that, the special cases are only a handful, and we're only tracking their
keys, values are opaque.
Hmm interesting with the example, I wonder how mysql interprets `ROW_FORMAT
DEFAULT CHARACTER SET latin1`. Since `DEFAULT` seems to also be a valid value
for `ROW_FORMAT` from their docs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]