@@ -2,6 +2,8 @@ package schema
22
33import (
44 "encoding/json"
5+ "slices"
6+ "strings"
57
68 "github.com/apache/arrow-go/v18/arrow"
79 "github.com/cloudquery/plugin-sdk/v4/types"
@@ -40,6 +42,36 @@ func FindEmptyColumns(table *Table, records []arrow.Record) []string {
4042 return emptyColumns
4143}
4244
45+ func FindNotMatchingSensitiveColumns (table * Table , records []arrow.Record ) ([]string , []string ) {
46+ if len (table .SensitiveColumns ) == 0 {
47+ return []string {}, []string {}
48+ }
49+
50+ nonMatchingColumns := make ([]string , 0 )
51+ nonMatchingJsonColumns := make ([]string , 0 )
52+ tableColumns := table .Columns .Names ()
53+ for _ , c := range table .SensitiveColumns {
54+ isJsonPath := false
55+ if strings .Contains (c , "." ) {
56+ c = strings .Split (c , "." )[0 ]
57+ isJsonPath = true
58+ }
59+ if ! slices .Contains (tableColumns , c ) {
60+ nonMatchingColumns = append (nonMatchingColumns , c )
61+ continue
62+ }
63+ if ! isJsonPath {
64+ continue
65+ }
66+ col := table .Columns .Get (c )
67+ if ! arrow .TypeEqual (col .Type , types .ExtensionTypes .JSON ) {
68+ nonMatchingJsonColumns = append (nonMatchingJsonColumns , c )
69+ continue
70+ }
71+ }
72+ return nonMatchingColumns , nonMatchingJsonColumns
73+ }
74+
4375func isEmptyJSON (msg json.RawMessage ) bool {
4476 if len (msg ) == 0 {
4577 return true
0 commit comments