helpful-analyst-45214
02/12/2024, 7:57 AMlemon-application-45367
02/12/2024, 10:50 AMgraphql
query {
dataset(urn: "your_dataset_urn") {
name
description
schema {
columns {
name
type
description
}
}
upstreamLineage {
upstreams {
dataset {
name
urn
}
}
}
downstreamLineage {
downstreams {
dataset {
name
urn
}
}
}
}
}
Replace "your_dataset_urn" with the actual URN of the dataset you are interested in. This query fetches information about the dataset, its columns, and its upstream and downstream lineage.
Remember to check the Datahub documentation for your specific version to ensure you are using the correct syntax and field names. Additionally, make sure that your Datahub instance is properly configured to expose the GraphQL API.
Here are some key points from the query:
- `dataset`: Fetches information about a specific dataset.
- name and `description`: Retrieve basic information about the dataset.
- `schema`: Fetches information about the dataset's schema, including its columns.
- upstreamLineage and `downstreamLineage`: Fetch information about datasets that are upstream or downstream from the current dataset.
Or you can use Datahub SDK for Python, the script might look something like this:
from datahub import DatahubClient
# Replace these with your actual Datahub instance and dataset URN
datahub_base_url = "<https://your-datahub-instance.com>"
dataset_urn = "urn:li:dataset:your_dataset_urn"
# Create a Datahub client
datahub_client = DatahubClient(base_url=datahub_base_url)
# Get dataset metadata
dataset_metadata = datahub_client.get_dataset_by_urn(dataset_urn)
# Extract column information
columns = dataset_metadata.schema.columns
# Now 'columns' contains information about each column in the dataset
for column in columns:
column_name = column.name
column_type = column.type
print(f"Column: {column_name}, Type: {column_type}")helpful-analyst-45214
02/12/2024, 11:19 AMlemon-application-45367
02/12/2024, 12:25 PMhelpful-analyst-45214
02/15/2024, 9:40 AMrich-barista-93413
02/15/2024, 12:19 PMgray-shoe-75895
02/20/2024, 8:01 PM