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

Commit 1f6d758

Browse files
authored
Remove dead code or tests that are utterly useless by now (#1110)
1 parent cb8fd7b commit 1f6d758

File tree

3 files changed

+0
-327
lines changed

3 files changed

+0
-327
lines changed

quesma/queryparser/query_parser.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -217,36 +217,6 @@ func (cw *ClickhouseQueryTranslator) ParseHighlighter(queryMap QueryMap) model.H
217217
return highlighter
218218
}
219219

220-
func (cw *ClickhouseQueryTranslator) ParseQueryAsyncSearch(queryAsJson string) (model.SimpleQuery, model.HitsCountInfo, model.Highlighter) {
221-
queryAsMap, err := types.ParseJSON(queryAsJson)
222-
if err != nil {
223-
logger.ErrorWithCtx(cw.Ctx).Err(err).Msg("error parsing query request's JSON")
224-
return model.NewSimpleQuery(nil, false), model.NewEmptyHitsCountInfo(), NewEmptyHighlighter()
225-
}
226-
227-
// we must parse "highlights" here, because it is stripped from the queryAsMap later
228-
highlighter := cw.ParseHighlighter(queryAsMap)
229-
230-
var parsedQuery model.SimpleQuery
231-
if query, ok := queryAsMap["query"]; ok {
232-
queryMap, ok := query.(QueryMap)
233-
if !ok {
234-
logger.WarnWithCtx(cw.Ctx).Msgf("invalid query type: %T, value: %v", query, query)
235-
return model.NewSimpleQuery(nil, false), model.NewEmptyHitsCountInfo(), NewEmptyHighlighter()
236-
}
237-
parsedQuery = cw.parseQueryMap(queryMap)
238-
} else {
239-
return model.NewSimpleQuery(nil, true), cw.tryProcessSearchMetadata(queryAsMap), highlighter
240-
}
241-
242-
if sort, ok := queryAsMap["sort"]; ok {
243-
parsedQuery.OrderBy = cw.parseSortFields(sort)
244-
}
245-
queryInfo := cw.tryProcessSearchMetadata(queryAsMap)
246-
247-
return parsedQuery, queryInfo, highlighter
248-
}
249-
250220
// Metadata attributes are the ones that are on the same level as query tag
251221
// They are moved into separate map for further processing if needed
252222
func (cw *ClickhouseQueryTranslator) parseMetadata(queryMap QueryMap) QueryMap {

quesma/queryparser/query_parser_async_search_test.go

Lines changed: 0 additions & 91 deletions
This file was deleted.

quesma/queryparser/query_parser_test.go

Lines changed: 0 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -213,212 +213,6 @@ func TestQueryParserNoAttrsConfig(t *testing.T) {
213213
}
214214
}
215215

