Documentation
¶
Index ¶
- Constants
- func BuildMetadata(sc *SourceConfig, mc *ModelConfig) error
- func BuildModels(sc *SourceConfig, mc *ModelConfig) error
- func ConfirmInsert(modelName string, dc chan []int64, rowsExpected int64)
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func GetConfig(modelTarget string) (*SourceConfig, *ModelConfig, error)
- func GetMysqlPoolFromSource(source Source) (*sql.DB, error)
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func Initialize(logLevels ...string) error
- func Insert(modelName ModelName, ic <-chan []driver.Value, dc chan<- []int64)
- func IsValidLogLevel(logLevel string) error
- func ParseModelColumns(mc *ModelConfig, columnMetadata ColumnMetadata) error
- func ParseModelTables(mc *ModelConfig) error
- func PrintPrettyJSON(data []map[string]interface{}) error
- func PrintPrettyStruct(v interface{}) error
- func ReadRows(rows *sql.Rows, c chan map[string]any) error
- func Retrieve(sc *SourceConfig, mc *ModelConfig) error
- func ValidateConfigs(sc *SourceConfig, mc *ModelConfig) error
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- func WithError(err error) *logrus.Entry
- func WithFields(fields logrus.Fields) *logrus.Entry
- func WriteToTable(rows []map[string]any, columns []string, outputFormat string) error
- type Column
- type ColumnMetadata
- type ColumnName
- type ColumnType
- type Connection
- type Env
- type Fields
- type FuncName
- type MajorityType
- type Model
- type ModelConfig
- type ModelName
- type Options
- type QueryResult
- type QueryResults
- type Retriever
- type Source
- type SourceConfig
- type TableAlias
- type TableMap
- type TableName
- type TableSet
- type Type
Constants ¶
const Version = "v0.2.4"
Variables ¶
This section is empty.
Functions ¶
func BuildMetadata ¶
func BuildMetadata(sc *SourceConfig, mc *ModelConfig) error
BuildMetadata builds any required metadata for the sources in the sources.yaml config. Postgres and MySQL sources require an information schema to be built. S3 sources require duckDB secrets to be stored.
func BuildModels ¶
func BuildModels(sc *SourceConfig, mc *ModelConfig) error
This is the main entry point for building models. The CLI commands call this function.
func ConfirmInsert ¶
func GetConfig ¶
func GetConfig(modelTarget string) (*SourceConfig, *ModelConfig, error)
func Initialize ¶
func IsValidLogLevel ¶
func ParseModelColumns ¶
func ParseModelColumns(mc *ModelConfig, columnMetadata ColumnMetadata) error
func ParseModelTables ¶
func ParseModelTables(mc *ModelConfig) error
func PrintPrettyJSON ¶
PrintPrettyJSON prints the pretty JSON to the console.
func PrintPrettyStruct ¶
func PrintPrettyStruct(v interface{}) error
func Retrieve ¶
func Retrieve(sc *SourceConfig, mc *ModelConfig) error
Retrieve data from sources and insert into the duckDB database. Database sources are inserted via the Insert function. File sources are inserted via the native duckDB integrations.
func ValidateConfigs ¶
func ValidateConfigs(sc *SourceConfig, mc *ModelConfig) error
Types ¶
type ColumnMetadata ¶
type ColumnMetadata map[TableName]map[ColumnName]ColumnType
func BuildColumnMetadata ¶
func BuildColumnMetadata() (ColumnMetadata, error)
BuildColumnMetadata does 2 things: 1) Acts as the interface between information schema data stored in DuckDB and the parts of the application that will need to consume that data, in particular the model builder 2) Performs type validation against each column pulled from the source databases, via the Boyer-Moore majority voting algorithm. This majority type is then packaged into the ColumnMetadata and return to the caller. This is important for typing the model tables created in DuckDB
type ColumnName ¶
type ColumnName string
type ColumnType ¶
type ColumnType struct { // Types is a slice of every data type found for a column from its sources Types []string `json:"types"` MajorityType MajorityType `json:"majority_type"` }
type Connection ¶
type Connection struct { Host string `yaml:"host"` Port int `yaml:"port"` Database string `yaml:"database"` Username string `yaml:"username"` Password string `yaml:"password"` AuthSource string `yaml:"auth_source"` BucketName string `yaml:"bucket_name"` Region string `yaml:"region"` Schema string `yaml:"schema"` Warehouse string `yaml:"warehouse"` Role string `yaml:"role"` Account string `yaml:"account"` }
type MajorityType ¶
type MajorityType string
type Model ¶
type Model struct { Name ModelName `yaml:"name"` Type string `yaml:"type"` Format string `yaml:"format"` Options Options `yaml:"options"` Query string `yaml:"query"` FilePatterns *[]string `yaml:"file_patterns"` Collection string `yaml:"collection"` Parsed sqlparser.Statement DDLString string Columns map[TableName]map[ColumnName]Column TableMap TableMap TableSet TableSet }
type ModelConfig ¶
func GetModelConfigs ¶
func GetModelConfigs(modelTarget string) (*ModelConfig, error)
type Options ¶
type Options struct { AllVarchar *bool `default:"false" yaml:"all_varchar"` AllowQuotedNulls *bool `default:"true" yaml:"allow_quoted_nulls"` AutoDetect *bool `default:"true" yaml:"auto_detect"` AutoTypeCandidates *[]string `default:"-" yaml:"auto_type_candidates"` Columns *[]Type `default:"-" yaml:"columns"` Compression *string `default:"auto" yaml:"compression"` DateFormat *string `default:"-" yaml:"date_format"` DecimalSeparator *string `default:"." yaml:"decimal_separator"` Delim *string `default:"," yaml:"delim"` Escape *string `default:"\"" yaml:"escape"` FileName *bool `default:"false" yaml:"filename"` ForceNotNull *[]string `default:"[]" yaml:"force_not_null"` Header *bool `default:"false" yaml:"header"` HivePartitioning *bool `default:"false" yaml:"hive_partitioning"` IgnoreErrors *bool `default:"false" yaml:"ignore_errors"` MaxLineSize *int64 `default:"2097152" yaml:"max_line_size"` Names *[]string `default:"-" yaml:"names"` NewLine *string `default:"-" yaml:"new_line"` NormalizeNames *bool `default:"false" yaml:"normalize_names"` NullPadding *bool `default:"false" yaml:"null_padding"` NullString *[]string `default:"-" yaml:"null_string"` Parallel *bool `default:"true" yaml:"parallel"` Quote *string `default:"\"" yaml:"quote"` SampleSize *int64 `default:"20480" yaml:"sample_size"` Skip *int64 `default:"0" yaml:"skip"` TimestampFormat *string `default:"-" yaml:"timestamp_format"` Types *[]Type `default:"-" yaml:"types"` UnionByName *bool `default:"false" yaml:"union_by_name"` }
type QueryResult ¶
type QueryResults ¶
func Execute ¶
func Execute(statement string) (*QueryResults, error)
type Source ¶
type Source struct { Name string `yaml:"name"` Engine string `yaml:"engine"` Connection Connection `yaml:"connection"` Models []string `yaml:"models"` }
type SourceConfig ¶
func GetSourceConfig ¶
func GetSourceConfig() (*SourceConfig, error)
type TableAlias ¶
type TableAlias string
type TableMap ¶
type TableMap map[TableAlias]TableName