@@ -20,24 +20,24 @@ class IntentionCache:
2020 def __init__ (self , engine : "SnowDDLEngine" ):
2121 self .engine = engine
2222
23- self .drop_intention : Dict [ObjectType , Set [str ]] = defaultdict (set )
24- self .replace_intention : Dict [ObjectType , Set [str ]] = defaultdict (set )
23+ self .object_drop_intention : Dict [ObjectType , Set [str ]] = defaultdict (set )
24+ self .object_name_warning : Dict [ObjectType , Set [str ]] = defaultdict (set )
2525
26- self .invalid_name_warning : Dict [ObjectType , Set [str ]] = defaultdict (set )
26+ self .column_drop_intention : Dict [str , Set [str ]] = defaultdict (set )
2727
28- def add_drop_intention (self , object_type : ObjectType , object_full_name : str ):
29- self .drop_intention [object_type ].add (object_full_name )
28+ def add_object_drop_intention (self , object_type : ObjectType , object_full_name : str ):
29+ self .object_drop_intention [object_type ].add (object_full_name )
3030
31- def add_replace_intention (self , object_type : ObjectType , object_full_name : str ):
32- self .replace_intention [object_type ].add (object_full_name )
31+ def add_object_name_warning (self , object_type : ObjectType , object_full_name : str ):
32+ self .object_name_warning [object_type ].add (object_full_name )
3333
34- def add_invalid_name_warning (self , object_type : ObjectType , object_full_name : str ):
35- self .invalid_name_warning [ object_type ].add (object_full_name )
34+ def add_column_drop_intention (self , object_full_name : str , column_name : str ):
35+ self .column_drop_intention [ object_full_name ].add (column_name )
3636
37- def check_drop_intention (self , object_type : ObjectType , object_full_name : str ):
38- return object_full_name in self .drop_intention [object_type ]
37+ def check_object_drop_intention (self , object_type : ObjectType , object_full_name : str ):
38+ return object_full_name in self .object_drop_intention [object_type ]
3939
40- def check_parent_drop_intention (self , object_type : ObjectType , object_full_name : str ):
40+ def check_parent_object_drop_intention (self , object_type : ObjectType , object_full_name : str ):
4141 blueprint_cls = object_type .blueprint_cls
4242 object_full_name_parts = object_full_name .partition ("(" )[0 ].split ("." )
4343
@@ -47,24 +47,27 @@ def check_parent_drop_intention(self, object_type: ObjectType, object_full_name:
4747
4848 # All schemas and schema objects are implicitly dropped by DATABASE
4949 if issubclass (blueprint_cls , (SchemaBlueprint , SchemaObjectBlueprint , DatabaseRoleBlueprint )) and (
50- database_name in self .drop_intention [ObjectType .DATABASE ]
50+ database_name in self .object_drop_intention [ObjectType .DATABASE ]
5151 ):
5252 return True
5353
5454 # All schema objects are implicitly dropped by SCHEMA
55- if issubclass (blueprint_cls , SchemaObjectBlueprint ) and (schema_name in self .drop_intention [ObjectType .SCHEMA ]):
55+ if issubclass (blueprint_cls , SchemaObjectBlueprint ) and (schema_name in self .object_drop_intention [ObjectType .SCHEMA ]):
5656 return True
5757
5858 # All stage files are implicitly dropped by STAGE
59- if issubclass (blueprint_cls , StageFileBlueprint ) and (schema_object_name in self .drop_intention [ObjectType .STAGE ]):
59+ if issubclass (blueprint_cls , StageFileBlueprint ) and (schema_object_name in self .object_drop_intention [ObjectType .STAGE ]):
6060 return True
6161
6262 # All table constraints are implicitly dropped by various TABLE types which support constraints
6363 if issubclass (blueprint_cls , (ForeignKeyBlueprint , PrimaryKeyBlueprint , UniqueKeyBlueprint )) and (
64- schema_object_name in self .drop_intention [ObjectType .TABLE ]
65- or schema_object_name in self .drop_intention [ObjectType .EXTERNAL_TABLE ]
66- or schema_object_name in self .drop_intention [ObjectType .HYBRID_TABLE ]
64+ schema_object_name in self .object_drop_intention [ObjectType .TABLE ]
65+ or schema_object_name in self .object_drop_intention [ObjectType .EXTERNAL_TABLE ]
66+ or schema_object_name in self .object_drop_intention [ObjectType .HYBRID_TABLE ]
6767 ):
6868 return True
6969
7070 return False
71+
72+ def check_column_drop_intention (self , object_full_name : str , column_name : str ):
73+ return column_name in self .column_drop_intention [object_full_name ]
0 commit comments