Skip to content

Commit

Permalink
Adding override as target property (#952)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelewski authored Nov 6, 2024
1 parent e796220 commit c5d5ebf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
10 changes: 10 additions & 0 deletions quesma/quesma/config/config_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,10 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
if val, exists := target.properties["useCommonTable"]; exists {
processedConfig.UseCommonTable = val == "true"
}
if val, exists := target.properties["tableName"]; exists {
processedConfig.Override = val.(string)
}

}
if len(processedConfig.QueryTarget) == 2 && !((processedConfig.QueryTarget[0] == ClickhouseTarget && processedConfig.QueryTarget[1] == ElasticsearchTarget) ||
(processedConfig.QueryTarget[0] == ElasticsearchTarget && processedConfig.QueryTarget[1] == ClickhouseTarget)) {
Expand Down Expand Up @@ -718,6 +722,9 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
if val, exists := target.properties["useCommonTable"]; exists {
processedConfig.UseCommonTable = val == true
}
if val, exists := target.properties["tableName"]; exists {
processedConfig.Override = val.(string)
}
}
if len(processedConfig.QueryTarget) == 2 && !((processedConfig.QueryTarget[0] == ClickhouseTarget && processedConfig.QueryTarget[1] == ElasticsearchTarget) ||
(processedConfig.QueryTarget[0] == ElasticsearchTarget && processedConfig.QueryTarget[1] == ClickhouseTarget)) {
Expand Down Expand Up @@ -764,6 +771,9 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
if val, exists := target.properties["useCommonTable"]; exists {
processedConfig.UseCommonTable = val == true
}
if val, exists := target.properties["tableName"]; exists {
processedConfig.Override = val.(string)
}
}
conf.IndexConfig[indexName] = processedConfig
}
Expand Down
12 changes: 11 additions & 1 deletion quesma/quesma/config/config_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,11 @@ func TestTargetNewVariant(t *testing.T) {
}
legacyConf := cfg.TranslateToLegacyConfig()
assert.False(t, legacyConf.TransparentProxy)
assert.Equal(t, 3, len(legacyConf.IndexConfig))
assert.Equal(t, 4, len(legacyConf.IndexConfig))
ecommerce := legacyConf.IndexConfig["kibana_sample_data_ecommerce"]
flights := legacyConf.IndexConfig["kibana_sample_data_flights"]
logs := legacyConf.IndexConfig["kibana_sample_data_logs"]
override := legacyConf.IndexConfig["test_override"]

assert.Equal(t, []string{ClickhouseTarget}, ecommerce.QueryTarget)
assert.Equal(t, []string{ClickhouseTarget}, ecommerce.IngestTarget)
Expand All @@ -252,8 +253,17 @@ func TestTargetNewVariant(t *testing.T) {
assert.Equal(t, []string{ClickhouseTarget}, logs.QueryTarget)
assert.Equal(t, []string{ClickhouseTarget}, logs.IngestTarget)

assert.Equal(t, []string{ClickhouseTarget}, override.QueryTarget)
assert.Equal(t, []string{ClickhouseTarget}, override.IngestTarget)

assert.Equal(t, false, flights.UseCommonTable)
assert.Equal(t, "", flights.Override)
assert.Equal(t, false, ecommerce.UseCommonTable)
assert.Equal(t, "", ecommerce.Override)
assert.Equal(t, true, logs.UseCommonTable)
assert.Equal(t, "", logs.Override)
assert.Equal(t, true, legacyConf.EnableIngest)

const expectedOverride = "new_override"
assert.Equal(t, expectedOverride, override.Override)
}
2 changes: 1 addition & 1 deletion quesma/quesma/config/index_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
type IndexConfiguration struct {
SchemaOverrides *SchemaConfiguration `koanf:"schemaOverrides"`
Optimizers map[string]OptimizerConfiguration `koanf:"optimizers"`
Override string `koanf:"override"`
Override string `koanf:"tableName"`
UseCommonTable bool `koanf:"useCommonTable"`
Target any `koanf:"target"`

Expand Down
8 changes: 8 additions & 0 deletions quesma/quesma/config/test_configs/target_new_variant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ processors:
target:
- my-clickhouse-data-source:
useCommonTable: true
"test_override":
target:
- my-clickhouse-data-source:
tableName: "new_override"
"*":
target: [ my-minimal-elasticsearch ]

Expand All @@ -58,6 +62,10 @@ processors:
target:
- my-clickhouse-data-source:
useCommonTable: true
"test_override":
target:
- my-clickhouse-data-source:
tableName: "new_override"
"*":
target: [ my-minimal-elasticsearch ]
pipelines:
Expand Down

0 comments on commit c5d5ebf

Please sign in to comment.