Skip to content

Commit

Permalink
fix(ingestion/salesforce): handle the label with none value scenario (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dushayntAW authored May 8, 2024
1 parent 4d20c22 commit 96061be
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 26 deletions.
26 changes: 14 additions & 12 deletions metadata-ingestion/src/datahub/ingestion/source/salesforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
},
"systemMetadata": {
"lastObserved": 1652353200000,
"runId": "salesforce-test"
"runId": "salesforce-test",
"lastRunId": "no-run-id-provided"
}
},
{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1465,7 +1483,8 @@
},
"systemMetadata": {
"lastObserved": 1652353200000,
"runId": "salesforce-test"
"runId": "salesforce-test",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -1482,7 +1501,8 @@
},
"systemMetadata": {
"lastObserved": 1652353200000,
"runId": "salesforce-test"
"runId": "salesforce-test",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -1504,7 +1524,8 @@
},
"systemMetadata": {
"lastObserved": 1652353200000,
"runId": "salesforce-test"
"runId": "salesforce-test",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -1526,7 +1547,8 @@
},
"systemMetadata": {
"lastObserved": 1652353200000,
"runId": "salesforce-test"
"runId": "salesforce-test",
"lastRunId": "no-run-id-provided"
}
},
{
Expand Down Expand Up @@ -1554,7 +1576,8 @@
},
"systemMetadata": {
"lastObserved": 1652353200000,
"runId": "salesforce-test"
"runId": "salesforce-test",
"lastRunId": "no-run-id-provided"
}
},
{
Expand Down Expand Up @@ -1951,7 +1974,8 @@
},
"systemMetadata": {
"lastObserved": 1652353200000,
"runId": "salesforce-test"
"runId": "salesforce-test",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -1968,7 +1992,8 @@
},
"systemMetadata": {
"lastObserved": 1652353200000,
"runId": "salesforce-test"
"runId": "salesforce-test",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -1985,7 +2010,8 @@
},
"systemMetadata": {
"lastObserved": 1652353200000,
"runId": "salesforce-test"
"runId": "salesforce-test",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -2006,7 +2032,8 @@
},
"systemMetadata": {
"lastObserved": 1652353200000,
"runId": "salesforce-test"
"runId": "salesforce-test",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -2021,7 +2048,8 @@
},
"systemMetadata": {
"lastObserved": 1652353200000,
"runId": "salesforce-test"
"runId": "salesforce-test",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -2036,7 +2064,8 @@
},
"systemMetadata": {
"lastObserved": 1652353200000,
"runId": "salesforce-test"
"runId": "salesforce-test",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -2051,7 +2080,8 @@
},
"systemMetadata": {
"lastObserved": 1652353200000,
"runId": "salesforce-test"
"runId": "salesforce-test",
"lastRunId": "no-run-id-provided"
}
},
{
Expand All @@ -2066,7 +2096,8 @@
},
"systemMetadata": {
"lastObserved": 1652353200000,
"runId": "salesforce-test"
"runId": "salesforce-test",
"lastRunId": "no-run-id-provided"
}
}
]

0 comments on commit 96061be

Please sign in to comment.