@@ -296,6 +296,89 @@ func TestPostgreSQLAdapter_InterpretDataQualityCheck(t *testing.T) {
296296 expectError : true ,
297297 errorMessage : "dataset must be in format database.table" ,
298298 },
299+ {
300+ name : "columns_not_present check with column list" ,
301+ check : & dbqcore.DataQualityCheck {
302+ Expression : "columns_not_present" ,
303+ SchemaCheck : & dbqcore.SchemaCheckConfig {
304+ ColumnsNotPresent : & dbqcore.ColumnsNotPresentConfig {
305+ Columns : []string {"credit_card_number" , "ssn" , "password" },
306+ },
307+ },
308+ },
309+ dataset : "public.users" ,
310+ whereClause : "" ,
311+ expectedSQL : `select count(*)
312+ from information_schema.columns
313+ where table_schema = 'public'
314+ and table_name = 'users'
315+ and (column_name = 'credit_card_number' or column_name = 'ssn' or column_name = 'password')` ,
316+ },
317+ {
318+ name : "columns_not_present check with pattern" ,
319+ check : & dbqcore.DataQualityCheck {
320+ Expression : "columns_not_present" ,
321+ SchemaCheck : & dbqcore.SchemaCheckConfig {
322+ ColumnsNotPresent : & dbqcore.ColumnsNotPresentConfig {
323+ Pattern : "pii_*" ,
324+ },
325+ },
326+ },
327+ dataset : "analytics.events" ,
328+ whereClause : "" ,
329+ expectedSQL : `select count(*)
330+ from information_schema.columns
331+ where table_schema = 'analytics'
332+ and table_name = 'events'
333+ and (column_name LIKE 'pii_%')` ,
334+ },
335+ {
336+ name : "columns_not_present check with both columns and pattern" ,
337+ check : & dbqcore.DataQualityCheck {
338+ Expression : "columns_not_present" ,
339+ SchemaCheck : & dbqcore.SchemaCheckConfig {
340+ ColumnsNotPresent : & dbqcore.ColumnsNotPresentConfig {
341+ Columns : []string {"credit_card" , "cvv" },
342+ Pattern : "sensitive_*" ,
343+ },
344+ },
345+ },
346+ dataset : "shop.orders" ,
347+ whereClause : "" ,
348+ expectedSQL : `select count(*)
349+ from information_schema.columns
350+ where table_schema = 'shop'
351+ and table_name = 'orders'
352+ and (column_name = 'credit_card' or column_name = 'cvv' or column_name LIKE 'sensitive_%')` ,
353+ },
354+ {
355+ name : "columns_not_present check with neither columns nor pattern" ,
356+ check : & dbqcore.DataQualityCheck {
357+ Expression : "columns_not_present" ,
358+ SchemaCheck : & dbqcore.SchemaCheckConfig {
359+ ColumnsNotPresent : & dbqcore.ColumnsNotPresentConfig {},
360+ },
361+ },
362+ dataset : "test.table" ,
363+ whereClause : "" ,
364+ expectError : true ,
365+ errorMessage : "columns_not_present check requires either 'columns' list or 'pattern'" ,
366+ },
367+ {
368+ name : "columns_not_present check invalid dataset format" ,
369+ check : & dbqcore.DataQualityCheck {
370+ Expression : "columns_not_present" ,
371+ SchemaCheck : & dbqcore.SchemaCheckConfig {
372+ ColumnsNotPresent : & dbqcore.ColumnsNotPresentConfig {
373+ Columns : []string {"temp_col" },
374+ },
375+ },
376+ },
377+ dataset : "invalid_dataset" ,
378+ whereClause : "" ,
379+ expectError : true ,
380+ errorMessage : "dataset must be in format database.table" ,
381+ },
299382 {
300383 name : "unknown function fallback" ,
301384 check : & dbqcore.DataQualityCheck {
0 commit comments