rai

package
v0.4.5-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: Apache-2.0 Imports: 27 Imported by: 1

Documentation

Index

Constants

View Source
const (
	PathDatabase     = "/database"
	PathEngine       = "/compute"
	PathIntegrations = "/integration/v1alpha1/integrations"
	PathOAuthClients = "/oauth-clients"
	PathTransaction  = "/transaction"
	PathTransactions = "/transactions"
	PathUsers        = "/users"
)
View Source
const DefaultConfigFile = "~/.rai/config"
View Source
const DefaultConfigProfile = "default"
View Source
const DefaultHost = "azure.relationalai.com"
View Source
const DefaultPort = "443"
View Source
const DefaultRegion = "us-east"
View Source
const DefaultScheme = "https"
View Source
const Version = "0.4.5-alpha"

Variables

View Source
var (
	// Simple types
	BoolType        = typeOf[bool]()
	CharType        = typeOf[Char]()
	Float16Type     = typeOf[float16.Num]()
	Float64Type     = typeOf[float64]()
	Float32Type     = typeOf[float32]()
	Int128Type      = typeOf[Int128]()
	Int64Type       = typeOf[int64]()
	Int32Type       = typeOf[int32]()
	Int16Type       = typeOf[int16]()
	Int8Type        = typeOf[int8]()
	StringType      = typeOf[string]()
	Uint128Type     = typeOf[Uint128]()
	Uint64Type      = typeOf[uint64]()
	Uint32Type      = typeOf[uint32]()
	Uint16Type      = typeOf[uint16]()
	Uint8Type       = typeOf[uint8]()
	UnspecifiedType = typeOf[Unspecified]()

	// Composite types
	AnyListType     = typeOf[[]any]()
	Float32ListType = typeOf[[]float32]()
	Float64ListType = typeOf[[]float64]()
	Int8ListType    = typeOf[[]int8]()
	Int16ListType   = typeOf[[]int16]()
	Int32ListType   = typeOf[[]int32]()
	Int64ListType   = typeOf[[]int64]()
	Uint64ListType  = typeOf[[]uint64]()
	StructType      = typeOf[array.Struct]()
)

Partition column types (many also appear in relations)

View Source
var (
	AnyType      = typeOf[any]() // heterogenous, tabular column
	BigIntType   = typeOf[*big.Int]()
	TimeType     = typeOf[time.Time]()
	DecimalType  = typeOf[decimal.Decimal]()
	RationalType = typeOf[*big.Rat]()
	RuneType     = typeOf[rune]()
	MissingType  = typeOf[Missing]()
	MixedType    = typeOf[Mixed]()
)

Relation specific column types

View Source
var ErrMissingFilterValue = errors.New("missing filter value")
View Source
var ErrNotFound = newHTTPError(http.StatusNotFound, nil, "")
View Source
var UnknownType = typeOf[Unknown]()

Functions

func DateFromRataDie

func DateFromRataDie(d int64) time.Time

Returns the epoch millis corresponding to the given Rata Die day number.

func DateFromRataMillis

func DateFromRataMillis(d int64) time.Time

Returns the epoch millis corresponding to the given millis since 1AD.

func Encode

func Encode(w io.Writer, item interface{}, indent int) error

Encode the given item as JSON to the given writer.

func LoadConfig

func LoadConfig(cfg *Config) error

Load settings from the default profile of the default config file.

func LoadConfigFile

func LoadConfigFile(fname, profile string, cfg *Config) error

Load settings from the given profile of the named config file.

func LoadConfigProfile

func LoadConfigProfile(profile string, cfg *Config) error

Load settings from the given profile in the default config file.

func LoadConfigString

func LoadConfigString(source, profile string, cfg *Config) error

Load settings from the given profile of the provided config source.

func NewBigInt128

func NewBigInt128(lo, hi uint64) *big.Int

func NewBigUint128

func NewBigUint128(lo, hi uint64) *big.Int

func NewDecimal128

func NewDecimal128(lo, hi uint64, digits int32) decimal.Decimal

func NewRational128

func NewRational128(n, d *big.Int) *big.Rat

func Print deprecated

func Print(item interface{}, indent int) error

Deprecated: Use `ShowJSON` instead.

func ShowJSON

func ShowJSON(item interface{}, indent int) error

Print the given item as JSON to stdout.

func ShowMetadata

func ShowMetadata(m *pb.MetadataInfo)

Show protobuf metadata.

func ShowRelation

func ShowRelation(r Relation)

func ShowTabularData

func ShowTabularData(d Tabular)

Show a tabular data value.

Types

type AccessToken

type AccessToken struct {
	Token     string `json:"access_token"`
	Scope     string `json:"scope"`
	ExpiresIn int    `json:"expires_in"` // token lifetime in seconds
	CreatedOn int64  `json:"created_on"` // epoch seconds
}

todo: make sure CreatedOn is persisted as epoch seconds

func (*AccessToken) ExpiresOn

func (a *AccessToken) ExpiresOn() int64

Instant the token expires in epoch seconds.

func (*AccessToken) IsExpired

func (a *AccessToken) IsExpired() bool

Anticipate access token expiration by 5 seconds

func (*AccessToken) Load

func (a *AccessToken) Load(r io.Reader) error

func (*AccessToken) String

func (a *AccessToken) String() string

type AccessTokenHandler

type AccessTokenHandler interface {
	GetAccessToken() (string, error)
}

type CSVOptions

type CSVOptions struct {
	Schema     map[string]string
	HeaderRow  *int
	Delim      rune
	EscapeChar rune
	QuoteChar  rune
}

func NewCSVOptions

func NewCSVOptions() *CSVOptions

func (*CSVOptions) WithDelim

func (opts *CSVOptions) WithDelim(delim rune) *CSVOptions

func (*CSVOptions) WithEscapeChar

func (opts *CSVOptions) WithEscapeChar(escapeChar rune) *CSVOptions

func (*CSVOptions) WithHeaderRow

func (opts *CSVOptions) WithHeaderRow(headerRow int) *CSVOptions

func (*CSVOptions) WithQuoteChar

func (opts *CSVOptions) WithQuoteChar(quoteChar rune) *CSVOptions

func (*CSVOptions) WithSchema

func (opts *CSVOptions) WithSchema(schema map[string]string) *CSVOptions

type Char

type Char uint32

type Client

type Client struct {
	Region     string
	Scheme     string
	Host       string
	Port       string
	HttpClient *http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, opts *ClientOptions) *Client

func NewClientFromConfig

func NewClientFromConfig(profile string) (*Client, error)

Returns a new client using the background context and config settings from the named profile.

func NewDefaultClient

func NewDefaultClient() (*Client, error)

Returns a new client using the background context and config settings from the default profile.

func (*Client) AccessToken

func (c *Client) AccessToken() (string, error)

Returns the current access token

func (*Client) CancelTransaction added in v0.1.1

func (c *Client) CancelTransaction(id string) (string, error)

func (*Client) CloneDatabase

func (c *Client) CloneDatabase(database, source string) (*Database, error)

func (*Client) Context

func (c *Client) Context() context.Context

func (*Client) CreateDatabase

func (c *Client) CreateDatabase(database string) (*Database, error)

func (*Client) CreateEngine

func (c *Client) CreateEngine(engine, size string) (*Engine, error)

Request the creation of an engine, and wait for the opeartion to complete. This can block the caller for up to a minute.

func (*Client) CreateEngineAsync

func (c *Client) CreateEngineAsync(engine, size string) (*Engine, error)

Request the creation of an engine, and immediately return. The process of provisioning a new engine can take up to a minute.

func (*Client) CreateOAuthClient

func (c *Client) CreateOAuthClient(
	name string, perms []string,
) (*OAuthClientExtra, error)

func (*Client) CreateSnowflakeDataStream

func (c *Client) CreateSnowflakeDataStream(
	integration, dbLink string, creds *SnowflakeCredentials, opts *DataStreamOpts,
) (*SnowflakeDataStream, error)
func (c *Client) CreateSnowflakeDatabaseLink(
	integration, database, schema, role string, creds *SnowflakeCredentials,
) (*SnowflakeDatabaseLink, error)

func (*Client) CreateSnowflakeIntegration

func (c *Client) CreateSnowflakeIntegration(
	name, snowflakeAccount, raiEngine string, adminCreds, proxyCreds *SnowflakeCredentials,
) (*Integration, error)

func (*Client) CreateUser

func (c *Client) CreateUser(email string, roles []string) (*User, error)

func (*Client) Delete

func (c *Client) Delete(path string, args url.Values, data, result interface{}) error

func (*Client) DeleteDatabase

func (c *Client) DeleteDatabase(database string) error

func (*Client) DeleteEngine

func (c *Client) DeleteEngine(engine string) error

Request the deletion of an engine and wait for the operation to complete.

func (*Client) DeleteEngineAsync

func (c *Client) DeleteEngineAsync(engine string) (*Engine, error)

func (*Client) DeleteModel

func (c *Client) DeleteModel(
	database, engine, name string,
) (*TransactionResult, error)

func (*Client) DeleteModels

func (c *Client) DeleteModels(
	database, engine string, models []string,
) (*TransactionResult, error)

func (*Client) DeleteOAuthClient

func (c *Client) DeleteOAuthClient(id string) (*DeleteOAuthClientResponse, error)

func (*Client) DeleteSnowflakeDataStream

func (c *Client) DeleteSnowflakeDataStream(
	integration, dbLink, objectName, role string, creds *SnowflakeCredentials,
) error
func (c *Client) DeleteSnowflakeDatabaseLink(
	integration, database, schema, role string, creds *SnowflakeCredentials,
) error

func (*Client) DeleteSnowflakeIntegration

func (c *Client) DeleteSnowflakeIntegration(name string, adminCreds *SnowflakeCredentials) error

func (*Client) DeleteUser

func (c *Client) DeleteUser(id string) (*DeleteUserResponse, error)

func (*Client) DisableUser

func (c *Client) DisableUser(id string) (*User, error)

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Execute the given request and return the response or error.

func (*Client) EnableUser

func (c *Client) EnableUser(id string) (*User, error)

func (*Client) Execute

func (c *Client) Execute(
	database, engine, source string,
	inputs map[string]string, readonly bool,
	tags ...string,
) (*TransactionResponse, error)

todo: consider making the polling coefficients part of tx options

func (*Client) ExecuteAsync

func (c *Client) ExecuteAsync(
	database, engine, query string,
	inputs map[string]string, readonly bool,
	tags ...string,
) (*TransactionResponse, error)

func (*Client) ExecuteV1 deprecated added in v0.2.0

func (c *Client) ExecuteV1(
	database, engine, source string,
	inputs map[string]string,
	readonly bool,
) (*TransactionResult, error)

Deprecated: use `Execute`

func (*Client) FindOAuthClient

func (c *Client) FindOAuthClient(name string) (*OAuthClient, error)

Returns the OAuth client with the given name or ErrNotFound if it does not exist.

func (*Client) FindUser

func (c *Client) FindUser(email string) (*User, error)

Returns the User with the given email or nil if it does not exist.

func (*Client) Get

func (c *Client) Get(path string, headers map[string]string, args url.Values, result interface{}) error

func (*Client) GetAccessToken

func (c *Client) GetAccessToken(creds *ClientCredentials) (*AccessToken, error)

Fetch a new access token using the given client credentials.

func (*Client) GetDatabase

func (c *Client) GetDatabase(database string) (*Database, error)

func (*Client) GetEngine

func (c *Client) GetEngine(engine string) (*Engine, error)

func (*Client) GetModel

func (c *Client) GetModel(database, engine, model string) (*Model, error)

func (*Client) GetOAuthClient

func (c *Client) GetOAuthClient(id string) (*OAuthClientExtra, error)

func (*Client) GetSnowflakeDataStream

func (c *Client) GetSnowflakeDataStream(
	integration, dbLink, objectName string,
) (*SnowflakeDataStream, error)
func (c *Client) GetSnowflakeDatabaseLink(
	integration, database, schema string,
) (*SnowflakeDatabaseLink, error)

func (*Client) GetSnowflakeIntegration

func (c *Client) GetSnowflakeIntegration(name string) (*Integration, error)

func (*Client) GetTransaction

func (c *Client) GetTransaction(id string, opts ...GetTransactionOptions) (
	*TransactionResponse, error,
)

Returns the transaction resource identified by `id` and any other outputs selected in `opts`, if available.

func (*Client) GetTransactionMetadata

func (c *Client) GetTransactionMetadata(id string) (
	*TransactionMetadata, error,
)

func (*Client) GetTransactionProblems

func (c *Client) GetTransactionProblems(id string) ([]Problem, error)

todo: deprecated, should be loaded from partitions

func (*Client) GetTransactionResults

func (c *Client) GetTransactionResults(id string) (map[string]*Partition, error)

func (*Client) GetUser

func (c *Client) GetUser(id string) (*User, error)

func (*Client) ListDatabases

func (c *Client) ListDatabases(filters ...interface{}) ([]Database, error)

func (*Client) ListEDBs

func (c *Client) ListEDBs(database, engine string) ([]EDB, error)

func (*Client) ListEngines

func (c *Client) ListEngines(filters ...interface{}) ([]Engine, error)

func (*Client) ListModelNames

func (c *Client) ListModelNames(database, engine string) ([]string, error)

Returns a list of model names for the given database.

func (*Client) ListModels

func (c *Client) ListModels(database, engine string) ([]Model, error)

Returns the names of models installed in the given database.

func (*Client) ListOAuthClients

func (c *Client) ListOAuthClients() ([]OAuthClient, error)

func (*Client) ListSnowflakeDataStreams

func (c *Client) ListSnowflakeDataStreams(
	integration, dbLink string,
) ([]SnowflakeDataStream, error)
func (c *Client) ListSnowflakeDatabaseLinks(
	integration string,
) ([]SnowflakeDatabaseLink, error)

func (*Client) ListSnowflakeIntegrations

func (c *Client) ListSnowflakeIntegrations() ([]Integration, error)

func (*Client) ListTransactions

func (c *Client) ListTransactions(tags ...string) ([]Transaction, error)

func (*Client) ListUsers

func (c *Client) ListUsers() ([]User, error)

func (*Client) LoadCSV

func (c *Client) LoadCSV(
	database, engine, relation string, r io.Reader, opts *CSVOptions,
) (*TransactionResult, error)

func (*Client) LoadJSON

func (c *Client) LoadJSON(
	database, engine, relation string, r io.Reader,
) (*TransactionResult, error)

func (*Client) LoadModel

func (c *Client) LoadModel(
	database, engine, name string, r io.Reader,
) (*TransactionResult, error)

func (*Client) LoadModels

func (c *Client) LoadModels(
	database, engine string, models map[string]io.Reader,
) (*TransactionResult, error)

func (*Client) Patch

func (c *Client) Patch(path string, args url.Values, data, result interface{}) error

func (*Client) Post

func (c *Client) Post(path string, args url.Values, data, result interface{}) error

func (*Client) Put

func (c *Client) Put(path string, args url.Values, data, result interface{}) error

func (*Client) SetAccessTokenHandler

func (c *Client) SetAccessTokenHandler(handler AccessTokenHandler)

func (*Client) SetContext

func (c *Client) SetContext(ctx context.Context)

func (*Client) UpdateUser

func (c *Client) UpdateUser(id string, req UpdateUserRequest) (*User, error)

func (*Client) Url

func (c *Client) Url(path string) string

Returns a URL constructed from given path.

type ClientCredentials

type ClientCredentials struct {
	ClientID             string `json:"clientId"`
	ClientSecret         string `json:"-"`
	ClientCredentialsUrl string `json:"clientCredentialsUrl"`
	Audience             string `json:"audience"`
}

type ClientCredentialsHandler

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

func NewClientCredentialsHandler

func NewClientCredentialsHandler(
	c *Client, creds *ClientCredentials,
) *ClientCredentialsHandler

This handler uses the given OAuth client credentials to retrieve access tokens, as needed, and caches them locally in ~/.rai/tokens.json.

func (*ClientCredentialsHandler) GetAccessToken

func (h *ClientCredentialsHandler) GetAccessToken() (string, error)

type ClientOptions

type ClientOptions struct {
	Config
	HTTPClient         *http.Client
	AccessTokenHandler AccessTokenHandler
	PreRequestHook     PreRequestHook
}

func NewClientOptions

func NewClientOptions(cfg *Config) *ClientOptions

type Column

type Column interface {
	NumRows() int
	String(int) string
	Type() any // reflect.Type | MixedType
	Value(int) any
}

Column provides access to a single column of data.

type Config

type Config struct {
	Region      string             `json:"region"`
	Scheme      string             `json:"scheme"`
	Host        string             `json:"host"`
	Port        string             `json:"port"`
	Credentials *ClientCredentials `json:"credentials"`
}

type ConstType

type ConstType Signature

func (ConstType) String

func (t ConstType) String() string

func (ConstType) Strings

func (t ConstType) Strings() []string

type DataColumn

type DataColumn[T any] interface {
	Column
	Item(int) T
}

DataColumn is a Column with a typed accessor.

type DataStreamOpts

type DataStreamOpts struct {
	IsView      bool
	RaiDatabase string
	Relation    string
	ObjectName  string
	Role        string
	Warehouse   string
}

type Database

type Database struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Region      string `json:"region"`
	AccountName string `json:"account_name"`
	CreatedBy   string `json:"created_by"`
	CreatedOn   string `json:"created_on"`
	DeletedBy   string `json:"deleted_by,omitempty"`
	DeletedOn   string `json:"deleted_on,omitempty"`
	State       string `json:"state"`
}

type DbAction

type DbAction map[string]interface{}

type DeleteEngineStatus

type DeleteEngineStatus struct {
	Name    string `json:"name"`
	State   string `json:"state"`
	Message string `json:"message"`
}

type DeleteOAuthClientResponse

type DeleteOAuthClientResponse struct {
	ID      string `json:"client_id"`
	Message string `json:"message"`
}

type DeleteUserResponse

type DeleteUserResponse struct {
	ID      string `json:"user_id"`
	Message string `json:"message"`
}

type EDB

type EDB struct {
	Name   string   `json:"name"`
	Keys   []string `json:"keys"`
	Values []string `json:"values"`
}

type Engine

type Engine struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Region      string `json:"region"`
	AccountName string `json:"account_name"`
	CreatedBy   string `json:"created_by"`
	CreatedOn   string `json:"created_on,omitempty"` // todo: required?
	DeletedOn   string `json:"deleted_on,omitempty"`
	Size        string `json:"size"`
	State       string `json:"state"`
}

type GetTransactionOptions

type GetTransactionOptions struct {
	Results  bool
	Metadata bool
	Problems bool
}

If any of the following are true, `GetTransaction` will retrieve the corresponding outputs, if available.

type HTTPError

type HTTPError struct {
	StatusCode int
	Headers    http.Header
	Body       string
}

func (HTTPError) Error

func (e HTTPError) Error() string

type Int128

type Int128 [2]uint64

type Integration

