MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parse_position_expr

Method parse_position_expr

src/sql-parser/src/parser.rs:1142–1157  ·  view source on GitHub ↗

Parse calls to position(), which has the special form position('string' in 'string').

(&mut self)

Source from the content-addressed store, hash-verified

1140
1141 // Parse calls to position(), which has the special form position('string' in 'string').
1142 fn parse_position_expr(&mut self) -> Result<Expr<Raw>, ParserError> {
1143 self.expect_token(&Token::LParen)?;
1144 // we must be greater-equal the precedence of IN, which is Like to avoid
1145 // parsing away the IN as part of the sub expression
1146 let needle = self.parse_subexpr(Precedence::Like)?;
1147 self.expect_token(&Token::Keyword(IN))?;
1148 let haystack = self.parse_expr()?;
1149 self.expect_token(&Token::RParen)?;
1150 Ok(Expr::Function(Function {
1151 name: RawItemName::Name(UnresolvedItemName::unqualified(ident!("position"))),
1152 args: FunctionArgs::args(vec![needle, haystack]),
1153 filter: None,
1154 over: None,
1155 distinct: false,
1156 }))
1157 }
1158
1159 /// Parse calls to normalize(), which can take the form:
1160 /// - normalize('string')

Callers 1

parse_prefixMethod · 0.80

Calls 5

FunctionClass · 0.85
expect_tokenMethod · 0.80
parse_subexprMethod · 0.80
parse_exprMethod · 0.80
NameClass · 0.50

Tested by

no test coverage detected