Skip to content

Expand SQLCompiler to cover more of the TransformationSpecification #150

@amc-corey-cox

Description

@amc-corey-cox

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:

  1. Expression compilation — compile Python expressions (expr field) to equivalent SQL where possible (arithmetic, string concatenation, simple conditionals)
  2. Enum derivations — compile EnumDerivation / PermissibleValueDerivation to SQL CASE statements
  3. Join support — cross-class slot lookups (populated_from: org_id.name) as SQL JOINs
  4. Unit conversion — compile unit_conversion to SQL arithmetic where conversion factors are known
  5. Copy directivescopy_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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions