Documentation ¶
Overview ¶
Package kind encapsulates the notion of data "kind": that is, it is an abstraction over data types across implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Hash ¶ added in v0.41.0
Hash generates a hash from the kinds returned by the detectors. The detectors should already have sampled data.
func MungeEmptyStringAsNil ¶ added in v0.32.0
MungeEmptyStringAsNil munges v to nil if v is an empty string.
Types ¶
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector is used to detect the kind of a stream of values. The caller adds values via Sample and then invokes Detect.
func (*Detector) Detect ¶
Detect returns the detected Kind. If ambiguous, Text is returned, unless all sampled values were nil, in which case Null is returned. If the returned mungeFn is non-nil, it can be used to convert input values to their canonical form. For example, for Datetime the MungeFunc would accept string "2020-06-11T02:50:54Z" and return a time.Time, while for Date, the MungeFunc would accept "1970-01-01" or "01 Jan 1970" and always return a string in the canonicalized form "1970-01-01".
type Kind ¶
type Kind int
Kind models a generic data kind, which ultimately maps to some more specific implementation data type, such as a SQL VARCHAR or JSON boolean.
const ( // Unknown indicates an unknown kind. Unknown Kind = iota // Null indicates a NULL kind. Null // Text indicates a text kind. Text // Int indicates an integer kind. Int // Float indicates a float kind. Float // Decimal indicates a decimal kind. Decimal // Bool indicates a boolean kind. Bool // Bytes indicates a bytes or blob kind. Bytes // Datetime indicates a date-time kind. Datetime // Date indicates a date-only kind. For example "2022-12-31". Date // Time indicates a time-only kind. Time )
func (Kind) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Kind) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Kind) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.