From 2873736eace1dbc6bd8d19206b0d4c4e2f02a535 Mon Sep 17 00:00:00 2001 From: dushayntAW <158567391+dushayntAW@users.noreply.github.com> Date: Tue, 2 Apr 2024 23:05:47 +0530 Subject: [PATCH] fix(ingestion/salesforce): fixed the issue by escaping the markdown string (#10157) --- .../datahub/ingestion/source/salesforce.py | 7 +- .../account_fields_soql_response.json | 68 +++++++++++++++++++ .../salesforce/salesforce_mces_golden.json | 34 ++++++++++ 3 files changed, 108 insertions(+), 1 deletion(-) diff --git a/metadata-ingestion/src/datahub/ingestion/source/salesforce.py b/metadata-ingestion/src/datahub/ingestion/source/salesforce.py index 6d52646f85d0a..35af541c9e532 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/salesforce.py +++ b/metadata-ingestion/src/datahub/ingestion/source/salesforce.py @@ -573,10 +573,15 @@ def _get_schema_field( fieldTags: List[str] = self.get_field_tags(fieldName, field) + description = self._get_field_description(field, customField) + + # escaping string starting with `#` + description = "\\" + description if description.startswith("#") else description + schemaField = SchemaFieldClass( fieldPath=fieldPath, type=SchemaFieldDataTypeClass(type=TypeClass()), # type:ignore - description=self._get_field_description(field, customField), + description=description, # nativeDataType is set to data type shown on salesforce user interface, # not the corresponding API data type names. nativeDataType=field["FieldDefinition"]["DataType"], diff --git a/metadata-ingestion/tests/integration/salesforce/mock_files/account_fields_soql_response.json b/metadata-ingestion/tests/integration/salesforce/mock_files/account_fields_soql_response.json index 947761b8c79a0..138c574323588 100644 --- a/metadata-ingestion/tests/integration/salesforce/mock_files/account_fields_soql_response.json +++ b/metadata-ingestion/tests/integration/salesforce/mock_files/account_fields_soql_response.json @@ -2508,6 +2508,74 @@ }, "RelationshipName": null, "IsNillable": true + }, + { + "attributes": { + "type": "EntityParticle", + "url": "/services/data/v54.0/tooling/sobjects/EntityParticle/Account.Unique_Account" + }, + "QualifiedApiName": "Unique_Account", + "DeveloperName": "Unique_Account", + "Label": "# Unique_Account", + "FieldDefinition": { + "attributes": { + "type": "FieldDefinition", + "url": "/services/data/v54.0/tooling/sobjects/FieldDefinition/Account.Unique_Account" + }, + "DataType": "Text(80)", + "LastModifiedDate": null, + "LastModifiedBy": null, + "IsIndexed": false, + "ComplianceGroup": null, + "SecurityClassification": null + }, + "DataType": "string", + "Precision": 0, + "Scale": 0, + "Length": 80, + "Digits": 0, + "IsUnique": false, + "IsCompound": false, + "IsComponent": false, + "ReferenceTo": { + "referenceTo": null + }, + "RelationshipName": null, + "IsNillable": true + }, + { + "attributes": { + "type": "EntityParticle", + "url": "/services/data/v54.0/tooling/sobjects/EntityParticle/Account.Unique_Number" + }, + "QualifiedApiName": "Unique_Number", + "DeveloperName": "Unique_Account", + "Label": "#Unique_Number", + "FieldDefinition": { + "attributes": { + "type": "FieldDefinition", + "url": "/services/data/v54.0/tooling/sobjects/FieldDefinition/Account.Unique_Number" + }, + "DataType": "Text(80)", + "LastModifiedDate": null, + "LastModifiedBy": null, + "IsIndexed": false, + "ComplianceGroup": null, + "SecurityClassification": null + }, + "DataType": "string", + "Precision": 0, + "Scale": 0, + "Length": 80, + "Digits": 0, + "IsUnique": false, + "IsCompound": false, + "IsComponent": false, + "ReferenceTo": { + "referenceTo": null + }, + "RelationshipName": null, + "IsNillable": true } ] } \ No newline at end of file diff --git a/metadata-ingestion/tests/integration/salesforce/salesforce_mces_golden.json b/metadata-ingestion/tests/integration/salesforce/salesforce_mces_golden.json index 4e54f199eafed..90df0997495f0 100644 --- a/metadata-ingestion/tests/integration/salesforce/salesforce_mces_golden.json +++ b/metadata-ingestion/tests/integration/salesforce/salesforce_mces_golden.json @@ -1350,6 +1350,40 @@ }, "isPartOfKey": false, "jsonProps": "{}" + }, + { + "fieldPath": "Unique_Account", + "nullable": true, + "description": "\\# Unique_Account", + "type": { + "type": { + "com.linkedin.schema.StringType": {} + } + }, + "nativeDataType": "Text(80)", + "recursive": false, + "globalTags": { + "tags": [] + }, + "isPartOfKey": false, + "jsonProps": "{}" + }, + { + "fieldPath": "Unique_Number", + "nullable": true, + "description": "\\#Unique_Number", + "type": { + "type": { + "com.linkedin.schema.StringType": {} + } + }, + "nativeDataType": "Text(80)", + "recursive": false, + "globalTags": { + "tags": [] + }, + "isPartOfKey": false, + "jsonProps": "{}" } ], "primaryKeys": [