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

Commit 14ae9a7

Browse files
nablaonemieciu
andauthored
Dont expose internal table/index (#1442)
Users should not be able to create a data view that matches the common table. Querying the common table causes an error. This PR filters out our internal common table and index that contains a list of virtual tables. --------- Signed-off-by: Rafał Strzaliński <[email protected]> Co-authored-by: Przemysław Hejman <[email protected]>
1 parent 094f3a6 commit 14ae9a7

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

platform/functionality/resolve/resolve.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package resolve
44

55
import (
6+
"github.com/QuesmaOrg/quesma/platform/common_table"
67
"github.com/QuesmaOrg/quesma/platform/config"
78
"github.com/QuesmaOrg/quesma/platform/elasticsearch"
89
"github.com/QuesmaOrg/quesma/platform/logger"
@@ -23,16 +24,26 @@ func HandleResolve(pattern string, sr schema.Registry, ir elasticsearch.IndexRes
2324
sourcesToShow = &sourcesFromElasticsearch
2425
}
2526

27+
var filtered []elasticsearch.Index
28+
for _, index := range sourcesToShow.Indices {
29+
if index.Name != common_table.VirtualTableElasticIndexName {
30+
// don't include the common table in the results
31+
// it's internal table used by Quesma, and should not be exposed as an index / data stream
32+
filtered = append(filtered, index)
33+
}
34+
}
35+
sourcesToShow.Indices = filtered
36+
2637
tablesFromClickHouse := getMatchingClickHouseTables(sr.AllSchemas(), normalizedPattern)
2738

2839
addClickHouseTablesToSourcesFromElastic(sourcesToShow, tablesFromClickHouse)
40+
2941
return *sourcesToShow, nil
3042
}
3143

3244
func getMatchingClickHouseTables(schemas map[schema.IndexName]schema.Schema, normalizedPattern string) (tables []string) {
3345
for name, currentSchema := range schemas {
3446
indexName := name.AsString()
35-
3647
if config.MatchName(normalizedPattern, indexName) && currentSchema.ExistsInDataSource {
3748
tables = append(tables, indexName)
3849
}
@@ -41,7 +52,15 @@ func getMatchingClickHouseTables(schemas map[schema.IndexName]schema.Schema, nor
4152
}
4253

4354
func addClickHouseTablesToSourcesFromElastic(sourcesFromElastic *elasticsearch.Sources, chTableNames []string) {
44-
for _, name := range chTableNames { // Quesma presents CH tables as Elasticsearch Data Streams.
55+
for _, name := range chTableNames {
56+
57+
if name == common_table.TableName {
58+
// don't include the common table in the results
59+
// it's internal table used by Quesma, and should not be exposed as an index / data stream
60+
continue
61+
}
62+
63+
// Quesma presents CH tables as Elasticsearch Data Streams.
4564
sourcesFromElastic.DataStreams = append(sourcesFromElastic.DataStreams, elasticsearch.DataStream{
4665
Name: name,
4766
BackingIndices: []string{name},

0 commit comments

Comments
 (0)