You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 7, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: quesma/model/query.go
+72-48Lines changed: 72 additions & 48 deletions
Original file line number
Diff line number
Diff line change
@@ -8,10 +8,55 @@ import (
8
8
"strings"
9
9
)
10
10
11
-
constRowNumberColumnName="row_number"
12
-
constEmptyFieldSelection="''"// we can query SELECT '', that's why such quotes
11
+
const (
12
+
RowNumberColumnName="row_number"
13
+
EmptyFieldSelection="''"// we can query SELECT '', that's why such quotes
14
+
)
13
15
14
16
type (
17
+
Querystruct {
18
+
IsDistinctbool// true <=> query is SELECT DISTINCT
19
+
Fields []string// Fields in 'SELECT Fields FROM ...'
20
+
NonSchemaFields []string// Fields that are not in schema, but are in 'SELECT ...', e.g. count()
21
+
WhereClausestring// "WHERE ..." until next clause like GROUP BY/ORDER BY, etc.
22
+
GroupByFields []string// if not empty, we do GROUP BY GroupByFields... They are quoted if they are column names, unquoted if non-schema. So no quotes need to be added.
23
+
SuffixClauses []string// ORDER BY, etc.
24
+
FromClausestring// usually just "tableName", or databaseName."tableName". Sometimes a subquery e.g. (SELECT ...)
25
+
CanParsebool// true <=> query is valid
26
+
QueryInfoSearchQueryInfo
27
+
HighlighterHighlighter
28
+
NoDBQuerybool// true <=> we don't need query to DB here, true in some pipeline aggregations
29
+
Parentstring// parent aggregation name, used in some pipeline aggregations
30
+
Aggregators []Aggregator// keeps names of aggregators, e.g. "0", "1", "2", "suggestions". Needed for JSON response.
31
+
TypeQueryType
32
+
SortFieldsSortFields// fields to sort by
33
+
SubSelectstring
34
+
// dictionary to add as 'meta' field in the response.
35
+
// WARNING: it's probably not passed everywhere where it's needed, just in one place.
36
+
// But it works for the test + our dashboards, so let's fix it later if necessary.
37
+
// NoMetadataField (nil) is a valid option and means no meta field in the response.
38
+
MetadataJsonMap
39
+
}
40
+
QueryTypeinterface {
41
+
// TranslateSqlResponseToJson 'level' - we want to translate [level:] (metrics aggr) or [level-1:] (bucket aggr) columns to JSON
42
+
// Previous columns are used for bucketing.
43
+
// For 'bucket' aggregation result is a slice of buckets, for 'metrics' aggregation it's a single bucket (only look at [0])
// implements String() (now) and MakeResponse() interface (in the future (?))
39
-
typeQuerystruct {
40
-
IsDistinctbool// true <=> query is SELECT DISTINCT
41
-
Fields []string// Fields in 'SELECT Fields FROM ...'
42
-
NonSchemaFields []string// Fields that are not in schema, but are in 'SELECT ...', e.g. count()
43
-
WhereClausestring// "WHERE ..." until next clause like GROUP BY/ORDER BY, etc.
44
-
GroupByFields []string// if not empty, we do GROUP BY GroupByFields... They are quoted if they are column names, unquoted if non-schema. So no quotes need to be added.
45
-
SuffixClauses []string// ORDER BY, etc.
46
-
FromClausestring// usually just "tableName", or databaseName."tableName". Sometimes a subquery e.g. (SELECT ...)
47
-
CanParsebool// true <=> query is valid
48
-
QueryInfoSearchQueryInfo
49
-
HighlighterHighlighter
50
-
NoDBQuerybool// true <=> we don't need query to DB here, true in some pipeline aggregations
51
-
Parentstring// parent aggregation name, used in some pipeline aggregations
52
-
Aggregators []Aggregator// keeps names of aggregators, e.g. "0", "1", "2", "suggestions". Needed for JSON response.
53
-
TypeQueryType
54
-
SortFieldsSortFields// fields to sort by
55
-
SubSelectstring
56
-
// dictionary to add as 'meta' field in the response.
57
-
// WARNING: it's probably not passed everywhere where it's needed, just in one place.
58
-
// But it works for the test + our dashboards, so let's fix it later if necessary.
59
-
// NoMetadataField (nil) is a valid option and means no meta field in the response.
60
-
MetadataJsonMap
61
-
}
62
-
63
-
/*
64
-
type subQuery struct {
65
-
sql string
66
-
innerJoin string
67
-
name string
68
-
}
69
-
70
-
func newSubQuery(sql, innerJoin, name string) subQuery {
0 commit comments