@@ -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-
422216func Test_parseSortFields (t * testing.T ) {
423217 tests := []struct {
424218 name string
0 commit comments