snowflake

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Target

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

func NewTarget

func NewTarget(ctx context.Context, conn *sql.DB, database string, schema string) (*Target, error)

func (*Target) Close

func (t *Target) Close(context.Context) error

func (*Target) InitializeRelation

func (t *Target) InitializeRelation(ctx context.Context, relation *db.Relation, source io.Reader) error

InitializeRelation creates a relation and populates it with initial data from source In order to avoid leaving any relation in an intermediate state if interrupted by errors, the strategy is to create a table with `_SCRATCH` appended to the name and load data to the scratch table. When loading is complete, atomically make the table live (by removing the _SCRATCH) suffix. This would be simpler if it could be done in a transaction, but Snowflake ends any current transaction as soon as a DDL statement is executed (like CREATE TABLE or ALTER TABLE). https://docs.snowflake.com/en/sql-reference/transactions.html#ddl

func (*Target) String

func (t *Target) String() string

func (*Target) VerifyRelation

func (t *Target) VerifyRelation(ctx context.Context, relation *db.Relation) (bool, error)

func (*Target) Write

func (t *Target) Write(ctx context.Context, batch []*db.WalTransaction) error

Write pushes events from postgres into snowflake. Each batch is a list of complete postgres transactions (so referential integrity will be maintained after a complete batch). Each action affects one row, even if a single statement was issued in postgres that affected more than one row. For example, `INSERT INTO items(id) SELECT i FROM generate_series(0, 100) as t(i);` is one postgres statement that inserts 100 rows. This would generate an Actions object with 100 individual Insert actions. In order to execute this efficiently in Snowflake, we must group actions to execute multiple actions as a single snowflake statement.

Jump to

Keyboard shortcuts

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