table

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package table contains types that represent the makeup of a Kusto table.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	// Name is the name of the column.
	Name string `json:"ColumnName"`
	// Type is the type of value stored in this column. These are described
	// via constants starting with CT<type>.
	Type types.Column `json:"ColumnType"`
}

Column describes a column descriptor.

type Columns

type Columns []Column

Columns is a set of columns.

func (Columns) Validate

func (c Columns) Validate() error

type Row

type Row struct {
	// ColumnType contains all the column type information for the row.
	ColumnTypes Columns
	// Values is the list of values that make up the row.
	Values value.Values
	// Op is the operation that resulted in the row. This is for internal use.
	Op errors.Op
	// Replace indicates whether the existing result set should be cleared and replaced with this row.
	Replace bool
	// contains filtered or unexported fields
}

Row represents a row of Kusto data. Methods are not thread-safe.

func (*Row) ColumnNames

func (r *Row) ColumnNames() []string

ColumnNames returns a list of all column names.

func (*Row) Columns

func (r *Row) Columns(ptrs ...interface{}) error

Columns fetches all column names in the row at once. The name of the kth column will be decoded into the kth argument to Columns. The number of arguments must be equal to the number of columns. Pass nil to specify that a column should be ignored. ptrs may be either the *string or *types.Column type. An error in decoding may leave some ptrs set and others not.

func (*Row) ExtractValues

func (r *Row) ExtractValues(ptrs ...interface{}) error

ExtractValues fetches all values in the row at once. The value of the kth column will be decoded into the kth argument to ExtractValues. The number of arguments must be equal to the number of columns. Pass nil to specify that a column should be ignored. ptrs should be compatible with column types. An error in decoding may leave some ptrs set and others not.

func (*Row) Size

func (r *Row) Size() int

Size returns the number of columns contained in Row.

func (*Row) String

func (r *Row) String() string

String implements fmt.Stringer for a Row. This simply outputs a CSV version of the row.

func (*Row) ToStruct

func (r *Row) ToStruct(p interface{}) error

ToStruct fetches the columns in a row into the fields of a struct. p must be a pointer to struct. The rules for mapping a row's columns into a struct's exported fields are:

  1. If a field has a `kusto: "column_name"` tag, then decode column 'column_name' into the field. A special case is the `column_name: "-"` tag, which instructs ToStruct to ignore the field during decoding.

  2. Otherwise, if the name of a field matches the name of a column (ignoring case), decode the column into the field.

Slice and pointer fields will be set to nil if the source column is a null value, and a non-nil value if the column is not NULL. To decode NULL values of other types, use one of the kusto types (Int, Long, Dynamic, ...) as the type of the destination field. You can check the .Valid field of those types to see if the value was set.

type Rows

type Rows []*Row

Rows is a set of rows.

Jump to

Keyboard shortcuts

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