tabular

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: MIT Imports: 5 Imported by: 3

Documentation

Overview

Package tabular defines functions for working with rectangular datasets. qri positions tabular data as a special shape that comes with additional constraints. This package defines the methods necessary to enforce and interpret those constraints

Index

Constants

This section is empty.

Variables

View Source
var BaseTabularSchema = map[string]interface{}{
	"type": "array",
	"items": map[string]interface{}{
		"type":  "array",
		"items": []interface{}{},
	},
}

BaseTabularSchema is the base schema for tabular data

View Source
var ErrInvalidTabularSchema = errors.New("invalid tabular schema")

ErrInvalidTabularSchema is a base type for schemas that don't work as tables all parsing errors in this package can be errors.Is() to this one

Functions

This section is empty.

Types

type ColType

type ColType []string

ColType implements type information for a tabular column. Column Types can be one or more strings enumerating accepted types

func (ColType) HasType added in v0.3.0

func (ct ColType) HasType(t string) bool

HasType ranges over the column types and returns true if the type is present

func (ColType) MarshalJSON

func (ct ColType) MarshalJSON() ([]byte, error)

MarshalJSON encodes to string in the common case of a single type, an array of strings for a type enumeration

func (*ColType) UnmarshalJSON

func (ct *ColType) UnmarshalJSON(p []byte) error

UnmarshalJSON decodes string and string array data types

type Column

type Column struct {
	Title       string                 `json:"title"`
	Type        *ColType               `json:"type"`
	Description string                 `json:"description,omitempty"`
	Validation  map[string]interface{} `json:"validation,omitempty"`
}

Column defines values associated with an index of each row of data

type Columns

type Columns []Column

Columns is an ordered list of column information

func ColumnsFromJSONSchema

func ColumnsFromJSONSchema(sch map[string]interface{}) (Columns, []string, error)

ColumnsFromJSONSchema extracts column data from a jsonSchema object, erroring if the provided schema cannot be used to describe a table. a slice of problem strings describes non-breaking issues with the schema that should be addressed like missing column titles or column types the passed in schema must be a decoding of a json schema into default type mappings from the encoding/json package

func (Columns) Titles

func (cols Columns) Titles() []string

Titles gives just column titles as a slice of strings

func (Columns) ValidMachineTitles

func (cols Columns) ValidMachineTitles() error

ValidMachineTitles confirms column titles are valid for machine-readability using column titles that parse as proper variable names, and unique titles across the column set

Jump to

Keyboard shortcuts

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