Documentation
¶
Index ¶
- Variables
- func GetPluginForFormat(format *Format) (string, bool)
- func GetPluginForFormatByName(formatName string) (string, bool)
- func GetPluginForFormatPreset(fullName string, versionMap map[string]*versionfile.InstalledVersion) (string, bool)
- func GetPluginForFormatType(typeName string, versionMap map[string]*versionfile.InstalledVersion) (string, bool)
- func GetPluginForSourceType(sourceType string, versionMap map[string]*versionfile.InstalledVersion) string
- func GetPluginForTable(tableName string, versionMap map[string]*versionfile.InstalledVersion) string
- func IsColumnName(s string) bool
- func NewFilter(block *hcl.Block, fullName string) (modconfig.HclResource, hcl.Diagnostics)
- func NewFormat(block *hcl.Block, fullName string) (modconfig.HclResource, hcl.Diagnostics)
- func NewPartition(block *hcl.Block, fullName string) (modconfig.HclResource, hcl.Diagnostics)
- func NewTable(block *hcl.Block, fullName string) (modconfig.HclResource, hcl.Diagnostics)
- func NewTailpipeConnection(block *hcl.Block, fullName string) (modconfig.HclResource, hcl.Diagnostics)
- func NormalizeSqlExpression(expr string) string
- func ResourceHasSubtype(blockType string) bool
- type Column
- type Filter
- type Format
- type HclBytes
- type Partition
- func (p *Partition) AddFilter(filter string)
- func (p *Partition) CollectionStatePath(collectionDir string) string
- func (p *Partition) CtyValue() (cty.Value, error)
- func (p *Partition) FormatSupportsDirectConversion() bool
- func (p *Partition) GetFormat() *Format
- func (p *Partition) InferPluginName(v *versionfile.PluginVersionFile) string
- func (p *Partition) SetConfigHcl(u *HclBytes)
- func (p *Partition) Validate() hcl.Diagnostics
- type Source
- type SyntheticMetadata
- type Table
- type TailpipeConfig
- type TailpipeConnection
Constants ¶
This section is empty.
Variables ¶
var GlobalWorkspaceProfile *workspace_profile.TailpipeWorkspaceProfile
Functions ¶
func GetPluginForFormat ¶ added in v0.2.0
GetPluginForFormat determines the plugin which provides the given format, using the plugin versions file, Call either GetPluginForFormatPreset or GetPluginForFormatType
func GetPluginForFormatByName ¶ added in v0.2.0
GetPluginForFormatByName returns the plugin name that provides the given format name. Call either GetPluginForFormatPreset or GetPluginForFormatType
func GetPluginForFormatPreset ¶ added in v0.2.0
func GetPluginForFormatPreset(fullName string, versionMap map[string]*versionfile.InstalledVersion) (string, bool)
GetPluginForFormatPreset returns the plugin name that provides the given format preset. Format name should be in the format "type.name"
func GetPluginForFormatType ¶ added in v0.2.0
func GetPluginForFormatType(typeName string, versionMap map[string]*versionfile.InstalledVersion) (string, bool)
GetPluginForFormatType returns the plugin name that provides the given format type.
func GetPluginForSourceType ¶ added in v0.2.0
func GetPluginForSourceType(sourceType string, versionMap map[string]*versionfile.InstalledVersion) string
GetPluginForSourceType returns the plugin name that provides the given source.
func GetPluginForTable ¶ added in v0.2.0
func GetPluginForTable(tableName string, versionMap map[string]*versionfile.InstalledVersion) string
GetPluginForTable returns the plugin name that provides the given table. NOTE: this does not check custom tables - if the same table name is a custom table we should use the core plugin we cannot check that here as this function may be called before the config is fully populated
func IsColumnName ¶ added in v0.5.0
IsColumnName returns true if the string is a valid SQL column name. It checks that the name: 1. Contains only alphanumeric characters and underscores 2. Starts with a letter or underscore 3. Is not empty 4. Is not a DuckDB reserved keyword
func NewFilter ¶
func NewFilter(block *hcl.Block, fullName string) (modconfig.HclResource, hcl.Diagnostics)
func NewFormat ¶
func NewFormat(block *hcl.Block, fullName string) (modconfig.HclResource, hcl.Diagnostics)
func NewPartition ¶
func NewPartition(block *hcl.Block, fullName string) (modconfig.HclResource, hcl.Diagnostics)
func NewTable ¶
func NewTable(block *hcl.Block, fullName string) (modconfig.HclResource, hcl.Diagnostics)
func NewTailpipeConnection ¶
func NewTailpipeConnection(block *hcl.Block, fullName string) (modconfig.HclResource, hcl.Diagnostics)
func NormalizeSqlExpression ¶ added in v0.5.0
NormalizeSqlExpression processes a config value for use in SQL. It safely escapes and quotes strings, but passes through valid SQL expressions and column names. Not used fow now but may be needed if support for partition tp_index is broadened in the future to include functions or more complex expressions.
func ResourceHasSubtype ¶
Types ¶
type Column ¶ added in v0.2.0
type Column struct {
// The name of the column. This is the name that will be used in the output.
Name string `hcl:"name,label" cty:"name"`
// The DuckDB name of the column in the source.
Type *string `hcl:"type" cty:"type"`
// The source name of the column. This is the field name in the source data
Source *string `hcl:"source" cty:"source"`
// An optional description of the column.
Description *string `hcl:"description" cty:"description"`
// Is the column required?
Required *bool `hcl:"required" cty:"required"`
// An optional null value for the column. If the source value contains this, the column will be null
NullIf *string `hcl:"null_if" cty:"null_if"`
// A duck DB transform function to apply to the column. This should be expressed as a SQL function
// If a Transform is provided, no source should be provided.
// e.g. "upper(name)"
Transform *string `hcl:"transform" cty:"transform"`
}
func (Column) ToProto ¶ added in v0.3.0
func (c Column) ToProto() *proto.ColumnSchema
type Filter ¶
type Filter struct {
modconfig.HclResourceImpl
// required to allow partial decoding
Remain hcl.Body `hcl:",remain" json:"-"`
Where *string `hcl:"where"`
}
type Format ¶
type Format struct {
modconfig.HclResourceImpl
// required to allow partial decoding
Remain hcl.Body `hcl:",remain" json:"-"`
// the format type
Type string `cty:"type"`
// the raw HCL of the format (this will be decoded by the plugin which implements the format)
Config *HclBytes `cty:"config"`
// alternatively, the preset name opf the format
PresetName string `cty:"preset"`
}
func NewPresetFormat ¶ added in v0.2.0
func (*Format) CtyValue ¶ added in v0.2.0
CtyValue implements CtyValueProvider (note this must be implemented by each resource, we cannot rely on the HclResourceImpl implementation as it will only serialise its own properties) )
func (*Format) GetSubType ¶
GetSubType returns the subtype for the format block (the type). The presence of this function indicates this resource supports 3 part names, which affects how it is stored in the eval context
func (*Format) SetConfigHcl ¶
func (*Format) ToProto ¶
func (f *Format) ToProto() *proto.FormatData
type HclBytes ¶
type HclBytes struct {
Hcl []byte `cty:"hcl"`
Range hclhelpers.Range `cty:"range"`
}
func HclBytesForLines ¶ added in v0.2.0
HclBytesForLines extracts the HCL bytes for a given range from a source HCL byte buffer, ensuring that it includes full lines rather than using byte-based slicing.
func HclBytesForRange ¶
HclBytesForRange extracts the HCL bytes for a given range from a source HCL byte buffer This is used to extract the HCL for a unknown attributes so we can pass it to a plugin to parse
type Partition ¶
type Partition struct {
modconfig.HclResourceImpl
// required to allow partial decoding
Remain hcl.Body `hcl:",remain" json:"-"`
// the name of the table this partition is for - this is the first label in the partition block
TableName string
// if the partition of for a custom table, this will be set to the custom table config
CustomTable *Table `cty:"table"`
// Plugin used for this partition
Plugin *plugin.Plugin `cty:"-"`
// Source of the data for this partition
Source Source `cty:"source"`
// any partition-type specific config data for the partition
Config []byte `cty:"config"`
// the config location
ConfigRange hclhelpers.Range `cty:"config_range"`
// an option filter in the format of a SQL where clause
Filter string `cty:"filter"`
// the sql column to use for the tp_index
TpIndexColumn string `cty:"tp_index"`
// if this is a synthetic partition for testing, this will be non-null
SyntheticMetadata *SyntheticMetadata
}
func (*Partition) CollectionStatePath ¶
func (*Partition) CtyValue ¶ added in v0.2.0
CtyValue implements CtyValueProvider (note this must be implemented by each resource, we cannot rely on the HclResourceImpl implementation as it will only serialise its own properties) )
func (*Partition) FormatSupportsDirectConversion ¶ added in v0.3.0
func (*Partition) GetFormat ¶ added in v0.2.0
GetFormat returns the format for this partition, if either the source or the custom table has one
func (*Partition) InferPluginName ¶
func (p *Partition) InferPluginName(v *versionfile.PluginVersionFile) string
func (*Partition) SetConfigHcl ¶
type Source ¶
type Source struct {
Type string `hcl:" type,label" cty:"type"`
Connection *TailpipeConnection `hcl:"connection" cty:"connection"`
// optional: the format (for custom tables)
Format *Format `hcl:"format" cty:"format"`
// the config hcl
Config *HclBytes `cty:"config"`
}
func (*Source) SetConfigHcl ¶
func (*Source) ToProto ¶
func (s *Source) ToProto() *proto.ConfigData
type SyntheticMetadata ¶ added in v0.7.0
type Table ¶
type Table struct {
modconfig.HclResourceImpl
// required to allow partial decoding
Remain hcl.Body `hcl:",remain" json:"-"`
// the default format for this table
DefaultSourceFormat *Format `hcl:"format" cty:"format"`
Columns []Column `hcl:"column,block" cty:"columns"`
// should we include ALL source fields in addition to any defined columns, or ONLY include the columns defined
// default to automap ALL source fields (*)
MapFields []string `hcl:"map_fields,optional" cty:"map_fields"`
// the default null value for the table (may be overridden for specific columns)
NullIf string `hcl:"null_if,optional" cty:"null_if"`
}
Table is a struct representing a custom table definition
type TailpipeConfig ¶
type TailpipeConfig struct {
// map of partitions, keyed by unqualified name (<partition_type>.<partition_name>)
Partitions map[string]*Partition
Connections map[string]*TailpipeConnection
PluginVersions map[string]*versionfile.InstalledVersion
CustomTables map[string]*Table
Formats map[string]*Format
}
var GlobalConfig *TailpipeConfig
func NewTailpipeConfig ¶
func NewTailpipeConfig() *TailpipeConfig
func (*TailpipeConfig) Add ¶
func (c *TailpipeConfig) Add(resource modconfig.HclResource) error
func (*TailpipeConfig) InitPartitions ¶
func (c *TailpipeConfig) InitPartitions(versionMap *versionfile.PluginVersionFile)
func (*TailpipeConfig) Validate ¶
func (c *TailpipeConfig) Validate() hcl.Diagnostics
type TailpipeConnection ¶
type TailpipeConnection struct {
modconfig.HclResourceImpl
// required to allow partial decoding
Remain hcl.Body `hcl:",remain" json:"-"`
Plugin string `cty:"plugin"`
Hcl []byte `cty:"hcl"`
// the hcl range for the connection - use our version so we can sty serialise it
HclRange hclhelpers.Range `cty:"hcl_range"`
}
func (*TailpipeConnection) CtyValue ¶ added in v0.2.0
func (c *TailpipeConnection) CtyValue() (cty.Value, error)
CtyValue implements CtyValueProvider (note this must be implemented by each resource, we cannot rely on the HclResourceImpl implementation as it will only serialise its own properties) )
func (*TailpipeConnection) GetSubType ¶
func (c *TailpipeConnection) GetSubType() string
GetSubType returns the subtype for the connection (the plugin). The presence of this function indicates this resource supports 3 part names, which affects how it is stored in the eval context
func (*TailpipeConnection) ToProto ¶
func (c *TailpipeConnection) ToProto() *proto.ConfigData