value

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 10 Imported by: 2

Documentation

Overview

Package value holds Kusto data value representations. All types provide a Kusto that stores the native value and Valid which indicates if the value was set or was null.

Kusto Value

A value.Kusto can hold types that represent Kusto Scalar types that define column data. We represent that with an interface:

type Kusto interface

This interface can hold the following values:

value.Bool
value.Int
value.Long
value.Real
value.Decimal
value.String
value.Dynamic
value.DateTime
value.Timespan

Each type defined above has at minimum two fields:

.Value - The type specific value
.Valid - True if the value was non-null in the Kusto table

Each provides at minimum the following two methods:

.String() - Returns the string representation of the value.
.Unmarshal() - Unmarshals the value into a standard Go type.

The Unmarshal() is for internal use, it should not be needed by an end user. Use .Value or table.Row.ToStruct() instead.

Index

Constants

This section is empty.

Variables

View Source
var DecRE = regexp.MustCompile(`^((\d+\.?\d*)|(\d*\.?\d+))$`) // Matches decimal numbers, with or without decimal dot, with optional parts missing.

Functions

This section is empty.

Types

type Bool

type Bool struct {
	// Value holds the value of the type.
	Value bool
	// Valid indicates if this value was set.
	Valid bool
}

Bool represents a Kusto boolean type. Bool implements Kusto.

func (Bool) Convert added in v0.6.0

func (bo Bool) Convert(v reflect.Value) error

Convert Bool into reflect value.

func (Bool) String

func (bo Bool) String() string

String implements fmt.Stringer.

func (*Bool) Unmarshal

func (bo *Bool) Unmarshal(i interface{}) error

Unmarshal unmarshals i into Bool. i must be a bool or nil.

type DateTime

type DateTime struct {
	// Value holds the value of the type.
	Value time.Time
	// Valid indicates if this value was set.
	Valid bool
}

DateTime represents a Kusto datetime type. DateTime implements Kusto.

func (DateTime) Convert added in v0.6.0

func (d DateTime) Convert(v reflect.Value) error

Convert DateTime into reflect value.

func (DateTime) Marshal

func (d DateTime) Marshal() string

Marshal marshals the DateTime into a Kusto compatible string.

func (DateTime) String

func (d DateTime) String() string

String implements fmt.Stringer.

func (*DateTime) Unmarshal

func (d *DateTime) Unmarshal(i interface{}) error

Unmarshal unmarshals i into DateTime. i must be a string representing RFC3339Nano or nil.

type Decimal

type Decimal struct {
	// Value holds the value of the type.
	Value string
	// Valid indicates if this value was set.
	Valid bool
}

Decimal represents a Kusto decimal type. Decimal implements Kusto. Because Go does not have a dynamic decimal type that meets all needs, Decimal provides the string representation for you to unmarshal into.

func (Decimal) Convert added in v0.6.0

func (d Decimal) Convert(v reflect.Value) error

Convert Decimal into reflect value.

func (*Decimal) ParseFloat

func (d *Decimal) ParseFloat(base int, prec uint, mode big.RoundingMode) (f *big.Float, b int, err error)

ParseFloat provides builtin support for Go's *big.Float conversion where that type meets your needs.

func (Decimal) String

func (d Decimal) String() string

String implements fmt.Stringer.

func (*Decimal) Unmarshal

func (d *Decimal) Unmarshal(i interface{}) error

Unmarshal unmarshals i into Decimal. i must be a string representing a decimal type or nil.

type Dynamic

type Dynamic struct {
	// Value holds the value of the type.
	Value []byte
	// Valid indicates if this value was set.
	Valid bool
}

Dynamic represents a Kusto dynamic type. Dynamic implements Kusto.

func (Dynamic) Convert added in v0.6.0

func (d Dynamic) Convert(v reflect.Value) error

Convert Dynamic into reflect value.

func (Dynamic) String

func (d Dynamic) String() string

String implements fmt.Stringer.

func (*Dynamic) Unmarshal

func (d *Dynamic) Unmarshal(i interface{}) error

