mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-31 19:27:21 +00:00
Improve the create statement parser that uses create statements from pg database dump
Added PostgreSQL style casting
This commit is contained in:
parent
7d27abdfb4
commit
2007995938
6 changed files with 392 additions and 81 deletions
|
@ -66,6 +66,14 @@ pub enum Token {
|
|||
RParen,
|
||||
/// Period (used for compound identifiers or projections into nested types)
|
||||
Period,
|
||||
/// Colon `:`
|
||||
Colon,
|
||||
/// DoubleColon `::` (used for casting in postgresql)
|
||||
DoubleColon,
|
||||
/// Left bracket `[`
|
||||
LBracket,
|
||||
/// Right bracket `]`
|
||||
RBracket,
|
||||
}
|
||||
|
||||
/// Tokenizer error
|
||||
|
@ -243,6 +251,23 @@ impl<'a> Tokenizer<'a> {
|
|||
None => Ok(Some(Token::Gt)),
|
||||
}
|
||||
}
|
||||
// colon
|
||||
':' => {
|
||||
chars.next();
|
||||
match chars.peek() {
|
||||
Some(&ch) => match ch {
|
||||
// double colon
|
||||
':' => {
|
||||
self.consume_and_return(chars, Token::DoubleColon)
|
||||
}
|
||||
_ => Ok(Some(Token::Colon)),
|
||||
},
|
||||
None => Ok(Some(Token::Colon)),
|
||||
}
|
||||
}
|
||||
// brakets
|
||||
'[' => self.consume_and_return(chars, Token::LBracket),
|
||||
']' => self.consume_and_return(chars, Token::RBracket),
|
||||
_ => Err(TokenizerError(format!(
|
||||
"Tokenizer Error at Line: {}, Column: {}, unhandled char '{}'",
|
||||
self.line, self.col, ch
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue