(relation: RelationAdapter, ctx: &mut Context)
| 55 | } |
| 56 | |
| 57 | fn compile_relation(relation: RelationAdapter, ctx: &mut Context) -> Result<pq::SqlRelation> { |
| 58 | log::trace!("compiling relation {relation:#?}"); |
| 59 | |
| 60 | Ok(match relation { |
| 61 | RelationAdapter::Rq(rel) => { |
| 62 | match rel.kind { |
| 63 | // base case |
| 64 | rq::RelationKind::Pipeline(pipeline) => { |
| 65 | // preprocess |
| 66 | let pipeline = preprocess::preprocess(pipeline, ctx)?; |
| 67 | |
| 68 | // load names of output columns |
| 69 | ctx.anchor.load_names(&pipeline, rel.columns); |
| 70 | |
| 71 | compile_pipeline(pipeline, ctx)? |
| 72 | } |
| 73 | |
| 74 | rq::RelationKind::Literal(lit) => pq::SqlRelation::Literal(lit), |
| 75 | rq::RelationKind::SString(items) => pq::SqlRelation::SString(items), |
| 76 | rq::RelationKind::BuiltInFunction { name, args } => { |
| 77 | pq::SqlRelation::Operator { name, args } |
| 78 | } |
| 79 | |
| 80 | // ref cannot be converted directly into query and does not need it's own CTE |
| 81 | rq::RelationKind::ExternRef(_) => unreachable!(), |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | RelationAdapter::Preprocessed(pipeline, columns) => { |
| 86 | // load names of output columns |
| 87 | ctx.anchor.load_names(&pipeline, columns); |
| 88 | |
| 89 | compile_pipeline(pipeline, ctx)? |
| 90 | } |
| 91 | |
| 92 | RelationAdapter::Pq(rel) => rel, |
| 93 | }) |
| 94 | } |
| 95 | |
| 96 | fn compile_pipeline( |
| 97 | mut pipeline: Vec<pq::SqlTransform>, |
no test coverage detected