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

Function parse_flat_map

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

Source from the content-addressed store, hash-verified

347 }
348
349 fn parse_flat_map(ctx: CtxRef, input: ParseStream) -> Result {
350 use mz_expr::TableFunc::*;
351
352 let flat_map = input.parse::<kw::FlatMap>()?;
353
354 let ident = input.parse::<syn::Ident>()?;
355 let func = match ident.to_string().to_lowercase().as_str() {
356 "unnest_list" => UnnestList {
357 el_typ: SqlScalarType::Int64, // FIXME
358 },
359 "unnest_array" => UnnestArray {
360 el_typ: SqlScalarType::Int64, // FIXME
361 },
362 "wrap1" => Wrap {
363 types: vec![
364 SqlScalarType::Int64.nullable(true), // FIXME
365 ],
366 width: 1,
367 },
368 "wrap2" => Wrap {
369 types: vec![
370 SqlScalarType::Int64.nullable(true), // FIXME
371 SqlScalarType::Int64.nullable(true), // FIXME
372 ],
373 width: 2,
374 },
375 "wrap3" => Wrap {
376 types: vec![
377 SqlScalarType::Int64.nullable(true), // FIXME
378 SqlScalarType::Int64.nullable(true), // FIXME
379 SqlScalarType::Int64.nullable(true), // FIXME
380 ],
381 width: 3,
382 },
383 "generate_series" => GenerateSeriesInt64,
384 // Both int widths display as `generate_series`; this spelling lets a
385 // test pin the 32-bit variant (e.g. its widening casts) on input.
386 "generate_series_i32" => GenerateSeriesInt32,
387 "jsonb_object_keys" => JsonbObjectKeys,
388 _ => Err(Error::new(ident.span(), "unsupported function name"))?,
389 };
390
391 let exprs = {
392 let inner;
393 syn::parenthesized!(inner in input);
394 scalar::parse_exprs(&inner)?
395 };
396
397 let parse_input = ParseChildren::new(input, flat_map.span().start());
398 let input = Box::new(parse_input.parse_one(ctx, parse_expr)?);
399
400 Ok(MirRelationExpr::FlatMap { input, func, exprs })
401 }
402
403 fn parse_filter(ctx: CtxRef, input: ParseStream) -> Result {
404 use mz_expr::MirScalarExpr::CallVariadic;

Callers 1

parse_exprFunction · 0.85

Calls 6

parse_exprsFunction · 0.85
spanMethod · 0.80
parse_oneMethod · 0.80
as_strMethod · 0.45
to_stringMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected