Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit c5d5ebf

Browse files
authored
Adding override as target property (#952)
1 parent e796220 commit c5d5ebf

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

quesma/quesma/config/config_v2.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,10 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
598598
if val, exists := target.properties["useCommonTable"]; exists {
599599
processedConfig.UseCommonTable = val == "true"
600600
}
601+
if val, exists := target.properties["tableName"]; exists {
602+
processedConfig.Override = val.(string)
603+
}
604+
601605
}
602606
if len(processedConfig.QueryTarget) == 2 && !((processedConfig.QueryTarget[0] == ClickhouseTarget && processedConfig.QueryTarget[1] == ElasticsearchTarget) ||
603607
(processedConfig.QueryTarget[0] == ElasticsearchTarget && processedConfig.QueryTarget[1] == ClickhouseTarget)) {
@@ -718,6 +722,9 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
718722
if val, exists := target.properties["useCommonTable"]; exists {
719723
processedConfig.UseCommonTable = val == true
720724
}
725+
if val, exists := target.properties["tableName"]; exists {
726+
processedConfig.Override = val.(string)
727+
}
721728
}
722729
if len(processedConfig.QueryTarget) == 2 && !((processedConfig.QueryTarget[0] == ClickhouseTarget && processedConfig.QueryTarget[1] == ElasticsearchTarget) ||
723730
(processedConfig.QueryTarget[0] == ElasticsearchTarget && processedConfig.QueryTarget[1] == ClickhouseTarget)) {
@@ -764,6 +771,9 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
764771
if val, exists := target.properties["useCommonTable"]; exists {
765772
processedConfig.UseCommonTable = val == true
766773
}
774+
if val, exists := target.properties["tableName"]; exists {
775+
processedConfig.Override = val.(string)
776+
}
767777
}
768778
conf.IndexConfig[indexName] = processedConfig
769779
}

quesma/quesma/config/config_v2_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,11 @@ func TestTargetNewVariant(t *testing.T) {
238238
}
239239
legacyConf := cfg.TranslateToLegacyConfig()
240240
assert.False(t, legacyConf.TransparentProxy)
241-
assert.Equal(t, 3, len(legacyConf.IndexConfig))
241+
assert.Equal(t, 4, len(legacyConf.IndexConfig))
242242
ecommerce := legacyConf.IndexConfig["kibana_sample_data_ecommerce"]
243243
flights := legacyConf.IndexConfig["kibana_sample_data_flights"]
244244
logs := legacyConf.IndexConfig["kibana_sample_data_logs"]
245+
override := legacyConf.IndexConfig["test_override"]
245246

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

256+
assert.Equal(t, []string{ClickhouseTarget}, override.QueryTarget)
257+
assert.Equal(t, []string{ClickhouseTarget}, override.IngestTarget)
258+
255259
assert.Equal(t, false, flights.UseCommonTable)
260+
assert.Equal(t, "", flights.Override)
256261
assert.Equal(t, false, ecommerce.UseCommonTable)
262+
assert.Equal(t, "", ecommerce.Override)
257263
assert.Equal(t, true, logs.UseCommonTable)
264+
assert.Equal(t, "", logs.Override)
258265
assert.Equal(t, true, legacyConf.EnableIngest)
266+
267+
const expectedOverride = "new_override"
268+
assert.Equal(t, expectedOverride, override.Override)
259269
}

quesma/quesma/config/index_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const (
1616
type IndexConfiguration struct {
1717
SchemaOverrides *SchemaConfiguration `koanf:"schemaOverrides"`
1818
Optimizers map[string]OptimizerConfiguration `koanf:"optimizers"`
19-
Override string `koanf:"override"`
19+
Override string `koanf:"tableName"`
2020
UseCommonTable bool `koanf:"useCommonTable"`
2121
Target any `koanf:"target"`
2222

quesma/quesma/config/test_configs/target_new_variant.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ processors:
4040
target:
4141
- my-clickhouse-data-source:
4242
useCommonTable: true
43+
"test_override":
44+
target:
45+
- my-clickhouse-data-source:
46+
tableName: "new_override"
4347
"*":
4448
target: [ my-minimal-elasticsearch ]
4549

@@ -58,6 +62,10 @@ processors:
5862
target:
5963
- my-clickhouse-data-source:
6064
useCommonTable: true
65+
"test_override":
66+
target:
67+
- my-clickhouse-data-source:
68+
tableName: "new_override"
6169
"*":
6270
target: [ my-minimal-elasticsearch ]
6371
pipelines:

0 commit comments

Comments
 (0)