type Integration struct {
	ID         string `json:"id"`
	Kind       string `json:"kind"`
	Name       string `json:"name"`
	Account    string `json:"account"`
	CreatedBy  string `json:"createdBy"`
	CreatedOn  string `json:"createdOn"`
	State      string `json:"state"`
	ConsentURL string `json:"consentUrl"`
	Snowflake  struct {
		Account string `json:"account"`
	} `json:"snowflake"`
	RAI struct {
		Engine string `json:"engine"`
	} `json:"rai"`
}

type IntegrityConstraintViolation

type IntegrityConstraintViolation struct {
	Type    string   `json:"type"`
	Sources []Source `json:"sources"`
}

type Missing

type Missing struct{}

type Mixed

type Mixed struct{}

type Model

type Model struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type NopAccessTokenHandler

type NopAccessTokenHandler struct{}

This handler always returns an empty token, which results in requests not being authenticated.

func NewNopAccessTokenHandler

func NewNopAccessTokenHandler() NopAccessTokenHandler

func (NopAccessTokenHandler) GetAccessToken

func (h NopAccessTokenHandler) GetAccessToken() (string, error)

type OAuthClient

type OAuthClient struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	AccountName string    `json:"account_name"`
	CreatedBy   string    `json:"created_by"`
	CreatedOn   time.Time `json:"created_on"`
}

type OAuthClientExtra

type OAuthClientExtra struct {
	OAuthClient
	Permissions []string `json:"permissions"`
	Secret      string   `json:"secret"`
}

type Partition

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

func (*Partition) Column

func (p *Partition) Column(rnum int) Column

func (*Partition) Columns

func (p *Partition) Columns() []Column

func (*Partition) GetItem

func (p *Partition) GetItem(rnum int, out []any)

func (*Partition) GetRow

func (p *Partition) GetRow(rnum int, out []any)

func (*Partition) Item

func (p *Partition) Item(rnum int) []any

func (*Partition) NumCols

func (p *Partition) NumCols() int

func (*Partition) NumRows

func (p *Partition) NumRows() int

func (*Partition) Record

func (p *Partition) Record() arrow.Record

func (*Partition) Row

func (p *Partition) Row(rnum int) []any

func (*Partition) Signature

func (p *Partition) Signature() Signature

Returns the type signature describing the partition.

func (*Partition) String

func (p *Partition) String(rnum int) string

func (*Partition) Strings

func (p *Partition) Strings(rnum int) []string

func (*Partition) Type

func (p *Partition) Type() any

func (*Partition) Value

func (p *Partition) Value(rnum int) any

type PreRequestHook

type PreRequestHook func(*http.Request) *http.Request

type PrimitiveTypes

type PrimitiveTypes interface {
	bool | floatTypes | intTypes | string
}

type Problem

type Problem struct {
	Type        string `json:"type"`
	ErrorCode   string `json:"error_code"`
	Message     string `json:"message"`
	Report      string `json:"report"`
	Path        string `json:"path"` // ?
	IsError     bool   `json:"is_error"`
	IsException bool   `json:"is_exception"`
}

type ProblemV1

type ProblemV1 struct {
	Type        string `json:"type"`
	ErrorCode   string `json:"error_code"`
	IsError     bool   `json:"is_error"`
	IsException bool   `json:"is_exception"`
	Message     string `json:"message"`
	Report      string `json:"report"`
}

type RelKey

type RelKey struct {
	Name   string   `json:"name"`
	Keys   []string `json:"keys"`
	Values []string `json:"values"`
}

type Relation

type Relation interface {
	Tabular
	Showable
	Slice(int, ...int) Relation
}

type RelationCollection

type RelationCollection []Relation

func (RelationCollection) Select

func (c RelationCollection) Select(args ...any) RelationCollection

Select the relations matching the given signature prefix arguments. Match all if no arguments are given.

func (RelationCollection) Show

func (rc RelationCollection) Show()

func (RelationCollection) Union

func (c RelationCollection) Union() Relation