Unmarshal unmarshal's i into Dynamic. i must be a string, []byte, map[string]interface{}, []interface{}, other JSON serializable value or nil. If []byte or string, must be a JSON representation of a value.

type GUID

type GUID struct {
	// Value holds the value of the type.
	Value uuid.UUID
	// Valid indicates if this value was set.
	Valid bool
}

GUID represents a Kusto GUID type. GUID implements Kusto.

func (GUID) Convert added in v0.6.0

func (g GUID) Convert(v reflect.Value) error

Convert GUID into reflect value.

func (GUID) String

func (g GUID) String() string

String implements fmt.Stringer.

func (*GUID) Unmarshal

func (g *GUID) Unmarshal(i interface{}) error

Unmarshal unmarshals i into GUID. i must be a string representing a GUID or nil.

type Int

type Int struct {
	// Value holds the value of the type.
	Value int32
	// Valid indicates if this value was set.
	Valid bool
}

Int represents a Kusto int type. Values int type's are int32 values. Int implements Kusto.

func (Int) Convert added in v0.6.0

func (in Int) Convert(v reflect.Value) error

Convert Int into reflect value.

func (Int) String

func (in Int) String() string

String implements fmt.Stringer.

func (*Int) Unmarshal

func (in *Int) Unmarshal(i interface{}) error

Unmarshal unmarshals i into Int. i must be an int32 or nil.

type Kusto

type Kusto interface {

	// String implements fmt.Stringer().
	String() string
	// Convert into reflect value.
	Convert(v reflect.Value) error
	// contains filtered or unexported methods
}

Kusto represents a Kusto value.

type Long

type Long struct {
	// Value holds the value of the type.
	Value int64
	// Valid indicates if this value was set.
	Valid bool
}

Long represents a Kusto long type, which is an int64. Long implements Kusto.

func (Long) Convert added in v0.6.0

func (l Long) Convert(v reflect.Value) error

Convert Long into reflect value.

func (Long) String

func (l Long) String() string

String implements fmt.Stringer.

func (*Long) Unmarshal

func (l *Long) Unmarshal(i interface{}) error

Unmarshal unmarshals i into Long. i must be an int64 or nil.

type Real

type Real struct {
	// Value holds the value of the type.
	Value float64
	// Valid indicates if this value was set.
	Valid bool
}

Real represents a Kusto real type. Real implements Kusto.

func (Real) Convert added in v0.6.0

func (r Real) Convert(v reflect.Value) error

Convert Real into reflect value.

func (Real) String

func (r Real) String() string

String implements fmt.Stringer.

func (*Real) Unmarshal

func (r *Real) Unmarshal(i interface{}) error

Unmarshal unmarshals i into Real. i must be a json.Number(that is a float64), float64 or nil.

type String

type String struct {
	// Value holds the value of the type.
	Value string
	// Valid indicates if this value was set.
	Valid bool
}

String represents a Kusto string type. String implements Kusto.

func (String) Convert added in v0.6.0

func (s String) Convert(v reflect.Value) error

Convert String into reflect value.

func (String) String

func (s String) String() string

String implements fmt.Stringer.

func (*String) Unmarshal

func (s *String) Unmarshal(i interface{}) error

Unmarshal unmarshals i into String. i must be a string or nil.

type Timespan

type Timespan struct {
	// Value holds the value of the type.
	Value time.Duration
	// Valid indicates if this value was set.
	Valid bool
}

Timespan represents a Kusto timespan type. Timespan implements Kusto.

func (Timespan) Convert added in v0.6.0

func (ts Timespan) Convert(v reflect.Value) error

Convert Timespan into reflect value.

func (Timespan) Marshal

func (t Timespan) Marshal() string

Marshal marshals the Timespan into a Kusto compatible string. The string is the contant invariant(c) format. See https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-timespan-format-strings .

func (Timespan) String

func (t Timespan) String() string

String implements fmt.Stringer.

func (*Timespan) Unmarshal

func (t *Timespan) Unmarshal(i interface{}) error

Unmarshal unmarshals i into Timespan. i must be a string representing a Values timespan or nil.

type Values

type Values []Kusto

Values is a list of Kusto values, usually an ordered row.

Jump to

Keyboard shortcuts

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