snowflake

package
v0.25.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SfAccount                           = "sf-account"
	SfUser                              = "sf-user"
	SfPassword                          = "sf-password"
	SfRole                              = "sf-role"
	SfExcludedDatabases                 = "sf-excluded-databases"
	SfExcludedSchemas                   = "sf-excluded-schemas"
	SfExcludedRoles                     = "sf-excluded-roles"
	SfExternalIdentityStoreOwners       = "sf-external-identity-store-owners"
	SfStandardEdition                   = "sf-standard-edition"
	SfLinkToExternalIdentityStoreGroups = "sf-link-to-external-identity-store-groups"
	SfSkipTags                          = "sf-skip-tags"
	SfSkipColumns                       = "sf-skip-columns"
	SfDataUsageWindow                   = "sf-data-usage-window"

	TagSource = "Snowflake"
)
View Source
const AccountAdmin = "ACCOUNTADMIN"
View Source
const ConnectionStringIdentifier = "Raito_CLI"
View Source
const ExternalTable = "external-" + ds.Table
View Source
const MaterializedView = "materialized-" + ds.View
View Source
const SfLimit = 10000

Variables

View Source
var AcceptedTypes = map[string]struct{}{"ACCOUNT": {}, "WAREHOUSE": {}, "DATABASE": {}, "SCHEMA": {}, "TABLE": {}, "VIEW": {}, "COLUMN": {}, "SHARED-DATABASE": {}, "EXTERNAL_TABLE": {}, "MATERIALIZED_VIEW": {}}
View Source
var RolesNotinternalizable = []string{"ORGADMIN", "ACCOUNTADMIN", "SECURITYADMIN", "USERADMIN", "SYSADMIN", "PUBLIC"}

Functions

func CheckSFLimitExceeded

func CheckSFLimitExceeded(query string, size int) error

func ConnectToSnowflake

func ConnectToSnowflake(params map[string]string, role string) (*sql.DB, string, error)

func GetQueryDbEntitiesColumnNames added in v0.11.0

func GetQueryDbEntitiesColumnNames(tag string, includeTag string) []string

func QuerySnowflake

func QuerySnowflake(conn *sql.DB, query string) (*sql.Rows, error)

Types

type AccessSyncer

type AccessSyncer struct {
	// contains filtered or unexported fields
}

func NewDataAccessSyncer added in v0.10.8

func NewDataAccessSyncer() *AccessSyncer

func (*AccessSyncer) SyncAccessAsCodeToTarget added in v0.10.8

func (s *AccessSyncer) SyncAccessAsCodeToTarget(ctx context.Context, access map[string]*importer.AccessProvider, prefix string, configMap *config.ConfigMap) error

func (*AccessSyncer) SyncAccessProvidersFromTarget added in v0.10.8

func (s *AccessSyncer) SyncAccessProvidersFromTarget(ctx context.Context, accessProviderHandler wrappers.AccessProviderHandler, configMap *config.ConfigMap) error

func (*AccessSyncer) SyncAccessProvidersToTarget added in v0.10.8

func (s *AccessSyncer) SyncAccessProvidersToTarget(ctx context.Context, rolesToRemove []string, accessProviders map[string]*importer.AccessProvider, feedbackHandler wrappers.AccessProviderFeedbackHandler, configMap *config.ConfigMap) error

type ColumnEntity added in v0.22.0

type ColumnEntity struct {
	Database string  `db:"TABLE_CATALOG"`
	Schema   string  `db:"TABLE_SCHEMA"`
	Table    string  `db:"TABLE_NAME"`
	Name     string  `db:"COLUMN_NAME"`
	Comment  *string `db:"COMMENT"`
}

type DataSourceSyncer

type DataSourceSyncer struct {
	SfSyncRole string
	// contains filtered or unexported fields
}

func NewDataSourceSyncer added in v0.10.7

func NewDataSourceSyncer() *DataSourceSyncer

