mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 10:39:30 +00:00 
			
		
		
		
	salesforce table description from label if not through query (#18286)
This commit is contained in:
		
							parent
							
								
									51448452d0
								
							
						
					
					
						commit
						4f89dc582b
					
				| @ -203,15 +203,18 @@ class SalesforceSource(DatabaseServiceSource): | |||||||
|                 ) |                 ) | ||||||
|             ) |             ) | ||||||
| 
 | 
 | ||||||
|     def get_table_description(self, table_name: str) -> Optional[str]: |     def get_table_description( | ||||||
|  |         self, table_name: str, object_label: Optional[str] | ||||||
|  |     ) -> Optional[str]: | ||||||
|         """ |         """ | ||||||
|         Method to get the table description for salesforce with Tooling API |         Method to get the table description for salesforce with Tooling API | ||||||
|         """ |         """ | ||||||
|  |         table_description = None | ||||||
|         try: |         try: | ||||||
|             result = self.client.toolingexecute( |             result = self.client.toolingexecute( | ||||||
|                 f"query/?q=SELECT+Description+FROM+EntityDefinition+WHERE+QualifiedApiName='{table_name}'" |                 f"query/?q=SELECT+Description+FROM+EntityDefinition+WHERE+QualifiedApiName='{table_name}'" | ||||||
|             ) |             ) | ||||||
|             return result["records"][0]["Description"] |             table_description = result["records"][0]["Description"] | ||||||
|         except KeyError as err: |         except KeyError as err: | ||||||
|             logger.warning( |             logger.warning( | ||||||
|                 f"Unable to get required key from Tooling API response for table [{table_name}]: {err}" |                 f"Unable to get required key from Tooling API response for table [{table_name}]: {err}" | ||||||
| @ -225,7 +228,7 @@ class SalesforceSource(DatabaseServiceSource): | |||||||
|             logger.warning( |             logger.warning( | ||||||
|                 f"Unable to get description with Tooling API for table [{table_name}]: {exc}" |                 f"Unable to get description with Tooling API for table [{table_name}]: {exc}" | ||||||
|             ) |             ) | ||||||
|         return None |         return table_description if table_description else object_label | ||||||
| 
 | 
 | ||||||
|     def yield_table( |     def yield_table( | ||||||
|         self, table_name_and_type: Tuple[str, TableType] |         self, table_name_and_type: Tuple[str, TableType] | ||||||
| @ -241,11 +244,13 @@ class SalesforceSource(DatabaseServiceSource): | |||||||
|                 f"sobjects/{table_name}/describe/", |                 f"sobjects/{table_name}/describe/", | ||||||
|                 params=None, |                 params=None, | ||||||
|             ) |             ) | ||||||
|             columns = self.get_columns(salesforce_objects["fields"]) |             columns = self.get_columns(salesforce_objects.get("fields", [])) | ||||||
|             table_request = CreateTableRequest( |             table_request = CreateTableRequest( | ||||||
|                 name=EntityName(table_name), |                 name=EntityName(table_name), | ||||||
|                 tableType=table_type, |                 tableType=table_type, | ||||||
|                 description=self.get_table_description(table_name), |                 description=self.get_table_description( | ||||||
|  |                     table_name, salesforce_objects.get("label") | ||||||
|  |                 ), | ||||||
|                 columns=columns, |                 columns=columns, | ||||||
|                 tableConstraints=table_constraints, |                 tableConstraints=table_constraints, | ||||||
|                 databaseSchema=FullyQualifiedEntityName( |                 databaseSchema=FullyQualifiedEntityName( | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 harshsoni2024
						harshsoni2024