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

Method filter

src/expr/src/relation.rs:1206–1231  ·  view source on GitHub ↗

Retain only the rows satisfying each of several predicates.

(mut self, predicates: I)

Source from the content-addressed store, hash-verified

1204
1205 /// Retain only the rows satisfying each of several predicates.
1206 pub fn filter<I>(mut self, predicates: I) -> Self
1207 where
1208 I: IntoIterator<Item = MirScalarExpr>,
1209 {
1210 // Extract existing predicates
1211 let mut new_predicates = if let MirRelationExpr::Filter { input, predicates } = self {
1212 self = *input;
1213 predicates
1214 } else {
1215 Vec::new()
1216 };
1217 // Normalize collection of predicates.
1218 new_predicates.extend(predicates);
1219 new_predicates.retain(|p| !p.is_literal_true());
1220 new_predicates.sort();
1221 new_predicates.dedup();
1222 // Introduce a `Filter` only if we have predicates.
1223 if !new_predicates.is_empty() {
1224 self = MirRelationExpr::Filter {
1225 input: Box::new(self),
1226 predicates: new_predicates,
1227 };
1228 }
1229
1230 self
1231 }
1232
1233 /// Form the Cartesian outer-product of rows in both inputs.
1234 pub fn product(mut self, right: Self) -> Self {

Callers 1

keys_with_input_keysMethod · 0.45

Calls 4

sortMethod · 0.80
extendMethod · 0.45
is_literal_trueMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected