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

Method parse_case_expr

src/sql-parser/src/parser.rs:945–973  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

943 }
944
945 fn parse_case_expr(&mut self) -> Result<Expr<Raw>, ParserError> {
946 let mut operand = None;
947 if !self.parse_keyword(WHEN) {
948 operand = Some(Box::new(self.parse_expr()?));
949 self.expect_keyword(WHEN)?;
950 }
951 let mut conditions = vec![];
952 let mut results = vec![];
953 loop {
954 conditions.push(self.parse_expr()?);
955 self.expect_keyword(THEN)?;
956 results.push(self.parse_expr()?);
957 if !self.parse_keyword(WHEN) {
958 break;
959 }
960 }
961 let else_result = if self.parse_keyword(ELSE) {
962 Some(Box::new(self.parse_expr()?))
963 } else {
964 None
965 };
966 self.expect_keyword(END)?;
967 Ok(Expr::Case {
968 operand,
969 conditions,
970 results,
971 else_result,
972 })
973 }
974
975 /// Parse a SQL CAST function e.g. `CAST(expr AS FLOAT)`
976 fn parse_cast_expr(&mut self) -> Result<Expr<Raw>, ParserError> {

Callers 1

parse_prefixMethod · 0.80

Calls 4

parse_keywordMethod · 0.80
parse_exprMethod · 0.80
expect_keywordMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected