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

Function preprocess

prqlc/prqlc/src/sql/pq/preprocess.rs:22–38  ·  view source on GitHub ↗

Converts RQ AST into SqlRQ AST and applies a few preprocessing operations. Note that some SQL translation mechanisms depend on behavior of some of these functions (i.e. reorder).

(
    pipeline: Vec<Transform>,
    ctx: &mut Context,
)

Source from the content-addressed store, hash-verified

20/// Note that some SQL translation mechanisms depend on behavior of some of these
21/// functions (i.e. reorder).
22pub(in crate::sql) fn preprocess(
23 pipeline: Vec<Transform>,
24 ctx: &mut Context,
25) -> Result<Vec<SqlTransform>> {
26 Ok(pipeline)
27 .and_then(normalize)
28 .and_then(|p| wrap(p, ctx))
29 .and_then(|p| prune_inputs(p, ctx))
30 .and_then(|p| distinct(p, ctx))
31 .and_then(|p| union(p, ctx))
32 .and_then(|p| except(p, ctx))
33 .and_then(|p| intersect(p, ctx))
34 .map(reorder)
35 .inspect(|p| {
36 debug::log_entry(|| debug::DebugEntryKind::ReprPqEarly(p.clone()));
37 })
38}
39
40// This function was disabled because it changes semantics of the pipeline in some cases.
41// /// Pushes all [Transform::Select]s to the back of the pipeline.

Callers 2

compile_relationFunction · 0.85
compile_loopFunction · 0.85

Calls 8

wrapFunction · 0.85
prune_inputsFunction · 0.85
distinctFunction · 0.85
unionFunction · 0.85
exceptFunction · 0.85
intersectFunction · 0.85
log_entryFunction · 0.85
mapMethod · 0.80

Tested by

no test coverage detected