Documentation ¶
Overview ¶
Package utils contains various helpers and utility functions
Index ¶
- Variables
- func APIErrorToLogFields(apiErr *api_service_protos.TError) []log.Field
- func AnnotateLogger(logger log.Logger, method string, dsi *api_common.TDataSourceInstance) log.Logger
- func DumpProtoMessageToJSON(msg proto.Message, stream io.Writer) error
- func DumpReadSplitsResponse(logger log.Logger, resp *api_service_protos.TReadSplitsResponse)
- func EndpointToString(ep *api_common.TEndpoint) string
- func IsSuccess(apiErr *api_service_protos.TError) bool
- func LogCloserError(logger log.Logger, closer io.Closer, msg string)
- func MakeDescribeTableQuery(logger log.Logger, formatter SQLFormatter, ...) (string, []any)
- func MakeReadSplitQuery(logger log.Logger, formatter SQLFormatter, request *api_service_protos.TSelect) (string, []any, error)
- func MakeTestSplit() *api_service_protos.TSplit
- func NewAPIErrorFromStdError(err error) *api_service_protos.TError
- func NewColumnExpression(name string) *api_service_protos.TExpression
- func NewDefaultLogger() (log.Logger, error)
- func NewDefaultWhat() *api_service_protos.TSelect_TWhat
- func NewInt32ValueExpression(val int32) *api_service_protos.TExpression
- func NewLoggerFromConfig(cfg *config.TLoggerConfig) (log.Logger, error)
- func NewPrimitiveType(t Ydb.Type_PrimitiveTypeId) *Ydb.Type
- func NewSTDErrorFromAPIError(apiErr *api_service_protos.TError) error
- func NewSuccess() *api_service_protos.TError
- func NewTestLogger(t *testing.T) log.Logger
- func NewTextValueExpression(val string) *api_service_protos.TExpression
- func NewUint64ValueExpression(val uint64) *api_service_protos.TExpression
- func SelectToFields(slct *api_service_protos.TSelect) []log.Field
- func SelectWhatToArrowSchema(selectWhat *api_service_protos.TSelect_TWhat) (*arrow.Schema, error)
- func SelectWhatToYDBTypes(selectWhat *api_service_protos.TSelect_TWhat) ([]*Ydb.Type, error)
- func TimeToYDBDate(t *time.Time) (uint16, error)
- func TimeToYDBDatetime(t *time.Time) (uint32, error)
- func TimeToYDBTimestamp(t *time.Time) (uint64, error)
- func YdbTypeToYdbPrimitiveTypeID(ydbType *Ydb.Type) (Ydb.Type_PrimitiveTypeId, error)
- func YdbTypesToArrowBuilders(ydbTypes []*Ydb.Type, arrowAllocator memory.Allocator) ([]array.Builder, error)
- type ArrowBuilder
- type BoolConverter
- type BytesConverter
- type Connection
- type ConnectionManager
- type ConnectionManagerBase
- type ConnectionManagerMock
- type ConnectionMock
- type Counter
- type DataConverter
- type DateConverter
- type DateToStringConverter
- type DatetimeConverter
- type DatetimeToStringConverter
- type Float32Converter
- type Float64Converter
- type Int16Converter
- type Int32Converter
- type Int64Converter
- type Int8Converter
- type QueryLogger
- type QueryLoggerFactory
- type Rows
- type RowsMock
- type SQLFormatter
- type StringConverter
- type StringToBytesConverter
- type TimestampConverter
- type TimestampToStringConverter
- type Transformer
- type TransformerMock
- type TypeMapper
- type Uint16Converter
- type Uint32Converter
- type Uint64Converter
- type Uint8Converter
- type ValueConverter
- type ValueType
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTableDoesNotExist = fmt.Errorf("table does not exist") ErrDataSourceNotSupported = fmt.Errorf("data source not supported") ErrDataTypeNotSupported = fmt.Errorf("data type not supported") ErrReadLimitExceeded = fmt.Errorf("read limit exceeded") ErrInvalidRequest = fmt.Errorf("invalid request") ErrValueOutOfTypeBounds = fmt.Errorf("value is out of possible range of values for the type") ErrUnimplemented = fmt.Errorf("unimplemented") ErrUnimplementedTypedValue = fmt.Errorf("unimplemented typed value") ErrUnimplementedExpression = fmt.Errorf("unimplemented expression") ErrUnsupportedExpression = fmt.Errorf("expression is not supported") ErrUnimplementedOperation = fmt.Errorf("unimplemented operation") ErrUnimplementedPredicateType = fmt.Errorf("unimplemented predicate type") ErrInvariantViolation = fmt.Errorf("implementation error (invariant violation)") ErrUnimplementedArithmeticalExpression = fmt.Errorf("unimplemented arithmetical expression") ErrEmptyTableName = fmt.Errorf("empty table name") ErrPageSizeExceeded = fmt.Errorf("page size exceeded, check service configuration") )
Functions ¶
func APIErrorToLogFields ¶
func APIErrorToLogFields(apiErr *api_service_protos.TError) []log.Field
func AnnotateLogger ¶
func AnnotateLogger(logger log.Logger, method string, dsi *api_common.TDataSourceInstance) log.Logger
func DumpProtoMessageToJSON ¶
func DumpReadSplitsResponse ¶
func DumpReadSplitsResponse(logger log.Logger, resp *api_service_protos.TReadSplitsResponse)
func EndpointToString ¶
func EndpointToString(ep *api_common.TEndpoint) string
func IsSuccess ¶
func IsSuccess(apiErr *api_service_protos.TError) bool
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)
func MakeTestSplit ¶
func MakeTestSplit() *api_service_protos.TSplit
func NewAPIErrorFromStdError ¶
func NewAPIErrorFromStdError(err error) *api_service_protos.TError
func NewColumnExpression ¶
func NewColumnExpression(name string) *api_service_protos.TExpression
func NewDefaultLogger ¶
func NewDefaultWhat ¶
func NewDefaultWhat() *api_service_protos.TSelect_TWhat
NewDefaultWhat generates default What field with a pair of columns
func NewInt32ValueExpression ¶
func NewInt32ValueExpression(val int32) *api_service_protos.TExpression
func NewLoggerFromConfig ¶
func NewLoggerFromConfig(cfg *config.TLoggerConfig) (log.Logger, error)
func NewPrimitiveType ¶
func NewPrimitiveType(t Ydb.Type_PrimitiveTypeId) *Ydb.Type
func NewSTDErrorFromAPIError ¶
func NewSTDErrorFromAPIError(apiErr *api_service_protos.TError) error
func NewSuccess ¶
func NewSuccess() *api_service_protos.TError
func NewTextValueExpression ¶
func NewTextValueExpression(val string) *api_service_protos.TExpression
func NewUint64ValueExpression ¶
func NewUint64ValueExpression(val uint64) *api_service_protos.TExpression
func SelectToFields ¶
func SelectToFields(slct *api_service_protos.TSelect) []log.Field
func SelectWhatToArrowSchema ¶
func SelectWhatToArrowSchema(selectWhat *api_service_protos.TSelect_TWhat) (*arrow.Schema, error)
func SelectWhatToYDBTypes ¶
func SelectWhatToYDBTypes(selectWhat *api_service_protos.TSelect_TWhat) ([]*Ydb.Type, error)
func YdbTypeToYdbPrimitiveTypeID ¶
func YdbTypeToYdbPrimitiveTypeID(ydbType *Ydb.Type) (Ydb.Type_PrimitiveTypeId, error)
Types ¶
type ArrowBuilder ¶
type ArrowBuilder[VT ValueType] interface { AppendNull() Append(value VT) }
type BoolConverter ¶
type BoolConverter struct{}
type BytesConverter ¶
type BytesConverter struct{}
type Connection ¶
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 QueryLoggerFactory
}
type ConnectionManagerMock ¶
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 ¶
func (*ConnectionMock) Close ¶
func (m *ConnectionMock) Close() error
type Counter ¶
type Counter[T number] struct {
// contains filtered or unexported fields
}
func NewCounter ¶
func NewCounter[T number]() *Counter[T]
type DataConverter ¶
type DataConverter struct{}
DataConverter should be used only from unit tests
func (DataConverter) RowsToColumnBlocks ¶
func (dc DataConverter) RowsToColumnBlocks(input [][]any, rowsPerBlock int) [][][]any
type DateConverter ¶
type DateConverter struct{}
type DateToStringConverter ¶
type DateToStringConverter struct{}
type DatetimeConverter ¶
type DatetimeConverter struct{}
type DatetimeToStringConverter ¶
type DatetimeToStringConverter struct{}
type Float32Converter ¶
type Float32Converter struct{}
type Float64Converter ¶
type Float64Converter struct{}
type Int16Converter ¶
type Int16Converter struct{}
type Int32Converter ¶
type Int32Converter struct{}
type Int64Converter ¶
type Int64Converter struct{}
type Int8Converter ¶
type Int8Converter struct{}
type QueryLogger ¶
func (*QueryLogger) Dump ¶
func (ql *QueryLogger) Dump(query string, args ...any)
type QueryLoggerFactory ¶
type QueryLoggerFactory struct {
// contains filtered or unexported fields
}
func NewQueryLoggerFactory ¶
func NewQueryLoggerFactory(cfg *config.TLoggerConfig) QueryLoggerFactory
func (*QueryLoggerFactory) Make ¶
func (f *QueryLoggerFactory) Make(logger log.Logger) QueryLogger
type RowsMock ¶
func (*RowsMock) MakeTransformer ¶
func (m *RowsMock) MakeTransformer(ydbType []*Ydb.Type) (Transformer, 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 }
type StringConverter ¶
type StringConverter struct{}
type StringToBytesConverter ¶
type StringToBytesConverter struct{}
type TimestampConverter ¶
type TimestampConverter struct{}
type TimestampToStringConverter ¶
type TimestampToStringConverter struct{}
type Transformer ¶
type Transformer interface { // Return acceptors for scan values from a row GetAcceptors() []any // Convert and append to arrow buiders accepted values AppendToArrowBuilders(builder []array.Builder) error }
Transformer accepts values from a row, converts them and appends to arrow builders
type TransformerMock ¶
func (*TransformerMock) AppendToArrowBuilders ¶
func (t *TransformerMock) AppendToArrowBuilders(builder []array.Builder) error
func (*TransformerMock) GetAcceptors ¶
func (t *TransformerMock) GetAcceptors() []any
type TypeMapper ¶
type TypeMapper interface {
SQLTypeToYDBColumn(columnName, typeName string, rules *api_service_protos.TTypeMappingSettings) (*Ydb.Column, error)
}
type Uint16Converter ¶
type Uint16Converter struct{}
type Uint32Converter ¶
type Uint32Converter struct{}
type Uint64Converter ¶
type Uint64Converter struct{}
type Uint8Converter ¶
type Uint8Converter struct{}
type ValueConverter ¶
Click to show internal directories.
Click to hide internal directories.