From e9f4bef4becc0749cd0f2aee1c5744f73277710d Mon Sep 17 00:00:00 2001 From: Ravi Suhag Date: Wed, 29 May 2024 12:25:05 -0500 Subject: [PATCH] feat(bigquery): add taxonomy name along with policy tag name for columns in bigquery asset --- plugins/extractors/bigquery/bigquery.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/extractors/bigquery/bigquery.go b/plugins/extractors/bigquery/bigquery.go index 27047644..1d92b6ba 100755 --- a/plugins/extractors/bigquery/bigquery.go +++ b/plugins/extractors/bigquery/bigquery.go @@ -704,7 +704,20 @@ func (e *Extractor) getPolicyTagList(ctx context.Context, col *bigquery.FieldSch continue } - pt = append(pt, fmt.Sprintf("policy_tag:%s:%s", policyTag.DisplayName, policyTag.Name)) + policyTagSplit := strings.Split(name, "/") + if len(policyTagSplit) < 2 { + e.logger.Error("error splitting policy tag ", "policy_tag", name, "err", "incorrect format") + continue + } + + taxonomyResourceName := strings.Join(policyTagSplit[:len(policyTagSplit)-2], "/") + taxonomy, err := e.policyTagClient.GetTaxonomy(ctx, &datacatalogpb.GetTaxonomyRequest{Name: taxonomyResourceName}) + if err != nil { + e.logger.Error("error fetching taxonomy", "taxonomy", taxonomy, "err", err) + continue + } + + pt = append(pt, fmt.Sprintf("%s:%s:%s", taxonomy.DisplayName, policyTag.DisplayName, policyTag.Name)) } return pt