utils

package
v0.6.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 14 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 MakeTestSplit added in v0.1.1

func MakeTestSplit() *api_service_protos.TSplit

func NewColumnExpression added in v0.1.1

func NewColumnExpression(name string) *api_service_protos.TExpression

func NewDefaultWhat added in v0.1.1

func NewDefaultWhat() *api_service_protos.TSelect_TWhat

NewDefaultWhat generates default What field with a pair of columns

func NewEmptyColumnWhat added in v0.4.9

func NewEmptyColumnWhat() *api_service_protos.TSelect_TWhat

NewEmptyColumnWhat generates What field with a one column of type Int32

func NewInt32ValueExpression added in v0.1.1

func NewInt32ValueExpression(val int32) *api_service_protos.TExpression

func NewInt64ValueExpression added in v0.5.11

func NewInt64ValueExpression(val int64) *api_service_protos.TExpression

func NewNestedValueExpression added in v0.5.10

func NewNestedValueExpression(val string) *api_service_protos.TExpression

func NewTextValueExpression added in v0.1.1

func NewTextValueExpression(val string) *api_service_protos.TExpression

func NewUint64ValueExpression added in v0.1.1

func NewUint64ValueExpression(val uint64) *api_service_protos.TExpression

Types

type Connection

type Connection interface {
	Query(params *QueryParams) (Rows, error)
	Close() error
}

type ConnectionManager

type ConnectionManager interface {
	Make(params *ConnectionParamsMakeParams) (Connection, error)
	Release(ctx context.Context, logger *zap.Logger, connection Connection)
}

type ConnectionManagerBase

type ConnectionManagerBase struct {
	QueryLoggerFactory common.QueryLoggerFactory
}

type ConnectionManagerMock

type ConnectionManagerMock struct {
	mock.Mock
}

func (*ConnectionManagerMock) Make

func (*ConnectionManagerMock) Release

func (m *ConnectionManagerMock) Release(_ context.Context, _ *zap.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(params *QueryParams) (Rows, error)

type ConnectionParamsMakeParams added in v0.6.0

type ConnectionParamsMakeParams struct {
	Ctx                context.Context                        // mandatory
	Logger             *zap.Logger                            // mandatory
	DataSourceInstance *api_common.TGenericDataSourceInstance // mandatory
	TableName          string                                 // optional
}

type DataConverter added in v0.1.1

type DataConverter struct{}

DataConverter should be used only from unit tests

func (DataConverter) RowsToColumnBlocks added in v0.1.1

func (dc DataConverter) RowsToColumnBlocks(input [][]any, rowsPerBlock int) [][][]any

type DefaultSchemaProvider added in v0.1.0

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

func (*DefaultSchemaProvider) GetSchema added in v0.1.0

type QueryArg added in v0.5.11

type QueryArg struct {
	YdbType *Ydb.Type
	Value   any
}

type QueryArgs added in v0.5.11

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

func (*QueryArgs) AddTyped added in v0.5.11

func (q *QueryArgs) AddTyped(ydbType *Ydb.Type, arg any) *QueryArgs

func (*QueryArgs) AddUntyped added in v0.5.11

func (q *QueryArgs) AddUntyped(arg any) *QueryArgs

func (*QueryArgs) Count added in v0.5.11

func (q *QueryArgs) Count() int

func (*QueryArgs) Get added in v0.5.11

func (q *QueryArgs) Get(i int) *QueryArg

func (*QueryArgs) GetAll added in v0.5.11

func (q *QueryArgs) GetAll() []*QueryArg

func (*QueryArgs) Values added in v0.5.11

func (q *QueryArgs) Values() []any

type QueryParams added in v0.5.11

type QueryParams struct {
	Ctx       context.Context
	Logger    *zap.Logger
	QueryText string
	QueryArgs *QueryArgs
}

type ReadSplitsQuery added in v0.5.11

type ReadSplitsQuery struct {
	QueryParams
	What *api_service_protos.TSelect_TWhat
}

func MakeReadSplitsQuery added in v0.5.10

func MakeReadSplitsQuery(
	ctx context.Context,
	logger *zap.Logger,
	formatter SQLFormatter,
	slct *api_service_protos.TSelect,
	filtering api_service_protos.TReadSplitsRequest_EFiltering,
) (*ReadSplitsQuery, 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 (*RowTransformerMock) SetAcceptors([]any)

type Rows

type Rows interface {
	Close() error
	Err() error
	Next() bool
	NextResultSet() bool
	Scan(dest ...any) error
	MakeTransformer(ydbTypes []*Ydb.Type, cc conversion.Collection) (paging.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, _ conversion.Collection) (paging.RowTransformer[any], error)

func (*RowsMock) Next

func (m *RowsMock) Next() bool

func (*RowsMock) NextResultSet added in v0.2.8

func (m *RowsMock) NextResultSet() bool

func (*RowsMock) Scan

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

type SQLFormatter

type SQLFormatter interface {
	// 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

	// FormatFrom builds a substring containing the literals
	// that must be placed after FROM (`SELECT ... FROM <this>`).
	// For some datasources this call may involve queries to external APIs.
	FormatFrom(params *SQLFormatterFormatFromParams) (string, error)
}

type SQLFormatterFormatFromParams added in v0.6.0

type SQLFormatterFormatFromParams struct {
	Ctx                context.Context
	Logger             *zap.Logger
	TableName          string
	DataSourceInstance *api_common.TGenericDataSourceInstance
}

type SchemaBuilder added in v0.1.0

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

func NewSchemaBuilder added in v0.1.0

func NewSchemaBuilder(
	typeMapper datasource.TypeMapper,
	typeMappingSettings *api_service_protos.TTypeMappingSettings,
) *SchemaBuilder

func (*SchemaBuilder) AddColumn added in v0.1.0

func (sb *SchemaBuilder) AddColumn(columnName, columnType string) error

func (*SchemaBuilder) Build added in v0.1.0

func (sb *SchemaBuilder) Build(logger *zap.Logger) (*api_service_protos.TSchema, error)

type SchemaProvider added in v0.1.0

type SchemaProvider interface {
	GetSchema(
		ctx context.Context,
		logger *zap.Logger,
		conn Connection,
		request *api_service_protos.TDescribeTableRequest,
	) (*api_service_protos.TSchema, error)
}

func NewDefaultSchemaProvider added in v0.1.0

func NewDefaultSchemaProvider(
	typeMapper datasource.TypeMapper,
	getArgsAndQueryFunc func(request *api_service_protos.TDescribeTableRequest) (string, *QueryArgs),
) SchemaProvider

Jump to

Keyboard shortcuts

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