216-
// TODO this will be updated in the next PR
217-
var tests = []string{
218-
`{
219-
"_source": {
220-
"excludes": []
221-
},
222-
"aggs": {
223-
"0": {
224-
"histogram": {
225-
"field": "FlightDelayMin",
226-
"interval": 1,
227-
"min_doc_count": 1
228-
}
229-
}
230-
},
231-
"fields": [
232-
{
233-
"field": "timestamp",
234-
"format": "date_time"
235-
}
236-
],
237-
"query": {
238-
"bool": {
239-
"filter": [
240-
{
241-
"range": {
242-
"timestamp": {
243-
"format": "strict_date_optional_time",
244-
"gte": "2024-02-02T13:47:16.029Z",
245-
"lte": "2024-02-09T13:47:16.029Z"
246-
}
247-
}
248-
}
249-
],
250-
"must": [],
251-
"must_not": [
252-
{
253-
"match_phrase": {
254-
"FlightDelayMin": {
255-
"query": 0
256-
}
257-
}
258-
}
259-
],
260-
"should": []
261-
}
262-
},
263-
"runtime_mappings": {
264-
"hour_of_day": {
265-
"script": {
266-
"source": "emit(doc['timestamp'].value.getHour());"
267-
},
268-
"type": "long"
269-
}
270-
},
271-
"script_fields": {},
272-
"size": 0,
273-
"stored_fields": [
274-
"*"
275-
],
276-
"track_total_hits": true
277-
}`,
278-
`{
279-
"_source": {
280-
"excludes": []
281-
},
282-
"aggs": {
283-
"0": {
284-
"aggs": {
285-
"1-bucket": {
286-
"filter": {
287-
"bool": {
288-
"filter": [
289-
{
290-
"bool": {
291-
"minimum_should_match": 1,
292-
"should": [
293-
{
294-
"match": {
295-
"FlightDelay": true
296-
}
297-
}
298-
]
299-
}
300-
}
301-
],
302-
"must": [],
303-
"must_not": [],
304-
"should": []
305-
}
306-
}
307-
},
308-
"3-bucket": {
309-
"filter": {
310-
"bool": {
311-
"filter": [
312-
{
313-
"bool": {
314-
"minimum_should_match": 1,
315-
"should": [
316-
{
317-
"match": {
318-
"Cancelled": true
319-
}
320-
}
321-
]
322-
}
323-
}
324-
],
325-
"must": [],
326-
"must_not": [],
327-
"should": []
328-
}
329-
}
330-
}
331-
},
332-
"terms": {
333-
"field": "OriginCityName",
334-
"order": {
335-
"_key": "asc"
336-
},
337-
"size": 1000
338-
}
339-
}
340-
},
341-
"fields": [
342-
{
343-
"field": "timestamp",
344-
"format": "date_time"
345-
}
346-
],
347-
"query": {
348-
"bool": {
349-
"filter": [
350-
{
351-
"range": {
352-
"timestamp": {
353-
"format": "strict_date_optional_time",
354-
"gte": "2024-02-02T13:47:16.029Z",
355-
"lte": "2024-02-09T13:47:16.029Z"
356-
}
357-
}
358-
}
359-
],
360-
"must": [],
361-
"must_not": [],
362-
"should": []
363-
}
364-
},
365-
"runtime_mappings": {
366-
"hour_of_day": {
367-
"script": {
368-
"source": "emit(doc['timestamp'].value.getHour());"
369-
},
370-
"type": "long"
371-
}
372-
},
373-
"script_fields": {},
374-
"size": 0,
375-
"stored_fields": [
376-
"*"
377-
],
378-
"track_total_hits": true
379-
}`,
380-
}
381-
382-
// TODO this will be updated in the next PR
383-
func TestNew(t *testing.T) {
384-
tableName := `"logs-generic-default"`
385-
table, err := clickhouse.NewTable(`CREATE TABLE `+tableName+`
386-
( "message" String, "timestamp" DateTime64(3, 'UTC') )
387-
ENGINE = Memory`,
388-
clickhouse.NewNoTimestampOnlyStringAttrCHConfig(),
389-
)
390-
if err != nil {
391-
t.Fatal(err)
392-
}
393-
lm := clickhouse.NewLogManager(util.NewSyncMapWith(tableName, table), &config.QuesmaConfiguration{})
394-
s := schema.StaticRegistry{
395-
Tables: map[schema.IndexName]schema.Schema{
396-
"logs-generic-default": {
397-
Fields: map[schema.FieldName]schema.Field{
398-
"host.name": {PropertyName: "host.name", InternalPropertyName: "host.name", Type: schema.QuesmaTypeObject},
399-
"type": {PropertyName: "type", InternalPropertyName: "type", Type: schema.QuesmaTypeText},
400-
"name": {PropertyName: "name", InternalPropertyName: "name", Type: schema.QuesmaTypeText},
401-
"content": {PropertyName: "content", InternalPropertyName: "content", Type: schema.QuesmaTypeText},
402-
"message": {PropertyName: "message", InternalPropertyName: "message", Type: schema.QuesmaTypeText},
403-
"host_name.keyword": {PropertyName: "host_name.keyword", InternalPropertyName: "host_name.keyword", Type: schema.QuesmaTypeKeyword},
404-
"FlightDelay": {PropertyName: "FlightDelay", InternalPropertyName: "FlightDelay", Type: schema.QuesmaTypeText},
405-
"Cancelled": {PropertyName: "Cancelled", InternalPropertyName: "Cancelled", Type: schema.QuesmaTypeText},
406-
"FlightDelayMin": {PropertyName: "FlightDelayMin", InternalPropertyName: "FlightDelayMin", Type: schema.QuesmaTypeText},
407-
"_id": {PropertyName: "_id", InternalPropertyName: "_id", Type: schema.QuesmaTypeText},
408-
},
409-
},
410-
},
411-
}
412-
413-
cw := ClickhouseQueryTranslator{ClickhouseLM: lm, Table: table, Ctx: context.Background(), Schema: s.Tables[schema.IndexName("logs-generic-default")]}
414-
for _, tt := range tests {
415-
t.Run("test", func(t *testing.T) {
416-
simpleQuery, _, _ := cw.ParseQueryAsyncSearch(tt)
417-
assert.True(t, simpleQuery.CanParse)
418-
})
419-
}
420-
}
421-
422216
func Test_parseSortFields(t *testing.T) {
423217
tests := []struct {
424218
name string

0 commit comments

Comments
 (0)