scalar

package
v4.40.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MPL-2.0, MIT Imports: 21 Imported by: 7

README

CloudQuery Type System

This directory is heavily based on jackc/pgtype and modified per CQ needs and thus fall under the original MIT license and copyright.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToBuilder

func AppendToBuilder(bldr array.Builder, s Scalar)

func AppendToRecordBuilder

func AppendToRecordBuilder(bldr *array.RecordBuilder, vector Vector)

Types

type Binary

type Binary struct {
	Valid bool
	Value []byte
}

func (*Binary) DataType

func (*Binary) DataType() arrow.DataType

func (*Binary) Equal

func (s *Binary) Equal(rhs Scalar) bool

func (*Binary) Get

func (s *Binary) Get() any

func (*Binary) IsValid

func (s *Binary) IsValid() bool

func (*Binary) Set

func (s *Binary) Set(val any) error

func (*Binary) String

func (s *Binary) String() string

type Bool

type Bool struct {
	Valid bool
	Value bool
}

func (*Bool) DataType

func (*Bool) DataType() arrow.DataType

func (*Bool) Equal

func (s *Bool) Equal(rhs Scalar) bool

func (*Bool) Get

func (s *Bool) Get() any

func (*Bool) IsValid

func (s *Bool) IsValid() bool

func (*Bool) Set

func (s *Bool) Set(val any) error

func (*Bool) String

func (s *Bool) String() string

type Date32

type Date32 struct {
	Valid bool
	Value arrow.Date32
}

func (*Date32) DataType

func (*Date32) DataType() arrow.DataType

func (*Date32) Equal

func (s *Date32) Equal(rhs Scalar) bool

func (*Date32) Get

func (s *Date32) Get() any

func (*Date32) IsValid

func (s *Date32) IsValid() bool

func (*Date32) Set

func (s *Date32) Set(val any) error

func (*Date32) String

func (s *Date32) String() string

type Date64

type Date64 struct {
	Valid bool
	Value arrow.Date64
}

func (*Date64) DataType

func (*Date64) DataType() arrow.DataType

func (*Date64) Equal

func (s *Date64) Equal(rhs Scalar) bool

func (*Date64) Get

func (s *Date64) Get() any

func (*Date64) IsValid

func (s *Date64) IsValid() bool

func (*Date64) Set

func (s *Date64) Set(val any) error

func (*Date64) String

func (s *Date64) String() string

type DayTimeInterval

type DayTimeInterval struct {
	Value arrow.DayTimeInterval
	Valid bool
}

func (*DayTimeInterval) DataType

func (*DayTimeInterval) DataType() arrow.DataType

func (*DayTimeInterval) Equal

func (s *DayTimeInterval) Equal(rhs Scalar) bool

func (*DayTimeInterval) Get

func (s *DayTimeInterval) Get() any

func (*DayTimeInterval) IsValid

func (s *DayTimeInterval) IsValid() bool

func (*DayTimeInterval) Set

func (s *DayTimeInterval) Set(value any) error

func (*DayTimeInterval) String

func (s *DayTimeInterval) String() string

type Decimal128

type Decimal128 struct {
	Valid bool
	Value decimal128.Num
	Type  *arrow.Decimal128Type // Stores precision and scale
}

func (*Decimal128) DataType

func (s *Decimal128) DataType() arrow.DataType

func (*Decimal128) Equal

func (s *Decimal128) Equal(rhs Scalar) bool

func (*Decimal128) Get

func (s *Decimal128) Get() any

func (*Decimal128) IsValid

func (s *Decimal128) IsValid() bool

func (*Decimal128) Set

func (s *Decimal128) Set(val any) error

func (*Decimal128) String

func (s *Decimal128) String() string

type Decimal256

type Decimal256 struct {
	Valid bool
	Value decimal256.Num
	Type  *arrow.Decimal256Type // Stores precision and scale
}

func (*Decimal256) DataType

func (s *Decimal256) DataType() arrow.DataType

func (*Decimal256) Equal

func (s *Decimal256) Equal(rhs Scalar) bool

func (*Decimal256) Get

func (s *Decimal256) Get() any

func (*Decimal256) IsValid

func (s *Decimal256) IsValid() bool

func (*Decimal256) Set

func (s *Decimal256) Set(val any) error

func (*Decimal256) String

func (s *Decimal256) String() string

type Duration

type Duration struct {
	Int
	Unit arrow.TimeUnit
}

func (*Duration) DataType

func (s *Duration) DataType() arrow.DataType

func (*Duration) Equal

func (s *Duration) Equal(rhs Scalar) bool

func (*Duration) Set

func (s *Duration) Set(value any) error

func (*Duration) String

func (s *Duration) String() string

type Float

type Float struct {
	Valid    bool
	Value    float64
	BitWidth uint8 // defaults to 64
}

func (*Float) DataType

func (s *Float) DataType() arrow.DataType

func (*Float) Equal

func (s *Float) Equal(rhs Scalar) bool

func (*Float) Get

func (s *Float) Get() any

func (*Float) IsValid

func (s *Float) IsValid() bool

func (*Float) Set

func (s *Float) Set(val any) error

func (*Float) String

func (s *Float) String() string

type Inet

type Inet struct {
	Valid bool
	Value *net.IPNet
}

func (*Inet) DataType

func (*Inet) DataType() arrow.DataType

func (*Inet) Equal

func (s *Inet) Equal(rhs Scalar) bool

func (*Inet) Get

func (s *Inet) Get() any

func (*Inet) IsValid

func (s *Inet) IsValid() bool

func (*Inet) Set

func (s *Inet) Set(val any) error

func (*Inet) String

func (s *Inet) String() string

type Int

type Int struct {
	Valid    bool
	Value    int64
	BitWidth uint8 // defaults to 64
}

func (*Int) DataType

func (s *Int) DataType() arrow.DataType

func (*Int) Equal

func (s *Int) Equal(rhs Scalar) bool

func (*Int) Get

func (s *Int) Get() any

func (*Int) IsValid

func (s *Int) IsValid() bool

func (*Int) Set

func (s *Int) Set(val any) error

func (*Int) String

func (s *Int) String() string

type JSON

type JSON struct {
	Valid bool
	Value []byte
}

func (*JSON) DataType

func (*JSON) DataType() arrow.DataType

func (*JSON) Equal

func (s *JSON) Equal(rhs Scalar) bool

func (*JSON) Get

func (s *JSON) Get() any

func (*JSON) IsValid

func (s *JSON) IsValid() bool

func (*JSON) Set

func (s *JSON) Set(val any) error

func (*JSON) String

func (s *JSON) String() string

type LargeBinary

type LargeBinary struct {
	Binary
}

func (*LargeBinary) DataType

func (*LargeBinary) DataType() arrow.DataType

type LargeString

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

func (*LargeString) DataType

func (*LargeString) DataType() arrow.DataType

func (*LargeString) Equal

func (s *LargeString) Equal(rhs Scalar) bool

func (*LargeString) Get

func (s *LargeString) Get() any

func (*LargeString) IsValid

func (s *LargeString) IsValid() bool

func (*LargeString) Set

func (s *LargeString) Set(val any) error

func (*LargeString) String

func (s *LargeString) String() string

type List

type List struct {
	Valid bool
	Value Vector
	Type  arrow.DataType
}

func (*List) DataType

func (s *List) DataType() arrow.DataType

func (*List) Equal

func (s *List) Equal(rhs Scalar) bool

func (*List) Get

func (s *List) Get() any

func (*List) IsValid

func (s *List) IsValid() bool

func (*List) Set

func (s *List) Set(val any) error

func (*List) String

func (s *List) String() string

type Mac

type Mac struct {
	Valid bool
	Value net.HardwareAddr
}

func (*Mac) DataType

func (*Mac) DataType() arrow.DataType

func (*Mac) Equal

func (s *Mac) Equal(rhs Scalar) bool

func (*Mac) Get

func (s *Mac) Get() any

func (*Mac) IsValid

func (s *Mac) IsValid() bool

func (*Mac) Set

func (s *Mac) Set(val any) error

func (*Mac) String

func (s *Mac) String() string

type MonthDayNanoInterval

type MonthDayNanoInterval struct {
	Value arrow.MonthDayNanoInterval
	Valid bool
}

func (*MonthDayNanoInterval) DataType

func (*MonthDayNanoInterval) DataType() arrow.DataType

func (*MonthDayNanoInterval) Equal

func (s *MonthDayNanoInterval) Equal(rhs Scalar) bool

func (*MonthDayNanoInterval) Get

func (s *MonthDayNanoInterval) Get() any

func (*MonthDayNanoInterval) IsValid

func (s *MonthDayNanoInterval) IsValid() bool

func (*MonthDayNanoInterval) Set

func (s *MonthDayNanoInterval) Set(value any) error

func (*MonthDayNanoInterval) String

func (s *MonthDayNanoInterval) String() string

type MonthInterval

type MonthInterval struct {
	Int
}

func (*MonthInterval) DataType

func (*MonthInterval) DataType() arrow.DataType

func (*MonthInterval) Equal

func (s *MonthInterval) Equal(rhs Scalar) bool

func (*MonthInterval) Set

func (s *MonthInterval) Set(value any) error

func (*MonthInterval) String

func (s *MonthInterval) String() string

type Scalar

type Scalar interface {
	fmt.Stringer
	// IsValid returns true if the value is non-null, otherwise false.
	IsValid() bool
	// The datatype of the value in this scalar
	DataType() arrow.DataType
	// Performs cheap validation checks, returns nil if successful
	// Validate() error
	// tries to set the value of the scalar to the given value
	Set(val any) error

	Get() any
	Equal(other Scalar) bool
}

Scalar represents a single value of a specific DataType as opposed to an array.

Scalars are useful for passing single value inputs to compute functions (not yet implemented) or for representing individual array elements, (with a non-trivial cost though).

func NewScalar

func NewScalar(dt arrow.DataType) Scalar

type String

type String struct {
	Valid bool
	Value string
}

func (*String) DataType

func (*String) DataType() arrow.DataType

func (*String) Equal

func (s *String) Equal(rhs Scalar) bool

func (*String) Get

func (s *String) Get() any

func (*String) IsValid

func (s *String) IsValid() bool

func (*String) Set

func (s *String) Set(val any) error

func (*String) String

func (s *String) String() string

type Struct

type Struct struct {
	Valid bool
	Value any

	Type *arrow.StructType
}

func (*Struct) DataType

func (s *Struct) DataType() arrow.DataType

func (*Struct) Equal

func (s *Struct) Equal(rhs Scalar) bool

func (*Struct) Get

func (s *Struct) Get() any

func (*Struct) IsValid

func (s *Struct) IsValid() bool

func (*Struct) Set

func (s *Struct) Set(val any) error

func (*Struct) String

func (s *Struct) String() string

type Time

type Time struct {
	Int
	Unit arrow.TimeUnit
}

func (*Time) DataType

func (s *Time) DataType() arrow.DataType

func (*Time) Equal

func (s *Time) Equal(rhs Scalar) bool

func (*Time) Get

func (s *Time) Get() any

func (*Time) Set

func (s *Time) Set(value any) error

func (*Time) String

func (s *Time) String() string

type Timestamp

type Timestamp struct {
	Valid bool
	Value time.Time
	Type  *arrow.TimestampType
}

func (*Timestamp) DataType

func (s *Timestamp) DataType() arrow.DataType

func (*Timestamp) DecodeText

func (s *Timestamp) DecodeText(src []byte) error

func (*Timestamp) Equal

func (s *Timestamp) Equal(rhs Scalar) bool

func (*Timestamp) Get

func (s *Timestamp) Get() any

func (*Timestamp) IsValid

func (s *Timestamp) IsValid() bool

func (*Timestamp) Set

func (s *Timestamp) Set(val any) error

func (*Timestamp) String

func (s *Timestamp) String() string

type UUID

type UUID struct {
	Valid bool
	Value uuid.UUID
}

func (*UUID) DataType

func (*UUID) DataType() arrow.DataType

func (*UUID) Equal

func (s *UUID) Equal(rhs Scalar) bool

func (*UUID) Get

func (s *UUID) Get() any

func (*UUID) IsValid

func (s *UUID) IsValid() bool

func (*UUID) Set

func (s *UUID) Set(src any) error

func (*UUID) String

func (s *UUID) String() string

type Uint

type Uint struct {
	Valid    bool
	Value    uint64
	BitWidth uint8 // defaults to 64
}

func (*Uint) DataType

func (s *Uint) DataType() arrow.DataType

func (*Uint) Equal

func (s *Uint) Equal(rhs Scalar) bool

func (*Uint) Get

func (s *Uint) Get() any

func (*Uint) IsValid

func (s *Uint) IsValid() bool

func (*Uint) Set

func (s *Uint) Set(val any) error

func (*Uint) String

func (s *Uint) String() string

type ValidationError

type ValidationError struct {
	Err   error
	Msg   string
	Type  arrow.DataType
	Value any
}

func (*ValidationError) Error

func (e *ValidationError) Error() string

func (*ValidationError) MaskedError

func (e *ValidationError) MaskedError() string

this prints the error without the value

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

type Vector

type Vector []Scalar

func (Vector) Equal

func (v Vector) Equal(r Vector) bool

func (Vector) ToArrowRecord

func (v Vector) ToArrowRecord(sc *arrow.Schema) arrow.Record

Jump to

Keyboard shortcuts

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