utils

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package utils contains helper types and functions that can be used by any relational data source.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeDescribeTableQuery

func MakeDescribeTableQuery(logger log.Logger, formatter SQLFormatter, request *api_service_protos.TDescribeTableRequest) (string, []any)

func MakeReadSplitQuery

func MakeReadSplitQuery(logger log.Logger, formatter SQLFormatter, request *api_service_protos.TSelect) (string, []any, error)

Types

type Connection

type Connection interface {
	Query(ctx context.Context, query string, args ...any) (Rows, error)
	Close() error
}

type ConnectionManager

type ConnectionManager interface {
	Make(ctx context.Context, logger log.Logger, dataSourceInstance *api_common.TDataSourceInstance) (Connection, error)
	Release(logger log.Logger, connection Connection)
}

type ConnectionManagerBase

type ConnectionManagerBase struct {
	QueryLoggerFactory utils.QueryLoggerFactory
}

type ConnectionManagerMock

type ConnectionManagerMock struct {
	mock.Mock
}

func (*ConnectionManagerMock) Make

func (m *ConnectionManagerMock) Make(
	ctx context.Context,
	logger log.Logger,
	dataSourceInstance *api_common.TDataSourceInstance) (Connection, error)

func (*ConnectionManagerMock) Release

func (m *ConnectionManagerMock) Release(logger log.Logger, conn Connection)

type ConnectionMock

type ConnectionMock struct {
	mock.Mock
}

func (*ConnectionMock) Close

func (m *ConnectionMock) Close() error

func (*ConnectionMock) Query

func (m *ConnectionMock) Query(ctx context.Context, query string, params ...any) (Rows, error)

type RowTransformerMock

type RowTransformerMock struct {
	mock.Mock
	Acceptors []any
}

func (*RowTransformerMock) AppendToArrowBuilders

func (t *RowTransformerMock) AppendToArrowBuilders(builder []array.Builder) error

func (*RowTransformerMock) GetAcceptors

func (t *RowTransformerMock) GetAcceptors() []any

func (*RowTransformerMock) SetAcceptors

func (t *RowTransformerMock) SetAcceptors([]any)

type Rows

type Rows interface {
	Close() error
	Err() error
	Next() bool
	Scan(dest ...any) error
	MakeTransformer(ydbTypes []*Ydb.Type) (utils.RowTransformer[any], error)
}

type RowsMock

type RowsMock struct {
	mock.Mock
	PredefinedData [][]any
	// contains filtered or unexported fields
}

func (*RowsMock) Close

func (m *RowsMock) Close() error

func (*RowsMock) Err

func (m *RowsMock) Err() error

func (*RowsMock) MakeTransformer

func (m *RowsMock) MakeTransformer(ydbType []*Ydb.Type) (utils.RowTransformer[any], error)

func (*RowsMock) Next

func (m *RowsMock) Next() bool

func (*RowsMock) Scan

func (m *RowsMock) Scan(dest ...any) error

type SQLFormatter

type SQLFormatter interface {
	GetDescribeTableQuery(request *api_service_protos.TDescribeTableRequest) (string, []any)

	// Get placeholder for n'th argument (starting from 0) for prepared statement
	GetPlaceholder(n int) string

	// Sanitize names of databases, tables, columns, views, schemas
	SanitiseIdentifier(ident string) string

	// Support for high level expression (without subexpressions, they are checked separately)
	SupportsPushdownExpression(expression *api_service_protos.TExpression) bool
}

Jump to

Keyboard shortcuts

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