helix_ir.normalize

helix_ir.normalize — schema normalization.

helix_ir.normalize.normalize(schema: Schema, strategy: str = '1nf', inline_threshold: int = 5) NormalizationPlan[source]

Normalize a nested Schema into a set of relational tables.

Parameters:
  • schema – The source schema (may contain nested structs and arrays).

  • strategy – Normalization strategy: ‘1nf’ — extract all arrays to child tables, flatten structs. ‘mongo’ — keep arrays and structs as JSON/SUPER columns. ‘inline_small’ — inline small arrays (cardinality <= inline_threshold). ‘custom’ — same as ‘1nf’ (extend by subclassing decomposer).

  • inline_threshold – For ‘inline_small’, max cardinality to inline.

Returns:

A NormalizationPlan with one or more Schema tables and FK relationships.

class helix_ir.normalize.NormalizationPlan(tables: list[Schema] = <factory>, foreign_keys: list[ForeignKey] = <factory>, lineage: Lineage = <factory>)[source]

Bases: object

The output of normalize(): a set of tables with FK relationships.

tables: list[Schema]
foreign_keys: list[ForeignKey]
lineage: Lineage
root_table() Schema[source]

Return the root (first) table — typically the main entity table.

table_names() list[str][source]
get_table(name: str) Schema | None[source]
class helix_ir.normalize.ForeignKey(from_table: str, from_column: str, to_table: str, to_column: str)[source]

Bases: object

A foreign key relationship between two tables.

from_table: str
from_column: str
to_table: str
to_column: str