plugin

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BigIntConverter = data.FieldConverter{
	OutputFieldType: data.FieldTypeNullableInt64,
	Converter: func(v any) (any, error) {
		return convertBigInt(v.(*pb.Value))
	},
}

BigIntConverter converts bigInt to float64

View Source
var DecimalToNullableFloat64 = data.FieldConverter{
	OutputFieldType: data.FieldTypeNullableFloat64,
	Converter: func(v any) (any, error) {

		convert := func(val *pb.Value) (*float64, error) {
			dec, err := client.ToDecimal(val)
			if err != nil {
				return nil, err
			}

			str := dec.String()
			if float, err := strconv.ParseFloat(str, 64); err == nil {
				return &float, nil
			}
			return nil, errors.New("unable to convert decimal to float")
		}
		return toNullable(v.(*pb.Value), convert)
	},
}

DecimalToNullableFloat64 returns an error if the input is not a float64.

View Source
var Float32ToNullableFloat64 = data.FieldConverter{
	OutputFieldType: data.FieldTypeNullableFloat64,
	Converter: func(v any) (any, error) {
		convert := func(val any) (*float64, error) {
			v, ok := v.(float32)
			if !ok {
				return nil, errors.New("failed converting to float64")
			}
			f64 := math.Round((float64(v) * 100)) / 100
			return &f64, nil
		}
		return anyToNullable(v, convert)
	},
}

Float32ToNullableFloat64 converts float32 to float64

View Source
var SmallIntConverter = data.FieldConverter{
	OutputFieldType: data.FieldTypeNullableInt64,
	Converter: func(v any) (any, error) {
		return convertSmallInt(v.(*pb.Value))
	},
}

SmallIntConverter converts smallInt to int64

View Source
var TimeConverter = data.FieldConverter{
	OutputFieldType: data.FieldTypeNullableInt64,
	Converter: func(v any) (any, error) {
		convert := func(val any) (*uint64, error) {
			v := val.(uint64)
			return &v, nil
		}
		return anyToNullable(v, convert)
	},
}

TimeConverter converts uint64 to nullable uint64

View Source
var TimestampConverter = data.FieldConverter{
	OutputFieldType: data.FieldTypeNullableInt64,
	Converter: func(v any) (any, error) {
		return convertIntToTimestamp(v.(int64))
	},
}

TimestampConverter converts uint64 to time

View Source
var VarIntConverter = data.FieldConverter{
	OutputFieldType: data.FieldTypeNullableInt64,
	Converter: func(v any) (any, error) {
		return convertVarInt(v.(*pb.Value))
	},
}

VarIntConverter converts smallInt to int64

Functions

func Frame

func Frame(res *pb.Response, qm models.QueryModel) (*data.Frame, error)

func NewColumn

func NewColumn(col *pb.ColumnSpec, name string, alias string, kind string, labels data.Labels) column

Types

type AstraDatasource

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

func (*AstraDatasource) CheckHealth

func (*AstraDatasource) Dispose

func (d *AstraDatasource) Dispose()

func (*AstraDatasource) QueryData

type BaseDriver

type BaseDriver struct {
}

BaseDriver implements the driver interface for macro interpolation sqlds provides default macros using sqlds.Interpolate

func (BaseDriver) Connect

func (BaseDriver) Converters

func (d BaseDriver) Converters() []sqlutil.Converter

func (BaseDriver) Macros

func (d BaseDriver) Macros() sqlds.Macros

type Converted

type Converted interface {
	float64 | int64 | int32 | uint64 | bool | string | time.Time
}

type Int

type Int interface {
	int | int64 | uint64
}

type Number

type Number interface {
	*int | *int64 | *uint64 | *float64 | *time.Time
}

Jump to

Keyboard shortcuts

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