common/schema: make alias/generate configureable

This commit is contained in:
Marvin Gaube
2023-03-23 15:25:43 +01:00
parent 59c0e25e84
commit 00026beabd
4 changed files with 35 additions and 1 deletions

View File

@@ -22,6 +22,16 @@ type Component struct {
// New creates a new schema component.
func New(config Configuration) (*Component, error) {
schema := flows()
for _, k := range config.Generate {
if column, ok := schema.LookupColumnByKey(k); ok {
if column.ClickHouseAlias != "" {
column.ClickHouseGenerateFrom = column.ClickHouseAlias
column.ClickHouseAlias = ""
} else {
return nil, fmt.Errorf("no alias configured for %s that can be converted to generate", k)
}
}
}
for _, k := range config.Enabled {
if column, ok := schema.LookupColumnByKey(k); ok {
column.Disabled = false