mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-13 04:02:34 +00:00
122 lines
3.4 KiB
Markdown
122 lines
3.4 KiB
Markdown
![]() |
# Reading Owners On Datasets/Columns
|
||
|
|
||
|
## Why Would You Read Owners?
|
||
|
|
||
|
Assigning an owner to an entity helps to establish accountability for the metadata and collaborating as a team.
|
||
|
If there are any issues or questions about the data, the designated owner can serve as a reliable point of contact.
|
||
|
|
||
|
### Goal Of This Guide
|
||
|
|
||
|
This guide will show you how to read owners attached to a dataset `SampleHiveDataset`.
|
||
|
|
||
|
## Prerequisites
|
||
|
|
||
|
For this tutorial, you need to deploy DataHub Quickstart and ingest sample data.
|
||
|
For detailed steps, please refer to [Datahub Quickstart Guide](/docs/quickstart.md).
|
||
|
|
||
|
:::note
|
||
|
Before reading owners, you need to ensure the targeted dataset and the owner are already present in your datahub.
|
||
|
If you attempt to manipulate entities that do not exist, your operation will fail.
|
||
|
In this guide, we will be using data from a sample ingestion.
|
||
|
:::
|
||
|
|
||
|
## Read Owners With GraphQL
|
||
|
|
||
|
:::note
|
||
|
Please note that there are two available endpoints (`:8000`, `:9002`) to access `graphql`.
|
||
|
For more information about the differences between these endpoints, please refer to [DataHub Metadata Service](../../../metadata-service/README.md#graphql-api)
|
||
|
:::
|
||
|
|
||
|
### GraphQL Explorer
|
||
|
|
||
|
GraphQL Explorer is the fastest way to experiment with GraphQL without any dependencies.
|
||
|
Navigate to GraphQL Explorer (`http://localhost:9002/api/graphiql`) and run the following query.
|
||
|
|
||
|
```json
|
||
|
query {
|
||
|
dataset(urn: "urn:li:dataset:(urn:li:dataPlatform:hive,SampleHiveDataset,PROD)") {
|
||
|
ownership {
|
||
|
owners {
|
||
|
owner {
|
||
|
... on CorpUser {
|
||
|
urn
|
||
|
type
|
||
|
}
|
||
|
... on CorpGroup {
|
||
|
urn
|
||
|
type
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
If you see the following response, the operation was successful:
|
||
|
|
||
|
```python
|
||
|
{
|
||
|
"data": {
|
||
|
"dataset": {
|
||
|
"ownership": {
|
||
|
"owners": [
|
||
|
{
|
||
|
"owner": {
|
||
|
"urn": "urn:li:corpuser:jdoe",
|
||
|
"type": "CORP_USER"
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
"owner": {
|
||
|
"urn": "urn:li:corpuser:datahub",
|
||
|
"type": "CORP_USER"
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"extensions": {}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
### CURL
|
||
|
|
||
|
With CURL, you need to provide tokens. To generate a token, please refer to [Access Token Management](/docs/api/graphql/token-management.md).
|
||
|
With `accessToken`, you can run the following command.
|
||
|
|
||
|
```shell
|
||
|
curl --location --request POST 'http://localhost:8080/api/graphql' \
|
||
|
--header 'Authorization: Bearer <my-access-token>' \
|
||
|
--header 'Content-Type: application/json' \
|
||
|
--data-raw '{ "query": "{ dataset(urn: \"urn:li:dataset:(urn:li:dataPlatform:hive,SampleHiveDataset,PROD)\") { ownership { owners { owner { ... on CorpUser { urn type } ... on CorpGroup { urn type } } } } } }", "variables":{}}'
|
||
|
```
|
||
|
|
||
|
Expected Response:
|
||
|
|
||
|
```json
|
||
|
{
|
||
|
"data": {
|
||
|
"dataset": {
|
||
|
"ownership": {
|
||
|
"owners": [
|
||
|
{ "owner": { "urn": "urn:li:corpuser:jdoe", "type": "CORP_USER" } },
|
||
|
{ "owner": { "urn": "urn:li:corpuser:datahub", "type": "CORP_USER" } }
|
||
|
]
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"extensions": {}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
## Read Owners With Python SDK
|
||
|
|
||
|
The following code reads owners attached to a dataset `fct_users_created`.
|
||
|
|
||
|
> Coming Soon!
|
||
|
|
||
|
We're using the `MetdataChangeProposalWrapper` to change entities in this example.
|
||
|
For more information about the `MetadataChangeProposal`, please refer to [MetadataChangeProposal & MetadataChangeLog Events](/docs/advanced/mcp-mcl.md)
|