schema

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: MPL-2.0, MIT Imports: 26 Imported by: 7

README

CloudQuery Type System

This directory is heavily based on jackc/pgtype and modified per CQ needs and thus fall under the original MIT license and copyright.

Documentation

Overview

Package schema defines types supported by tables in source plugins

nolint:gocritic

Index

Constants

View Source
const (
	MetadataUnique         = "cq:extension:unique"
	MetadataPrimaryKey     = "cq:extension:primary_key"
	MetadataConstraintName = "cq:extension:constraint_name"
	MetadataIncremental    = "cq:extension:incremental"

	MetadataTrue      = "true"
	MetadataFalse     = "false"
	MetadataTableName = "cq:table_name"
)

Variables

View Source
var CqIDColumn = Column{
	Name:        "_cq_id",
	Type:        TypeUUID,
	Description: "Internal CQ ID of the row",
	CreationOptions: ColumnCreationOptions{
		NotNull: true,
		Unique:  true,
	},
}

These columns are managed and populated by the source plugins

View Source
var CqIDField = arrow.Field{
	Name: "_cq_id",
	Type: types.ExtensionTypes.UUID,
	Metadata: arrow.MetadataFrom(map[string]string{
		MetadataUnique: MetadataTrue,
	}),
}
View Source
var CqParentIDColumn = Column{
	Name:          "_cq_parent_id",
	Type:          TypeUUID,
	Description:   "Internal CQ ID of the parent row",
	Resolver:      parentCqUUIDResolver(),
	IgnoreInTests: true,
}
View Source
var CqSourceNameColumn = Column{
	Name:        "_cq_source_name",
	Type:        TypeString,
	Description: "Internal CQ row that references the source plugin name data was retrieved",
}
View Source
var CqSourceNameField = arrow.Field{
	Name: "_cq_source_name",
	Type: arrow.BinaryTypes.String,
}
View Source
var CqSyncTimeColumn = Column{
	Name:        "_cq_sync_time",
	Type:        TypeTimestamp,
	Description: "Internal CQ row of when sync was started (this will be the same for all rows in a single fetch)",
}

These columns are managed and populated by the destination plugin.

View Source
var CqSyncTimeField = arrow.Field{
	Name: "_cq_sync_time",
	Type: arrow.FixedWidthTypes.Timestamp_us,
}

Functions

func CQColumnToArrowField

func CQColumnToArrowField(col *Column) arrow.Field

func CQSchemaToArrow

func CQSchemaToArrow(table *Table) *arrow.Schema

func CQTypesOneToRecord

func CQTypesOneToRecord(mem memory.Allocator, c CQTypes, arrowSchema *arrow.Schema) arrow.Record

func CQTypesToRecord

func CQTypesToRecord(mem memory.Allocator, c []CQTypes, arrowSchema *arrow.Schema) arrow.Record

func IsIncremental

func IsIncremental(s *arrow.Schema) bool

func IsPk

func IsPk(f arrow.Field) bool

func IsUnique

func IsUnique(f arrow.Field) bool

func NewFieldMetadataFromOptions

func NewFieldMetadataFromOptions(opts MetadataFieldOptions) arrow.Metadata

func NewSchemaMetadataFromOptions

func NewSchemaMetadataFromOptions(opts MetadataSchemaOptions) arrow.Metadata

func PrimaryKeyIndices

func PrimaryKeyIndices(sc *arrow.Schema) []int

func SetPk

func SetPk(f *arrow.Field)

func TableName

func TableName(sc *arrow.Schema) string

func TableNameFromSchema

func TableNameFromSchema(schema *arrow.Schema) (string, error)

func TransformWithTransformer

func TransformWithTransformer(transformer CQTypeTransformer, values CQTypes) []any

func UnsetPk

func UnsetPk(f *arrow.Field)

func ValidateTable

func ValidateTable(t *Table) error

Types

type ArrayDimension

type ArrayDimension struct {
	Length     int32
	LowerBound int32
}

type Bool

type Bool struct {
	Bool   bool
	Status Status
}

func (*Bool) Equal

func (dst *Bool) Equal(src CQType) bool

func (Bool) Get

func (dst Bool) Get() any

func (*Bool) GetStatus

func (dst *Bool) GetStatus() Status

func (*Bool) Set

func (dst *Bool) Set(src any) error

func (*Bool) Size

func (*Bool) Size() int

func (*Bool) String

func (dst *Bool) String() string

func (*Bool) Type

func (*Bool) Type() ValueType

type BoolTransformer

type BoolTransformer interface {
	TransformBool(*Bool) any
}

type Bytea

type Bytea struct {
	Bytes  []byte
	Status Status
}

func (*Bytea) Equal

func (dst *Bytea) Equal(src CQType) bool

func (Bytea) Get

func (dst Bytea) Get() any

func (*Bytea) GetStatus

func (dst *Bytea) GetStatus() Status

func (*Bytea) Set

func (dst *Bytea) Set(src any) error

func (*Bytea) Size

func (dst *Bytea) Size() int

func (*Bytea) String

func (dst *Bytea) String() string

func (*Bytea) Type

func (*Bytea) Type() ValueType

type ByteaTransformer

type ByteaTransformer interface {
	TransformBytea(*Bytea) any
}

type CIDR

type CIDR Inet

func (*CIDR) Equal

func (dst *CIDR) Equal(src CQType) bool

func (CIDR) Get

func (dst CIDR) Get() any

func (*CIDR) GetStatus

func (dst *CIDR) GetStatus() Status

func (*CIDR) Set

func (dst *CIDR) Set(src any) error

func (*CIDR) Size

func (dst *CIDR) Size() int

func (*CIDR) String

func (dst *CIDR) String() string

func (*CIDR) Type

func (*CIDR) Type() ValueType

func (*CIDR) UnmarshalJSON

func (dst *CIDR) UnmarshalJSON(b []byte) error

type CIDRArray

type CIDRArray struct {
	Elements   []CIDR
	Dimensions []ArrayDimension
	Status     Status
}

func (*CIDRArray) Equal

func (dst *CIDRArray) Equal(src CQType) bool

func (CIDRArray) Get

func (dst CIDRArray) Get() any

func (*CIDRArray) GetStatus

func (dst *CIDRArray) GetStatus() Status

func (*CIDRArray) Set

func (dst *CIDRArray) Set(src any) error

func (*CIDRArray) Size

func (dst *CIDRArray) Size() int

func (*CIDRArray) String

func (dst *CIDRArray) String() string

func (*CIDRArray) Type

func (*CIDRArray) Type() ValueType

type CIDRArrayTransformer

type CIDRArrayTransformer interface {
	TransformCIDRArray(*CIDRArray) any
}

type CIDRTransformer

type CIDRTransformer interface {
	TransformCIDR(*CIDR) any
}

type CQType

type CQType interface {
	Set(v any) error
	Get() any
	String() string
	// Used only in testing
	Equal(CQType) bool
	Type() ValueType
	Size() int
	GetStatus() Status
}

func NewCqTypeFromValueType

func NewCqTypeFromValueType(typ ValueType) CQType

type CQTypes

type CQTypes []CQType

func (CQTypes) Diff

func (c CQTypes) Diff(other CQTypes) string

Used in testing only.

func (CQTypes) Equal

func (c CQTypes) Equal(other CQTypes) bool

func (CQTypes) Len

func (c CQTypes) Len() int

func (CQTypes) MarshalJSON

func (c CQTypes) MarshalJSON() ([]byte, error)

func (CQTypes) Size

func (c CQTypes) Size() int

Size returns total number of bytes occupied by all values this useful to understand how much data is being transferred, rather than just number of resources.

func (CQTypes) String

func (c CQTypes) String() string

func (*CQTypes) UnmarshalJSON

func (c *CQTypes) UnmarshalJSON(b []byte) error

type ClientMeta

type ClientMeta interface {
	ID() string
}

type Column

type Column struct {
	// Name of column
	Name string `json:"name,omitempty"`
	// Value Type of column i.e String, UUID etc'
	Type ValueType `json:"type,omitempty"`
	// Description about column, this description is added as a comment in the database
	Description string `json:"-"`
	// Column Resolver allows to set your own data for a column; this can be an API call, setting multiple embedded values, etc
	Resolver ColumnResolver `json:"-"`
	// Creation options allow modifying how column is defined when table is created
	CreationOptions ColumnCreationOptions `json:"creation_options,omitempty"`
	// IgnoreInTests is used to skip verifying the column is non-nil in integration tests.
	// By default, integration tests perform a fetch for all resources in cloudquery's test account, and
	// verify all columns are non-nil.
	// If IgnoreInTests is true, verification is skipped for this column.
	// Used when it is hard to create a reproducible environment with this column being non-nil (e.g. various error columns).
	IgnoreInTests bool `json:"-"`
}

Column definition for Table

func (Column) String

func (c Column) String() string

func (Column) ToArrowField

func (c Column) ToArrowField() arrow.Field

type ColumnCreationOptions

type ColumnCreationOptions struct {
	PrimaryKey bool `json:"primary_key,omitempty"`
	NotNull    bool `json:"not_null,omitempty"`
	// IncrementalKey is a flag that indicates if the column is used as part of an incremental key.
	// It is mainly used for documentation purposes, but may also be used as part of ensuring that
	// migrations are done correctly.
	IncrementalKey bool `json:"incremental_key"`
	Unique         bool `json:"unique,omitempty"`
}

ColumnCreationOptions allow modification of how column is defined when table is created

type ColumnList

type ColumnList []Column

func (ColumnList) Get

func (c ColumnList) Get(name string) *Column

func (ColumnList) Index

func (c ColumnList) Index(col string) int

func (ColumnList) Names

func (c ColumnList) Names() []string

func (ColumnList) String

func (c ColumnList) String() string

func (*ColumnList) UnmarshalJSON

func (c *ColumnList) UnmarshalJSON(data []byte) (err error)

type ColumnResolver

type ColumnResolver func(ctx context.Context, meta ClientMeta, resource *Resource, c Column) error

ColumnResolver is called for each row received in TableResolver's data fetch. execution holds all relevant information regarding execution as well as the Column called. resource holds the current row we are resolving the column for.

func ParentColumnResolver

func ParentColumnResolver(name string) ColumnResolver

ParentColumnResolver resolves a column from the parent's table data, if name isn't set the column will be set to null

func PathResolver

func PathResolver(path string) ColumnResolver

PathResolver resolves a field in the Resource.Item

Examples: PathResolver("Field") PathResolver("InnerStruct.Field") PathResolver("InnerStruct.InnerInnerStruct.Field")

type DefaultTransformer

type DefaultTransformer struct {
}

func (*DefaultTransformer) TransformBool

func (*DefaultTransformer) TransformBool(v *Bool) any

func (*DefaultTransformer) TransformBytea

func (*DefaultTransformer) TransformBytea(v *Bytea) any

func (*DefaultTransformer) TransformCIDR

func (*DefaultTransformer) TransformCIDR(v *CIDR) any

func (*DefaultTransformer) TransformCIDRArray

func (*DefaultTransformer) TransformCIDRArray(v *CIDRArray) any

func (*DefaultTransformer) TransformFloat8

func (*DefaultTransformer) TransformFloat8(v *Float8) any

func (*DefaultTransformer) TransformInet

func (*DefaultTransformer) TransformInet(v *Inet) any

func (*DefaultTransformer) TransformInetArray

func (*DefaultTransformer) TransformInetArray(v *InetArray) any

func (*DefaultTransformer) TransformInt8

func (*DefaultTransformer) TransformInt8(v *Int8) any

func (*DefaultTransformer) TransformInt8Array

func (*DefaultTransformer) TransformInt8Array(v *Int8Array) any

func (*DefaultTransformer) TransformJSON

func (*DefaultTransformer) TransformJSON(v *JSON) any

func (*DefaultTransformer) TransformMacaddr

func (*DefaultTransformer) TransformMacaddr(v *Macaddr) any

func (*DefaultTransformer) TransformMacaddrArray

func (*DefaultTransformer) TransformMacaddrArray(v *MacaddrArray) any

func (*DefaultTransformer) TransformText

func (*DefaultTransformer) TransformText(v *Text) any

func (*DefaultTransformer) TransformTextArray

func (*DefaultTransformer) TransformTextArray(v *TextArray) any

func (*DefaultTransformer) TransformTimestamptz

func (*DefaultTransformer) TransformTimestamptz(v *Timestamptz) any

func (*DefaultTransformer) TransformUUID

func (*DefaultTransformer) TransformUUID(v *UUID) any

func (*DefaultTransformer) TransformUUIDArray

func (*DefaultTransformer) TransformUUIDArray(v *UUIDArray) any

type DestinationResource

type DestinationResource struct {
	TableName string  `json:"table_name"`
	Data      CQTypes `json:"data"`
}

This struct is what we send over the wire to destination. We dont want to reuse the same struct as otherwise we will have to comment on fields which don't get sent over the wire but still accessible code wise

type FieldChange

type FieldChange struct {
	Type       TableColumnChangeType
	ColumnName string
	Current    arrow.Field
	Previous   arrow.Field
}

func GetSchemaChanges

func GetSchemaChanges(target *arrow.Schema, source *arrow.Schema) []FieldChange

Get changes return changes between two schemas

type Float8

type Float8 struct {
	Float  float64
	Status Status
}

func (*Float8) Equal

func (dst *Float8) Equal(src CQType) bool

func (Float8) Get

func (dst Float8) Get() any

func (*Float8) GetStatus

func (dst *Float8) GetStatus() Status

func (*Float8) Set

func (dst *Float8) Set(src any) error

func (*Float8) Size

func (dst *Float8) Size() int

func (*Float8) String

func (dst *Float8) String() string

func (*Float8) Type

func (*Float8) Type() ValueType

type Float8Transformer

type Float8Transformer interface {
	TransformFloat8(*Float8) any
}

type Inet

type Inet struct {
	IPNet  *net.IPNet
	Status Status
}

Inet represents both inet and cidr PostgreSQL types.

func (*Inet) Equal

func (dst *Inet) Equal(src CQType) bool

func (Inet) Get

func (dst Inet) Get() any

func (*Inet) GetStatus

func (dst *Inet) GetStatus() Status

func (*Inet) Set

func (dst *Inet) Set(src any) error

func (*Inet) Size

func (dst *Inet) Size() int

func (*Inet) String

func (dst *Inet) String() string

func (*Inet) Type

func (*Inet) Type() ValueType

func (*Inet) UnmarshalJSON

func (dst *Inet) UnmarshalJSON(b []byte) error

workaround this Golang bug: https://github.com/golang/go/issues/35727

type InetArray

type InetArray struct {
	Elements   []Inet
	Dimensions []ArrayDimension
	Status     Status
}

func (*InetArray) Equal

func (dst *InetArray) Equal(src CQType) bool

func (InetArray) Get

func (dst InetArray) Get() any

func (*InetArray) GetStatus

func (dst *InetArray) GetStatus() Status

func (*InetArray) Set

func (dst *InetArray) Set(src any) error

func (*InetArray) Size

func (dst *InetArray) Size() int

func (*InetArray) String

func (dst *InetArray) String() string

func (*InetArray) Type

func (*InetArray) Type() ValueType

type InetArrayTransformer

type InetArrayTransformer interface {
	TransformInetArray(*InetArray) any
}

type InetTransformer

type InetTransformer interface {
	TransformInet(*Inet) any
}

type InfinityModifier

type InfinityModifier int8
const (
	Infinity         InfinityModifier = 1
	None             InfinityModifier = 0
	NegativeInfinity InfinityModifier = -Infinity
)

type Int8

type Int8 struct {
	Int    int64
	Status Status
}

func (*Int8) Equal

func (dst *Int8) Equal(src CQType) bool

func (Int8) Get

func (dst Int8) Get() any

func (*Int8) GetStatus

func (dst *Int8) GetStatus() Status

func (*Int8) Set

func (dst *Int8) Set(src any) error

func (*Int8) Size

func (*Int8) Size() int

func (*Int8) String

func (dst *Int8) String() string

func (*Int8) Type

func (*Int8) Type() ValueType

type Int8Array

type Int8Array struct {
	Elements   []Int8
	Dimensions []ArrayDimension
	Status     Status
}

func (*Int8Array) Equal

func (dst *Int8Array) Equal(src CQType) bool

func (Int8Array) Get

func (dst Int8Array) Get() any

func (*Int8Array) GetStatus

func (dst *Int8Array) GetStatus() Status

func (*Int8Array) Set

func (dst *Int8Array) Set(src any) error

func (*Int8Array) Size

func (dst *Int8Array) Size() int

func (*Int8Array) String

func (dst *Int8Array) String() string

func (*Int8Array) Type

func (*Int8Array) Type() ValueType

type Int8ArrayTransformer

type Int8ArrayTransformer interface {
	TransformInt8Array(*Int8Array) any
}

type Int8Transformer

type Int8Transformer interface {
	TransformInt8(*Int8) any
}

type JSON

type JSON struct {
	Bytes  []byte
	Status Status
}

func (*JSON) Equal

func (dst *JSON) Equal(src CQType) bool

func (JSON) Get

func (dst JSON) Get() any

func (*JSON) GetStatus

func (dst *JSON) GetStatus() Status

func (*JSON) Set

func (dst *JSON) Set(src any) error

func (*JSON) Size

func (dst *JSON) Size() int

func (*JSON) String

func (dst *JSON) String() string

func (*JSON) Type

func (*JSON) Type() ValueType

type JSONTransformer

type JSONTransformer interface {
	TransformJSON(*JSON) any
}

type LengthTableValidator

type LengthTableValidator struct{}

func (LengthTableValidator) Validate

func (LengthTableValidator) Validate(t *Table) error

type Macaddr

type Macaddr struct {
	Addr   net.HardwareAddr
	Status Status
}

func (*Macaddr) Equal

func (dst *Macaddr) Equal(src CQType) bool

func (Macaddr) Get

func (dst Macaddr) Get() any

func (*Macaddr) GetStatus

func (dst *Macaddr) GetStatus() Status

func (*Macaddr) Set

func (dst *Macaddr) Set(src any) error

func (*Macaddr) Size

func (dst *Macaddr) Size() int

func (*Macaddr) String

func (dst *Macaddr) String() string

func (*Macaddr) Type

func (*Macaddr) Type() ValueType

type MacaddrArray

type MacaddrArray struct {
	Elements   []Macaddr
	Dimensions []ArrayDimension
	Status     Status
}

func (*MacaddrArray) Equal

func (dst *MacaddrArray) Equal(src CQType) bool

func (MacaddrArray) Get

func (dst MacaddrArray) Get() any

func (*MacaddrArray) GetStatus

func (dst *MacaddrArray) GetStatus() Status

func (*MacaddrArray) Set

func (dst *MacaddrArray) Set(src any) error

func (*MacaddrArray) Size

func (dst *MacaddrArray) Size() int

func (*MacaddrArray) String

func (dst *MacaddrArray) String() string

func (*MacaddrArray) Type

func (*MacaddrArray) Type() ValueType

type MacaddrArrayTransformer

type MacaddrArrayTransformer interface {
	TransformMacaddrArray(*MacaddrArray) any
}

type MacaddrTransformer

type MacaddrTransformer interface {
	TransformMacaddr(*Macaddr) any
}

type MetadataFieldOptions

type MetadataFieldOptions struct {
	PrimaryKey bool
	Unique     bool
}

type MetadataSchemaOptions

type MetadataSchemaOptions struct {
	TableName string
}

type Multiplexer

type Multiplexer func(meta ClientMeta) []ClientMeta

type Resource

type Resource struct {
	// Original resource item that wa from prior resolve
	Item any
	// Set if this is an embedded table
	Parent *Resource
	// internal fields
	Table *Table
	// contains filtered or unexported fields
}

Resource represents a row in it's associated table, it carries a reference to the original item, and automatically generates an Id based on Table's Columns. Resource data can be accessed by the Get and Set methods

func NewResourceData

func NewResourceData(t *Table, parent *Resource, item any) *Resource

func (*Resource) CalculateCQID

func (r *Resource) CalculateCQID(deterministicCQID bool) error

func (*Resource) Columns

func (r *Resource) Columns() []string

func (*Resource) Get

func (r *Resource) Get(columnName string) CQType

func (*Resource) GetItem

func (r *Resource) GetItem() any

func (*Resource) GetValues

func (r *Resource) GetValues() CQTypes

func (*Resource) Set

func (r *Resource) Set(columnName string, value any) error

Set sets a column with value. This does validation and conversion to one of concrete it returns an error just for backward compatibility and panics in case it fails

func (*Resource) SetItem

func (r *Resource) SetItem(item any)

Override original item (this is useful for apis that follow list/details pattern)

func (*Resource) ToDestinationResource

func (r *Resource) ToDestinationResource() DestinationResource

func (*Resource) Validate

func (r *Resource) Validate() error

Validates that all primary keys have values.

type Resources

type Resources []*Resource

func (Resources) ColumnNames

func (rr Resources) ColumnNames() []string

func (Resources) TableName

func (rr Resources) TableName() string

type RowResolver

type RowResolver func(ctx context.Context, meta ClientMeta, resource *Resource) error

type Schemas

type Schemas []*arrow.Schema

func (Schemas) Len

func (s Schemas) Len() int

func (Schemas) SchemaByName

func (s Schemas) SchemaByName(name string) *arrow.Schema

type Status

type Status byte
const (
	Undefined Status = iota
	Null
	Present
)

type SyncSummary

type SyncSummary struct {
	Resources uint64
	Errors    uint64
	Panics    uint64
}

This is deprecated

type Table

type Table struct {
	// Name of table
	Name string `json:"name"`
	// Title to be used in documentation (optional: will be generated from name if not set)
	Title string `json:"title"`
	// table description
	Description string `json:"description"`
	// Columns are the set of fields that are part of this table
	Columns ColumnList `json:"columns"`
	// Relations are a set of related tables defines
	Relations Tables `json:"relations"`
	// Transform
	Transform Transform `json:"-"`
	// Resolver is the main entry point to fetching table data and
	Resolver TableResolver `json:"-"`
	// Multiplex returns re-purposed meta clients. The sdk will execute the table with each of them
	Multiplex Multiplexer `json:"-"`
	// PostResourceResolver is called after all columns have been resolved, but before the Resource is sent to be inserted. The ordering of resolvers is:
	//  (Table) Resolver → PreResourceResolver → ColumnResolvers → PostResourceResolver
	PostResourceResolver RowResolver `json:"-"`
	// PreResourceResolver is called before all columns are resolved but after Resource is created. The ordering of resolvers is:
	//  (Table) Resolver → PreResourceResolver → ColumnResolvers → PostResourceResolver
	PreResourceResolver RowResolver `json:"-"`
	// IsIncremental is a flag that indicates if the table is incremental or not. This flag mainly affects how the table is
	// documented.
	IsIncremental bool

	// IgnoreInTests is used to exclude a table from integration tests.
	// By default, integration tests fetch all resources from cloudquery's test account, and verify all tables
	// have at least one row.
	// When IgnoreInTests is true, integration tests won't fetch from this table.
	// Used when it is hard to create a reproducible environment with a row in this table.
	IgnoreInTests bool `json:"ignore_in_tests"`

	// Parent is the parent table in case this table is called via parent table (i.e. relation)
	Parent *Table `json:"-"`

	PkConstraintName string `json:"pk_constraint_name"`
}

func (*Table) Column

func (t *Table) Column(name string) *Column

func (*Table) Copy

func (t *Table) Copy(parent *Table) *Table

func (*Table) GetChanges

