snowflake

package
v0.100.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SuspendTrigger suspends all assigned warehouses while allowing currently running queries to complete.
	SuspendTrigger = "SUSPEND"
	// SuspendImmediatelyTrigger suspends all assigned warehouses immediately and cancel any currently running queries or statements using the warehouses.
	SuspendImmediatelyTrigger = "SUSPEND_IMMEDIATE"
	// NotifyTrigger sends an alert (to all users who have enabled notifications for themselves), but do not take any other action.
	NotifyTrigger = "NOTIFY"
)

Variables

This section is empty.

Functions

func DescStage added in v0.12.2

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

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.12.2

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

func Query added in v0.12.2

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.12.2

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 ScanDatabase added in v0.12.2

func ScanDatabase(row *sqlx.Row) (*database, error)

func ScanManagedAccount added in v0.12.2

func ScanManagedAccount(row *sqlx.Row) (*managedAccount, error)

func ScanPipe added in v0.12.2

func ScanPipe(row *sqlx.Row) (*pipe, error)

func ScanResourceMonitor added in v0.12.2

func ScanResourceMonitor(row *sqlx.Row) (*resourceMonitor, error)

func ScanRole added in v0.12.2

func ScanRole(row *sqlx.Row) (*role, error)

func ScanSchema added in v0.12.2

func ScanSchema(row *sqlx.Row) (*schema, error)

func ScanShare added in v0.12.2

func ScanShare(row *sqlx.Row) (*share, error)

func ScanStageShow added in v0.12.2

func ScanStageShow(row *sqlx.Row) (*stage, error)

func ScanStorageIntegration added in v0.12.2

func ScanStorageIntegration(row *sqlx.Row) (*storageIntegration, error)

func ScanUser added in v0.12.2

func ScanUser(row *sqlx.Row) (*user, error)

func ScanView added in v0.12.2

func ScanView(row *sqlx.Row) (*view, error)

func ScanWarehouse added in v0.12.2

func ScanWarehouse(row *sqlx.Row) (*warehouse, error)

func ValidateIdentifier

func ValidateIdentifier(val interface{}) (warns []string, errs []error)

ValidateIdentifier implements a strict definition of valid identifiers from https://docs.snowflake.net/manuals/sql-reference/identifiers-syntax.html

Types

type AlterPropertiesBuilder added in v0.3.0

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

func (*AlterPropertiesBuilder) SetBool added in v0.3.0

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

func (*AlterPropertiesBuilder) SetFloat added in v0.8.1

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) SetString added in v0.3.0

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

func (*AlterPropertiesBuilder) SetStringList added in v0.11.0

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

func (*AlterPropertiesBuilder) Statement added in v0.3.0

func (ab *AlterPropertiesBuilder) Statement() string

type Builder added in v0.3.0

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

func Database added in v0.3.0

func Database(name string) *Builder

Database returns a pointer to a Builder for a database

func ManagedAccount added in v0.4.0

func ManagedAccount(name string) *Builder

ManagedAccount returns a pointer to a Builder that abstracts the DDL operations for a reader account.

Supported DDL operations are:

  • CREATE MANAGED ACCOUNT
  • DROP MANAGED ACCOUNT
  • SHOW MANAGED ACCOUNTS

