Retrieving Dataset Schema in GraphQL with the Dataset's URN

Original Slack Thread

<@U06TM7M40RK> in GraphQL, how do I get the schema for a dataset, goven the URN?

To retrieve the schema for a dataset using GraphQL, given the dataset’s URN, you can use the dataset query. This query allows you to fetch detailed schema information, including fields and their metadata.

Here’s an example of how you can structure your GraphQL query to get the schema for a dataset:

query getDatasetSchema($urn: String!) {
  dataset(urn: $urn) {
    schemaMetadata(version: 0) {
      fields {
        fieldPath
        description
        nativeDataType
        type
      }
    }
  }
}

In this query:

  • Replace $urn with the actual URN of the dataset you are interested in.
  • The schemaMetadata field provides access to the schema details, including each field’s path, description, native data type, and type.

You can execute this query using a GraphQL client or a tool like curl to interact with the DataHub GraphQL API.

Would you like more detailed steps or additional troubleshooting tips?

Sources:

Hi <@U064583E403>, how did my answer work out for you? Need any more assistance? You can also tag <@U07FV3UHE4D> to let your fellow community members know you’re still looking for guidance.

Hi :slight_smile: ! Did this interaction resolve your issue or do you still require assistance ?

Please tag @ RunLLM if you still need further assistance !

Or tag @Datahub Community Support if you require a person to take a look :slight_smile:

Hope this helps ! ><