cdm_data_loaders.converters.core.dlt_normalization ¶
Lossless, parent-linked normalization of dlt table definitions.
DltNormalizationError ¶
Bases: ConversionError
Raised for malformed tables, invalid parent graphs, or inconsistent trees.
DltTableNode
dataclass
¶
A table with its mapping name, declared parent, property key, and raw definition.
Roots use their mapping name as their key. Children are keyed by property name in declaration order. Table metadata and column definitions remain unfiltered. Identity fields are frozen; table and children mappings are independently owned.
Source code in src/cdm_data_loaders/converters/core/dlt_normalization.py
child_key ¶
Remove exactly one declared-parent prefix, or return the full child name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_name
|
str
|
declared parent table name |
required |
child_name
|
str
|
full child table name |
required |
Returns:
| Type | Description |
|---|---|
str
|
property key relative to |
Source code in src/cdm_data_loaders/converters/core/dlt_normalization.py
child_table_name ¶
Join a parent table name and property key without interpreting either path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_name
|
str
|
declared parent table name |
required |
key
|
str
|
child property key |
required |
Returns:
| Type | Description |
|---|---|
str
|
joined child table name |
Source code in src/cdm_data_loaders/converters/core/dlt_normalization.py
unflatten_tables ¶
Build a forest using explicit parent links, preserving root and sibling order.
Mapping keys identify tables, even when raw name metadata differs. Missing
columns stay missing. Empty input yields an empty forest. Dangling parents,
cycles (including disconnected cycles), and ambiguous child keys are errors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tables
|
Mapping[str, TTableSchema]
|
mapping of table name to dlt table schema |
required |
Returns:
| Type | Description |
|---|---|
dict[str, DltTableNode]
|
ordered mapping of root table names to |
Raises:
| Type | Description |
|---|---|
DltNormalizationError
|
if |
Source code in src/cdm_data_loaders/converters/core/dlt_normalization.py
flatten_nodes ¶
Copy a forest into tables in depth-first, parents-first declaration order.
Raw definitions are preserved, including absent columns or parent fields. Node identity, mapping keys, and raw parent links must agree with the tree. Duplicate table names and repeated nodes (including cycles) are rejected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roots
|
Mapping[str, DltTableNode]
|
ordered mapping of root table names to |
required |
Returns:
| Type | Description |
|---|---|
dict[str, TTableSchema]
|
ordered mapping of table names to dlt table schemas |
Raises:
| Type | Description |
|---|---|
DltNormalizationError
|
if a cycle, duplicate name, or parent/key mismatch is detected |
Source code in src/cdm_data_loaders/converters/core/dlt_normalization.py
tables_parents_first ¶
Return isolated table definitions with each parent before its descendants.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tables
|
Mapping[str, TTableSchema]
|
mapping of table name to dlt table schema |
required |
Returns:
| Type | Description |
|---|---|
list[TTableSchema]
|
list of table schemas ordered with parents before children |