google-cloud-platformgoogle-data-catalog

Google Cloud Platform: Any way to rearrange fields in an existing Data Catalog template?


I've added a new field to an existing GCP Data Catalog template which by default adds it to the bottom. I'd like for this new field to appear higher up. Is there some way I'm not seeing to rearrange the order of fields in a DC template? If that isn't possible and I'll be forced to recreate the template, is there a way to export the DC metadata and then import it into a new version of the template? Thanks for any assistance!


Solution

  • This answer uses the Data Catalog REST API as example. If you use the client library or gcloud SDK check the proper documentation.

    Have you tried to use the order attribute on the TagTemplateField resource?

    In the PATCH Tag Template Field API call:
    PATCH https://datacatalog.googleapis.com/v1/projects/{project}/locations/{location}/tagTemplates/{tagtemplate}/fields/{field}

    You can update the TagTemplateField order:

    {
      "name": string,
      "displayName": string,
      "type": {
        object (FieldType)
      },
      "isRequired": boolean,
      "description": string,
      "order": integer
    }
    

    Regarding exporting DC metadata, there is an open source package datacatalog-util that you can use to export your tag-templates and tags, and then import them using the same package.