Skip to content

Commit

Permalink
Fixes open-metadata#13556: Support for Salesforce table description i…
Browse files Browse the repository at this point in the history
…ngestion (open-metadata#14733)

* ISSUE-13556: Add suport for Salesforce table description ingestion

* ISSUE-13556: Remove unnecessary blank line

* ISSUE-13556: Fix to get description for each table

---------

Co-authored-by: Teddy <teddy.crepineau@gmail.com>
  • Loading branch information
2 people authored and Abhishek332 committed Jan 25, 2024
1 parent 4c9865e commit 874bb93
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def get_tables_name_and_type(self) -> Optional[Iterable[Tuple[str, str]]]:
:return: tables or views, depending on config
"""
schema_name = self.context.database_schema

try:
if self.service_connection.sobjectName:
table_name = self.standardize_table_name(
Expand Down Expand Up @@ -191,6 +192,30 @@ def get_tables_name_and_type(self) -> Optional[Iterable[Tuple[str, str]]]:
)
)

def get_table_description(self, table_name: str) -> Optional[str]:
"""
Method to get the table description for salesforce with Tooling API
"""
try:
result = self.client.toolingexecute(
f"query/?q=SELECT+Description+FROM+EntityDefinition+WHERE+QualifiedApiName='{table_name}'"
)
return result["records"][0]["Description"]
except KeyError as err:
logger.warning(
f"Unable to get required key from Tooling API response for table [{table_name}]: {err}"
)
except IndexError as err:
logger.warning(
f"Unable to get row for table [{table_name}] from EntityDefinition: {err}"
)
except Exception as exc:
logger.debug(traceback.format_exc())
logger.warning(
f"Unable to get description with Tooling API for table [{table_name}]: {exc}"
)
return None

def yield_table(
self, table_name_and_type: Tuple[str, str]
) -> Iterable[Either[CreateTableRequest]]:
Expand All @@ -209,6 +234,7 @@ def yield_table(
table_request = CreateTableRequest(
name=table_name,
tableType=table_type,
description=self.get_table_description(table_name),
columns=columns,
tableConstraints=table_constraints,
databaseSchema=fqn.build(
Expand Down

0 comments on commit 874bb93

Please sign in to comment.