diff --git a/platform/frontend_connectors/search_test.go b/platform/frontend_connectors/search_test.go index fcedb4d34..d5b39cbed 100644 --- a/platform/frontend_connectors/search_test.go +++ b/platform/frontend_connectors/search_test.go @@ -272,7 +272,7 @@ func TestSearchHandler(t *testing.T) { "user.id": {PropertyName: "user.id", InternalPropertyName: "user_id", Type: schema.QuesmaTypeKeyword}, "tags": {PropertyName: "tags", InternalPropertyName: "tags", Type: schema.QuesmaTypeKeyword}, "age": {PropertyName: "age", InternalPropertyName: "age", Type: schema.QuesmaTypeInteger}, - "host.name": {PropertyName: "host.name", InternalPropertyName: "host_name", Type: schema.QuesmaTypeObject}, + "host.name": {PropertyName: "host.name", InternalPropertyName: "host_name", Type: schema.QuesmaTypeKeyword}, "status": {PropertyName: "status", InternalPropertyName: "status", Type: schema.QuesmaTypeKeyword}, "namespace": {PropertyName: "namespace", InternalPropertyName: "namespace", Type: schema.QuesmaTypeKeyword}, "namespaces": {PropertyName: "namespaces", InternalPropertyName: "namespaces", Type: schema.QuesmaTypeKeyword}, diff --git a/platform/frontend_connectors/search_util.go b/platform/frontend_connectors/search_util.go index b09894675..ae0657b3b 100644 --- a/platform/frontend_connectors/search_util.go +++ b/platform/frontend_connectors/search_util.go @@ -110,7 +110,27 @@ func (q *QueryRunner) resolveIndexesNonCommonTable(ctx context.Context, clickhou return } - currentSchema = resolvedSchema + // Clone the resolved schema to currentSchema + // + // Schema can be modified during the query execution, we don't want to modify the original schema, and we don't need any concurrency issues here. + // + // resolveIndexesCommonTable also returns an ephemeral schema + + currentSchema = schema.Schema{ + Fields: make(map[schema.FieldName]schema.Field), + Aliases: make(map[schema.FieldName]schema.FieldName), + ExistsInDataSource: resolvedSchema.ExistsInDataSource, + DatabaseName: resolvedSchema.DatabaseName, + } + + for fieldName, field := range resolvedSchema.Fields { + currentSchema.Fields[fieldName] = field + } + + for aliasName, targetFieldName := range resolvedSchema.Aliases { + currentSchema.Aliases[aliasName] = targetFieldName + } + return }