func (t *Table) GetChanges(old *Table) []TableColumnChange

Get Changes returns changes between two tables when t is the new one and old is the old one.

func (*Table) IncrementalKeys

func (t *Table) IncrementalKeys() []string

func (*Table) OverwriteOrAddColumn

func (t *Table) OverwriteOrAddColumn(column *Column)

If the column with the same name exists, overwrites it. Otherwise, adds the column to the beginning of the table.

func (*Table) PrimaryKeys

func (t *Table) PrimaryKeys() []string

func (*Table) TableNames

func (t *Table) TableNames() []string

func (*Table) ToArrowSchema

func (t *Table) ToArrowSchema() *arrow.Schema

func (*Table) ValidateColumnNames

func (t *Table) ValidateColumnNames() error

func (*Table) ValidateDuplicateColumns

func (t *Table) ValidateDuplicateColumns() error

func (*Table) ValidateName

func (t *Table) ValidateName() error

type TableColumnChange

type TableColumnChange struct {
	Type       TableColumnChangeType
	ColumnName string
	Current    Column
	Previous   Column
}

func (TableColumnChange) String

func (t TableColumnChange) String() string

type TableColumnChangeType

type TableColumnChangeType int
const (
	TableColumnChangeTypeUnknown TableColumnChangeType = iota
	TableColumnChangeTypeAdd
	TableColumnChangeTypeUpdate
	TableColumnChangeTypeRemove
)

func (TableColumnChangeType) String

func (t TableColumnChangeType) String() string

type TableResolver

type TableResolver func(ctx context.Context, meta ClientMeta, parent *Resource, res chan<- any) error

TableResolver is the main entry point when a table is sync is called.

Table resolver has 3 main arguments: - meta(ClientMeta): is the client returned by the plugin.Provider Configure call - parent(Resource): resource is the parent resource in case this table is called via parent table (i.e. relation) - res(chan any): is a channel to pass results fetched by the TableResolver

type TableValidator

type TableValidator interface {
	Validate(t *Table) error
}

type Tables

type Tables []*Table

func (Tables) FilterDfs

func (tt Tables) FilterDfs(tables, skipTables []string, skipDependentTables bool) (Tables, error)

func (Tables) FilterDfsFunc

func (tt Tables) FilterDfsFunc(include, exclude func(*Table) bool, skipDependentTables bool) Tables

func (Tables) FlattenTables

func (tt Tables) FlattenTables() Tables

func (Tables) Get

func (tt Tables) Get(name string) *Table

Get returns a table by name. Returns top-level tables and relations.

func (Tables) GetTopLevel

func (tt Tables) GetTopLevel(name string) *Table

GetTopLevel returns a table by name. Only returns the table if it is in top-level list.

func (Tables) TableNames

func (tt Tables) TableNames() []string

func (Tables) ToArrowSchemas

func (tt Tables) ToArrowSchemas() Schemas

func (Tables) ValidateColumnNames

func (tt Tables) ValidateColumnNames() error

func (Tables) ValidateDuplicateColumns

func (tt Tables) ValidateDuplicateColumns() error

func (Tables) ValidateDuplicateTables

func (tt Tables) ValidateDuplicateTables() error

func (Tables) ValidateTableNames

func (tt Tables) ValidateTableNames() error

type Text

type Text struct {
	Str    string
	Status Status
}

func (*Text) Equal

func (dst *Text) Equal(src CQType) bool

Used only in tests - we allow one of the strings to be missing null byttes (since some destinations like) postgresql strip it.

func (Text) Get

func (dst Text) Get() any

func (*Text) GetStatus

func (dst *Text) GetStatus() Status

func (*Text) Set

func (dst *Text) Set(src any) error

func (*Text) Size

func (dst *Text) Size() int

func (*Text) String

func (dst *Text) String() string

func (*Text) Type

func (*Text) Type() ValueType

type TextArray

type TextArray struct {
	Elements   []Text
	Dimensions []ArrayDimension
	Status     Status
}

func (*TextArray) Equal

func (dst *TextArray) Equal(src CQType) bool

func (TextArray) Get

func (dst TextArray) Get() any

func (*TextArray) GetStatus

func (dst *TextArray) GetStatus() Status

func (*TextArray) Set

func (dst *TextArray) Set(src any) error

func (*TextArray) Size

func (dst *TextArray) Size() int

func (*TextArray) String

func (dst *TextArray) String() string

func (*TextArray) Type

func (*TextArray) Type() ValueType

type TextArrayTransformer

type TextArrayTransformer interface {
	TransformTextArray(*TextArray) any
}

type TextTransformer

type TextTransformer interface {
	TransformText(*Text) any
}

type Timestamptz

type Timestamptz struct {
	Time             time.Time
	Status           Status
	InfinityModifier InfinityModifier
}

func (*Timestamptz) DecodeText

func (dst *Timestamptz) DecodeText(src []byte) error

func (*Timestamptz) Equal

func (dst *Timestamptz) Equal(src CQType) bool

func (Timestamptz) Get

func (dst Timestamptz) Get() any

func (*Timestamptz) GetStatus

func (dst *Timestamptz) GetStatus() Status

func (*Timestamptz) Set

func (dst *Timestamptz) Set(src any) error

func (*Timestamptz) Size

func (dst *Timestamptz) Size() int

func (*Timestamptz) String

func (dst *Timestamptz) String() string

func (*Timestamptz) Type

func (*Timestamptz) Type() ValueType

type TimestamptzTransformer

type TimestamptzTransformer interface {
	TransformTimestamptz(*Timestamptz) any
}

type Transform

type Transform func(table *Table) error

type UUID

type UUID struct {
	Bytes  [16]byte
	Status Status
}

func (*UUID) Equal

func (dst *UUID) Equal(src CQType) bool

func (UUID) Get

func (dst UUID) Get() any

func (*UUID) GetStatus

func (dst *UUID) GetStatus() Status

func (*UUID) Set

func (dst *UUID) Set(src any) error

func (*UUID) Size

func (dst *UUID) Size() int

func (*UUID) String

func (dst *UUID) String() string

func (*UUID) Type

func (*UUID) Type() ValueType

type UUIDArray

type UUIDArray struct {
	Elements   []UUID
	Dimensions []ArrayDimension
	Status     Status
}

func (*UUIDArray) Equal

func (dst *UUIDArray) Equal(src CQType) bool

func (UUIDArray) Get

func (dst UUIDArray) Get() any

func (*UUIDArray) GetStatus

func (dst *UUIDArray) GetStatus() Status

func (*UUIDArray) Set

func (dst *UUIDArray) Set(src any) error

func (*UUIDArray) Size

func (dst *UUIDArray) Size() int

func (*UUIDArray) String

func (dst *UUIDArray) String() string

func (*UUIDArray) Type

func (*UUIDArray) Type() ValueType

type UUIDArrayTransformer

type UUIDArrayTransformer interface {
	TransformUUIDArray(*UUIDArray) any
}

type UUIDTransformer

type UUIDTransformer interface {
	TransformUUID(*UUID) any
}

type ValidationError

type ValidationError struct {
	Err   error
	Msg   string
	Type  ValueType
	Value any
}

func (*ValidationError) Error

func (e *ValidationError) Error() string

func (*ValidationError) MaskedError

func (e *ValidationError) MaskedError() string

this prints the error without the value

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

type ValueType

type ValueType int
const (
	TypeInvalid ValueType = iota
	TypeBool
	TypeInt
	TypeFloat
	TypeUUID
	TypeString
	TypeByteArray
	TypeStringArray
	TypeIntArray
	TypeTimestamp
	TypeJSON
	TypeUUIDArray
	TypeInet
	TypeInetArray
	TypeCIDR
	TypeCIDRArray
	TypeMacAddr
	TypeMacAddrArray
	TypeTimeIntervalDeprecated
	TypeEnd
)

func (ValueType) String

func (r ValueType) String() string

func (*ValueType) UnmarshalJSON

func (r *ValueType) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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