@@ -57,6 +57,8 @@ func TestTableResolver(t *testing.T) {
5757
5858 cfg := config.QuesmaConfiguration {IndexConfig : indexConf , DefaultQueryTarget : []string {config .ElasticsearchTarget }, DefaultIngestTarget : []string {config .ElasticsearchTarget }}
5959
60+ cfgClickhouseOnlyUseCommonTable := config.QuesmaConfiguration {IndexConfig : indexConf , DefaultQueryTarget : []string {config .ClickhouseTarget }, DefaultIngestTarget : []string {config .ClickhouseTarget }, UseCommonTableForWildcard : true }
61+
6062 tests := []struct {
6163 name string
6264 pipeline string
@@ -66,6 +68,7 @@ func TestTableResolver(t *testing.T) {
6668 virtualTables []string
6769 indexConf map [string ]config.IndexConfiguration
6870 expected mux.Decision
71+ quesmaConf * config.QuesmaConfiguration
6972 }{
7073 {
7174 name : "elastic fallback" ,
@@ -266,6 +269,21 @@ func TestTableResolver(t *testing.T) {
266269 },
267270 indexConf : indexConf ,
268271 },
272+ {
273+ name : "query pattern (not existing virtual table)" ,
274+ pipeline : mux .QueryPipeline ,
275+ pattern : "common-index1,common-index2" ,
276+ virtualTables : []string {"common-index1" },
277+ expected : mux.Decision {
278+ UseConnectors : []mux.ConnectorDecision {& mux.ConnectorDecisionClickhouse {
279+ ClickhouseTableName : common_table .TableName ,
280+ ClickhouseIndexes : []string {"common-index1" , "common-index2" },
281+ IsCommonTable : true ,
282+ }},
283+ },
284+ indexConf : indexConf ,
285+ quesmaConf : & cfgClickhouseOnlyUseCommonTable ,
286+ },
269287 {
270288 name : "query kibana internals" ,
271289 pipeline : mux .QueryPipeline ,
@@ -377,6 +395,12 @@ func TestTableResolver(t *testing.T) {
377395
378396 for _ , tt := range tests {
379397 t .Run (tt .name , func (t * testing.T ) {
398+
399+ currentQuesmaConf := cfg
400+ if tt .quesmaConf != nil {
401+ currentQuesmaConf = * tt .quesmaConf
402+ }
403+
380404 tableDiscovery := clickhouse .NewEmptyTableDiscovery ()
381405
382406 for _ , index := range tt .clickhouseIndexes {
@@ -394,7 +418,7 @@ func TestTableResolver(t *testing.T) {
394418
395419 elasticResolver := elasticsearch .NewFixedIndexManagement (tt .elasticIndexes ... )
396420
397- resolver := NewTableResolver (cfg , tableDiscovery , elasticResolver )
421+ resolver := NewTableResolver (currentQuesmaConf , tableDiscovery , elasticResolver )
398422
399423 decision := resolver .Resolve (tt .pipeline , tt .pattern )
400424
0 commit comments