common/schema: allow to move some data in or out the main table

This commit is contained in:
Vincent Bernat
2023-01-26 00:33:06 +01:00
parent 6482c4c258
commit d3b1ae7ad2
8 changed files with 114 additions and 18 deletions

View File

@@ -22,13 +22,6 @@ type Component struct {
// New creates a new schema component.
func New(config Configuration) (*Component, error) {
schema := flows()
for _, k1 := range config.Enabled {
for _, k2 := range config.Disabled {
if k1 == k2 {
return nil, fmt.Errorf("column %q contained in both EnabledColumns and DisabledColumns", k1)
}
}
}
for _, k := range config.Enabled {
if column, ok := schema.LookupColumnByKey(k); ok {
column.Disabled = false
@@ -45,6 +38,23 @@ func New(config Configuration) (*Component, error) {
column.Disabled = true
}
}
for _, k := range config.NotMainTableOnly {
if column, ok := schema.LookupColumnByKey(k); ok {
column.ClickHouseMainOnly = false
}
}
for _, k := range config.MainTableOnly {
if column, ok := schema.LookupColumnByKey(k); ok {
if column.NoDisable {
return nil, fmt.Errorf("column %q cannot be present on main table only", k)
}
if slices.Contains(schema.clickHousePrimaryKeys, k) {
// Primary keys are part of the sorting key.
return nil, fmt.Errorf("column %q cannot be present on main table only (primary key)", k)
}
column.ClickHouseMainOnly = true
}
}
return &Component{
c: config,
Schema: schema.finalize(),