MCPcopy Create free account
hub / github.com/PRQL/prql / apply_active_mapping

Method apply_active_mapping

prqlc/prqlc/src/sql/pq/positional_mapping.rs:29–47  ·  view source on GitHub ↗

Reorder or remove columns to make `Union` happy.

(&mut self, output: Vec<CId>)

Source from the content-addressed store, hash-verified

27
28 /// Reorder or remove columns to make `Union` happy.
29 pub(crate) fn apply_active_mapping(&mut self, output: Vec<CId>) -> Vec<CId> {
30 if let Some(mapping) = &self.active_positional_mapping {
31 // Check if the mapping indices are valid for the output
32 if mapping.iter().any(|idx| *idx >= output.len()) {
33 log::warn!(
34 "positional mapping indices out of bounds: mapping={mapping:?}, output_len={}",
35 output.len()
36 );
37 // If mapping is invalid, don't apply it
38 return output;
39 }
40
41 let new_output = mapping.iter().map(|idx| output[*idx]).collect();
42 log::debug!("remapping {output:?} to {new_output:?} via {mapping:?}");
43 new_output
44 } else {
45 output
46 }
47 }
48
49 pub fn compute_and_store_mapping(&mut self, before: &[CId], after: &[CId], riid: &RIId) {
50 let mapping: Vec<_> = after

Callers 1

extract_atomicFunction · 0.80

Calls 4

iterMethod · 0.80
lenMethod · 0.80
mapMethod · 0.80
collectMethod · 0.45

Tested by

no test coverage detected