composite
sqllocks_spindle.domains.composite
¶
Cross-domain composition for Spindle.
CompositeDomain merges multiple domain schemas into a single unified SpindleSchema that the existing Spindle engine can generate. It handles table name conflicts via domain-name prefixing, shared entity resolution, and FK rewiring across domain boundaries.
Classes¶
CompositeDomain
¶
Bases: Domain
A domain composed of multiple child domains with shared entity linkage.
Merges schemas from all child domains into a single SpindleSchema,
prefixing table names with the domain name to avoid collisions
(e.g., retail_customer, hr_employee). Shared entities are
generated once from a primary domain and referenced by other domains
via cross-domain FK relationships.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domains
|
list[Domain]
|
List of Domain instances to compose. |
required |
shared_entities
|
dict[str, dict[str, Any]] | None
|
Explicit shared entity mapping. Format:: { "person": { "primary": "hr.employee", "links": { "retail": "customer.employee_id", "financial": "account.holder_id", }, }, "location": { "primary": "retail.store", "links": { "hr": "employee.office_id", }, }, } |
None
|
registry
|
SharedEntityRegistry | None
|
Optional SharedEntityRegistry instance. If not provided,
a default registry is used. Ignored when |
None
|
schema_mode
|
str
|
Schema layout variant passed to child domains. |
'3nf'
|
profile
|
str
|
Profile name passed to child domains. |
'default'
|
overrides
|
dict[str, Any] | None
|
Profile overrides passed to child domains. |
None
|
Example::
from sqllocks_spindle.domains.retail.retail import RetailDomain
from sqllocks_spindle.domains.hr.hr import HrDomain
from sqllocks_spindle.domains.composite import CompositeDomain
from sqllocks_spindle.engine.generator import Spindle
composite = CompositeDomain(
domains=[RetailDomain(), HrDomain()],
shared_entities={
"person": {
"primary": "hr.employee",
"links": {"retail": "customer.employee_id"},
},
},
)
result = Spindle().generate(domain=composite, scale="fabric_demo")
Attributes¶
domain_path
property
¶
Composite domains have no single directory — return the domains/ root.
child_domains
property
¶
The child domains being composed.
Methods:¶
get_schema()
¶
Load and return the merged composite schema.
Overrides the base class to always build programmatically (there is no JSON schema file for a composite domain).