mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 10:39:30 +00:00 
			
		
		
		
	fix: mark table deleted dependencies (#10476)
This commit is contained in:
		
							parent
							
								
									4c6d184ef5
								
							
						
					
					
						commit
						ddbc0311e8
					
				| @ -11,6 +11,8 @@ | ||||
| """ | ||||
| Table related pydantic definitions | ||||
| """ | ||||
| from typing import Optional | ||||
| 
 | ||||
| from pydantic import BaseModel | ||||
| 
 | ||||
| from metadata.generated.schema.entity.data.table import Table | ||||
| @ -20,3 +22,4 @@ class DeleteTable(BaseModel): | ||||
|     """Entity Reference of a table to be deleted""" | ||||
| 
 | ||||
|     table: Table | ||||
|     mark_deleted_tables: Optional[bool] = False | ||||
|  | ||||
| @ -339,7 +339,12 @@ class MetadataRestSink(Sink[Entity]): | ||||
| 
 | ||||
|     def delete_table(self, record: DeleteTable): | ||||
|         try: | ||||
|             self.metadata.delete(entity=Table, entity_id=record.table.id) | ||||
| 
 | ||||
|             self.metadata.delete( | ||||
|                 entity=Table, | ||||
|                 entity_id=record.table.id, | ||||
|                 recursive=record.mark_deleted_tables, | ||||
|             ) | ||||
|             logger.debug( | ||||
|                 f"{record.table.name} doesn't exist in source state, marking it as deleted" | ||||
|             ) | ||||
|  | ||||
| @ -429,7 +429,10 @@ class DatabaseServiceSource( | ||||
|         ) | ||||
|         for table in database_state: | ||||
|             if str(table.fullyQualifiedName.__root__) not in self.database_source_state: | ||||
|                 yield DeleteTable(table=table) | ||||
|                 yield DeleteTable( | ||||
|                     table=table, | ||||
|                     mark_deleted_tables=self.source_config.markDeletedTables, | ||||
|                 ) | ||||
| 
 | ||||
|     def fetch_all_schema_and_delete_tables(self): | ||||
|         """ | ||||
|  | ||||
| @ -381,9 +381,13 @@ public class TableResource extends EntityResource<Table, TableRepository> { | ||||
|           @QueryParam("hardDelete") | ||||
|           @DefaultValue("false") | ||||
|           boolean hardDelete, | ||||
|       @Parameter(description = "Recursively delete this entity and it's children. (Default `false`)") | ||||
|           @QueryParam("recursive") | ||||
|           @DefaultValue("false") | ||||
|           boolean recursive, | ||||
|       @Parameter(description = "Id of the table", schema = @Schema(type = "UUID")) @PathParam("id") UUID id) | ||||
|       throws IOException { | ||||
|     return delete(uriInfo, securityContext, id, false, hardDelete); | ||||
|     return delete(uriInfo, securityContext, id, recursive, hardDelete); | ||||
|   } | ||||
| 
 | ||||
|   @DELETE | ||||
|  | ||||
| @ -19,7 +19,7 @@ | ||||
|       "default": "DatabaseMetadata" | ||||
|     }, | ||||
|     "markDeletedTables": { | ||||
|       "description": "Optional configuration to soft delete tables in OpenMetadata if the source tables are deleted.", | ||||
|       "description": "Optional configuration to soft delete tables in OpenMetadata if the source tables are deleted. Also, if the table is deleted, all the associated entities like testSuite, lineage, etc., with that table will be deleted", | ||||
|       "type": "boolean", | ||||
|       "default": true | ||||
|     }, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 NiharDoshi99
						NiharDoshi99