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

Method union

src/expr/src/interpret.rs:50–79  ·  view source on GitHub ↗
(self, other: Values<'a>)

Source from the content-addressed store, hash-verified

48 }
49
50 fn union(self, other: Values<'a>) -> Values<'a> {
51 match (self, other) {
52 (Values::Empty, r) => r,
53 (r, Values::Empty) => r,
54 (Values::Within(a0, a1), Values::Within(b0, b1)) => {
55 Values::Within(a0.min(b0), a1.max(b1))
56 }
57 (Values::Nested(a), Values::Nested(mut b)) => {
58 // `Nested(map)` treats keys missing from `map` as fully unconstrained, so a
59 // key present in only one side of the union must be treated as `anything`
60 // on the other side. Because `x ∪ anything = anything`, such keys drop
61 // out of the merged map (the Nested default is already "anything").
62 let mut merged = BTreeMap::new();
63 for (key, a_spec) in a {
64 if let Some(b_spec) = b.remove(&key) {
65 let unioned = a_spec.union(b_spec);
66 if unioned != ResultSpec::anything() {
67 merged.insert(key, unioned);
68 }
69 }
70 }
71 if merged.is_empty() {
72 Values::All
73 } else {
74 Values::Nested(merged)
75 }
76 }
77 _ => Values::All,
78 }
79 }
80
81 fn intersect(self, other: Values<'a>) -> Values<'a> {
82 match (self, other) {

Callers 8

flat_mapMethod · 0.45
for_funcMethod · 0.45
eqMethod · 0.45
condMethod · 0.45
gen_columnFunction · 0.45
test_inequalityFunction · 0.45

Calls 5

minMethod · 0.80
maxMethod · 0.45
removeMethod · 0.45
insertMethod · 0.45
is_emptyMethod · 0.45