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

Function parse_reduce

src/expr-parser/src/parser.rs:488–527  ·  view source on GitHub ↗
(ctx: CtxRef, input: ParseStream)

Source from the content-addressed store, hash-verified

486 }
487
488 fn parse_reduce(ctx: CtxRef, input: ParseStream) -> Result {
489 let reduce = input.parse::<kw::Reduce>()?;
490
491 let group_key = if input.eat(kw::group_by) {
492 input.parse::<syn::Token![=]>()?;
493 let inner;
494 syn::bracketed!(inner in input);
495 inner.parse_comma_sep(scalar::parse_expr)?
496 } else {
497 vec![]
498 };
499
500 let aggregates = {
501 input.parse::<kw::aggregates>()?;
502 input.parse::<syn::Token![=]>()?;
503 let inner;
504 syn::bracketed!(inner in input);
505 inner.parse_comma_sep(aggregate::parse_expr)?
506 };
507
508 let monotonic = input.eat(kw::monotonic);
509
510 let expected_group_size = if input.eat(kw::exp_group_size) {
511 input.parse::<syn::Token![=]>()?;
512 Some(input.parse::<syn::LitInt>()?.base10_parse::<u64>()?)
513 } else {
514 None
515 };
516
517 let parse_inputs = ParseChildren::new(input, reduce.span().start());
518 let input = Box::new(parse_inputs.parse_one(ctx, parse_expr)?);
519
520 Ok(MirRelationExpr::Reduce {
521 input,
522 group_key,
523 aggregates,
524 monotonic,
525 expected_group_size,
526 })
527 }
528
529 fn parse_top_k(ctx: CtxRef, input: ParseStream) -> Result {
530 let top_k = input.parse::<kw::TopK>()?;

Callers 1

parse_exprFunction · 0.85

Calls 5

eatMethod · 0.80
parse_comma_sepMethod · 0.80
spanMethod · 0.80
parse_oneMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected