@@ -117,15 +117,19 @@ def create_entity(self, schema, entity, columns, exist_ok=False):
117117 response = self ._ddl .CreateEntity (CreateEntityMessage (txId = self ._tid , definition = entity_def ))
118118 return self ._parse_query_response (response )
119119
120- def drop_entity (self , schema , entity ):
120+ def drop_entity (self , schema , entity , not_exist_ok = True ):
121121 """Drops the given entity from the given schema."""
122+ if not_exist_ok and entity not in [s .split ('.' )[- 1 ] for s in self .list_entities (schema )]:
123+ return
122124 schema_name = SchemaName (name = schema )
123125 entity_name = EntityName (schema = schema_name , name = entity )
124126 response = self ._ddl .DropEntity (DropEntityMessage (txId = self ._tid , entity = entity_name ))
125127 return self ._parse_query_response (response )
126128
127- def truncate_entity (self , schema , entity ):
129+ def truncate_entity (self , schema , entity , not_exist_ok = True ):
128130 """Truncates the specified entity."""
131+ if not_exist_ok and entity not in [s .split ('.' )[- 1 ] for s in self .list_entities (schema )]:
132+ return
129133 schema_name = SchemaName (name = schema )
130134 entity_name = EntityName (schema = schema_name , name = entity )
131135 response = self ._ddl .TruncateEntity (TruncateEntityMessage (txId = self ._tid , entity = entity_name ))
0 commit comments