Skip to content

Commit

Permalink
Using UseCommonTableForWildcardproperty for wildcard config (#917)
Browse files Browse the repository at this point in the history
This is PR to handle queries where following configuration is used (no
explicit index configuration)

```
'*':
  useCommonTable: true
  target: [ my-clickhouse-data-source ]
```
  • Loading branch information
pdelewski authored Oct 24, 2024
1 parent 77ac9ec commit 0461d8e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions quesma/quesma/schema_transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

type SchemaCheckPass struct {
cfg map[string]config.IndexConfiguration
cfg *config.QuesmaConfiguration
}

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

var useCommonTable bool
if len(query.Indexes) == 1 {
if indexConf, ok := s.cfg[query.Indexes[0]]; ok {
if indexConf, ok := s.cfg.IndexConfig[query.Indexes[0]]; ok {
useCommonTable = indexConf.UseCommonTable
} else if s.cfg.UseCommonTableForWildcard {
useCommonTable = true
}
} else { // we can handle querying multiple indexes from common table only
useCommonTable = true
Expand Down
10 changes: 5 additions & 5 deletions quesma/quesma/schema_transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func Test_ipRangeTransform(t *testing.T) {
TableName: "kibana_sample_data_logs_nested", FieldName: "nested.clientip"}: "nested_clientip",
}
s := schema.NewSchemaRegistry(tableDiscovery, &cfg, clickhouse.SchemaTypeAdapter{})
transform := &SchemaCheckPass{cfg: indexConfig}
transform := &SchemaCheckPass{cfg: &cfg}
s.UpdateFieldEncodings(fieldEncodings)

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

transform := &SchemaCheckPass{cfg: indexConfig}
transform := &SchemaCheckPass{cfg: &config.QuesmaConfiguration{IndexConfig: indexConfig}}

tests := []struct {
name string
Expand Down Expand Up @@ -607,7 +607,7 @@ func TestApplyWildCard(t *testing.T) {
},
}

transform := &SchemaCheckPass{cfg: indexConfig}
transform := &SchemaCheckPass{cfg: &config.QuesmaConfiguration{IndexConfig: indexConfig}}

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

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

tests := []struct {
name string
Expand Down Expand Up @@ -958,7 +958,7 @@ func TestFullTextFields(t *testing.T) {
}

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

indexSchema, ok := s.FindSchema("test")
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion quesma/quesma/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func NewQueryRunner(lm *clickhouse.LogManager,
AsyncQueriesContexts: async_search_storage.NewAsyncQueryContextStorageInMemory(),
transformationPipeline: TransformationPipeline{
transformers: []model.QueryTransformer{
&SchemaCheckPass{cfg: cfg.IndexConfig},
&SchemaCheckPass{cfg: cfg},
},
},
schemaRegistry: schemaRegistry,
Expand Down

0 comments on commit 0461d8e

Please sign in to comment.