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

Commit 86050ac

Browse files
authored
UseCommonTable global per processor (#962)
This PR moves global `useCommonTable` to processor level (under config) instead of fully global : ``` processors: - name: my-query-processor type: quesma-v1-processor-query config: useCommonTable: true ```
1 parent 410069d commit 86050ac

File tree

4 files changed

+39
-12
lines changed

4 files changed

+39
-12
lines changed

ci/it/configs/quesma-with-dual-writes-and-common-table.yml.template

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ processors:
3333
logs-dual-query:
3434
target: [ c, e ]
3535
logs-4:
36-
useCommonTable: true
37-
target: [ c ]
36+
target:
37+
- c:
38+
useCommonTable: true
3839
logs-5:
39-
useCommonTable: true
40-
target: [ c ]
40+
target:
41+
- c:
42+
useCommonTable: true
4143
"*":
4244
target: [ e ]
4345
- name: IP
@@ -53,13 +55,13 @@ processors:
5355
logs-dual-query:
5456
target: [ c, e ]
5557
logs-4:
56-
useCommonTable: true
57-
target: [ c ]
58+
target:
59+
- c:
60+
useCommonTable: true
61+
logs-5:
62+
target:
5863
"*":
5964
target: [ e ]
60-
logs-5:
61-
useCommonTable: true
62-
target: [ ]
6365

6466
pipelines:
6567
- name: my-elasticsearch-proxy-read

quesma/quesma/config/config_v2.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ const DefaultWildcardIndexName = "*"
112112

113113
// Configuration of QuesmaV1ProcessorQuery and QuesmaV1ProcessorIngest
114114
type QuesmaProcessorConfig struct {
115-
IndexConfig map[string]IndexConfiguration `koanf:"indexes"`
115+
UseCommonTable bool `koanf:"useCommonTable"`
116+
IndexConfig map[string]IndexConfiguration `koanf:"indexes"`
116117
}
117118

118119
func LoadV2Config() QuesmaNewConfiguration {
@@ -296,6 +297,9 @@ func (c *QuesmaNewConfiguration) validatePipelines() error {
296297
queryProcessor.Type != QuesmaV1ProcessorNoOp {
297298
return fmt.Errorf("query pipeline must have query or noop processor")
298299
}
300+
if queryProcessor.Config.UseCommonTable != ingestProcessor.Config.UseCommonTable {
301+
return fmt.Errorf("query and ingest processors must have the same configuration of 'useCommonTable'")
302+
}
299303
if !(queryProcessor.Type == QuesmaV1ProcessorNoOp) {
300304
if _, found := queryProcessor.Config.IndexConfig[DefaultWildcardIndexName]; !found {
301305
return fmt.Errorf("the default index configuration (under the name '%s') must be defined in the query processor", DefaultWildcardIndexName)
@@ -565,6 +569,10 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
565569
if val, exists := target.properties["useCommonTable"]; exists {
566570
conf.CreateCommonTable = val == "true"
567571
conf.UseCommonTableForWildcard = val == "true"
572+
} else {
573+
// inherit setting from the processor level
574+
conf.CreateCommonTable = queryProcessor.Config.UseCommonTable
575+
conf.UseCommonTableForWildcard = queryProcessor.Config.UseCommonTable
568576
}
569577
}
570578

@@ -600,6 +608,9 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
600608
}
601609
if val, exists := target.properties["useCommonTable"]; exists {
602610
processedConfig.UseCommonTable = val == "true"
611+
} else {
612+
// inherit setting from the processor level
613+
processedConfig.UseCommonTable = queryProcessor.Config.UseCommonTable
603614
}
604615
if val, exists := target.properties["tableName"]; exists {
605616
processedConfig.Override = val.(string)
@@ -660,6 +671,10 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
660671
if val, exists := target.properties["useCommonTable"]; exists {
661672
conf.CreateCommonTable = val == "true"
662673
conf.UseCommonTableForWildcard = val == "true"
674+
} else {
675+
// inherit setting from the processor level
676+
conf.CreateCommonTable = queryProcessor.Config.UseCommonTable
677+
conf.UseCommonTableForWildcard = queryProcessor.Config.UseCommonTable
663678
}
664679
}
665680
if defaultConfig.SchemaOverrides != nil {
@@ -686,6 +701,10 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
686701
if val, exists := target.properties["useCommonTable"]; exists {
687702
conf.CreateCommonTable = val == "true"
688703
conf.UseCommonTableForWildcard = val == "true"
704+
} else {
705+
// inherit setting from the processor level
706+
conf.CreateCommonTable = ingestProcessor.Config.UseCommonTable
707+
conf.UseCommonTableForWildcard = ingestProcessor.Config.UseCommonTable
689708
}
690709
}
691710
if ingestProcessorDefaultIndexConfig.SchemaOverrides != nil {
@@ -730,6 +749,9 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
730749
}
731750
if val, exists := target.properties["useCommonTable"]; exists {
732751
processedConfig.UseCommonTable = val == true
752+
} else {
753+
// inherit setting from the processor level
754+
processedConfig.UseCommonTable = queryProcessor.Config.UseCommonTable
733755
}
734756
if val, exists := target.properties["tableName"]; exists {
735757
processedConfig.Override = val.(string)
@@ -779,6 +801,9 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
779801
}
780802
if val, exists := target.properties["useCommonTable"]; exists {
781803
processedConfig.UseCommonTable = val == true
804+
} else {
805+
// inherit setting from the processor level
806+
processedConfig.UseCommonTable = ingestProcessor.Config.UseCommonTable
782807
}
783808
if val, exists := target.properties["tableName"]; exists {
784809
processedConfig.Override = val.(string)

quesma/quesma/config/config_v2_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ func TestTargetNewVariant(t *testing.T) {
269269
}
270270

271271
func TestUseCommonTableGlobalProperty(t *testing.T) {
272-
t.Skip()
273272
os.Setenv(configFileLocationEnvVar, "./test_configs/use_common_table_global_property.yaml")
274273
cfg := LoadV2Config()
275274
if err := cfg.Validate(); err != nil {

quesma/quesma/config/test_configs/use_common_table_global_property.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# TEST CONFIGURATION
22
licenseKey: "cdd749a3-e777-11ee-bcf8-0242ac150004"
3-
useCommonTable: true
43
frontendConnectors:
54
- name: elastic-ingest
65
type: elasticsearch-fe-ingest
@@ -29,6 +28,7 @@ processors:
2928
- name: my-query-processor
3029
type: quesma-v1-processor-query
3130
config:
31+
useCommonTable: true
3232
indexes:
3333
kibana_sample_data_ecommerce:
3434
target:
@@ -43,6 +43,7 @@ processors:
4343
- name: my-ingest-processor
4444
type: quesma-v1-processor-ingest
4545
config:
46+
useCommonTable: true
4647
indexes:
4748
kibana_sample_data_ecommerce:
4849
target:

0 commit comments

Comments
 (0)