type RelationV1

type RelationV1 struct {
	RelKey  RelKey          `json:"rel_key"`
	Columns [][]interface{} `json:"columns"`
}

func (*RelationV1) GetRow

func (r *RelationV1) GetRow(n int) []interface{}

func (*RelationV1) Name

func (r *RelationV1) Name() string

func (*RelationV1) RowCount

func (r *RelationV1) RowCount() int

func (*RelationV1) Schema

func (r *RelationV1) Schema() string

func (*RelationV1) Show

func (r *RelationV1) Show()

type Showable

type Showable interface {
	Show()
}

type Signature

type Signature []any

func (Signature) String

func (s Signature) String() string

func (Signature) Strings

func (s Signature) Strings() []string

type SimpleColumn

type SimpleColumn[T SimpleTypes] interface {
	DataColumn[T]
	GetItem(int, *T)
}

SimpleColumn is a DataColumn with a typed placement accessor for simple types.

type SimpleTypes

type SimpleTypes interface {
	PrimitiveTypes | *big.Int | *big.Rat | decimal.Decimal | time.Time
}

type SnowflakeCredentials

type SnowflakeCredentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type SnowflakeDataStream

type SnowflakeDataStream struct {
	Account     string `json:"account"` // partition key
	ID          string `json:"id"`
	Name        string `json:"name"` // database.schema.object
	Integration string `json:"integration"`
	DbLink      string `json:"dbLink"`
	CreatedBy   string `json:"createdBy"`
	CreatedOn   string `json:"createdOn"`
	State       string `json:"state"`
	Snowflake   struct {
		Database string `json:"database"`
		Schema   string `json:"schema"`
		Object   string `json:"object"` // fully qualified object name
	} `json:"snowflake"`
	RAI struct {
		Database string `json:"database"`
		Relation string `json:"relation"`
	} `json:"rai"`
}
type SnowflakeDatabaseLink struct {
	ID          string `json:"id"`
	Name        string `json:"name"` // database.schema
	Account     string `json:"account"`
	CreatedBy   string `json:"createdBy"`
	CreatedOn   string `json:"createdOn"`
	State       string `json:"state"`
	Integration string `json:"integration"`
	Snowflake   struct {
		Database string `json:"database"`
		Schema   string `json:"schema"`
	} `json:"snowflake"`
}

type Source

type Source struct {
	RelKey RelKey `json:"rel_key"`
	Source string `json:"source"`
	Type   string `json:"type"`
}

type Tabular

type Tabular interface {
	Column
	Column(int) Column
	Columns() []Column
	GetRow(int, []any)
	NumCols() int
	Row(int) []any
	Signature() Signature
	Strings(int) []string
}

Tabular is a generic interface to a sequence of columns of data with a type siganture.

type TabularColumn

type TabularColumn[T any] interface {
	DataColumn[[]T]
	GetItem(int, []T)
	NumCols() int
	Strings(int) []string
}

TabularColumn is a DataColumn with a typed placement accessor for composite types.

type Transaction

type Transaction struct {
	ID                    string           `json:"id"`
	AccountName           string           `json:"account_name,omitempty"`
	Database              string           `json:"database_name,omitempty"`
	Query                 string           `json:"query,omitempty"`
	State                 TransactionState `json:"state"`
	ReadOnly              bool             `json:"read_only,omitempty"`
	CreatedBy             string           `json:"created_by,omitempty"`
	CreatedOn             int64            `json:"created_on,omitempty"`
	FinishedAt            int64            `json:"finished_at,omitempty"`
	LastRequestedInterval int64            `json:"last_requested_interval,omitempty"`
}

type TransactionMetadata

type TransactionMetadata struct {
	Info *pb.MetadataInfo // protobuf metadata
	// contains filtered or unexported fields
}

func (TransactionMetadata) Signature

func (m TransactionMetadata) Signature(id string) Signature

Returns the metadata signature corresponding to the given `id`, and nil if the requested `id` does not exist.