[Snowflake Reference](https://docs.snowflake.net/manuals/user-guide/data-sharing-reader-create.html)

func Role added in v0.3.0

func Role(name string) *Builder

func Share added in v0.4.0

func Share(name string) *Builder

Share returns a pointer to a Builder that abstracts the DDL operations for a share.

Supported DDL operations are:

  • CREATE SHARE
  • ALTER SHARE
  • DROP SHARE
  • SHOW SHARES
  • DESCRIBE SHARE

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

func StorageIntegration added in v0.11.0

func StorageIntegration(name string) *Builder

StorageIntegration returns a pointer to a Builder that abstracts the DDL operations for a storage integration.

Supported DDL operations are:

  • CREATE STORAGE INTEGRATION
  • ALTER STORAGE INTEGRATION
  • DROP INTEGRATION
  • SHOW INTEGRATIONS
  • DESCRIBE INTEGRATION

[Snowflake Reference](https://docs.snowflake.net/manuals/sql-reference/ddl-user-security.html#storage-integrations)

func User added in v0.3.0

func User(name string) *Builder

func Warehouse added in v0.3.0

func Warehouse(name string) *Builder

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.11.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 CreateBuilder added in v0.3.0

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

func (*CreateBuilder) SetBool added in v0.3.0

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

func (*CreateBuilder) SetFloat added in v0.8.1

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) SetString added in v0.3.0

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

func (*CreateBuilder) SetStringList added in v0.11.0

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

func (*CreateBuilder) Statement added in v0.3.0

func (b *CreateBuilder) Statement() string

type CurrentGrantBuilder added in v0.5.0

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

CurrentGrantBuilder abstracts the creation of GrantExecutables

func (*CurrentGrantBuilder) Name added in v0.5.0

func (gb *CurrentGrantBuilder) Name() string

Name returns the object name for this CurrentGrantBuilder

func (*CurrentGrantBuilder) Role added in v0.5.0

Role returns a pointer to a CurrentGrantExecutable for a role

func (*CurrentGrantBuilder) Share added in v0.5.0

Share returns a pointer to a CurrentGrantExecutable for a share

func (*CurrentGrantBuilder) Show added in v0.5.0

func (gb *CurrentGrantBuilder) Show() string

Show returns the SQL that will show all privileges on the grant

type CurrentGrantExecutable added in v0.5.0

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

CurrentGrantExecutable abstracts the creation of SQL queries to build grants for different resources

func (*CurrentGrantExecutable) Grant added in v0.5.0

func (ge *CurrentGrantExecutable) Grant(p string) string

Grant returns the SQL that will grant privileges on the grant to the grantee

func (*CurrentGrantExecutable) Revoke added in v0.5.0

func (ge *CurrentGrantExecutable) Revoke(p string) string

Revoke returns the SQL that will revoke privileges on the grant from the grantee

func (*CurrentGrantExecutable) Show added in v0.5.0

func (ge *CurrentGrantExecutable) Show() string

Show returns the SQL that will show all grants of the grantee

type DatabaseCloneBuilder added in v0.6.0

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

DatabaseCloneBuilder is a basic builder that just creates databases from a source database

func DatabaseFromDatabase added in v0.6.0

func DatabaseFromDatabase(name, database string) *DatabaseCloneBuilder

DatabaseFromDatabase returns a pointer to a builder that can create a database from a source database

func (*DatabaseCloneBuilder) Create added in v0.6.0

func (dsb *DatabaseCloneBuilder) Create() string

Create returns the SQL statement required to create a database from a source database

type DatabaseShareBuilder added in v0.4.0

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

DatabaseShareBuilder is a basic builder that just creates databases from shares

func DatabaseFromShare added in v0.4.0

func DatabaseFromShare(name, provider, share string) *DatabaseShareBuilder

DatabaseFromShare returns a pointer to a builder that can create a database from a share

func (*DatabaseShareBuilder) Create added in v0.4.0

func (dsb *DatabaseShareBuilder) Create() string

Create returns the SQL statement required to create a database from a share

type EntityType added in v0.3.0

type EntityType string
const (
	DatabaseType           EntityType = "DATABASE"
	ManagedAccountType     EntityType = "MANAGED ACCOUNT"
	ResourceMonitorType    EntityType = "RESOURCE MONITOR"
	RoleType               EntityType = "ROLE"
	ShareType              EntityType = "SHARE"
	StorageIntegrationType EntityType = "STORAGE INTEGRATION"
	UserType               EntityType = "USER"
	WarehouseType          EntityType = "WAREHOUSE"
)

type FutureGrantBuilder added in v0.5.0

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

FutureGrantBuilder abstracts the creation of FutureGrantExecutables

func (*FutureGrantBuilder) Name added in v0.5.0

func (fgb *FutureGrantBuilder) Name() string

Name returns the object name for this FutureGrantBuilder

func (*FutureGrantBuilder) Role added in v0.5.0

Role returns a pointer to a FutureGrantExecutable for a role

func (*FutureGrantBuilder) Share added in v0.5.0

Share is not implemented because future objects cannot be granted to shares.

func (*FutureGrantBuilder) Show added in v0.5.0

func (fgb *FutureGrantBuilder) Show() string

Show returns the SQL that will show all privileges on the grant

type FutureGrantExecutable added in v0.5.0

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

FutureGrantExecutable abstracts the creation of SQL queries to build future grants for different future grant types.

func (*FutureGrantExecutable) Grant added in v0.5.0

func (fge *FutureGrantExecutable) Grant(p string) string

Grant returns the SQL that will grant future privileges on the grant to the grantee

func (*FutureGrantExecutable) Revoke added in v0.5.0

func (fge *FutureGrantExecutable) Revoke(p string) string

Revoke returns the SQL that will revoke future privileges on the grant from the grantee

func (*FutureGrantExecutable) Show added in v0.5.0

func (fge *FutureGrantExecutable) Show() string

Show returns the SQL that will show all future grants on the schema

type GrantBuilder added in v0.4.0

type GrantBuilder interface {
	Name() string
	Role(string) GrantExecutable
	Share(string) GrantExecutable
	Show() string
}

func AccountGrant added in v0.11.0

func AccountGrant() GrantBuilder

AccountGrant returns a pointer to a CurrentGrantBuilder for an account

func DatabaseGrant added in v0.4.0

func DatabaseGrant(name string) GrantBuilder

DatabaseGrant returns a pointer to a CurrentGrantBuilder for a database

func FutureSchemaGrant added in v0.12.0

func FutureSchemaGrant(db string) GrantBuilder

FutureSchemaGrant returns a pointer to a FutureGrantBuilder for a schema

func FutureTableGrant added in v0.5.0

func FutureTableGrant(db, schema string) GrantBuilder

FutureTableGrant returns a pointer to a FutureGrantBuilder for a table

func FutureViewGrant added in v0.5.0

func FutureViewGrant(db, schema string) GrantBuilder

FutureViewGrant returns a pointer to a FutureGrantBuilder for a view

func IntegrationGrant added in v0.11.0

func IntegrationGrant(w string) GrantBuilder

IntegrationGrant returns a pointer to a CurrentGrantBuilder for a warehouse

func ResourceMonitorGrant added in v0.11.0

func ResourceMonitorGrant(w string) GrantBuilder

ResourceMonitorGrant returns a pointer to a CurrentGrantBuilder for a warehouse

func SchemaGrant added in v0.4.0

func SchemaGrant(db, schema string) GrantBuilder

SchemaGrant returns a pointer to a CurrentGrantBuilder for a schema

func StageGrant added in v0.9.3

func StageGrant(db, schema, stage string) GrantBuilder

StageGrant returns a pointer to a CurrentGrantBuilder for a stage

func TableGrant added in v0.5.0

func TableGrant(db, schema, table string) GrantBuilder

TableGrant returns a pointer to a CurrentGrantBuilder for a table

func ViewGrant added in v0.4.0

func ViewGrant(db, schema, view string) GrantBuilder

ViewGrant returns a pointer to a CurrentGrantBuilder for a view

func WarehouseGrant added in v0.4.0

func WarehouseGrant(w string) GrantBuilder

WarehouseGrant returns a pointer to a CurrentGrantBuilder for a warehouse

type GrantExecutable added in v0.4.0

type GrantExecutable interface {
	Grant(p string) string
	Revoke(p string) string
	Show() string
}

type PipeBuilder added in v0.10.0

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

PipeBuilder abstracts the creation of SQL queries for a Snowflake schema

func Pipe added in v0.10.0

func Pipe(name, db, schema string) *PipeBuilder

Pipe returns a pointer to a Builder that abstracts the DDL operations for a pipe.

Supported DDL operations are:

  • CREATE PIPE
  • ALTER PIPE
  • DROP PIPE
  • SHOW PIPE

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

func (*PipeBuilder) ChangeComment added in v0.10.0

func (pb *PipeBuilder) ChangeComment(c string) string

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

func (*PipeBuilder) Create added in v0.10.0

func (pb *PipeBuilder) Create() string

Create returns the SQL statement required to create a pipe

func (*PipeBuilder) Drop added in v0.10.0

func (pb *PipeBuilder) Drop() string

Drop returns the SQL query that will drop a pipe.

func (*PipeBuilder) QualifiedName added in v0.10.0

func (pb *PipeBuilder) QualifiedName() string

QualifiedName prepends the db and schema if set and escapes everything nicely

func (*PipeBuilder) RemoveComment added in v0.10.0

func (pb *PipeBuilder) RemoveComment() string

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

func (*PipeBuilder) Show added in v0.10.0

func (pb *PipeBuilder) Show() string

Show returns the SQL query that will show a pipe.

func (*PipeBuilder) WithAutoIngest added in v0.10.0

func (pb *PipeBuilder) WithAutoIngest() *PipeBuilder

Transient adds the auto_ingest flag to the PipeBuilder

func (*PipeBuilder) WithComment added in v0.10.0

func (pb *PipeBuilder) WithComment(c string) *PipeBuilder

WithComment adds a comment to the PipeBuilder

func (*PipeBuilder) WithCopyStatement added in v0.10.0

func (pb *PipeBuilder) WithCopyStatement(s string) *PipeBuilder

WithURL adds a URL to the PipeBuilder

type ResourceMonitorBuilder added in v0.4.0

type ResourceMonitorBuilder struct {
	Builder
}

ResourceMonitorBuilder extends the generic builder to provide support for triggers

func ResourceMonitor added in v0.4.0

func ResourceMonitor(name string) *ResourceMonitorBuilder

ResourceMonitor returns a pointer to a ResourceMonitorBuilder that abstracts the DDL operations for a resource monitor.

Supported DDL operations are:

  • CREATE RESOURCE MONITOR
  • ALTER RESOURCE MONITOR
  • DROP RESOURCE MONITOR
  • SHOW RESOURCE MONITOR

[Snowflake Reference](https://docs.snowflake.net/manuals/user-guide/resource-monitors.html#ddl-for-resource-monitors)

func (*ResourceMonitorBuilder) Create added in v0.4.0

Create returns a pointer to a ResourceMonitorCreateBuilder

type ResourceMonitorCreateBuilder added in v0.4.0

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

ResourceMonitorCreateBuilder extends the generic create builder to provide support for triggers

func (*ResourceMonitorCreateBuilder) NotifyAt added in v0.4.0

NotifyAt adds a notify trigger at the specified percentage threshold

func (*ResourceMonitorCreateBuilder) Statement added in v0.4.0

func (rcb *ResourceMonitorCreateBuilder) Statement() string

Statement returns the SQL statement needed to actually create the resource

func (*ResourceMonitorCreateBuilder) SuspendAt added in v0.4.0

SuspendAt adds a suspend trigger at the specified percentage threshold

func (*ResourceMonitorCreateBuilder) SuspendImmediatelyAt added in v0.4.0

func (rcb *ResourceMonitorCreateBuilder) SuspendImmediatelyAt(pct int) *ResourceMonitorCreateBuilder

SuspendImmediatelyAt adds a suspend immediately trigger at the specified percentage threshold

type RoleGrantBuilder

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

func RoleGrant

func RoleGrant(name string) *RoleGrantBuilder

func (*RoleGrantBuilder) Role

func (*RoleGrantBuilder) User

type RoleGrantExecutable

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

func (*RoleGrantExecutable) Grant

func (gr *RoleGrantExecutable) Grant() string

func (*RoleGrantExecutable) Revoke

func (gr *RoleGrantExecutable) Revoke() string

type SchemaBuilder added in v0.4.0

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

SchemaBuilder abstracts the creation of SQL queries for a Snowflake schema

func Schema added in v0.4.0

func Schema(name string) *SchemaBuilder

Schema returns a pointer to a Builder that abstracts the DDL operations for a schema.

Supported DDL operations are:

  • CREATE SCHEMA
  • ALTER SCHEMA
  • DROP SCHEMA
  • UNDROP SCHEMA
  • USE SCHEMA
  • SHOW SCHEMAS

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

func (*SchemaBuilder) ChangeComment added in v0.4.0

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

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

func (*SchemaBuilder) ChangeDataRetentionDays added in v0.4.0

func (sb *SchemaBuilder) ChangeDataRetentionDays(d int) string

ChangeDataRetentionDays returns the SQL query that will update the data retention days on the schema.

func (*SchemaBuilder) Create added in v0.4.0

func (sb *SchemaBuilder) Create() string

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

func (*SchemaBuilder) Drop added in v0.4.0

func (sb *SchemaBuilder) Drop() string

Drop returns the SQL query that will drop a schema.

func (*SchemaBuilder) Manage added in v0.4.0

func (sb *SchemaBuilder) Manage() string

Manage returns the SQL query that will enable managed access for a schema.

func (*SchemaBuilder) Managed added in v0.4.0

func (sb *SchemaBuilder) Managed() *SchemaBuilder

Managed adds the WITH MANAGED ACCESS flag to the SchemaBuilder

func (*SchemaBuilder) QualifiedName added in v0.4.0

func (sb *SchemaBuilder) QualifiedName() string

QualifiedName prepends the db if set and escapes everything nicely

func (*SchemaBuilder) RemoveComment added in v0.4.0

func (sb *SchemaBuilder) RemoveComment() string

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

func (*SchemaBuilder) RemoveDataRetentionDays added in v0.4.0

func (sb *SchemaBuilder) RemoveDataRetentionDays() string

RemoveDataRetentionDays returns the SQL query that will remove the data retention days on the schema.

func (*SchemaBuilder) Rename added in v0.4.0

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

Rename returns the SQL query that will rename the schema.

func (*SchemaBuilder) Show added in v0.4.0

func (sb *SchemaBuilder) Show() string

Show returns the SQL query that will show a schema.

func (*SchemaBuilder) Swap added in v0.4.0

func (sb *SchemaBuilder) Swap(targetSchema string) string

Swap returns the SQL query that Swaps all objects (tables, views, etc.) and metadata, including identifiers, between the two specified schemas.

func (*SchemaBuilder) Transient added in v0.4.0

func (sb *SchemaBuilder) Transient() *SchemaBuilder

Transient adds the TRANSIENT flag to the SchemaBuilder

func (*SchemaBuilder) Undrop added in v0.4.0

func (sb *SchemaBuilder) Undrop() string

Undrop returns the SQL query that will undrop a schema.

func (*SchemaBuilder) Unmanage added in v0.4.0

func (sb *SchemaBuilder) Unmanage() string

Unmanage returns the SQL query that will disble managed access for a schema.

func (*SchemaBuilder) Use added in v0.4.0

func (sb *SchemaBuilder) Use() string

Use returns the SQL query that will use a schema.

func (*SchemaBuilder) WithComment added in v0.4.0

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

WithComment adds a comment to the SchemaBuilder

func (*SchemaBuilder) WithDB added in v0.4.0

func (sb *SchemaBuilder) WithDB(db string) *SchemaBuilder

WithDB adds the name of the database to the SchemaBuilder

func (*SchemaBuilder) WithDataRetentionDays added in v0.4.0

func (sb *SchemaBuilder) WithDataRetentionDays(d int) *SchemaBuilder

WithDataRetentionDays adds the days to retain data to the SchemaBuilder (must be 0-1 for standard edition, 0-90 for enterprise edition)

type SettingBuilder added in v0.11.0

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

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

type StageBuilder added in v0.9.3

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

StageBuilder abstracts the creation of SQL queries for a Snowflake stage

func Stage added in v0.9.3

func Stage(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) ChangeComment added in v0.9.3

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.9.3

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.9.3

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.9.3

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.9.3

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.11.0

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

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

func (*StageBuilder) ChangeURL added in v0.9.3

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.9.3

func (sb *StageBuilder) Create() string

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

func (*StageBuilder) Describe added in v0.9.3

func (sb *StageBuilder) Describe() string

Describe returns the SQL query that will describe a stage.

func (*StageBuilder) Drop added in v0.9.3

func (sb *StageBuilder) Drop() string

Drop returns the SQL query that will drop a stage.

func (*StageBuilder) QualifiedName added in v0.9.3

func (sb *StageBuilder) QualifiedName() string

QualifiedName prepends the db and schema and escapes everything nicely

func (*StageBuilder) RemoveComment added in v0.9.3

func (sb *StageBuilder) RemoveComment() string

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

func (*StageBuilder) Rename added in v0.9.3

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

Rename returns the SQL query that will rename the stage.

func (*StageBuilder) Show added in v0.9.3

func (sb *StageBuilder) Show() string

Show returns the SQL query that will show a stage.

func (*StageBuilder) Undrop added in v0.9.3

func (sb *StageBuilder) Undrop() string

Undrop returns the SQL query that will undrop a stage.

func (*StageBuilder) WithComment added in v0.9.3

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

WithComment adds a comment to the StageBuilder

func (*StageBuilder) WithCopyOptions added in v0.9.3

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

WithCopyOptions adds copy options to the StageBuilder

func (*StageBuilder) WithCredentials added in v0.9.3

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

WithCredentials adds credentials to the StageBuilder

func (*StageBuilder) WithEncryption added in v0.9.3

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

WithEncryption adds encryption to the StageBuilder

func (*StageBuilder) WithFileFormat added in v0.9.3

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

WithFileFormat adds a file format to the StageBuilder

func (*StageBuilder) WithStorageIntegration added in v0.11.0

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

WithStorageIntegration adds a storage integration to the StageBuilder

func (*StageBuilder) WithURL added in v0.9.3

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

WithURL adds a URL to the StageBuilder

type ViewBuilder added in v0.4.0

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

ViewBuilder abstracts the creation of SQL queries for a Snowflake View

func View added in v0.4.0

func View(name string) *ViewBuilder

View returns a pointer to a Builder that abstracts the DDL operations for a view.

Supported DDL operations are:

  • CREATE VIEW
  • ALTER VIEW
  • DROP VIEW
  • SHOW VIEWS
  • DESCRIBE VIEW

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

func (*ViewBuilder) ChangeComment added in v0.4.0

func (vb *ViewBuilder) ChangeComment(c string) string

ChangeComment returns the SQL query that will update the comment on the view. Note that comment is the only parameter, if more are released this should be abstracted as per the generic builder.

func (*ViewBuilder) Create added in v0.4.0

func (vb *ViewBuilder) Create() string

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

func (*ViewBuilder) Drop added in v0.4.0

func (vb *ViewBuilder) Drop() string

Drop returns the SQL query that will drop the row representing this view.

func (*ViewBuilder) QualifiedName added in v0.4.0

func (vb *ViewBuilder) QualifiedName() string

QualifiedName prepends the db and schema if set and escapes everything nicely

func (*ViewBuilder) RemoveComment added in v0.4.0

func (vb *ViewBuilder) RemoveComment() string

RemoveComment returns the SQL query that will remove the comment on the view. Note that comment is the only parameter, if more are released this should be abstracted as per the generic builder.

func (*ViewBuilder) Rename added in v0.4.0

func (vb *ViewBuilder) Rename(newName string) string

Rename returns the SQL query that will rename the view.

func (*ViewBuilder) Secure added in v0.4.0

func (vb *ViewBuilder) Secure() string

Secure returns the SQL query that will change the view to a secure view.

func (*ViewBuilder) Show added in v0.4.0

func (vb *ViewBuilder) Show() string

Show returns the SQL query that will show the row representing this view.

func (*ViewBuilder) Unsecure added in v0.4.0

func (vb *ViewBuilder) Unsecure() string

Unsecure returns the SQL query that will change the view to a normal (unsecured) view.

func (*ViewBuilder) WithComment added in v0.4.0

func (vb *ViewBuilder) WithComment(c string) *ViewBuilder

WithComment adds a comment to the ViewBuilder

func (*ViewBuilder) WithDB added in v0.4.0

func (vb *ViewBuilder) WithDB(db string) *ViewBuilder

WithDB adds the name of the database to the ViewBuilder

func (*ViewBuilder) WithSchema added in v0.4.0

func (vb *ViewBuilder) WithSchema(s string) *ViewBuilder

WithSchema adds the name of the schema to the ViewBuilder

func (*ViewBuilder) WithSecure added in v0.4.0

func (vb *ViewBuilder) WithSecure() *ViewBuilder

WithSecure sets the secure boolean to true [Snowflake Reference](https://docs.snowflake.net/manuals/user-guide/views-secure.html)

func (*ViewBuilder) WithStatement added in v0.4.0

func (vb *ViewBuilder) WithStatement(s string) *ViewBuilder

WithStatement adds the SQL statement to be used for the view

type ViewSelectStatementExtractor added in v0.12.1

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.

func NewViewSelectStatementExtractor added in v0.12.1

func NewViewSelectStatementExtractor(input string) *ViewSelectStatementExtractor

func (*ViewSelectStatementExtractor) Extract added in v0.12.1

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

Jump to

Keyboard shortcuts

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