Skip to main content

Module compiler

Module compiler 

Source
Expand description

ViewDefinition compiler (SQLite/PostgreSQL SQL and MongoDB pipelines).

Thin façade over the IR-based pipeline:

  1. build_plan walks the ViewDefinition JSON and produces a PlanNode tree plus the resolved ViewDefinition.constant[] values. The CompileTarget tunes target-specific lowering (e.g. trailing-[N] forEach).
  2. The emitter lowers the plan to the target form: emit_plan for SQL via the Dialect trait, or emit_mongo for a MongoDB aggregation pipeline.

Returns SofError::Uncompilable for FHIRPath constructs the in-DB pipeline doesn’t yet handle (e.g. where(crit) chains, the boundary functions without a column type hint, deeper unionAll/repeat nesting). There is no in-process fallback — the REST handler maps these errors to 422 Unprocessable Entity.

Structs§

CompiledPipeline
Output of compiling a ViewDefinition to a MongoDB aggregation pipeline.
CompiledQuery
Output of a successful ViewDefinition compilation.

Enums§

CompileTarget
Backend a ViewDefinition is being compiled for. Drives target-specific lowering decisions in build_plan (e.g. whether trailing-[N] forEach paths may use a correlated subquery) and selects the emitter.
CompiledView
Compiled SQL-on-FHIR view, in the form the target backend executes: parameterised SQL, or a MongoDB aggregation pipeline.
SqlDialect
SQL dialect to target during compilation.

Functions§

compile_view_definition
Compiles a raw ViewDefinition JSON value into a CompiledQuery for SQLite.
compile_view_definition_dialect
Compiles a raw ViewDefinition JSON value into a CompiledQuery for the given dialect.
compile_view_definition_mongo
Compiles a raw ViewDefinition JSON value into a MongoDB aggregation pipeline.