Hello Team, I am. getting the following error when...
# ingestion
r
Hello Team, I am. getting the following error when i tried to add tags to a dataset using GraphQL API. Can someone please help me figure out.
Copy code
{
  "errors": [
    {
      "message": "An unknown error occurred.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "addTag"
      ],
      "extensions": {
        "code": 500,
        "type": "SERVER_ERROR",
        "classification": "DataFetchingException"
      }
    }
  ],
  "data": {
    "addTag": null
  }
}
b
Hi @rough-eye-60206 - do you mind sending over the query you're using? And are you hitting the frontend server (9002) or the backend server (8080)?
r
I am hiiting 8080.
Copy code
mutation addTag($input: TagAssociationInput!) {
  addTag(input: $input)
}

variable set:
{
    "input":{"tagUrn":"urn:li:tag:testtag","resourceUrn": "urn:li:dataset:(urn:li:dataPlatform:hive,datahub_test.orders_test,PROD)"}
}
b
Are you adding the
X-DataHub-Actor
header?
r
Yes i added it.
Its working for addTerm but for addTag i am getting this error. Do i need to ingest all the tags separately ( like i did for GlossaryTerms) before assigning them to datasets using GraphQL API?
@miniature-tiger-96062
b
Yes. The tag must already exist
You can use the following create a tag: https://datahubproject.io/docs/graphql/mutations#updatetag
cc @green-football-43791 Who worked on these apis
g
Hey @rough-eye-60206 - as John said, you must have the tag already stored in your system. There are a few ways to do that: 1. you can create the tag in the UI by adding a new tag to an entity. This will prompt you to create a new tag & give that tag a description. 2. You can create the tag via graphql as John linked above using the updateTag mutation. 3. You can add the tag via an MCE. You can refer to how we create the
Legacy
tag here: https://github.com/linkedin/datahub/blob/master/metadata-ingestion/examples/mce_files/bootstrap_mce.json#L1500
let me know if that answers your questions!
separately, I filed an issue for improving the error messaging when a tag does not exist- that should be a much clearer error message
r
Thank you @green-football-43791. I think that should answer my question. I will go through the document and give it a try. Thank you.
g
Alright, sounds good! Let me know if you have any issues- happy to help further 🙂
r
@green-football-43791 Actually i have couple other questions , 1. Can we add column level TAGS and Terms also using GRAPHQL API's? or its just applied for Datasets.? 2. Can we ingest dataset description and column description using GraphQL API? if so how? 3. And Also i am not seeing description when i ingested the metadata for any table from hive. ( Which as per my knowledge should be done by default ingestion). Can you please help me
g
1. Yes! You certainly can. You would add a tag on a field like so:
Copy code
{
  "input": {
    "tagUrn": "urn:li:tag:SomeTag",
    "resourceUrn": "urn:li:dataset:(urn:li:dataPlatform:hive,SampleHiveDataset,PROD)",
    "subResource": "field_foo",
    "subResourceType": "DATASET_FIELD"
  }
}
2. Yes- you can update descriptions with the
updateDescription
graphql mutation. It takes a similar input to addTag. Currently it only supports updating dataset column descriptions, but if you need to be able to update dataset descriptions we can make sure to extend it to support that- its on the backlog. https://github.com/linkedin/datahub/blob/master/datahub-graphql-core/src/main/resources/entity.graphql#L201 3. This was a known bug that has since been resolved. Are you on the latest release?
r
@green-football-43791 Can you please provide me an example for this. "You can create the tag via graphql as John linked above using the updateTag mutation."
I tried this but i got an error
Copy code
mutation updateTag($input: TagUpdateInput!) {
  updateTag(input: $input)
}

{
    "input":{"urn":"urn:li:tag:testtag","name":"testtag",    "description":"ingesting testtag","owners":{"owner":"urn:li:corpuser:sai",
         "type":"DATAOWNER"}
   }
}
error:
Copy code
{
  "errors": [
    {
      "message": "Validation error of type MissingFieldArgument: Missing field argument urn @ 'updateTag'",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "extensions": {
        "classification": "ValidationError"
      }
    },
    {
      "message": "Validation error of type SubSelectionRequired: Sub selection required for type Tag of field updateTag @ 'updateTag'",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "extensions": {
        "classification": "ValidationError"
      }
    }
  ]
}
g
ah, try
Copy code
{
  "input": {
    "urn": "urn:li:tag:testtag",
    "name": "testtag",
    "description": "ingesting testtag",
    "owners": {
      "owner": "urn:li:corpuser:sai",
      "type": "DATAOWNER"
    }
  },
  "urn": "urn:li:tag:testtag"
}
it looks like you need urn as a top-level feld as well
Copy code
updateTag(urn: String!, input: TagUpdateInput!): Tag
see how updateTag takes in two params ^
r
Yes, I figured it out. I have attached below. But Thank you for the quick response.
Copy code
mutation updateTag {
    updateTag(
        urn: "urn:li:tag:testtag",
        input: {urn:"urn:li:tag:testtag",
                name:"testtag",
                description:"ingesting testtag"
                
   }
    ) {
        urn
    }
}
g
nice! got it working?
r
Yes. It working.
🎉 1
g
glad to hear. whats your use case for programmatically creating tags out of curiosity?
r
I am currently working on datahub POC for my organization. We dont have any data catalog system for our asset. So, we thought we will give datahub a try and implement it if satisfies all our requirements. And answer to you question is: My lead want me to explore the options of ingesting terms and tags using API. So i gave it a try
g
sounds good. let me know if you have any other questions!
b
Also any feedback about how to improve the experience!! Always welcomed!
f
I have used below query and It is giving an error
Copy code
mutation updateTag {
  updateTag(
    urn: "urn:li:container:test"
    input: {urn: "urn:li:tag:test", name: "test_tag", description: "ingesting testtag"}
  ) {
    urn
  }
}
Error
Copy code
{
  "errors": [
    {
      "message": "An unknown error occurred.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "updateTag"
      ],
      "extensions": {
        "code": 500,
        "type": "SERVER_ERROR",
        "classification": "DataFetchingException"
      }
    }
  ],
  "data": {
    "updateTag": null
  },
  "extensions": {}
}
I have tried this inside datahub graphiql UI
g
It looks are using the wrong urn,
urn: "urn:li:container:test"
If you are trying to update a tag (name, description or urn) urn should be something like below
Copy code
urn: "urn:li:tag:test"