snowflake

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

todo: remove this https://snowflakecomputing.atlassian.net/browse/SNOW-1205579

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains added in v0.34.0

func Contains(s []string, str string) bool

func EscapeSnowflakeString added in v0.34.0

func EscapeSnowflakeString(in string) string

EscapeSnowflakeString will escape single quotes with the SQL native double single quote.

func EscapeString

func EscapeString(in string) string

EscapeString will escape only the ' character. Would prefer a more robust OSS solution, but this should prevent some dumb errors for now.

func Exec added in v0.34.0

func Exec(db *sql.DB, query string) error

func ExecMulti added in v0.34.0

func ExecMulti(db *sql.DB, queries []string) error

func Query added in v0.34.0

func Query(db *sql.DB, stmt string) (*sqlx.Rows, error)

Query will run stmt against the db and return the rows. We use [DB.Unsafe](https://godoc.org/github.com/jmoiron/sqlx#DB.Unsafe) so that we can scan to structs without worrying about newly introduced columns.

func QueryRow added in v0.34.0

func QueryRow(db *sql.DB, stmt string) *sqlx.Row

QueryRow will run stmt against the db and return the row. We use [DB.Unsafe](https://godoc.org/github.com/jmoiron/sqlx#DB.Unsafe) so that we can scan to structs without worrying about newly introduced columns.

func QuoteStringList added in v0.86.0

func QuoteStringList(instrings []string) []string

func SystemGetPrivateLinkConfigQuery added in v0.34.0

func SystemGetPrivateLinkConfigQuery() string

func SystemGetSnowflakePlatformInfoQuery added in v0.34.0

func SystemGetSnowflakePlatformInfoQuery() string

func UnescapeSnowflakeString added in v0.34.0

func UnescapeSnowflakeString(in string) string

UnescapeSnowflakeString reverses EscapeSnowflakeString.

Types

type AWSSNSIAMPolicy added in v0.54.0

type AWSSNSIAMPolicy struct {
	Policy string `db:"policy"`
}

func ScanAWSSNSIAMPolicy added in v0.34.0

func ScanAWSSNSIAMPolicy(row *sqlx.Row) (*AWSSNSIAMPolicy, error)

ScanAWSSNSIAMPolicy convert a result into a.

type AlterPropertiesBuilder added in v0.3.0

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

func (*AlterPropertiesBuilder) GetTagValueString added in v0.34.0

func (ab *AlterPropertiesBuilder) GetTagValueString() string

func (*AlterPropertiesBuilder) SetBool added in v0.3.0

func (ab *AlterPropertiesBuilder) SetBool(key string, value bool)

func (*AlterPropertiesBuilder) SetFloat added in v0.34.0

func (ab *AlterPropertiesBuilder) SetFloat(key string, value float64)

func (*AlterPropertiesBuilder) SetInt added in v0.3.0

func (ab *AlterPropertiesBuilder) SetInt(key string, value int)

func (*AlterPropertiesBuilder) SetRaw added in v0.34.0

func (ab *AlterPropertiesBuilder) SetRaw(rawStatement string)

func (*AlterPropertiesBuilder) SetString added in v0.3.0

func (ab *AlterPropertiesBuilder) SetString(key, value string)

func (*AlterPropertiesBuilder) SetStringList added in v0.34.0

func (ab *AlterPropertiesBuilder) SetStringList(key string, value []string)

func (*AlterPropertiesBuilder) SetTags added in v0.34.0

func (ab *AlterPropertiesBuilder) SetTags(tags []TagValue)

func (*AlterPropertiesBuilder) Statement added in v0.3.0

func (ab *AlterPropertiesBuilder) Statement() string

type BaseManager added in v0.62.0

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

func (*BaseManager) Ok added in v0.62.0

func (m *BaseManager) Ok(_ interface{}, ok bool) bool

type Builder added in v0.3.0

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

func (*Builder) Alter added in v0.3.0

func (b *Builder) Alter() *AlterPropertiesBuilder

func (*Builder) Create added in v0.3.0

func (b *Builder) Create() *CreateBuilder

func (*Builder) Describe added in v0.34.0

func (b *Builder) Describe() string

func (*Builder) Drop added in v0.3.0

func (b *Builder) Drop() string

func (*Builder) Rename added in v0.3.0

func (b *Builder) Rename(newName string) string

func (*Builder) Show added in v0.3.0

func (b *Builder) Show() string

type ColumnIdentifier added in v0.63.0

type ColumnIdentifier struct {
	Database   string
	Schema     string
	ObjectName string `db:"NAME"`
	Column     string
}

func ColumnIdentifierFromQualifiedName added in v0.63.0

func ColumnIdentifierFromQualifiedName(name string) *ColumnIdentifier

func (*ColumnIdentifier) QualifiedName added in v0.63.0

func (i *ColumnIdentifier) QualifiedName() string

type CreateBuilder added in v0.3.0

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

func (*CreateBuilder) GetTagValueString added in v0.34.0

func (b *CreateBuilder) GetTagValueString() string

func (*CreateBuilder) SetBool added in v0.3.0

func (b *CreateBuilder) SetBool(key string, value bool)

func (*CreateBuilder) SetFloat added in v0.34.0

func (b *CreateBuilder) SetFloat(key string, value float64)

func (*CreateBuilder) SetInt added in v0.3.0

func (b *CreateBuilder) SetInt(key string, value int)

func (*CreateBuilder) SetRaw added in v0.34.0

func (b *CreateBuilder) SetRaw(rawStatement string)

func (*CreateBuilder) SetString added in v0.3.0

func (b *CreateBuilder) SetString(key, value string)

func (*CreateBuilder) SetStringList added in v0.34.0

func (b *CreateBuilder) SetStringList(key string, value []string)

func (*CreateBuilder) SetTags added in v0.34.0

func (b *CreateBuilder) SetTags(tags []TagValue)

func (*CreateBuilder) Statement added in v0.3.0

func (b *CreateBuilder) Statement() string

type EntityType added in v0.3.0

type EntityType string
const (
	SecurityIntegrationType EntityType = "SECURITY INTEGRATION"
)

type Identifier added in v0.62.0

type Identifier interface {
	QualifiedName() string
}

type KeywordPosition added in v0.62.0

type KeywordPosition = string
const (
	BeforeObjectType KeywordPosition = "beforeObjectType"
	AfterObjectType  KeywordPosition = "afterObjectType"
	PosParameter     KeywordPosition = "parameter"
)

type ParamType added in v0.62.0

type ParamType string
var (
	Integer    ParamType = "int"
	String     ParamType = "string"
	NullString ParamType = "nullstring"
	StringList ParamType = "stringlist"
	Bool       ParamType = "bool"
)

type PlatformInfo added in v0.54.0

type PlatformInfo struct {
	AzureVnetSubnetIds []string
	AwsVpcIds          []string
}

type PrivateLinkConfig added in v0.34.0

type PrivateLinkConfig struct {
	AccountName               string
	AwsVpceID                 string
	AzurePrivateLinkServiceID string
	AccountURL                string
	OCSPURL                   string
	InternalStage             string
	SnowsightURL              string
	RegionlessSnowsightURL    string
	RegionlessAccountURL      string
	ConnectionURLs            string
}

type RawPlatformInfo added in v0.54.0

type RawPlatformInfo struct {
	Info string `db:"INFO"`
}

func ScanSnowflakePlatformInfo added in v0.34.0

func ScanSnowflakePlatformInfo(row *sqlx.Row) (*RawPlatformInfo, error)

func (*RawPlatformInfo) GetStructuredConfig added in v0.54.0

func (r *RawPlatformInfo) GetStructuredConfig() (*PlatformInfo, error)

type RawPrivateLinkConfig added in v0.34.0

type RawPrivateLinkConfig struct {
	Config string `db:"config"`
}

func ScanPrivateLinkConfig added in v0.34.0

func ScanPrivateLinkConfig(row *sqlx.Row) (*RawPrivateLinkConfig, error)

func (*RawPrivateLinkConfig) GetStructuredConfig added in v0.34.0

func (r *RawPrivateLinkConfig) GetStructuredConfig() (*PrivateLinkConfig, error)

type SCIMAccessToken added in v0.54.0

type SCIMAccessToken struct {
	Token string `db:"TOKEN"`
}

func ScanSCIMAccessToken added in v0.34.0

func ScanSCIMAccessToken(row *sqlx.Row) (*SCIMAccessToken, error)

ScanSCIMAccessToken convert a result into a.

type SQLBuilder added in v0.62.0

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

func (*SQLBuilder) Alter added in v0.62.0

func (b *SQLBuilder) Alter(obj Identifier) (string, error)

func (*SQLBuilder) Create added in v0.62.0

func (b *SQLBuilder) Create(obj Identifier) (string, error)

func (*SQLBuilder) Describe added in v0.62.0

func (b *SQLBuilder) Describe(obj Identifier) (string, error)

func (*SQLBuilder) Drop added in v0.62.0

func (b *SQLBuilder) Drop(obj Identifier) (string, error)

func (*SQLBuilder) ParseDescribe added in v0.62.0

func (b *SQLBuilder) ParseDescribe(rows *sql.Rows, obj Identifier) error

func (*SQLBuilder) ShowLike added in v0.62.0

func (b *SQLBuilder) ShowLike(obj Identifier) (string, error)

func (*SQLBuilder) Unset added in v0.62.0

func (b *SQLBuilder) Unset(obj Identifier) (string, error)

type SQLBuilderConfig added in v0.62.0

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

type SQLParameter added in v0.62.0

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

type SchemaIdentifier added in v0.62.0

type SchemaIdentifier struct {
	Database string
	Schema   string
}

func (*SchemaIdentifier) QualifiedName added in v0.62.0

func (i *SchemaIdentifier) QualifiedName() string

type SchemaObjectIdentifier added in v0.62.0

type SchemaObjectIdentifier struct {
	Database   string
	Schema     string
	ObjectName string `db:"NAME"`
}

func SchemaObjectIdentifierFromQualifiedName added in v0.62.0

func SchemaObjectIdentifierFromQualifiedName(name string) *SchemaObjectIdentifier

func (*SchemaObjectIdentifier) QualifiedName added in v0.62.0

func (i *SchemaObjectIdentifier) QualifiedName() string

type SettingBuilder added in v0.34.0

type SettingBuilder interface {
	SetString(string, string)
	SetStringList(string, []string)
	SetBool(string, bool)
	SetInt(string, int)
	SetFloat(string, float64)
	SetRaw(string)
}

SettingBuilder is an interface for a builder that allows you to set key value pairs.

type StageBuilder added in v0.34.0

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

StageBuilder abstracts the creation of SQL queries for a Snowflake stage.

func NewStageBuilder added in v0.54.0

func NewStageBuilder(name, db, schema string) *StageBuilder

Stage returns a pointer to a Builder that abstracts the DDL operations for a stage.

Supported DDL operations are:

  • CREATE STAGE
  • ALTER STAGE
  • DROP STAGE
  • UNDROP STAGE
  • DESCRIBE STAGE

[Snowflake Reference](https://docs.snowflake.net/manuals/sql-reference/ddl-stage.html#stage-management)

func (*StageBuilder) AddTag added in v0.34.0

func (sb *StageBuilder) AddTag(tag TagValue) string

AddTag returns the SQL query that will add a new tag to the view.

func (*StageBuilder) ChangeComment added in v0.34.0

func (sb *StageBuilder) ChangeComment(c string) string

ChangeComment returns the SQL query that will update the comment on the stage.

func (*StageBuilder) ChangeCopyOptions added in v0.34.0

func (sb *StageBuilder) ChangeCopyOptions(c string) string

ChangeCopyOptions returns the SQL query that will update the copy options on the stage.

func (*StageBuilder) ChangeCredentials added in v0.34.0

func (sb *StageBuilder) ChangeCredentials(c string) string

ChangeCredentials returns the SQL query that will update the credentials on the stage.

func (*StageBuilder) ChangeEncryption added in v0.34.0

func (sb *StageBuilder) ChangeEncryption(e string) string

ChangeEncryption returns the SQL query that will update the encryption on the stage.

func (*StageBuilder) ChangeFileFormat added in v0.34.0

func (sb *StageBuilder) ChangeFileFormat(f string) string

ChangeFileFormat returns the SQL query that will update the file format on the stage.

func (*StageBuilder) ChangeStorageIntegration added in v0.34.0

func (sb *StageBuilder) ChangeStorageIntegration(s string) string

ChangeStorageIntegration returns the SQL query that will update the storage integration on the stage.

func (*StageBuilder) ChangeStorageIntegrationAndUrl added in v0.70.0

func (sb *StageBuilder) ChangeStorageIntegrationAndUrl(s string, url string) string

func (*StageBuilder) ChangeTag added in v0.34.0

func (sb *StageBuilder) ChangeTag(tag TagValue) string

ChangeTag returns the SQL query that will alter a tag on the view.

func (*StageBuilder) ChangeURL added in v0.34.0

func (sb *StageBuilder) ChangeURL(u string) string

ChangeURL returns the SQL query that will update the url on the stage.

func (*StageBuilder) Create added in v0.34.0

func (sb *StageBuilder) Create() string

Create returns the SQL query that will create a new stage.

func (*StageBuilder) QualifiedName added in v0.34.0

func (sb *StageBuilder) QualifiedName() string

QualifiedName prepends the db and schema and escapes everything nicely.

func (*StageBuilder) RemoveComment added in v0.34.0

func (sb *StageBuilder) RemoveComment() string

RemoveComment returns the SQL query that will remove the comment on the stage.

func (*StageBuilder) Rename added in v0.34.0

func (sb *StageBuilder) Rename(newName string) string

Rename returns the SQL query that will rename the stage.

func (*StageBuilder) UnsetTag added in v0.34.0

func (sb *StageBuilder) UnsetTag(tag TagValue) string

UnsetTag returns the SQL query that will unset a tag on the view.

func (*StageBuilder) WithComment added in v0.34.0

func (sb *StageBuilder) WithComment(c string) *StageBuilder

WithComment adds a comment to the StageBuilder.

func (*StageBuilder) WithCopyOptions added in v0.34.0

func (sb *StageBuilder) WithCopyOptions(c string) *StageBuilder

WithCopyOptions adds copy options to the StageBuilder.

func (*StageBuilder) WithCredentials added in v0.34.0

func (sb *StageBuilder) WithCredentials(c string) *StageBuilder

WithCredentials adds credentials to the StageBuilder.

func (*StageBuilder) WithDirectory added in v0.34.0

func (sb *StageBuilder) WithDirectory(d string) *StageBuilder

WithDirectory adds directory option to the StageBuilder.

func (*StageBuilder) WithEncryption added in v0.34.0

func (sb *StageBuilder) WithEncryption(e string) *StageBuilder

WithEncryption adds encryption to the StageBuilder.

func (*StageBuilder) WithFileFormat added in v0.34.0

func (sb *StageBuilder) WithFileFormat(f string) *StageBuilder

WithFileFormat adds a file format to the StageBuilder.

func (*StageBuilder) WithStorageIntegration added in v0.34.0

func (sb *StageBuilder) WithStorageIntegration(s string) *StageBuilder

WithStorageIntegration adds a storage integration to the StageBuilder.

func (*StageBuilder) WithTags added in v0.34.0

func (sb *StageBuilder) WithTags(tags []TagValue) *StageBuilder

WithTags sets the tags on the ExternalTableBuilder.

func (*StageBuilder) WithURL added in v0.34.0

func (sb *StageBuilder) WithURL(u string) *StageBuilder

WithURL adds a URL to the StageBuilder.

type SystemGenerateSCIMAccessTokenBuilder added in v0.34.0

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

SystemGenerateSCIMAccessTokenBuilder abstracts calling the SYSTEM$GENERATE_SCIM_ACCESS_TOKEN system function.

func NewSystemGenerateSCIMAccessTokenBuilder added in v0.54.0

func NewSystemGenerateSCIMAccessTokenBuilder(integrationName string) *SystemGenerateSCIMAccessTokenBuilder

SystemGenerateSCIMAccessToken returns a pointer to a builder that abstracts calling the the SYSTEM$GENERATE_SCIM_ACCESS_TOKEN system function.

func (*SystemGenerateSCIMAccessTokenBuilder) Select added in v0.34.0

Select generates the select statement for obtaining the scim access token.

type SystemGetAWSSNSIAMPolicyBuilder added in v0.34.0

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

SystemGetAWSSNSIAMPolicyBuilder abstracts calling the SYSTEM$GET_AWS_SNS_IAM_POLICY system function.

func NewSystemGetAWSSNSIAMPolicyBuilder added in v0.54.0

func NewSystemGetAWSSNSIAMPolicyBuilder(awsSnsTopicArn string) *SystemGetAWSSNSIAMPolicyBuilder

SystemGetAWSSNSIAMPolicy returns a pointer to a builder that abstracts calling the the SYSTEM$GET_AWS_SNS_IAM_POLICY system function.

func (*SystemGetAWSSNSIAMPolicyBuilder) Select added in v0.34.0

Select generates the select statement for obtaining the aws sns iam policy.

type TableColumn added in v0.63.0

type TableColumn struct {
	Table  *SchemaObjectIdentifier
	Column string
}

type TableColumnMaskingPolicyApplication added in v0.63.0

type TableColumnMaskingPolicyApplication struct {
	Table         *SchemaObjectIdentifier
	Column        string
	MaskingPolicy *SchemaObjectIdentifier
}

type TableColumnMaskingPolicyApplicationCreateInput added in v0.63.0

type TableColumnMaskingPolicyApplicationCreateInput struct {
	TableColumnMaskingPolicyApplication
}

type TableColumnMaskingPolicyApplicationDeleteInput added in v0.63.0

type TableColumnMaskingPolicyApplicationDeleteInput struct {
	TableColumn
}

type TableColumnMaskingPolicyApplicationManager added in v0.63.0

type TableColumnMaskingPolicyApplicationManager struct{}

func NewTableColumnMaskingPolicyApplicationManager added in v0.63.0

func NewTableColumnMaskingPolicyApplicationManager() *TableColumnMaskingPolicyApplicationManager

func (*TableColumnMaskingPolicyApplicationManager) Create added in v0.63.0

func (*TableColumnMaskingPolicyApplicationManager) Delete added in v0.63.0

func (*TableColumnMaskingPolicyApplicationManager) Parse added in v0.63.0

func (*TableColumnMaskingPolicyApplicationManager) Read added in v0.63.0

type TableColumnMaskingPolicyApplicationReadInput added in v0.63.0

type TableColumnMaskingPolicyApplicationReadInput = TableColumn

type Tag added in v0.34.0

type Tag struct {
	Name          sql.NullString `db:"name"`
	DatabaseName  sql.NullString `db:"database_name"`
	SchemaName    sql.NullString `db:"schema_name"`
	Comment       sql.NullString `db:"comment"`
	AllowedValues sql.NullString `db:"allowed_values"`
}

type TagBuilder added in v0.34.0

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

TagBuilder abstracts the creation of SQL queries for a Snowflake tag.

func NewTagBuilder added in v0.54.0

func NewTagBuilder(tid sdk.SchemaObjectIdentifier) *TagBuilder

Tag returns a pointer to a Builder that abstracts the DDL operations for a tag. [Snowflake Reference](https://docs.snowflake.com/en/user-guide/object-tagging.html)

func (*TagBuilder) ShowAttachedPolicy added in v0.43.0

func (tb *TagBuilder) ShowAttachedPolicy() string

Returns sql to show a tag with a specific policy attached to it.

func (*TagBuilder) WithMaskingPolicy added in v0.43.0

func (tb *TagBuilder) WithMaskingPolicy(mid sdk.SchemaObjectIdentifier) *TagBuilder

type TagPolicyAttachment added in v0.54.0

type TagPolicyAttachment struct {
	PolicyDB        sql.NullString `db:"POLICY_DB"`
	PolicySchema    sql.NullString `db:"POLICY_SCHEMA"`
	PolicyName      sql.NullString `db:"POLICY_NAME"`
	PolicyKind      sql.NullString `db:"POLICY_KIND"`
	RefDB           sql.NullString `db:"REF_DATABASE_NAME"`
	RefSchema       sql.NullString `db:"REF_SCHEMA_NAME"`
	RefEntity       sql.NullString `db:"REF_ENTITY_NAME"`
	RefEntityDomain sql.NullString `db:"REF_ENTITY_DOMAIN"`
}

func ScanTagPolicy added in v0.43.0

func ScanTagPolicy(row *sqlx.Row) (*TagPolicyAttachment, error)

type TagValue added in v0.34.0

type TagValue struct {
	Name     string
	Database string
	Schema   string
	Value    string
}

type TopLevelIdentifier added in v0.62.0

type TopLevelIdentifier struct {
	Name string
}

func TopLevelIdentifierFromQualifiedName added in v0.62.0

func TopLevelIdentifierFromQualifiedName(name string) *TopLevelIdentifier

func (*TopLevelIdentifier) QualifiedName added in v0.62.0

func (i *TopLevelIdentifier) QualifiedName() string

type ViewSelectStatementExtractor added in v0.34.0

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

ViewSelectStatementExtractor is a simplistic parser that only exists to extract the select statement from a create view statement

The implementation is optimized for undertandable and predictable behavior. So far we only seek to support queries of the sort that are generated by this project.

Also there is little error handling and we assume queries are well-formed. TODO (SNOW-1636212): remove

func NewViewSelectStatementExtractor added in v0.34.0

func NewViewSelectStatementExtractor(input string) *ViewSelectStatementExtractor

func (*ViewSelectStatementExtractor) Extract added in v0.34.0

func (e *ViewSelectStatementExtractor) Extract() (string, error)

func (*ViewSelectStatementExtractor) ExtractDynamicTable added in v0.86.0

func (e *ViewSelectStatementExtractor) ExtractDynamicTable() (string, error)

func (*ViewSelectStatementExtractor) ExtractMaterializedView added in v0.34.0

func (e *ViewSelectStatementExtractor) ExtractMaterializedView() (string, error)

Jump to

Keyboard shortcuts

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