Take ownership of `self`, leaving an empty `MirRelationExpr::Constant` with the optionally given scalar types. The given scalar types should be `base_eq` with the types that `typ()` would find. Keys and nullability are ignored in the given `SqlRelationType`, and instead we set the best possible key and nullability, since we are making an empty collection. If `typ` is not given, then this calls `.
(&mut self, typ: Option<ReprRelationType>)
| 1518 | /// If `typ` is not given, then this calls `.typ()` (which is possibly expensive) to determine |
| 1519 | /// the correct type. |
| 1520 | pub fn take_safely(&mut self, typ: Option<ReprRelationType>) -> MirRelationExpr { |
| 1521 | if let Some(typ) = &typ { |
| 1522 | let self_typ = self.typ(); |
| 1523 | soft_assert_no_log!( |
| 1524 | self_typ |
| 1525 | .column_types |
| 1526 | .iter() |
| 1527 | .zip_eq(typ.column_types.iter()) |
| 1528 | .all(|(t1, t2)| t1.scalar_type == t2.scalar_type) |
| 1529 | ); |
| 1530 | } |
| 1531 | let mut typ = typ.unwrap_or_else(|| self.typ()); |
| 1532 | typ.keys = vec![vec![]]; |
| 1533 | for ct in typ.column_types.iter_mut() { |
| 1534 | ct.nullable = false; |
| 1535 | } |
| 1536 | std::mem::replace( |
| 1537 | self, |
| 1538 | MirRelationExpr::Constant { |
| 1539 | rows: Ok(vec![]), |
| 1540 | typ, |
| 1541 | }, |
| 1542 | ) |
| 1543 | } |
| 1544 | |
| 1545 | /// Take ownership of `self`, leaving an empty `MirRelationExpr::Constant` with the given scalar |
| 1546 | /// types. Nullability is ignored in the given `SqlColumnType`s, and instead we set the best |
no test coverage detected