Append a Select of final table columns derived from frame
(
&mut self,
lineage: Option<Lineage>,
transforms: &mut Vec<Transform>,
)
| 656 | |
| 657 | /// Append a Select of final table columns derived from frame |
| 658 | fn push_select( |
| 659 | &mut self, |
| 660 | lineage: Option<Lineage>, |
| 661 | transforms: &mut Vec<Transform>, |
| 662 | ) -> Result<Vec<RelationColumn>> { |
| 663 | let lineage = lineage.unwrap_or_default(); |
| 664 | |
| 665 | log::debug!("push_select of a frame: {lineage:?}"); |
| 666 | |
| 667 | let mut columns = Vec::new(); |
| 668 | |
| 669 | // normal columns |
| 670 | for col in &lineage.columns { |
| 671 | match col { |
| 672 | LineageColumn::Single { |
| 673 | name, |
| 674 | target_id, |
| 675 | target_name, |
| 676 | } => { |
| 677 | let cid = self.lookup_cid(*target_id, target_name.as_ref())?; |
| 678 | |
| 679 | let name = name.as_ref().map(|i| i.name.clone()); |
| 680 | columns.push((RelationColumn::Single(name), cid)); |
| 681 | } |
| 682 | LineageColumn::All { input_id, except } => { |
| 683 | let Some(input) = lineage.find_input(*input_id) else { |
| 684 | return Err(Error::new_simple( |
| 685 | "column references a table not accessible in this context", |
| 686 | ) |
| 687 | .push_hint("join is not supported inside group")); |
| 688 | }; |
| 689 | |
| 690 | match &self.node_mapping[&input.id] { |
| 691 | LoweredTarget::Compute(_cid) => unreachable!(), |
| 692 | LoweredTarget::Input(input_cols) => { |
| 693 | let mut input_cols = input_cols |
| 694 | .iter() |
| 695 | .filter(|(c, _)| match c { |
| 696 | RelationColumn::Single(Some(name)) => !except.contains(name), |
| 697 | _ => true, |
| 698 | }) |
| 699 | .collect_vec(); |
| 700 | input_cols.sort_by_key(|e| e.1 .1); |
| 701 | |
| 702 | for (col, (cid, _)) in input_cols { |
| 703 | columns.push((col.clone(), *cid)); |
| 704 | } |
| 705 | } |
| 706 | } |
| 707 | } |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | let (cols, cids) = columns.into_iter().unzip(); |
| 712 | |
| 713 | log::debug!("... cids={cids:?}"); |
| 714 | transforms.push(Transform::Select(cids)); |
| 715 |
no test coverage detected