func (*DataSourceSyncer) GetDataSourceMetaData added in v0.12.0

func (s *DataSourceSyncer) GetDataSourceMetaData(ctx context.Context) (*ds.MetaData, error)

func (*DataSourceSyncer) SyncDataSource

func (s *DataSourceSyncer) SyncDataSource(ctx context.Context, dataSourceHandler wrappers.DataSourceObjectHandler, configParams *config.ConfigMap) error

type DataUsageSyncer

type DataUsageSyncer struct {
	// contains filtered or unexported fields
}

func NewDataUsageSyncer

func NewDataUsageSyncer() *DataUsageSyncer

func (*DataUsageSyncer) SyncDataUsage

func (s *DataUsageSyncer) SyncDataUsage(ctx context.Context, fileCreator wrappers.DataUsageStatementHandler, configParams *config.ConfigMap) error

type DbEntity added in v0.11.0

type DbEntity struct {
	Name    string  `db:"name"`
	Comment *string `db:"comment"`
}

type EntityCreator added in v0.22.0

type EntityCreator func() interface{}

type EntityHandler added in v0.22.0

type EntityHandler func(entity interface{}) error

type Grant

type Grant struct {
	Permissions string
	// OnType represents the raito data object type of the targeted object
	OnType string
	On     string
}

func (*Grant) GetGrantOnType added in v0.24.0

func (g *Grant) GetGrantOnType() string

GetGrantOnType returns the type to use in a GRANT query.

type GrantOfRole added in v0.11.0

type GrantOfRole struct {
	GrantedTo   string `db:"granted_to"`
	GranteeName string `db:"grantee_name"`
}

type GrantToRole added in v0.11.0

type GrantToRole struct {
	Privilege string `db:"privilege"`
	GrantedOn string `db:"granted_on"`
	Name      string `db:"name"`
}

type IdentityStoreSyncer

type IdentityStoreSyncer struct {
	// contains filtered or unexported fields
}

func NewIdentityStoreSyncer added in v0.10.6

func NewIdentityStoreSyncer() *IdentityStoreSyncer

func (*IdentityStoreSyncer) GetIdentityStoreMetaData added in v0.12.0

func (s *IdentityStoreSyncer) GetIdentityStoreMetaData(_ context.Context) (*is.MetaData, error)

func (*IdentityStoreSyncer) SyncIdentityStore

func (s *IdentityStoreSyncer) SyncIdentityStore(ctx context.Context, identityHandler wrappers.IdentityStoreIdentityHandler, configMap *config.ConfigMap) error

type NullString

type NullString sql.NullString

Implementation of Scanner interface for NullString

func (*NullString) Scan

func (nullString *NullString) Scan(value interface{}) error

type QueryDbEntities

type QueryDbEntities struct {
	ExternalId            string     `db:"QUERY_ID" useColumnName:"true"`
	Status                string     `db:"EXECUTION_STATUS" useColumnName:"true"`
	Query                 string     `db:"QUERY_TEXT" useColumnName:"true"`
	ErrorMessage          NullString `db:"ERROR_MESSAGE" useColumnName:"true"`
	DatabaseName          NullString `db:"DATABASE_NAME" useColumnName:"true"`
	SchemaName            NullString `db:"SCHEMA_NAME" useColumnName:"true"`
	User                  string     `db:"USER_NAME" useColumnName:"true"`
	Role                  string     `db:"ROLE_NAME" useColumnName:"true"`
	StartTime             string     `db:"START_TIME" useColumnName:"true"`
	EndTime               string     `db:"END_TIME" useColumnName:"true"`
	BytesTranferred       int        `db:"OUTBOUND_DATA_TRANSFER_BYTES" useColumnName:"true"`
	RowsReturned          int        `db:"EXTERNAL_FUNCTION_TOTAL_SENT_ROWS" useColumnName:"true"`
	CloudCreditsUsed      float32    `db:"CREDITS_USED_CLOUD_SERVICES" useColumnName:"true"`
	AccessId              NullString `db:"QID"`
	DirectObjectsAccessed *string    `db:"DIRECT_OBJECTS_ACCESSED"`
	BaseObjectsAccessed   *string    `db:"BASE_OBJECTS_ACCESSED"`
	ObjectsModified       *string    `db:"OBJECTS_MODIFIED"`
}

