Context
The SQLCompiler currently supports a limited subset of the TransformationSpecification:
- Simple
populated_from slot derivations
- Basic stringification (JSON cast, delimiter-based aggregation)
The TransformationSpecification is intended to be a declarative IR that can be executed by
different backends. The Python ObjectTransformer supports the full spec; the SQL backend
should grow toward parity over time.
Proposed work
Incrementally expand SQLCompiler to support more spec features, prioritized by utility:
- Expression compilation — compile Python expressions (
expr field) to equivalent SQL where possible (arithmetic, string concatenation, simple conditionals)
- Enum derivations — compile
EnumDerivation / PermissibleValueDerivation to SQL CASE statements
- Join support — cross-class slot lookups (
populated_from: org_id.name) as SQL JOINs
- Unit conversion — compile
unit_conversion to SQL arithmetic where conversion factors are known
- Copy directives —
copy_all / exclude as SELECT * EXCEPT patterns (DuckDB supports this)
Each of these can be a separate PR. The compiler should raise a clear error when it encounters
a spec feature it cannot compile, rather than silently producing incorrect SQL.
Non-goals
This is about expanding what the SQL compiler can express, not about adding new output formats
or changing the streaming/serialization layer.
Related
src/linkml_map/compiler/sql_compiler.py
src/linkml_map/transformer/duckdb_transformer.py
- SQL Compilation tutorial notebook:
docs/examples/Tutorial-SQLCompiler.ipynb
Context
The
SQLCompilercurrently supports a limited subset of theTransformationSpecification:populated_fromslot derivationsThe
TransformationSpecificationis intended to be a declarative IR that can be executed bydifferent backends. The Python
ObjectTransformersupports the full spec; the SQL backendshould grow toward parity over time.
Proposed work
Incrementally expand
SQLCompilerto support more spec features, prioritized by utility:exprfield) to equivalent SQL where possible (arithmetic, string concatenation, simple conditionals)EnumDerivation/PermissibleValueDerivationto SQL CASE statementspopulated_from: org_id.name) as SQL JOINsunit_conversionto SQL arithmetic where conversion factors are knowncopy_all/excludeas SELECT * EXCEPT patterns (DuckDB supports this)Each of these can be a separate PR. The compiler should raise a clear error when it encounters
a spec feature it cannot compile, rather than silently producing incorrect SQL.
Non-goals
This is about expanding what the SQL compiler can express, not about adding new output formats
or changing the streaming/serialization layer.
Related
src/linkml_map/compiler/sql_compiler.pysrc/linkml_map/transformer/duckdb_transformer.pydocs/examples/Tutorial-SQLCompiler.ipynb