in services/library/src/main/java/com/google/cloud/pso/bq_pii_classifier/functions/tagger/Tagger.java [283:329]
private TableFieldSchema recursiveUpdateFieldPolicyTags(TableFieldSchema field,
String fieldLkpName,
TableSpec tableSpec,
Map<String, PolicyTagInfo> fieldsToPolicyTagsMap,
Set<String> app_managed_taxonomies,
Boolean isDryRun,
String trackingId,
List<TagHistoryLogEntry> policyUpdateLogs
) {
if (!field.getType().equals("RECORD")) {
// stop recursion
// Return the updated field schema with policy tag
return updateFieldPolicyTags(field,
fieldLkpName,
tableSpec,
fieldsToPolicyTagsMap,
app_managed_taxonomies,
isDryRun,
trackingId,
policyUpdateLogs);
} else {
// If the field of type RECORD then apply depth-first recursion until you hit a leaf node
// Then return the updated sub-fields on each level
List<TableFieldSchema> subFields = field.getFields();
List<TableFieldSchema> updatedSubFields = new ArrayList<>();
for (TableFieldSchema subField : subFields) {
TableFieldSchema updatedSubField = recursiveUpdateFieldPolicyTags(
subField,
// use mainField.subField as a lookup name for the subField to find it in DLP results
String.format("%s.%s", fieldLkpName, subField.getName()),
tableSpec,
fieldsToPolicyTagsMap,
app_managed_taxonomies,
isDryRun,
trackingId,
policyUpdateLogs);
updatedSubFields.add(updatedSubField);
}
return field.setFields(updatedSubFields);
}
}