You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/feature-guides/logical-models/overview.md
+70-2Lines changed: 70 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,14 +38,74 @@ Columns on the logical parent and physical children can be linked as well:
38
38
39
39
## Creating Logical Models
40
40
41
+
Logical models are created like any DataHub dataset. We recommend using the Python SDK.
42
+
43
+
:::note Logical Model Platform
44
+
All DataHub datasets require a platform, representing where the dataset exists. If your logical models are stored in a system users are familiar with, we recommend creating a custom platform for that system and providing a custom icon. Otherwise, we recommend using the platform `logical`, which has a special default icon.
45
+
:::
46
+
47
+
### Create Dataset in "logical" Platform
48
+
49
+
```python
50
+
from datahub.sdk import DataHubClient, Dataset
51
+
client = DataHubClient.from_env()
52
+
dataset = Dataset(
53
+
platform="logical",
54
+
name=logical_model_name,
55
+
description=logical_model_description,
56
+
schema=[
57
+
# tuples of (field name / field path, data type, description)
58
+
(
59
+
"zipcode",
60
+
"varchar(50)",
61
+
"This is the zipcode of the address. Specified using extended form and limited to addresses in the United States",
62
+
),
63
+
("street", "varchar(100)", "Street corresponding to the address"),
64
+
("date_column", "date", "Date of the last sale date for this property"),
65
+
],
66
+
)
67
+
client.entities.upsert(dataset)
68
+
```
69
+
70
+
### Create Dataset in Custom Platform
71
+
72
+
```python
73
+
# Create custom platform with custom logo
74
+
from datahub.sdk import DataHubClient
75
+
from datahub.emitter.mcp import MetadataChangeProposalWrapper
76
+
from datahub.metadata.schema_classes import DataPlatformInfoClass, PlatformTypeClass
At its core, the logical -> physical relationship is created by the [`LogicalParent`](../../../generated/metamodel/entities/dataset.md#logicalparent) aspect. To link columns, this aspect must also be created on each child schmea field entity. However, for ease of use, we recommend the OpenAPI endpoint.
42
102
43
103
### OpenAPI
44
104
45
105
The OpenAPI endpoint creates a logical -> physical relationship for a single logical-physical pair, as well as the column-level relationships between their columns, if specified.
46
106
47
107
```shell
48
-
curl -X POST 'http://localhost:8080/openapi/v3/entity/logical/<physical_child_urn>/relationship/physicalInstanceOf/<logical_model_urn>' \
108
+
curl -X POST 'http://localhost:8080/openapi/v3/logical/<physical_child_urn>/relationship/physicalInstanceOf/<logical_model_urn>' \
49
109
-H 'accept: application/json' \
50
110
-H 'Content-Type: application/json' \
51
111
-d '{
@@ -55,14 +115,22 @@ curl -X POST 'http://localhost:8080/openapi/v3/entity/logical/<physical_child_ur
55
115
}'
56
116
```
57
117
118
+
These relationships can also be removed (as of DataHub Cloud v0.3.15):
0 commit comments