diff --git a/metadata-ingestion/src/datahub/ingestion/source/salesforce.py b/metadata-ingestion/src/datahub/ingestion/source/salesforce.py index 2960411574430..b25f67d6f5ef1 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/salesforce.py +++ b/metadata-ingestion/src/datahub/ingestion/source/salesforce.py @@ -537,20 +537,22 @@ def get_profile_workunit( # Here field description is created from label, description and inlineHelpText def _get_field_description(self, field: dict, customField: dict) -> str: - desc = ( - "\\" + field["Label"] if field["Label"].startswith("#") else field["Label"] - ) + if "Label" not in field or field["Label"] is None: + desc = "" + elif field["Label"].startswith("#"): + desc = "\\" + field["Label"] + else: + desc = field["Label"] - for key in ["FieldDefinition", "InlineHelpText"]: - text: Optional[str] = "" - if isinstance(field.get(key), dict): - text = field[key].get("Description") - else: - text = field.get(key) + text = field.get("FieldDefinition", {}).get("Description", None) + if text: + prefix = "\\" if text.startswith("#") else "" + desc += f"\n\n{prefix}{text}" - if text: - prefix = "\\" if text.startswith("#") else "" - desc += f"\n\n{prefix}{text}" + text = field.get("InlineHelpText", None) + if text: + prefix = "\\" if text.startswith("#") else "" + desc += f"\n\n{prefix}{text}" return desc 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 d00f4b1832418..2f75198d952db 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 @@ -2545,6 +2545,42 @@ "RelationshipName": null, "IsNillable": true }, + { + "attributes": { + "type": "EntityParticle", + "url": "/services/data/v54.0/tooling/sobjects/EntityParticle/Account.Blank_Label" + }, + "QualifiedApiName": "Blank_Label", + "DeveloperName": "Blank_Label", + "Label": null, + "InlineHelpText": "# Help Text", + "FieldDefinition": { + "attributes": { + "type": "FieldDefinition", + "url": "/services/data/v54.0/tooling/sobjects/FieldDefinition/Account.Blank_Label" + }, + "DataType": "Text(80)", + "LastModifiedDate": null, + "LastModifiedBy": null, + "IsIndexed": false, + "ComplianceGroup": null, + "SecurityClassification": null, + "Description": "This is the # description" + }, + "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", diff --git a/metadata-ingestion/tests/integration/salesforce/salesforce_mces_golden.json b/metadata-ingestion/tests/integration/salesforce/salesforce_mces_golden.json index 98deb2a2a7ad2..6a3ce983950b0 100644 --- a/metadata-ingestion/tests/integration/salesforce/salesforce_mces_golden.json +++ b/metadata-ingestion/tests/integration/salesforce/salesforce_mces_golden.json @@ -21,7 +21,8 @@ }, "systemMetadata": { "lastObserved": 1652353200000, - "runId": "salesforce-test" + "runId": "salesforce-test", + "lastRunId": "no-run-id-provided" } }, { @@ -1368,6 +1369,23 @@ "isPartOfKey": false, "jsonProps": "{}" }, + { + "fieldPath": "Blank_Label", + "nullable": true, + "description": "\n\nThis is the # description\n\n\\# Help Text", + "type": { + "type": { + "com.linkedin.schema.StringType": {} + } + }, + "nativeDataType": "Text(80)", + "recursive": false, + "globalTags": { + "tags": [] + }, + "isPartOfKey": false, + "jsonProps": "{}" + }, { "fieldPath": "Unique_Number", "nullable": true, @@ -1465,7 +1483,8 @@ }, "systemMetadata": { "lastObserved": 1652353200000, - "runId": "salesforce-test" + "runId": "salesforce-test", + "lastRunId": "no-run-id-provided" } }, { @@ -1482,7 +1501,8 @@ }, "systemMetadata": { "lastObserved": 1652353200000, - "runId": "salesforce-test" + "runId": "salesforce-test", + "lastRunId": "no-run-id-provided" } }, { @@ -1504,7 +1524,8 @@ }, "systemMetadata": { "lastObserved": 1652353200000, - "runId": "salesforce-test" + "runId": "salesforce-test", + "lastRunId": "no-run-id-provided" } }, { @@ -1526,7 +1547,8 @@ }, "systemMetadata": { "lastObserved": 1652353200000, - "runId": "salesforce-test" + "runId": "salesforce-test", + "lastRunId": "no-run-id-provided" } }, { @@ -1554,7 +1576,8 @@ }, "systemMetadata": { "lastObserved": 1652353200000, - "runId": "salesforce-test" + "runId": "salesforce-test", + "lastRunId": "no-run-id-provided" } }, { @@ -1951,7 +1974,8 @@ }, "systemMetadata": { "lastObserved": 1652353200000, - "runId": "salesforce-test" + "runId": "salesforce-test", + "lastRunId": "no-run-id-provided" } }, { @@ -1968,7 +1992,8 @@ }, "systemMetadata": { "lastObserved": 1652353200000, - "runId": "salesforce-test" + "runId": "salesforce-test", + "lastRunId": "no-run-id-provided" } }, { @@ -1985,7 +2010,8 @@ }, "systemMetadata": { "lastObserved": 1652353200000, - "runId": "salesforce-test" + "runId": "salesforce-test", + "lastRunId": "no-run-id-provided" } }, { @@ -2006,7 +2032,8 @@ }, "systemMetadata": { "lastObserved": 1652353200000, - "runId": "salesforce-test" + "runId": "salesforce-test", + "lastRunId": "no-run-id-provided" } }, { @@ -2021,7 +2048,8 @@ }, "systemMetadata": { "lastObserved": 1652353200000, - "runId": "salesforce-test" + "runId": "salesforce-test", + "lastRunId": "no-run-id-provided" } }, { @@ -2036,7 +2064,8 @@ }, "systemMetadata": { "lastObserved": 1652353200000, - "runId": "salesforce-test" + "runId": "salesforce-test", + "lastRunId": "no-run-id-provided" } }, { @@ -2051,7 +2080,8 @@ }, "systemMetadata": { "lastObserved": 1652353200000, - "runId": "salesforce-test" + "runId": "salesforce-test", + "lastRunId": "no-run-id-provided" } }, { @@ -2066,7 +2096,8 @@ }, "systemMetadata": { "lastObserved": 1652353200000, - "runId": "salesforce-test" + "runId": "salesforce-test", + "lastRunId": "no-run-id-provided" } } ] \ No newline at end of file