Data Usage

func (QueryDbEntities) String

func (entity QueryDbEntities) String() string

type RoleEntity added in v0.11.0

type RoleEntity struct {
	Name            string `db:"name"`
	AssignedToUsers int    `db:"assigned_to_users"`
	GrantedToRoles  int    `db:"granted_to_roles"`
	GrantedRoles    int    `db:"granted_roles"`
	Owner           string `db:"owner"`
}

Data Access

type SchemaEntity added in v0.22.0

type SchemaEntity struct {
	Database string  `db:"CATALOG_NAME"`
	Name     string  `db:"SCHEMA_NAME"`
	Comment  *string `db:"COMMENT"`
}

type SnowflakeRepository

type SnowflakeRepository struct {
	// contains filtered or unexported fields
}

func NewSnowflakeRepository

func NewSnowflakeRepository(params map[string]string, role string) (*SnowflakeRepository, error)

func (*SnowflakeRepository) BatchingInformation

func (repo *SnowflakeRepository) BatchingInformation(startDate *time.Time, historyTable string) (*string, *string, int, error)

func (*SnowflakeRepository) CheckAccessHistoryAvailability added in v0.10.6

func (repo *SnowflakeRepository) CheckAccessHistoryAvailability(historyTable string) (bool, error)

func (*SnowflakeRepository) Close

func (repo *SnowflakeRepository) Close() error

func (*SnowflakeRepository) CommentRoleIfExists added in v0.22.6

func (repo *SnowflakeRepository) CommentRoleIfExists(comment, objectName string) error

func (*SnowflakeRepository) CreateRole added in v0.10.8

func (repo *SnowflakeRepository) CreateRole(roleName string) error

func (*SnowflakeRepository) DataUsage

func (repo *SnowflakeRepository) DataUsage(columns []string, limit int, offset int, historyTable string, minTime, maxTime *string, accessHistoryAvailable bool) ([]QueryDbEntities, error)

func (*SnowflakeRepository) DescribePolicy added in v0.10.8

func (repo *SnowflakeRepository) DescribePolicy(policyType, dbName, schema, policyName string) ([]describePolicyEntity, error)

func (*SnowflakeRepository) DropRole added in v0.10.8

func (repo *SnowflakeRepository) DropRole(roleName string) error

func (*SnowflakeRepository) ExecuteGrant added in v0.10.8

func (repo *SnowflakeRepository) ExecuteGrant(perm, on, role string) error

func (*SnowflakeRepository) ExecuteRevoke added in v0.10.8

func (repo *SnowflakeRepository) ExecuteRevoke(perm, on, role string) error

func (*SnowflakeRepository) GetColumnsInDatabase added in v0.22.0

func (repo *SnowflakeRepository) GetColumnsInDatabase(databaseName string, handleEntity EntityHandler) error

func (*SnowflakeRepository) GetDataBases added in v0.10.7

func (repo *SnowflakeRepository) GetDataBases() ([]DbEntity, error)

func (*SnowflakeRepository) GetGrantsOfRole added in v0.10.8

func (repo *SnowflakeRepository) GetGrantsOfRole(roleName string) ([]GrantOfRole, error)

func (*SnowflakeRepository) GetGrantsToRole added in v0.10.8

func (repo *SnowflakeRepository) GetGrantsToRole(roleName string) ([]GrantToRole, error)

func (*SnowflakeRepository) GetPolicies added in v0.10.8

func (repo *SnowflakeRepository) GetPolicies(policy string) ([]policyEntity, error)

func (*SnowflakeRepository) GetPolicyReferences added in v0.10.8

