|
13 | 13 | NewType, |
14 | 14 | Union, |
15 | 15 | ) |
16 | | -from typing_extensions import Never |
| 16 | +from typing_extensions import Never, NotRequired |
17 | 17 |
|
18 | 18 | from dlt.common.data_types import TDataType |
19 | 19 | from dlt.common.normalizers.typing import TNormalizersConfig |
@@ -276,14 +276,43 @@ class TScd2StrategyDict(TMergeDispositionDict, total=False): |
276 | 276 | ] |
277 | 277 |
|
278 | 278 |
|
| 279 | +TReferenceCardinality = Literal["-", "<", ">", "<>"] |
| 280 | +"""Represents cardinality between `column` (left) and `referenced_column` (right) |
| 281 | +`-`: one-to-one |
| 282 | +`<`: one-to-many |
| 283 | +`>`: many-to-one |
| 284 | +`<>`: many-to-many |
| 285 | +
|
| 286 | +Note that `column <> referenced_column` is equivalent to specifying |
| 287 | +both `column < referenced_column` and `column > referenced_column` |
| 288 | +""" |
| 289 | + |
| 290 | + |
279 | 291 | class TTableReference(TypedDict): |
280 | 292 | """Describes a reference to another table's columns. |
281 | 293 | `columns` corresponds to the `referenced_columns` in the referenced table and their order should match. |
282 | 294 | """ |
283 | 295 |
|
| 296 | + label: NotRequired[str] |
| 297 | + """Label to describe the relation 'liked'.""" |
| 298 | + |
| 299 | + cardinality: NotRequired[TReferenceCardinality] |
| 300 | + """Cardinality of the relationship between `table.column` (left) and `referenced_table.referenced_column` (right).""" |
| 301 | + |
| 302 | + table: NotRequired[str] |
| 303 | + """Name of the table. |
| 304 | + When `TTableReference` is defined on a `TTableSchema` (i.e., "inline reference"), the `table` |
| 305 | + value is determined by `TTableSchema["name"]` |
| 306 | + """ |
| 307 | + |
284 | 308 | columns: Sequence[str] |
| 309 | + """Name of the column(s) from `table`""" |
| 310 | + |
285 | 311 | referenced_table: str |
| 312 | + """Name of the referenced table""" |
| 313 | + |
286 | 314 | referenced_columns: Sequence[str] |
| 315 | + """Name of the columns(s) from `referenced_table`""" |
287 | 316 |
|
288 | 317 |
|
289 | 318 | TTableReferenceParam = Sequence[TTableReference] |
|
0 commit comments