LucaCappelletti94 commented on code in PR #2250:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2250#discussion_r3207479127
##########
src/parser/mod.rs:
##########
@@ -5173,6 +5180,145 @@ impl<'a> Parser<'a> {
}
}
+ fn parse_text_search_object_type(&mut self) ->
Result<TextSearchObjectType, ParserError> {
+ match self.expect_one_of_keywords(&[
+ Keyword::DICTIONARY,
+ Keyword::CONFIGURATION,
+ Keyword::TEMPLATE,
+ Keyword::PARSER,
+ ])? {
+ Keyword::DICTIONARY => Ok(TextSearchObjectType::Dictionary),
+ Keyword::CONFIGURATION => Ok(TextSearchObjectType::Configuration),
+ Keyword::TEMPLATE => Ok(TextSearchObjectType::Template),
+ Keyword::PARSER => Ok(TextSearchObjectType::Parser),
+ // unreachable because expect_one_of_keywords used above
+ unexpected_keyword => Err(ParserError::ParserError(format!(
+ "Internal parser error: expected any of {{DICTIONARY,
CONFIGURATION, TEMPLATE, PARSER}}, got {unexpected_keyword:?}"
+ ))),
+ }
+ }
+
+ fn parse_text_search_option(&mut self) -> Result<SqlOption, ParserError> {
+ let key = self.parse_identifier()?;
+ self.expect_token(&Token::Eq)?;
+ let value = self.parse_expr()?;
+ Ok(SqlOption::KeyValue { key, value })
+ }
+
+ /// Parse a PostgreSQL `CREATE TEXT SEARCH ...` statement.
+ pub fn parse_create_text_search(&mut self) -> Result<CreateTextSearch,
ParserError> {
+ let object_type = self.parse_text_search_object_type()?;
+ let name = self.parse_object_name(false)?;
+ self.expect_token(&Token::LParen)?;
+ let options =
self.parse_comma_separated(Parser::parse_text_search_option)?;
Review Comment:
Done. `CREATE TEXT SEARCH` now parses options through
`parse_comma_separated(Parser::parse_sql_option)`.
--
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]