@@ -101,21 +101,41 @@ def validate_completeness(self, extracted: Dict[str, Any], db: str, schema: str)
101101
102102 return completeness
103103
104+ def normalize_column (col : Dict [str , Any ]) -> Dict [str , Any ]:
105+ """
106+ Normalize column metadata for comparison.
107+ Only keeps the essential fields needed for correctness validation.
108+ """
109+ col = {k .lower (): v for k , v in col .items ()}
110+
111+ return {
112+ "column_name" : col .get ("column_name" ),
113+ "data_type" : col .get ("data_type" ),
114+ "is_nullable" : col .get ("is_nullable" ),
115+ }
116+
104117 def validate_table_definition (self , db , schema , extracted_table : Dict [str , Any ]) -> Dict [str , Any ]:
105118 table_name = extracted_table ["table_name" ]
106119
107120 query = f"""
108- SELECT column_name, data_type, is_nullable
121+ SELECT column_name, data_type, is_nullable,
122+ character_maximum_length, numeric_precision, numeric_scale,
123+ column_default, comment
109124 FROM { db } .information_schema.columns
110125 WHERE table_schema = '{ schema } '
111126 AND table_name = '{ table_name } '
112127 ORDER BY ordinal_position
113128 """
114- sf_columns = [dict (row .as_dict ()) for row in self .session .sql (query ).collect ()]
115129
116- extracted_columns = extracted_table .get ("columns" , [])
130+ # Normalize Snowflake columns
131+ sf_columns_raw = [dict (row .as_dict ()) for row in self .session .sql (query ).collect ()]
132+ sf_columns = [normalize_column (col ) for col in sf_columns_raw ]
117133
118- # Compute correctness percentage
134+ # Normalize extracted columns
135+ extracted_columns_raw = extracted_table .get ("columns" , [])
136+ extracted_columns = [normalize_column (col ) for col in extracted_columns_raw ]
137+
138+ # Compute correctness statistics
119139 total = max (len (sf_columns ), len (extracted_columns ), 1 )
120140 matches = sum (1 for sf , ex in zip (sf_columns , extracted_columns ) if sf == ex )
121141 correctness_pct = round ((matches / total ) * 100 , 2 )
@@ -133,6 +153,7 @@ def validate_table_definition(self, db, schema, extracted_table: Dict[str, Any])
133153 }
134154
135155
156+
136157 def validate_view_definition (self , db , schema , extracted_view : Dict [str , Any ]) -> Dict [str , Any ]:
137158 view_name = extracted_view ["view_name" ]
138159
0 commit comments