func (repo *SnowflakeRepository) GetPolicyReferences(dbName, schema, policyName string) ([]policyReferenceEntity, error)

func (*SnowflakeRepository) GetRoles added in v0.10.8

func (repo *SnowflakeRepository) GetRoles() ([]RoleEntity, error)

func (*SnowflakeRepository) GetRolesWithPrefix added in v0.10.8

func (repo *SnowflakeRepository) GetRolesWithPrefix(prefix string) ([]RoleEntity, error)

func (*SnowflakeRepository) GetSchemasInDatabase added in v0.14.1

func (repo *SnowflakeRepository) GetSchemasInDatabase(databaseName string, handleEntity EntityHandler) error

func (*SnowflakeRepository) GetShares added in v0.10.7

func (repo *SnowflakeRepository) GetShares() ([]DbEntity, error)

func (*SnowflakeRepository) GetSnowFlakeAccountName added in v0.10.7

func (repo *SnowflakeRepository) GetSnowFlakeAccountName() (string, error)

func (*SnowflakeRepository) GetTablesInDatabase added in v0.22.0

func (repo *SnowflakeRepository) GetTablesInDatabase(databaseName string, schemaName string, handleEntity EntityHandler) error

func (*SnowflakeRepository) GetTags added in v0.22.0

func (repo *SnowflakeRepository) GetTags(databaseName string) (map[string][]*tag.Tag, error)

func (*SnowflakeRepository) GetUsers added in v0.10.6

func (repo *SnowflakeRepository) GetUsers() ([]UserEntity, error)

func (*SnowflakeRepository) GetWarehouses added in v0.10.7

func (repo *SnowflakeRepository) GetWarehouses() ([]DbEntity, error)

func (*SnowflakeRepository) GrantRolesToRole added in v0.10.8

func (repo *SnowflakeRepository) GrantRolesToRole(ctx context.Context, role string, roles ...string) error

func (*SnowflakeRepository) GrantUsersToRole added in v0.10.8

func (repo *SnowflakeRepository) GrantUsersToRole(ctx context.Context, role string, users ...string) error

func (*SnowflakeRepository) RevokeRolesFromRole added in v0.10.8

func (repo *SnowflakeRepository) RevokeRolesFromRole(ctx context.Context, role string, roles ...string) error

func (*SnowflakeRepository) RevokeUsersFromRole added in v0.10.8

func (repo *SnowflakeRepository) RevokeUsersFromRole(ctx context.Context, role string, users ...string) error

func (*SnowflakeRepository) TotalQueryTime

func (repo *SnowflakeRepository) TotalQueryTime() time.Duration

type TableEntity added in v0.22.0

type TableEntity struct {
	Database  string  `db:"TABLE_CATALOG"`
	Schema    string  `db:"TABLE_SCHEMA"`
	Name      string  `db:"TABLE_NAME"`
	TableType string  `db:"TABLE_TYPE"`
	Comment   *string `db:"COMMENT"`
}

type TagEntity added in v0.22.0

type TagEntity struct {
	Database string  `db:"OBJECT_DATABASE"`
	Schema   *string `db:"OBJECT_SCHEMA"`
	Name     string  `db:"OBJECT_NAME"`
	Domain   string  `db:"DOMAIN"`
	TagName  string  `db:"TAG_NAME"`
	TagValue string  `db:"TAG_VALUE"`
	Column   *string `db:"COLUMN_NAME"`
}

func (*TagEntity) CreateTag added in v0.22.0

func (t *TagEntity) CreateTag() *tag.Tag

func (*TagEntity) GetFullName added in v0.22.0

func (t *TagEntity) GetFullName() string

type UserEntity added in v0.11.0

type UserEntity struct {
	Name        string `db:"name"`
	LoginName   string `db:"login_name"`
	DisplayName string `db:"display_name"`
	Email       string `db:"email"`
	Owner       string `db:"owner"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL