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

Commit 1bdac85

Browse files
authored
Use common table for '*' wildcard (#915)
This PR is about `usingCommonTable` configuration property for `*` wildcard: ``` '*': useCommonTable: true target: [ my-clickhouse-data-source ] ```
1 parent 87c168d commit 1bdac85

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

quesma/quesma/config/config.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ type QuesmaConfiguration struct {
4444
DisableAuth bool
4545
AutodiscoveryEnabled bool
4646

47-
EnableIngest bool // this is computed from the configuration 2.0
48-
CreateCommonTable bool
49-
50-
DefaultIngestTarget []string
51-
DefaultQueryTarget []string
47+
EnableIngest bool // this is computed from the configuration 2.0
48+
CreateCommonTable bool
49+
UseCommonTableForWildcard bool //the meaning of this is to use a common table for wildcard (default) indexes
50+
DefaultIngestTarget []string
51+
DefaultQueryTarget []string
5252
}
5353

5454
func (c *QuesmaConfiguration) AliasFields(indexName string) map[string]string {

quesma/quesma/config/config_v2.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,12 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
552552
errAcc = multierror.Append(errAcc, fmt.Errorf("invalid target %s in configuration of %s", target, DefaultWildcardIndexName))
553553
}
554554
}
555+
if defaultConfig.UseCommonTable {
556+
// We set both flags to true here
557+
// as creating common table depends on the first one
558+
conf.CreateCommonTable = true
559+
conf.UseCommonTableForWildcard = true
560+
}
555561
if len(defaultConfig.QueryTarget) > 1 {
556562
errAcc = multierror.Append(errAcc, fmt.Errorf("the target configuration of default index ('%s') of query processor is not currently supported", DefaultWildcardIndexName))
557563
}
@@ -619,16 +625,36 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
619625
errAcc = multierror.Append(errAcc, fmt.Errorf("invalid target %s in configuration of %s", target, DefaultWildcardIndexName))
620626
}
621627
}
628+
if defaultConfig.UseCommonTable {
629+
// We set both flags to true here
630+
// as creating common table depends on the first one
631+
conf.CreateCommonTable = true
632+
conf.UseCommonTableForWildcard = true
633+
}
634+
635+
ingestProcessorDefaultIndexConfig := ingestProcessor.Config.IndexConfig[DefaultWildcardIndexName]
622636
for _, target := range ingestProcessor.Config.IndexConfig[DefaultWildcardIndexName].Target {
623637
if targetType, found := c.getTargetType(target); found {
624638
defaultConfig.IngestTarget = append(defaultConfig.IngestTarget, targetType)
625639
} else {
626640
errAcc = multierror.Append(errAcc, fmt.Errorf("invalid target %s in configuration of %s", target, DefaultWildcardIndexName))
627641
}
628642
}
643+
if ingestProcessorDefaultIndexConfig.UseCommonTable {
644+
// We set both flags to true here
645+
// as creating common table depends on the first one
646+
conf.CreateCommonTable = true
647+
conf.UseCommonTableForWildcard = true
648+
}
649+
629650
if len(defaultConfig.QueryTarget) > 1 {
630651
errAcc = multierror.Append(errAcc, fmt.Errorf("the target configuration of default index ('%s') of query processor is not currently supported", DefaultWildcardIndexName))
631652
}
653+
654+
if defaultConfig.UseCommonTable != ingestProcessorDefaultIndexConfig.UseCommonTable {
655+
errAcc = multierror.Append(errAcc, fmt.Errorf("the target configuration of default index ('%s') of query processor and ingest processor should consistently use quesma common table property", DefaultWildcardIndexName))
656+
}
657+
632658
// No restrictions for ingest target!
633659
conf.DefaultIngestTarget = defaultConfig.IngestTarget
634660
conf.DefaultQueryTarget = defaultConfig.QueryTarget

quesma/table_resolver/rules.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func makeDefaultWildcard(quesmaConf config.QuesmaConfiguration, pipeline string)
7979
case config.ClickhouseTarget:
8080
useConnectors = append(useConnectors, &ConnectorDecisionClickhouse{
8181
ClickhouseTableName: input.source,
82+
IsCommonTable: quesmaConf.UseCommonTableForWildcard,
8283
ClickhouseTables: []string{input.source},
8384
})
8485
case config.ElasticsearchTarget:

0 commit comments

Comments
 (0)