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

Method apply_demand

src/repr/src/relation.rs:1444–1468  ·  view source on GitHub ↗

Creates a new [`RelationDesc`] retaining only the columns specified in `demands`.

(&self, demands: &BTreeSet<usize>)

Source from the content-addressed store, hash-verified

1442
1443 /// Creates a new [`RelationDesc`] retaining only the columns specified in `demands`.
1444 pub fn apply_demand(&self, demands: &BTreeSet<usize>) -> RelationDesc {
1445 let mut new_desc = self.clone();
1446
1447 // Update ColumnMetadata.
1448 let mut removed = 0;
1449 new_desc.metadata.retain(|idx, metadata| {
1450 let retain = demands.contains(&idx.0);
1451 if !retain {
1452 removed += 1;
1453 } else {
1454 metadata.typ_idx -= removed;
1455 }
1456 retain
1457 });
1458
1459 // Update SqlColumnType.
1460 let mut idx = 0;
1461 new_desc.typ.column_types.retain(|_| {
1462 let keep = demands.contains(&idx);
1463 idx += 1;
1464 keep
1465 });
1466
1467 new_desc
1468 }
1469}
1470
1471#[cfg(any(test, feature = "proptest"))]

Callers 4

apply_demandFunction · 0.80
smoketest_projectionFunction · 0.80
build_compute_dataflowFunction · 0.80

Calls 2

cloneMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected