(
context: &mut ParserContext,
env: &mut Environment,
tokens: &[Token],
position: &mut usize,
)
| 1249 | } |
| 1250 | |
| 1251 | fn parse_window_named_over_clause( |
| 1252 | context: &mut ParserContext, |
| 1253 | env: &mut Environment, |
| 1254 | tokens: &[Token], |
| 1255 | position: &mut usize, |
| 1256 | ) -> Result<(), Box<Diagnostic>> { |
| 1257 | consume_token_or_error( |
| 1258 | tokens, |
| 1259 | position, |
| 1260 | TokenKind::Window, |
| 1261 | "Expect `WINDOW` keyword.", |
| 1262 | )?; |
| 1263 | |
| 1264 | let window_name_token = consume_conditional_token_or_errors( |
| 1265 | tokens, |
| 1266 | position, |
| 1267 | |t| matches!(t.kind, TokenKind::Symbol(_)), |
| 1268 | "Expect `Identifier` as window over clauses name.", |
| 1269 | )?; |
| 1270 | |
| 1271 | let location = window_name_token.location; |
| 1272 | let window_name = window_name_token.to_string(); |
| 1273 | |
| 1274 | consume_token_or_error( |
| 1275 | tokens, |
| 1276 | position, |
| 1277 | TokenKind::As, |
| 1278 | "Expect `AS` keyword after window name.", |
| 1279 | )?; |
| 1280 | |
| 1281 | let over_clauses = parse_over_window_definition(context, env, tokens, position)?; |
| 1282 | |
| 1283 | // Make sure each window clauses has unique name |
| 1284 | if context.named_window_clauses.contains_key(&window_name) { |
| 1285 | return Err(Diagnostic::error(&format!( |
| 1286 | "There is already defined window clauses with name {window_name}" |
| 1287 | )) |
| 1288 | .add_note("Window over clauses names must be unique from each other") |
| 1289 | .with_location(location) |
| 1290 | .as_boxed()); |
| 1291 | } |
| 1292 | |
| 1293 | // Register window over clauses with name |
| 1294 | context |
| 1295 | .named_window_clauses |
| 1296 | .insert(window_name, over_clauses); |
| 1297 | |
| 1298 | Ok(()) |
| 1299 | } |
| 1300 | |
| 1301 | pub(crate) fn parse_expression( |
| 1302 | context: &mut ParserContext, |
no test coverage detected
searching dependent graphs…