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/api/tutorials/structured-properties.md
+296-33
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ import TabItem from '@theme/TabItem';
6
6
## Why Would You Use Structured Properties?
7
7
8
8
Structured properties are a structured, named set of properties that can be attached to logical entities like Datasets, DataJobs, etc.
9
-
Structured properties have values that are types. Conceptually, they are like “field definitions”.
9
+
Structured properties have values that are typed and support constraints.
10
10
11
11
Learn more about structured properties in the [Structured Properties Feature Guide](../../../docs/features/feature-guides/properties/overview.md).
12
12
@@ -15,6 +15,7 @@ Learn more about structured properties in the [Structured Properties Feature Gui
15
15
16
16
This guide will show you how to execute the following actions with structured properties.
17
17
- Create structured properties
18
+
- List structured properties
18
19
- Read structured properties
19
20
- Delete structured properties
20
21
- Add structured properties to a dataset
@@ -32,7 +33,8 @@ Additionally, you need to have the following tools installed according to the me
32
33
<Tabs>
33
34
<TabItemvalue="CLI"label="CLI"default>
34
35
35
-
Install the relevant CLI version. Forms are available as of CLI version `0.13.1`. The corresponding DataHub Cloud release version is `v0.2.16.5`
36
+
Install the relevant CLI version.
37
+
Structured Properties were introduced in version `0.13.1`, but we continuously improve and add new functionality, so you should always [upgrade](https://datahubproject.io/docs/cli/#installation) to the latest cli for best results.
36
38
Connect to your instance via [init](https://datahubproject.io/docs/cli/#init):
37
39
38
40
- Run `datahub init` to update the instance you want to load into.
@@ -56,33 +58,8 @@ Requirements for OpenAPI are:
56
58
The following code will create a structured property `io.acryl.privacy.retentionTime`.
57
59
58
60
<Tabs>
59
-
<TabItemvalue="graphql"label="graphQL"default>
60
61
61
-
```graphql
62
-
mutationcreateStructuredProperty {
63
-
createStructuredProperty(
64
-
input: {
65
-
id: "retentionTime",
66
-
qualifiedName:"retentionTime",
67
-
displayName: "Retention Time",
68
-
description: "Retention Time is used to figure out how long to retain records in a dataset",
69
-
valueType: "urn:li:dataType:datahub.number",
70
-
allowedValues: [
71
-
{numberValue: 30, description: "30 days, usually reserved for datasets that are ephemeral and contain pii"},
72
-
{numberValue: 90, description:"description: Use this for datasets that drive monthly reporting but contain pii"},
73
-
{numberValue: 365, description:"Use this for non-sensitive data that can be retained for longer"}
Create a yaml file representing the properties you’d like to load.
88
65
For example, below file represents a property `io.acryl.privacy.retentionTime`. You can see the full example [here](https://github.com/datahub-project/datahub/blob/example-yaml-sp/metadata-ingestion/examples/structured_properties/struct_props.yaml).
@@ -108,13 +85,41 @@ For example, below file represents a property `io.acryl.privacy.retentionTime`.
108
85
```
109
86
110
87
Use the CLI to create your properties:
111
-
```commandline
88
+
```shell
112
89
datahub properties upsert -f {properties_yaml}
113
90
```
114
91
115
92
If successful, you should see `Created structured property urn:li:structuredProperty:...`
116
93
117
94
</TabItem>
95
+
96
+
<TabItemvalue="Graphql"label="GraphQL"default>
97
+
98
+
```graphql
99
+
mutationcreateStructuredProperty {
100
+
createStructuredProperty(
101
+
input: {
102
+
id: "retentionTime",
103
+
qualifiedName:"retentionTime",
104
+
displayName: "Retention Time",
105
+
description: "Retention Time is used to figure out how long to retain records in a dataset",
106
+
valueType: "urn:li:dataType:datahub.number",
107
+
allowedValues: [
108
+
{numberValue: 30, description: "30 days, usually reserved for datasets that are ephemeral and contain pii"},
109
+
{numberValue: 90, description:"description: Use this for datasets that drive monthly reporting but contain pii"},
110
+
{numberValue: 365, description:"Use this for non-sensitive data that can be retained for longer"}
You can list all structured properties in your DataHub instance using the following methods:
247
+
248
+
<Tabs>
249
+
<TabItemvalue="CLI"label="CLI"default>
250
+
251
+
```shell
252
+
datahub properties list
253
+
```
254
+
255
+
This will show all properties with their full details.
256
+
257
+
Example Response:
258
+
```json
259
+
{
260
+
"urn": "urn:li:structuredProperty:clusterName",
261
+
"qualified_name": "clusterName",
262
+
"type": "urn:li:dataType:datahub.string",
263
+
"description": "Test Cluster Name Property",
264
+
"display_name": "Cluster's name",
265
+
"entity_types": [
266
+
"urn:li:entityType:datahub.dataset"
267
+
],
268
+
"cardinality": "SINGLE"
269
+
}
270
+
{
271
+
"urn": "urn:li:structuredProperty:projectNames",
272
+
"qualified_name": "projectNames",
273
+
"type": "urn:li:dataType:datahub.string",
274
+
"description": "Test property for project name",
275
+
"display_name": "Project Name",
276
+
"entity_types": [
277
+
"urn:li:entityType:datahub.dataset",
278
+
"urn:li:entityType:datahub.dataFlow"
279
+
],
280
+
"cardinality": "MULTIPLE",
281
+
"allowed_values": [
282
+
{
283
+
"value": "Tracking",
284
+
"description": "test value 1 for project"
285
+
},
286
+
{
287
+
"value": "DataHub",
288
+
"description": "test value 2 for project"
289
+
}
290
+
]
291
+
}
292
+
```
293
+
294
+
295
+
If you only want to see the URNs, you can use:
296
+
297
+
```shell
298
+
datahub properties list --no-details
299
+
```
300
+
301
+
Example Response:
302
+
```
303
+
[2025-01-08 22:23:00,625] INFO {datahub.cli.specific.structuredproperties_cli:134} - Listing structured property urns only, use --details for more information
To download all the structured property definitions into a single file that you can use with the `upsert` command as described in the [create section](#create-structured-properties), you can run the list command with the `--to-file` option.
311
+
312
+
```shell
313
+
datahub properties list --to-file structured_properties.yaml
0 commit comments