func (TransactionMetadata) Signatures

func (m TransactionMetadata) Signatures() map[string]Signature

Returns a mapping from relation `id` to metadata signature.

type TransactionRequest

type TransactionRequest struct {
	Database string   `json:"dbname"`
	Engine   string   `json:"engine_name"`
	Query    string   `json:"query"`
	ReadOnly bool     `json:"readonly"`
	Inputs   []any    `json:"v1_inputs"`
	Tags     []string `json:"tags"`
}

type TransactionResponse

type TransactionResponse struct {
	Transaction Transaction
	Metadata    *TransactionMetadata
	Partitions  map[string]*Partition
	Problems    []Problem // todo: move to relational rep
	// contains filtered or unexported fields
}

func ReadTransactionResponse

func ReadTransactionResponse(rsp *http.Response) (*TransactionResponse, error)

Returns the results of a fast path response, which will contain data for the transaction resource, problems, metadata and results in various parts of the multipart response.

func (*TransactionResponse) EnsureMetadata

func (t *TransactionResponse) EnsureMetadata(c *Client) (*TransactionMetadata, error)

func (*TransactionResponse) EnsureProblems

func (t *TransactionResponse) EnsureProblems(c *Client) ([]Problem, error)

func (*TransactionResponse) EnsureResults

func (t *TransactionResponse) EnsureResults(c *Client) (map[string]*Partition, error)

func (*TransactionResponse) Partition

func (t *TransactionResponse) Partition(id string) *Partition

func (*TransactionResponse) Relation

func (t *TransactionResponse) Relation(id string) Relation

func (*TransactionResponse) Relations

func (t *TransactionResponse) Relations(args ...any) RelationCollection

Returns a collection of relations whose signature matches any of the optional prefix arguments, where value "_" in the prefix matches any value in the corresponding signature position.

func (*TransactionResponse) Show

func (rsp *TransactionResponse) Show()

func (TransactionResponse) Signature

func (t TransactionResponse) Signature(id string) Signature

Returns the type signature corresponding to the given relation ID.

type TransactionResult

type TransactionResult struct {
	Aborted  bool         `json:"aborted"`
	Output   []RelationV1 `json:"output"`
	Problems []ProblemV1  `json:"problems"`
}

func (*TransactionResult) Show

func (tx *TransactionResult) Show()

type TransactionState

type TransactionState string
const (
	Created   TransactionState = "CREATED" // Created, queued for execution
	Running   TransactionState = "RUNNING"
	Completed TransactionState = "COMPLETED"
	Aborted   TransactionState = "ABORTED"
)

type TransactionV1

type TransactionV1 struct {
	Region        string
	Database      string
	Engine        string
	Mode          string
	Source        string
	Abort         bool
	Readonly      bool
	NoWaitDurable bool
	Version       int
}

The transaction "request" envelope

func NewTransaction

func NewTransaction(region, database, engine, mode string) *TransactionV1

func (*TransactionV1) Payload

func (tx *TransactionV1) Payload(actions ...DbAction) map[string]interface{}

Constructs a transaction request payload.

func (*TransactionV1) QueryArgs

func (tx *TransactionV1) QueryArgs() url.Values

type Uint128

type Uint128 [2]uint64

type Unknown

type Unknown struct{}

type Unspecified

type Unspecified struct{}

type UpdateUserRequest

type UpdateUserRequest struct {
	Status string   `json:"status,omitempty"`
	Roles  []string `json:"roles,omitempty"`
}

type User

type User struct {
	AccountName string   `json:"account_name"`
	Email       string   `json:"email"`
	ID          string   `json:"id"`
	IDProviers  []string `json:"id_providers"`
	Roles       []string `json:"roles"`
	Status      string   `json:"status"`
}

type ValueType

type ValueType Signature

func (ValueType) String

func (t ValueType) String() string

func (ValueType) Strings

func (t ValueType) Strings() []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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