typeutils

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DateTimeFormats = []string{
	"2006-01-02",
	"2006-01-02 15:04:05",
	"2006-01-02 15:04:05 -07:00",
	"2006-01-02 15:04:05-07:00",
	"2006-01-02 15:04:05 -0700 MST",
	"2006-01-02T15:04:05",
	"2006-01-02T15:04:05.000000",
	"2006-01-02T15:04:05.999999999Z07:00",
	"2006-01-02T15:04:05+0000",
	"2020-08-17T05:50:22.895Z",
	"2006-01-02 15:04:05.999999-07",
	"2006-01-02 15:04:05.999999+00",
}
View Source
var (
	ErrNullValue = fmt.Errorf("null value")
)
View Source
var GeospatialTypes = []string{"geometry", "point", "polygon", "linestring", "multi"}

Functions

func Compare added in v0.1.3

func Compare(a, b any) int

return 0 for equal, -1 if a < b else 1 if a>b

func ExtractAndMapColumnType

func ExtractAndMapColumnType(columnType string, typeMapping map[string]types.DataType) types.DataType

func FormatCursorValue added in v0.3.5

func FormatCursorValue(cursorValue any) any

FormatCursorValue is used to make time format and object id format consistent to be saved in state

func MaximumOnDataType

func MaximumOnDataType[T any](typ types.DataType, a, b T) (T, error)

func ReformatBool added in v0.2.0

func ReformatBool(v interface{}) (bool, error)

func ReformatByteArraysToString

func ReformatByteArraysToString(data map[string]any) map[string]any

func ReformatDate

func ReformatDate(v interface{}) (time.Time, error)

reformat date

func ReformatFloat32

func ReformatFloat32(v interface{}) (float32, error)

func ReformatFloat64

func ReformatFloat64(v interface{}) (float64, error)

func ReformatGeoType added in v0.2.9

func ReformatGeoType(v any) (any, error)

func ReformatInt32

func ReformatInt32(v any) (int32, error)

func ReformatInt64

func ReformatInt64(v any) (int64, error)

func ReformatRecord

func ReformatRecord(fields Fields, record types.Record) error

func ReformatValue

func ReformatValue(dataType types.DataType, v any) (any, error)

func ReformatValueOnDataTypes

func ReformatValueOnDataTypes(datatypes []types.DataType, v any) (any, error)

func Resolve

func Resolve(stream *types.Stream, objects ...map[string]interface{}) error

func TypeFromValue

func TypeFromValue(v interface{}) types.DataType

Types

type Field

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

Field is a data type holder with occurrences

func NewField

func NewField(t types.DataType) *Field

NewField returns Field instance

func (*Field) Merge

func (f *Field) Merge(anotherField *Field)

Merge adds new type occurrences wipes field.type if new type was added

func (*Field) Types

func (f *Field) Types() []types.DataType

type Fields

type Fields map[string]*Field

func (Fields) Add

func (f Fields) Add(other Fields)

Add all new fields from other to current instance if field exists - skip it

func (Fields) Clone

func (f Fields) Clone() Fields

Clone copies fields into a new Fields object

func (Fields) FromSchema

func (f Fields) FromSchema(schema *types.TypeSchema)

func (Fields) Header

func (f Fields) Header() (header []string)

Header return fields names as a string slice

func (Fields) Merge

func (f Fields) Merge(other Fields)

Merge adds all fields from other to current instance or merge if exists

func (Fields) OverrideTypes

func (f Fields) OverrideTypes(other Fields)

OverrideTypes check if field exists in other then put its type

func (Fields) Process

func (f Fields) Process(record types.Record) (bool, bool, Fields)

Returns change, typeChange, mutations

func (Fields) ToProperties

func (f Fields) ToProperties() map[string]*types.Property

func (Fields) ToTypeSchema

func (f Fields) ToTypeSchema() *types.TypeSchema

type Flattener

type Flattener interface {
	Flatten(json types.Record) (types.Record, error)
}

func NewFlattener

func NewFlattener() Flattener

type FlattenerImpl

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

func (*FlattenerImpl) Flatten

func (f *FlattenerImpl) Flatten(json types.Record) (types.Record, error)

type StringInterface

type StringInterface interface {
	String() string
}

type Time

type Time struct {
	time.Time
}

func (Time) After added in v0.1.3

func (ct Time) After(u Time) bool

After reports whether the time instant ct is after u

func (Time) Before added in v0.1.3

func (ct Time) Before(u Time) bool

Before reports whether the time instant ct is before u

func (Time) Compare added in v0.1.3

func (ct Time) Compare(u Time) int

Compare compares the time instant ct with u. If ct is before u, it returns -1; if ct is after u, it returns +1; if they're the same, it returns 0.

func (Time) Equal added in v0.1.3

func (ct Time) Equal(u Time) bool

Equal reports whether ct and u represent the same time instant

func (*Time) UnmarshalJSON

func (ct *Time) UnmarshalJSON(b []byte) error

UnmarshalJSON overrides the default unmarshalling for CustomTime

Jump to

Keyboard shortcuts

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