| 469 | } |
| 470 | |
| 471 | fn create_a_table_instance( |
| 472 | &mut self, |
| 473 | id: usize, |
| 474 | name: Option<String>, |
| 475 | tid: TId, |
| 476 | ) -> rq::TableRef { |
| 477 | // create instance columns from table columns |
| 478 | let table = self.table_buffer.iter().find(|t| t.id == tid).unwrap(); |
| 479 | |
| 480 | let columns = (table.relation.columns.iter()) |
| 481 | .cloned() |
| 482 | .unique() |
| 483 | .map(|col| (col, self.cid.gen())) |
| 484 | .collect_vec(); |
| 485 | |
| 486 | log::debug!("... columns = {columns:?}"); |
| 487 | |
| 488 | let input_cids: HashMap<_, _> = columns |
| 489 | .iter() |
| 490 | .cloned() |
| 491 | .enumerate() |
| 492 | .map(|(index, (col, cid))| (col, (cid, index))) |
| 493 | .collect(); |
| 494 | self.node_mapping |
| 495 | .insert(id, LoweredTarget::Input(input_cids)); |
| 496 | rq::TableRef { |
| 497 | source: tid, |
| 498 | name, |
| 499 | columns, |
| 500 | prefer_cte: true, |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | fn lower_relation(&mut self, expr: pl::Expr) -> Result<rq::Relation> { |
| 505 | let span = expr.span; |