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

Method union_many

src/expr/src/relation.rs:1405–1430  ·  view source on GitHub ↗

Unions together any number inputs. If `inputs` is empty, then an empty relation of type `typ` is constructed.

(mut inputs: Vec<Self>, typ: ReprRelationType)

Source from the content-addressed store, hash-verified

1403 /// If `inputs` is empty, then an empty relation of type `typ` is
1404 /// constructed.
1405 pub fn union_many(mut inputs: Vec<Self>, typ: ReprRelationType) -> Self {
1406 // Deconstruct `inputs` as `Union`s and reconstitute.
1407 let mut flat_inputs = Vec::with_capacity(inputs.len());
1408 for input in inputs {
1409 if let MirRelationExpr::Union { base, inputs } = input {
1410 flat_inputs.push(*base);
1411 flat_inputs.extend(inputs);
1412 } else {
1413 flat_inputs.push(input);
1414 }
1415 }
1416 inputs = flat_inputs;
1417 if inputs.len() == 0 {
1418 MirRelationExpr::Constant {
1419 rows: Ok(vec![]),
1420 typ,
1421 }
1422 } else if inputs.len() == 1 {
1423 inputs.into_element()
1424 } else {
1425 MirRelationExpr::Union {
1426 base: Box::new(inputs.remove(0)),
1427 inputs,
1428 }
1429 }
1430 }
1431
1432 /// Produces one collection where each row is present with the sum of its frequencies in each input.
1433 pub fn union(self, other: Self) -> Self {

Callers

nothing calls this directly

Calls 5

into_elementMethod · 0.80
lenMethod · 0.45
pushMethod · 0.45
extendMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected