package types

import "github.com/ydb-platform/ydb-go-sdk/v3/table/types"

Index

Constants

const (
	TypeUnknown      = value.TypeUnknown
	TypeBool         = value.TypeBool
	TypeInt8         = value.TypeInt8
	TypeUint8        = value.TypeUint8
	TypeInt16        = value.TypeInt16
	TypeUint16       = value.TypeUint16
	TypeInt32        = value.TypeInt32
	TypeUint32       = value.TypeUint32
	TypeInt64        = value.TypeInt64
	TypeUint64       = value.TypeUint64
	TypeFloat        = value.TypeFloat
	TypeDouble       = value.TypeDouble
	TypeDate         = value.TypeDate
	TypeDatetime     = value.TypeDatetime
	TypeTimestamp    = value.TypeTimestamp
	TypeInterval     = value.TypeInterval
	TypeTzDate       = value.TypeTzDate
	TypeTzDatetime   = value.TypeTzDatetime
	TypeTzTimestamp  = value.TypeTzTimestamp
	TypeString       = value.TypeString
	TypeUTF8         = value.TypeUTF8
	TypeYSON         = value.TypeYSON
	TypeJSON         = value.TypeJSON
	TypeUUID         = value.TypeUUID
	TypeJSONDocument = value.TypeJSONDocument
	TypeDyNumber     = value.TypeDyNumber
)

Primitive types known by YDB.

Variables

var DefaultDecimal = DecimalType(22, 9)

Functions

func Equal

func Equal(lhs, rhs Type) bool

Equal checks for type equivalence

func WriteTypeStringTo

func WriteTypeStringTo(buf *bytes.Buffer, t Type)

Types

type Decimal

type Decimal struct {
	Bytes     [16]byte
	Precision uint32
	Scale     uint32
}

Decimal supported in scanner API

func (*Decimal) BigInt

func (d *Decimal) BigInt() *big.Int

func (*Decimal) String

func (d *Decimal) String() string

type DictValueOption

type DictValueOption func(*dictValueFields)

func DictFieldValue

func DictFieldValue(k, v Value) DictValueOption

type RawValue

type RawValue interface {
	Path() string
	WritePathTo(w io.Writer) (n int64, err error)
	Type() Type
	Bool() (v bool)
	Int8() (v int8)
	Uint8() (v uint8)
	Int16() (v int16)
	Uint16() (v uint16)
	Int32() (v int32)
	Uint32() (v uint32)
	Int64() (v int64)
	Uint64() (v uint64)
	Float() (v float32)
	Double() (v float64)
	Date() (v time.Time)
	Datetime() (v time.Time)
	Timestamp() (v time.Time)
	Interval() (v time.Duration)
	TzDate() (v time.Time)
	TzDatetime() (v time.Time)
	TzTimestamp() (v time.Time)
	String() (v []byte)
	UTF8() (v string)
	YSON() (v []byte)
	JSON() (v []byte)
	UUID() (v [16]byte)
	JSONDocument() (v []byte)
	DyNumber() (v string)
	Value() Value

	// Any returns any primitive or optional value.
	// Currently, it may return one of these types:
	//
	//   bool
	//   int8
	//   uint8
	//   int16
	//   uint16
	//   int32
	//   uint32
	//   int64
	//   uint64
	//   float32
	//   float64
	//   []byte
	//   string
	//   [16]byte
	//
	Any() interface{}

	// Unwrap unwraps current item under scan interpreting it as Optional<Type> types.
	Unwrap()
	AssertType(t Type) bool
	IsNull() bool
	IsOptional() bool

	// ListIn interprets current item under scan as a ydb's list.
	// It returns the size of the nested items.
	// If current item under scan is not a list types, it returns -1.
	ListIn() (size int)

	// ListItem selects current item i-th element as an item to scan.
	// ListIn() must be called before.
	ListItem(i int)

	// ListOut leaves list entered before by ListIn() call.
	ListOut()

	// TupleIn interprets current item under scan as a ydb's tuple.
	// It returns the size of the nested items.
	TupleIn() (size int)

	// TupleItem selects current item i-th element as an item to scan.
	// Note that TupleIn() must be called before.
	// It panics if it is out of bounds.
	TupleItem(i int)

	// TupleOut leaves tuple entered before by TupleIn() call.
	TupleOut()

	// StructIn interprets current item under scan as a ydb's struct.
	// It returns the size of the nested items – the struct fields values.
	// If there is no current item under scan it returns -1.
	StructIn() (size int)

	// StructField selects current item i-th field value as an item to scan.
	// Note that StructIn() must be called before.
	// It panics if i is out of bounds.
	StructField(i int) (name string)

	// StructOut leaves struct entered before by StructIn() call.
	StructOut()

	// DictIn interprets current item under scan as a ydb's dict.
	// It returns the size of the nested items pairs.
	// If there is no current item under scan it returns -1.
	DictIn() (size int)

	// DictKey selects current item i-th pair key as an item to scan.
	// Note that DictIn() must be called before.
	// It panics if i is out of bounds.
	DictKey(i int)

	// DictPayload selects current item i-th pair value as an item to scan.
	// Note that DictIn() must be called before.
	// It panics if i is out of bounds.
	DictPayload(i int)

	// DictOut leaves dict entered before by DictIn() call.
	DictOut()

	// Variant unwraps current item under scan interpreting it as Variant<Type> types.
	// It returns non-empty name of a field that is filled for struct-based
	// variant.
	// It always returns an index of filled field of a Type.
	Variant() (name string, index uint32)

	// Decimal returns decimal value represented by big-endian 128 bit signed integer.
	Decimal(t Type) (v [16]byte)

	// UnwrapDecimal returns decimal value represented by big-endian 128 bit signed
	// integer and its types information.
	UnwrapDecimal() Decimal
	IsDecimal() bool
	Err() error
}

RawValue scanning non-primitive yql types or for own implementation scanner native API

type Scanner

type Scanner interface {
	// UnmarshalYDB must be implemented on client-side for unmarshal raw ydb value.
	UnmarshalYDB(raw RawValue) error
}

Scanner scanning raw ydb types

type StructOption

type StructOption func(*tStructType)

func StructField

func StructField(name string, t Type) StructOption

type StructValueOption

type StructValueOption func(*structValueFields)

func StructFieldValue

func StructFieldValue(name string, v Value) StructValueOption

type Type

type Type interface {
	value.Type
}

Type describes YDB data types.

func DecimalType

func DecimalType(precision, scale uint32) Type

func DecimalTypeFromDecimal

func DecimalTypeFromDecimal(d *Decimal) Type

func Dict

func Dict(k, v Type) Type

func List

func List(t Type) Type

func Optional

func Optional(t Type) Type

func Struct

func Struct(opts ...StructOption) Type

func Tuple

func Tuple(elems ...Type) Type

func Variant

func Variant(x Type) Type

func Void

func Void() Type

type Value

type Value interface {
	value.Value
}

func BoolValue

func BoolValue(v bool) Value

func BytesValue

func BytesValue(v []byte) Value

func BytesValueFromString

func BytesValueFromString(v string) Value

func DateValue

func DateValue(v uint32) Value

func DateValueFromTime

func DateValueFromTime(v time.Time) Value

DateValueFromTime makes Date value from time.Time

Warning: all *From* helpers will be removed at next major release (functional will be implements with go1.18 type lists)

func DatetimeValue

func DatetimeValue(v uint32) Value

func DatetimeValueFromTime

func DatetimeValueFromTime(v time.Time) Value

DatetimeValueFromTime makes Datetime value from time.Time

Warning: all *From* helpers will be removed at next major release (functional will be implements with go1.18 type lists)

func DecimalValue

func DecimalValue(v *Decimal) Value

DecimalValue creates decimal value of given types t and value v. Note that Decimal.Bytes interpreted as big-endian int128.

func DecimalValueFromBigInt

func DecimalValueFromBigInt(v *big.Int, precision, scale uint32) Value

func DictValue

func DictValue(opts ...DictValueOption) Value

func DoubleValue

func DoubleValue(v float64) Value

func DyNumberValue

func DyNumberValue(v string) Value

func FloatValue

func FloatValue(v float32) Value

func Int16Value

func Int16Value(v int16) Value

func Int32Value

func Int32Value(v int32) Value

func Int64Value

func Int64Value(v int64) Value

func Int8Value

func Int8Value(v int8) Value

func IntervalValue

func IntervalValue(v int64) Value

IntervalValue makes Value from given microseconds value

Deprecated: use IntervalValueFromMicroseconds instead

func IntervalValueFromDuration

func IntervalValueFromDuration(v time.Duration) Value

IntervalValueFromDuration makes Interval value from time.Duration

Warning: all *From* helpers will be removed at next major release (functional will be implements with go1.18 type lists)

func IntervalValueFromMicroseconds

func IntervalValueFromMicroseconds(v int64) Value

IntervalValueFromMicroseconds makes Value from given microseconds value

func JSONDocumentValue

func JSONDocumentValue(v string) Value

func JSONDocumentValueFromBytes

func JSONDocumentValueFromBytes(v []byte) Value

JSONDocumentValueFromBytes makes JSONDocument value from bytes

Warning: all *From* helpers will be removed at next major release (functional will be implements with go1.18 type lists)

func JSONValue

func JSONValue(v string) Value

func JSONValueFromBytes

func JSONValueFromBytes(v []byte) Value

JSONValueFromBytes makes JSON value from bytes

Warning: all *From* helpers will be removed at next major release (functional will be implements with go1.18 type lists)

func ListValue

func ListValue(vs ...Value) Value

func NullValue

func NullValue(t Type) Value

func Nullable

func Nullable(t Type, v interface{}) Value

Nullable makes optional value from nullable type Warning: type interface will be replaced in the future with typed parameters pattern from go1.18

func NullableBoolValue

func NullableBoolValue(v *bool) Value

func NullableDateValue

func NullableDateValue(v *uint32) Value

func NullableDateValueFromTime

func NullableDateValueFromTime(v *time.Time) Value

func NullableDatetimeValue

func NullableDatetimeValue(v *uint32) Value

func NullableDatetimeValueFromTime

func NullableDatetimeValueFromTime(v *time.Time) Value

func NullableDoubleValue

func NullableDoubleValue(v *float64) Value

func NullableDyNumberValue

func NullableDyNumberValue(v *string) Value

func NullableFloatValue

func NullableFloatValue(v *float32) Value

func NullableInt16Value

func NullableInt16Value(v *int16) Value

func NullableInt32Value

func NullableInt32Value(v *int32) Value

func NullableInt64Value

func NullableInt64Value(v *int64) Value

func NullableInt8Value

func NullableInt8Value(v *int8) Value

func NullableIntervalValue

func NullableIntervalValue(v *int64) Value

NullableIntervalValue makes Value which maybe nil or valued

Deprecated: use NullableIntervalValueFromMicroseconds instead

func NullableIntervalValueFromDuration

func NullableIntervalValueFromDuration(v *time.Duration) Value

func NullableIntervalValueFromMicroseconds

func NullableIntervalValueFromMicroseconds(v *int64) Value

func NullableJSONDocumentValue

func NullableJSONDocumentValue(v *string) Value

func NullableJSONDocumentValueFromBytes

func NullableJSONDocumentValueFromBytes(v *[]byte) Value

func NullableJSONValue

func NullableJSONValue(v *string) Value

func NullableJSONValueFromBytes

func NullableJSONValueFromBytes(v *[]byte) Value

func NullableStringValue

func NullableStringValue(v *[]byte) Value

func NullableStringValueFromString

func NullableStringValueFromString(v *string) Value

func NullableTimestampValue

func NullableTimestampValue(v *uint64) Value

func NullableTimestampValueFromTime

func NullableTimestampValueFromTime(v *time.Time) Value

func NullableTzDateValue

func NullableTzDateValue(v *string) Value

func NullableTzDateValueFromTime

func NullableTzDateValueFromTime(v *time.Time) Value

func NullableTzDatetimeValue

func NullableTzDatetimeValue(v *string) Value

func NullableTzDatetimeValueFromTime

func NullableTzDatetimeValueFromTime(v *time.Time) Value

func NullableTzTimestampValue

func NullableTzTimestampValue(v *string) Value

func NullableTzTimestampValueFromTime

func NullableTzTimestampValueFromTime(v *time.Time) Value

func NullableUTF8Value

func NullableUTF8Value(v *string) Value

func NullableUUIDValue

func NullableUUIDValue(v *[16]byte) Value

func NullableUint16Value

func NullableUint16Value(v *uint16) Value

func NullableUint32Value

func NullableUint32Value(v *uint32) Value

func NullableUint64Value

func NullableUint64Value(v *uint64) Value

func NullableUint8Value

func NullableUint8Value(v *uint8) Value

func NullableYSONValue

func NullableYSONValue(v *string) Value

func NullableYSONValueFromBytes

func NullableYSONValueFromBytes(v *[]byte) Value

func OptionalValue

func OptionalValue(v Value) Value

func StringValue

func StringValue(v []byte) Value

func StringValueFromString

func StringValueFromString(v string) Value

StringValueFromString makes String value from string

Warning: all *From* helpers will be removed at next major release (functional will be implements with go1.18 type lists)

func StructValue

func StructValue(opts ...StructValueOption) Value

func TextValue

func TextValue(v string) Value

func TimestampValue

func TimestampValue(v uint64) Value

func TimestampValueFromTime

func TimestampValueFromTime(v time.Time) Value

TimestampValueFromTime makes Timestamp value from time.Time

Warning: all *From* helpers will be removed at next major release (functional will be implements with go1.18 type lists)

func TupleValue

func TupleValue(vs ...Value) Value

func TzDateValue

func TzDateValue(v string) Value

TzDateValue makes TzDate value from string

func TzDateValueFromTime

func TzDateValueFromTime(v time.Time) Value

TzDateValueFromTime makes TzDate value from time.Time

Warning: all *From* helpers will be removed at next major release (functional will be implements with go1.18 type lists)

func TzDatetimeValue

func TzDatetimeValue(v string) Value

TzDatetimeValue makes TzDatetime value from string

func TzDatetimeValueFromTime

func TzDatetimeValueFromTime(v time.Time) Value

TzDatetimeValueFromTime makes TzDatetime value from time.Time

Warning: all *From* helpers will be removed at next major release (functional will be implements with go1.18 type lists)

func TzTimestampValue

func TzTimestampValue(v string) Value

TzTimestampValue makes TzTimestamp value from string

func TzTimestampValueFromTime

func TzTimestampValueFromTime(v time.Time) Value

TzTimestampValueFromTime makes TzTimestamp value from time.Time

Warning: all *From* helpers will be removed at next major release (functional will be implements with go1.18 type lists)

func UTF8Value

func UTF8Value(v string) Value

func UUIDValue

func UUIDValue(v [16]byte) Value

func Uint16Value

func Uint16Value(v uint16) Value

func Uint32Value

func Uint32Value(v uint32) Value

func Uint64Value

func Uint64Value(v uint64) Value

func Uint8Value

func Uint8Value(v uint8) Value

func VariantValue

func VariantValue(v Value, i uint32, variantT Type) Value

func VoidValue

func VoidValue() Value

func YSONValue

func YSONValue(v string) Value

func YSONValueFromBytes

func YSONValueFromBytes(v []byte) Value

YSONValueFromBytes makes YSON value from bytes

Warning: all *From* helpers will be removed at next major release (functional will be implements with go1.18 type lists)

func ZeroValue

func ZeroValue(t Type) Value

Source Files

types.go value.go

Version
v3.36.0
Published
Aug 24, 2022
Platform
linux/amd64
Imports
8 packages
Last checked
30 minutes ago

Tools for package owners.