MCPcopy Create free account
hub / github.com/PRQL/prql / fold_sql_transform

Function fold_sql_transform

prqlc/prqlc/src/sql/pq/ast.rs:157–204  ·  view source on GitHub ↗
(
    fold: &mut F,
    transform: SqlTransform<RelIn, SuperIn>,
)

Source from the content-addressed store, hash-verified

155}
156
157pub fn fold_sql_transform<
158 RelIn,
159 RelOut,
160 SuperIn,
161 SuperOut,
162 F: ?Sized + PqMapper<RelIn, RelOut, SuperIn, SuperOut>,
163>(
164 fold: &mut F,
165 transform: SqlTransform<RelIn, SuperIn>,
166) -> Result<SqlTransform<RelOut, SuperOut>> {
167 Ok(match transform {
168 SqlTransform::Super(t) => SqlTransform::Super(fold.fold_super(t)?),
169
170 SqlTransform::From(rel) => SqlTransform::From(fold.fold_rel(rel)?),
171 SqlTransform::Join { side, with, filter } => SqlTransform::Join {
172 side,
173 with: fold.fold_rel(with)?,
174 filter: fold.fold_expr(filter)?,
175 },
176
177 SqlTransform::Distinct => SqlTransform::Distinct,
178 SqlTransform::DistinctOn(ids) => SqlTransform::DistinctOn(fold.fold_cids(ids)?),
179 SqlTransform::Union { bottom, distinct } => SqlTransform::Union {
180 bottom: fold.fold_rel(bottom)?,
181 distinct,
182 },
183 SqlTransform::Except { bottom, distinct } => SqlTransform::Except {
184 bottom: fold.fold_rel(bottom)?,
185 distinct,
186 },
187 SqlTransform::Intersect { bottom, distinct } => SqlTransform::Intersect {
188 bottom: fold.fold_rel(bottom)?,
189 distinct,
190 },
191 SqlTransform::Select(v) => SqlTransform::Select(fold.fold_cids(v)?),
192 SqlTransform::Filter(v) => SqlTransform::Filter(fold.fold_expr(v)?),
193 SqlTransform::Aggregate { partition, compute } => SqlTransform::Aggregate {
194 partition: fold.fold_cids(partition)?,
195 compute: fold.fold_cids(compute)?,
196 },
197 SqlTransform::Sort(v) => SqlTransform::Sort(fold_column_sorts(fold, v)?),
198 SqlTransform::Take(take) => SqlTransform::Take(rq::Take {
199 partition: fold.fold_cids(take.partition)?,
200 sort: fold_column_sorts(fold, take.sort)?,
201 range: take.range,
202 }),
203 })
204}
205
206pub trait PqFold: PqMapper<RelationExpr, RelationExpr, (), ()> {
207 fn fold_sql_query(&mut self, query: SqlQuery) -> Result<SqlQuery> {

Callers 1

fold_sql_transformsMethod · 0.85

Calls 6

TakeClass · 0.85
fold_cidsMethod · 0.80
fold_column_sortsFunction · 0.50
fold_superMethod · 0.45
fold_relMethod · 0.45
fold_exprMethod · 0.45

Tested by

no test coverage detected