Creates [SqlTransform::Union] from [Transform::Append]
(
pipeline: Vec<SqlTransform>,
ctx: &mut Context,
)
| 275 | |
| 276 | /// Creates [SqlTransform::Union] from [Transform::Append] |
| 277 | pub(in crate::sql) fn union( |
| 278 | pipeline: Vec<SqlTransform>, |
| 279 | ctx: &mut Context, |
| 280 | ) -> Result<Vec<SqlTransform>> { |
| 281 | use SqlTransform::*; |
| 282 | use Transform::*; |
| 283 | |
| 284 | let mut res = Vec::with_capacity(pipeline.len()); |
| 285 | let mut pipeline = pipeline.into_iter().peekable(); |
| 286 | while let Some(t) = pipeline.next() { |
| 287 | let Super(Append(bottom)) = t else { |
| 288 | res.push(t); |
| 289 | continue; |
| 290 | }; |
| 291 | let bottom = ctx.anchor.create_relation_instance(bottom, HashMap::new()); |
| 292 | |
| 293 | let distinct = if let Some(Distinct) = &pipeline.peek() { |
| 294 | pipeline.next(); |
| 295 | true |
| 296 | } else { |
| 297 | false |
| 298 | }; |
| 299 | |
| 300 | res.push(SqlTransform::Union { bottom, distinct }); |
| 301 | } |
| 302 | Ok(res) |
| 303 | } |
| 304 | |
| 305 | /// Creates [SqlTransform::Except] from [Transform::Join] and [Transform::Filter] |
| 306 | pub(in crate::sql) fn except( |
no test coverage detected