Constructs a constant collection from specific rows and schema, where each row can have an arbitrary multiplicity.
(rows: Vec<(Vec<Datum>, Diff)>, typ: ReprRelationType)
| 1074 | /// Constructs a constant collection from specific rows and schema, where |
| 1075 | /// each row can have an arbitrary multiplicity. |
| 1076 | pub fn constant_diff(rows: Vec<(Vec<Datum>, Diff)>, typ: ReprRelationType) -> Self { |
| 1077 | for (row, _diff) in &rows { |
| 1078 | for (datum, column_typ) in row.iter().zip_eq(typ.column_types.iter()) { |
| 1079 | assert!( |
| 1080 | datum.is_instance_of(column_typ), |
| 1081 | "Expected datum of type {:?}, got value {:?}", |
| 1082 | column_typ, |
| 1083 | datum |
| 1084 | ); |
| 1085 | } |
| 1086 | } |
| 1087 | let rows = Ok(rows |
| 1088 | .into_iter() |
| 1089 | .map(move |(row, diff)| (Row::pack_slice(&row), diff)) |
| 1090 | .collect()); |
| 1091 | MirRelationExpr::Constant { rows, typ } |
| 1092 | } |
| 1093 | |
| 1094 | /// If self is a constant, return the value and the type, otherwise `None`. |
| 1095 | /// Looks behind `ArrangeBy`s. |