table

package
v0.2.76 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlattenMapIntoColumns

func FlattenMapIntoColumns(rows types.MapRow) types.MapRow

func PreserveColumnOrder

func PreserveColumnOrder(oldColumns []types.FieldName, newColumns map[types.FieldName]interface{}) []types.FieldName

Types

type AddFieldMiddleware added in v0.2.60

type AddFieldMiddleware struct {
	Fields map[string]string
}

func NewAddFieldMiddleware added in v0.2.60

func NewAddFieldMiddleware(fields map[string]string) *AddFieldMiddleware

func (*AddFieldMiddleware) Process added in v0.2.60

func (a *AddFieldMiddleware) Process(table *types.Table) (*types.Table, error)

type ColumnMiddlewareConfig

type ColumnMiddlewareConfig struct {
	FieldRenames map[types.FieldName]types.FieldName `yaml:"renames"`
	// FIXME regex renames actually need to ordered
	RegexpRenames RegexpReplacements `yaml:"regexpRenames"`
}

type FieldsFilterMiddleware

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

FieldsFilterMiddleware keeps columns that are in the fields list and removes columns that are in the filters list.

empty lists means that all columns are accepted.

The returned rows are SimpleRows

func NewFieldsFilterMiddleware

func NewFieldsFilterMiddleware(fields []string, filters []string) *FieldsFilterMiddleware

func (*FieldsFilterMiddleware) Process

func (ffm *FieldsFilterMiddleware) Process(table *types.Table) (*types.Table, error)

type FlattenObjectMiddleware

type FlattenObjectMiddleware struct {
}

func NewFlattenObjectMiddleware

func NewFlattenObjectMiddleware() *FlattenObjectMiddleware

func (*FlattenObjectMiddleware) Process

func (fom *FlattenObjectMiddleware) Process(table *types.Table) (*types.Table, error)

type PreserveColumnOrderMiddleware

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

func NewPreserveColumnOrderMiddleware

func NewPreserveColumnOrderMiddleware(columns []types.FieldName) *PreserveColumnOrderMiddleware

func (*PreserveColumnOrderMiddleware) Process

func (scm *PreserveColumnOrderMiddleware) Process(table *types.Table) (*types.Table, error)

type RegexReplacement

type RegexReplacement struct {
	Regexp      *regexp.Regexp
	Replacement string
}

type RegexpReplacement

type RegexpReplacement struct {
	Regexp      *regexp.Regexp
	Replacement string
}

type RegexpReplacements

type RegexpReplacements []*RegexpReplacement

func (*RegexpReplacements) UnmarshalYAML

func (rr *RegexpReplacements) UnmarshalYAML(value *yaml.Node) error

type RegexpSkip

type RegexpSkip struct {
	Regexp *regexp.Regexp
}

type RemoveDuplicatesMiddleware

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

func NewRemoveDuplicatesMiddleware

func NewRemoveDuplicatesMiddleware(columns ...string) *RemoveDuplicatesMiddleware

func (*RemoveDuplicatesMiddleware) Process

func (r *RemoveDuplicatesMiddleware) Process(table *types.Table) (*types.Table, error)

type RemoveNullsMiddleware

type RemoveNullsMiddleware struct {
}

func NewRemoveNullsMiddleware

func NewRemoveNullsMiddleware() *RemoveNullsMiddleware

func (*RemoveNullsMiddleware) Process

func (rnm *RemoveNullsMiddleware) Process(table *types.Table) (*types.Table, error)

type RenameColumnMiddleware

type RenameColumnMiddleware struct {
	Renames map[types.FieldName]types.FieldName
	// orderedmap *regexp.Regexp -> string
	RegexpRenames RegexpReplacements
}

func NewFieldRenameColumnMiddleware

func NewFieldRenameColumnMiddleware(renames map[types.FieldName]types.FieldName) *RenameColumnMiddleware

func NewRegexpRenameColumnMiddleware

func NewRegexpRenameColumnMiddleware(renames RegexpReplacements) *RenameColumnMiddleware

func NewRenameColumnMiddleware

func NewRenameColumnMiddleware(
	renames map[types.FieldName]types.FieldName,
	regexpRenames RegexpReplacements,
) *RenameColumnMiddleware

func NewRenameColumnMiddlewareFromYAML

func NewRenameColumnMiddlewareFromYAML(decoder *yaml.Decoder) (*RenameColumnMiddleware, error)

func (*RenameColumnMiddleware) Process

func (r *RenameColumnMiddleware) Process(table *types.Table) (*types.Table, error)

func (*RenameColumnMiddleware) RenameColumns

func (r *RenameColumnMiddleware) RenameColumns(
	columns []types.FieldName,
) ([]types.FieldName, map[types.FieldName]types.FieldName)

type ReorderColumnOrderMiddleware

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

func NewReorderColumnOrderMiddleware

func NewReorderColumnOrderMiddleware(columns []types.FieldName) *ReorderColumnOrderMiddleware

func (*ReorderColumnOrderMiddleware) Process

func (scm *ReorderColumnOrderMiddleware) Process(table *types.Table) (*types.Table, error)

type ReplaceMiddleware

type ReplaceMiddleware struct {
	Replacements      map[types.FieldName][]*Replacement
	RegexReplacements map[types.FieldName][]*RegexpReplacement
	RegexSkips        map[types.FieldName][]*RegexpSkip
	Skips             map[types.FieldName][]*Skip
}

func NewReplaceMiddleware

func NewReplaceMiddleware(
	replacements map[types.FieldName][]*Replacement,
	regexReplacements map[types.FieldName][]*RegexpReplacement,
	regexSkips map[types.FieldName][]*RegexpSkip,
	skips map[types.FieldName][]*Skip,
) *ReplaceMiddleware

func NewReplaceMiddlewareFromYAML

func NewReplaceMiddlewareFromYAML(b []byte) (*ReplaceMiddleware, error)

func (*ReplaceMiddleware) Process

func (r *ReplaceMiddleware) Process(table *types.Table) (*types.Table, error)

type Replacement

type Replacement struct {
	Pattern     string
	Replacement string
}

type RowGoTemplateMiddleware

type RowGoTemplateMiddleware struct {

	// this field is used to replace "." in keys before passing them to the template,
	// in order to avoid having to use the `index` template function to access fields
	// that contain a ".", which is frequent due to flattening.
	RenameSeparator string
	// contains filtered or unexported fields
}

func NewRowGoTemplateMiddleware

func NewRowGoTemplateMiddleware(
	templateStrings map[types.FieldName]string,
	renameSeparator string) (*RowGoTemplateMiddleware, error)

NewRowGoTemplateMiddleware creates a new RowGoTemplateMiddleware which is the simplest go template middleware.

It will render the template for each row and return the result as a new column called with the given title.

Because nested objects will be flattened to individual columns using the . separator, this will make fields inaccessible to the template. One way around this is to use {{ index . "field.subfield" }} in the template. Another is to pass a separator rename option.

TODO(manuel, 2023-02-02) Add support for passing in custom funcmaps See #110 https://github.com/go-go-golems/glazed/issues/110

func (*RowGoTemplateMiddleware) Process

func (rgtm *RowGoTemplateMiddleware) Process(table *types.Table) (*types.Table, error)

type Skip

type Skip struct {
	Pattern string
}

type SortByMiddleware

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

SortByMiddleware sorts the table by the given columns, in ascending or descending order. If the column contains rows with the same type, the order is undefined.

func NewSortByMiddlewareFromColumns

func NewSortByMiddlewareFromColumns(columns ...string) *SortByMiddleware

NewSortByMiddlewareFromColumns creates a new SortByMiddleware from the given columns. To sort in descending order, prefix the column name with a minus sign.

Example:

NewSortByMiddlewareFromColumns("name", "-age")

This will sort by name in ascending order and by age in descending order.

func (*SortByMiddleware) Process

func (s *SortByMiddleware) Process(table *types.Table) (*types.Table, error)

type SortColumnsMiddleware

type SortColumnsMiddleware struct {
}

func NewSortColumnsMiddleware

func NewSortColumnsMiddleware() *SortColumnsMiddleware

func (*SortColumnsMiddleware) Process

func (scm *SortColumnsMiddleware) Process(table *types.Table) (*types.Table, error)

Jump to

Keyboard shortcuts

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