mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-24 07:54:06 +00:00
Remove duplicated code by parse_boolean_string usage
This commit is contained in:
parent
7697d35d86
commit
032c9bb2d4
2 changed files with 3 additions and 21 deletions
|
@ -598,29 +598,11 @@ pub fn parse_create_table(
|
||||||
}
|
}
|
||||||
Keyword::ENABLE_SCHEMA_EVOLUTION => {
|
Keyword::ENABLE_SCHEMA_EVOLUTION => {
|
||||||
parser.expect_token(&Token::Eq)?;
|
parser.expect_token(&Token::Eq)?;
|
||||||
let enable_schema_evolution =
|
builder = builder.enable_schema_evolution(Some(parser.parse_boolean_string()?));
|
||||||
match parser.parse_one_of_keywords(&[Keyword::TRUE, Keyword::FALSE]) {
|
|
||||||
Some(Keyword::TRUE) => true,
|
|
||||||
Some(Keyword::FALSE) => false,
|
|
||||||
_ => {
|
|
||||||
return parser.expected("TRUE or FALSE", next_token);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
builder = builder.enable_schema_evolution(Some(enable_schema_evolution));
|
|
||||||
}
|
}
|
||||||
Keyword::CHANGE_TRACKING => {
|
Keyword::CHANGE_TRACKING => {
|
||||||
parser.expect_token(&Token::Eq)?;
|
parser.expect_token(&Token::Eq)?;
|
||||||
let change_tracking =
|
builder = builder.change_tracking(Some(parser.parse_boolean_string()?));
|
||||||
match parser.parse_one_of_keywords(&[Keyword::TRUE, Keyword::FALSE]) {
|
|
||||||
Some(Keyword::TRUE) => true,
|
|
||||||
Some(Keyword::FALSE) => false,
|
|
||||||
_ => {
|
|
||||||
return parser.expected("TRUE or FALSE", next_token);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
builder = builder.change_tracking(Some(change_tracking));
|
|
||||||
}
|
}
|
||||||
Keyword::DATA_RETENTION_TIME_IN_DAYS => {
|
Keyword::DATA_RETENTION_TIME_IN_DAYS => {
|
||||||
parser.expect_token(&Token::Eq)?;
|
parser.expect_token(&Token::Eq)?;
|
||||||
|
|
|
@ -9772,7 +9772,7 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse a boolean string
|
/// Parse a boolean string
|
||||||
pub fn parse_boolean_string(&mut self) -> Result<bool, ParserError> {
|
pub(crate) fn parse_boolean_string(&mut self) -> Result<bool, ParserError> {
|
||||||
match self.parse_one_of_keywords(&[Keyword::TRUE, Keyword::FALSE]) {
|
match self.parse_one_of_keywords(&[Keyword::TRUE, Keyword::FALSE]) {
|
||||||
Some(Keyword::TRUE) => Ok(true),
|
Some(Keyword::TRUE) => Ok(true),
|
||||||
Some(Keyword::FALSE) => Ok(false),
|
Some(Keyword::FALSE) => Ok(false),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue