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

Commit 0461d8e

Browse files
authored
Using UseCommonTableForWildcardproperty for wildcard config (#917)
This is PR to handle queries where following configuration is used (no explicit index configuration) ``` '*': useCommonTable: true target: [ my-clickhouse-data-source ] ```
1 parent 77ac9ec commit 0461d8e

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

quesma/quesma/schema_transformer.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
type SchemaCheckPass struct {
19-
cfg map[string]config.IndexConfiguration
19+
cfg *config.QuesmaConfiguration
2020
}
2121

2222
func (s *SchemaCheckPass) applyBooleanLiteralLowering(index schema.Schema, query *model.Query) (*model.Query, error) {
@@ -354,8 +354,10 @@ func (s *SchemaCheckPass) applyPhysicalFromExpression(currentSchema schema.Schem
354354

355355
var useCommonTable bool
356356
if len(query.Indexes) == 1 {
357-
if indexConf, ok := s.cfg[query.Indexes[0]]; ok {
357+
if indexConf, ok := s.cfg.IndexConfig[query.Indexes[0]]; ok {
358358
useCommonTable = indexConf.UseCommonTable
359+
} else if s.cfg.UseCommonTableForWildcard {
360+
useCommonTable = true
359361
}
360362
} else { // we can handle querying multiple indexes from common table only
361363
useCommonTable = true

quesma/quesma/schema_transformer_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func Test_ipRangeTransform(t *testing.T) {
8181
TableName: "kibana_sample_data_logs_nested", FieldName: "nested.clientip"}: "nested_clientip",
8282
}
8383
s := schema.NewSchemaRegistry(tableDiscovery, &cfg, clickhouse.SchemaTypeAdapter{})
84-
transform := &SchemaCheckPass{cfg: indexConfig}
84+
transform := &SchemaCheckPass{cfg: &cfg}
8585
s.UpdateFieldEncodings(fieldEncodings)
8686

8787
selectColumns := []model.Expr{model.NewColumnRef("message")}
@@ -430,7 +430,7 @@ func Test_arrayType(t *testing.T) {
430430
Fields: fields,
431431
}
432432

433-
transform := &SchemaCheckPass{cfg: indexConfig}
433+
transform := &SchemaCheckPass{cfg: &config.QuesmaConfiguration{IndexConfig: indexConfig}}
434434

435435
tests := []struct {
436436
name string
@@ -607,7 +607,7 @@ func TestApplyWildCard(t *testing.T) {
607607
},
608608
}
609609

610-
transform := &SchemaCheckPass{cfg: indexConfig}
610+
transform := &SchemaCheckPass{cfg: &config.QuesmaConfiguration{IndexConfig: indexConfig}}
611611

612612
tests := []struct {
613613
name string
@@ -697,7 +697,7 @@ func TestApplyPhysicalFromExpression(t *testing.T) {
697697
td.Store(tableDefinition.Name, &tableDefinition)
698698

699699
s := schema.NewSchemaRegistry(tableDiscovery, &cfg, clickhouse.SchemaTypeAdapter{})
700-
transform := &SchemaCheckPass{cfg: indexConfig}
700+
transform := &SchemaCheckPass{cfg: &config.QuesmaConfiguration{IndexConfig: indexConfig}}
701701

702702
tests := []struct {
703703
name string
@@ -958,7 +958,7 @@ func TestFullTextFields(t *testing.T) {
958958
}
959959

960960
s := schema.NewSchemaRegistry(tableDiscovery, &cfg, clickhouse.SchemaTypeAdapter{})
961-
transform := &SchemaCheckPass{cfg: indexConfig}
961+
transform := &SchemaCheckPass{cfg: &config.QuesmaConfiguration{IndexConfig: indexConfig}}
962962

963963
indexSchema, ok := s.FindSchema("test")
964964
if !ok {

quesma/quesma/search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func NewQueryRunner(lm *clickhouse.LogManager,
8181
AsyncQueriesContexts: async_search_storage.NewAsyncQueryContextStorageInMemory(),
8282
transformationPipeline: TransformationPipeline{
8383
transformers: []model.QueryTransformer{
84-
&SchemaCheckPass{cfg: cfg.IndexConfig},
84+
&SchemaCheckPass{cfg: cfg},
8585
},
8686
},
8787
schemaRegistry: schemaRegistry,

0 commit comments

Comments
 (0)