Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: only fetch active snowflake users (#4916)

Tianzhou (天舟)d674b761b959
diff --git a/backend/plugin/db/snowflake/role.go b/backend/plugin/db/snowflake/role.go
index 64b7dc88cc..c1d711451f 100644
--- a/backend/plugin/db/snowflake/role.go
+++ b/backend/plugin/db/snowflake/role.go
@@ -64,10 +64,14 @@ func (driver *Driver) getInstanceRoles(ctx context.Context) ([]*storepb.Instance
}
// Query user info
+ // The same user could have multiple entires in the usage if it's been deleted and recreated,
+ // so we need to use DELETED_ON IS NULL to retrieve the active user.
userQuery := `
SELECT
name
FROM SNOWFLAKE.ACCOUNT_USAGE.USERS
+ WHERE DELETED_ON IS NULL
+ ORDER BY name ASC
`
var instanceRoles []*storepb.InstanceRoleMetadata
rows, err := driver.db.QueryContext(ctx, userQuery)