query

package
v1.0.0-preview-2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToStructs

func ToStructs[T any](data interface{}) ([]T, error)

ToStructs converts a table, a non-iterative dataset or a slice of rows into a slice of structs. If a dataset is provided, it should contain exactly one table.

func ToStructsIterative

func ToStructsIterative[T any](tb IterativeTable) chan StructResult[T]

Types

type BaseDataset

type BaseDataset interface {
	Context() context.Context
	Op() errors.Op

	PrimaryResultKind() string
}

BaseDataset represents a result from kusto - a set of tables with metadata This basic interface is implemented by all dataset types - both v1 and v2 for specific

func NewBaseDataset

func NewBaseDataset(ctx context.Context, op errors.Op, primaryResultsKind string) BaseDataset

type BaseTable

type BaseTable interface {
	Id() string
	Index() int64
	Name() string
	Columns() []Column
	Kind() string
	ColumnByName(name string) Column
	Op() errors.Op
	IsPrimaryResult() bool
}

func NewBaseTable

func NewBaseTable(ds BaseDataset, index int64, id string, name string, kind string, columns []Column) BaseTable

type Column

type Column interface {
	// Ordinal returns the column's index in the table.
	Index() int
	// Name returns the column's name.
	Name() string
	// Type returns the column's kusto data type.
	Type() types.Column
}

Column represents a column in a table.

func NewColumn

func NewColumn(ordinal int, name string, kustoType types.Column) Column

type Columns

type Columns []Column

type Dataset

type Dataset interface {
	BaseDataset
	Tables() []Table
}

func NewDataset

func NewDataset(base BaseDataset, tables []Table) Dataset

type IterativeDataset

type IterativeDataset interface {
	BaseDataset
	Tables() <-chan TableResult
	ToDataset() (Dataset, error)
	Close() error
}

IterativeDataset represents an iterative result from kusto - where the tables are streamed as they are received from the service.

type IterativeTable

type IterativeTable interface {
	BaseTable
	// Rows returns a channel that will be populated with rows as they are read.
	Rows() <-chan RowResult
	// SkipToEnd skips all remaining rows in the table.
	SkipToEnd() []error
	ToTable() (Table, error)
}

IterativeTable is a table that returns rows one at a time.

type Row

type Row interface {
	// Index returns the index of the row.
	Index() int

	// Columns returns the columns of the table that the row belongs to.
	Columns() Columns

	// Values returns all the values in the row.
	Values() value.Values

	// Value returns the value at the specified index.
	Value(i int) (value.Kusto, error)

	ValueByColumn(c Column) (value.Kusto, error)

	// ValueByName returns the value with the specified column name.
	ValueByName(name string) (value.Kusto, error)

	// ToStruct converts the row into a struct and assigns it to the provided pointer.
	// It returns an error if the conversion fails.
	ToStruct(p interface{}) error

	// String returns a string representation of the row.
	String() string

	BoolByIndex(i int) (*bool, error)
	IntByIndex(i int) (*int32, error)
	LongByIndex(i int) (*int64, error)
	RealByIndex(i int) (*float64, error)
	DecimalByIndex(i int) (*decimal.Decimal, error)
	StringByIndex(i int) (string, error)
	DynamicByIndex(i int) ([]byte, error)
	DateTimeByIndex(i int) (*time.Time, error)
	TimespanByIndex(i int) (*time.Duration, error)
	GuidByIndex(i int) (*uuid.UUID, error)

	BoolByName(name string) (*bool, error)
	IntByName(name string) (*int32, error)
	LongByName(name string) (*int64, error)
	RealByName(name string) (*float64, error)
	DecimalByName(name string) (*decimal.Decimal, error)
	StringByName(name string) (string, error)
	DynamicByName(name string) ([]byte, error)
	DateTimeByName(name string) (*time.Time, error)
	TimespanByName(name string) (*time.Duration, error)
	GuidByName(name string) (*uuid.UUID, error)
}

Row is an interface that represents a row in a table. It provides methods to access and manipulate the data in the row.

func NewRow

func NewRow(t BaseTable, ordinal int, values value.Values) Row

func NewRowFromParts

func NewRowFromParts(c Columns, columnByName func(string) Column, ordinal int, values value.Values) Row

type RowResult

type RowResult interface {
	Row() Row
	Err() error
}

RowResult is a single streamed row from a table. It can contain either a row or an error.

func RowResultError

func RowResultError(err error) RowResult

func RowResultSuccess

func RowResultSuccess(row Row) RowResult

type StructResult

type StructResult[T any] struct {
	Out T
	Err error
}

type Table

type Table interface {
	BaseTable
	Rows() []Row
}

func NewTable

func NewTable(base BaseTable, rows []Row) Table

type TableResult

type TableResult interface {
	Table() IterativeTable
	Err() error
}

func TableResultError

func TableResultError(err error) TableResult

func TableResultSuccess

func TableResultSuccess(table IterativeTable) TableResult

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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