From 931ba4881fa5fca43a73491dd9e2cbbf101f83b7 Mon Sep 17 00:00:00 2001 From: Przemek Delewski Date: Tue, 21 Jan 2025 13:11:52 +0100 Subject: [PATCH 1/2] Moving query content --- quesma/processors/base_processor.go | 2 +- .../query_transformation_pipeline.go | 30 ++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/quesma/processors/base_processor.go b/quesma/processors/base_processor.go index fe52df9c3..9aceebc16 100644 --- a/quesma/processors/base_processor.go +++ b/quesma/processors/base_processor.go @@ -69,7 +69,7 @@ func (p *BaseProcessor) Handle(metadata map[string]interface{}, messages ...any) // Execute the queries var results [][]QueryResultRow for _, query := range queries { - result, _ := p.executeQuery(query.Query) + result, _ := p.executeQuery(query.SelectCommand.String()) results = append(results, result) } // Transform the results diff --git a/quesma/processors/query_transformation_pipeline.go b/quesma/processors/query_transformation_pipeline.go index 14601ea48..306a967a4 100644 --- a/quesma/processors/query_transformation_pipeline.go +++ b/quesma/processors/query_transformation_pipeline.go @@ -3,11 +3,39 @@ package processors +import ( + "github.com/QuesmaOrg/quesma/quesma/model" + "github.com/QuesmaOrg/quesma/quesma/schema" +) + // Query This is placeholder // Concrete definition will be taken // from `quesma/model/query.go` type Query struct { - Query string + Query string + SelectCommand model.SelectCommand // The representation of SELECT query + + OptimizeHints *model.QueryOptimizeHints // it can be optional + TransformationHistory model.TransformationHistory // it can be optional + + Type model.QueryType + TableName string // TODO delete this and use Indexes instead + + Indexes []string // list of indexes we're going to use for this query + + // this is schema for current query, this schema should be used in pipeline processing + Schema schema.Schema + + Highlighter model.Highlighter + SearchAfter any // Value of query's "search_after" param. Used for pagination of hits. SearchAfterEmpty means no pagination + + RuntimeMappings map[string]model.RuntimeMapping + + // dictionary to add as 'meta' field in the response. + // WARNING: it's probably not passed everywhere where it's needed, just in one place. + // But it works for the test + our dashboards, so let's fix it later if necessary. + // NoMetadataField (nil) is a valid option and means no meta field in the response. + Metadata model.JsonMap } // ExecutionPlan This is placeholder From ee9a62e193bc9c20e4abb16ad930a10b137394c7 Mon Sep 17 00:00:00 2001 From: Przemek Delewski Date: Tue, 21 Jan 2025 13:33:51 +0100 Subject: [PATCH 2/2] Update ExecutionPlan --- quesma/processors/query_transformation_pipeline.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/quesma/processors/query_transformation_pipeline.go b/quesma/processors/query_transformation_pipeline.go index 306a967a4..6bd83729a 100644 --- a/quesma/processors/query_transformation_pipeline.go +++ b/quesma/processors/query_transformation_pipeline.go @@ -6,6 +6,7 @@ package processors import ( "github.com/QuesmaOrg/quesma/quesma/model" "github.com/QuesmaOrg/quesma/quesma/schema" + "time" ) // Query This is placeholder @@ -42,7 +43,17 @@ type Query struct { // Concrete definition will be taken // from `quesma/model/query.go` type ExecutionPlan struct { + Name string + + IndexPattern string + Queries []*Query + + QueryRowsTransformers []model.QueryRowsTransformer + + // add more fields here + // JSON renderers + StartTime time.Time } // QueryResultTransformer This is a copy of the