@@ -345,33 +345,56 @@ def test_invalid_query(self) -> None:
345345 "project" : [self .project .id ],
346346 "dataset" : "spans" ,
347347 "field" : ["span.duration" ],
348- "query" : "Thing AND" ,
348+ "query" : "project:foo AND" ,
349349 }
350350 )
351351
352352 assert response .status_code == 400 , response .content
353353 assert not response .data ["valid" ]
354- assert response .data ["query" ] == [
355- {"valid" : False , "error" : "Condition is missing on the right side of 'AND' operator" }
356- ]
354+ assert response .data ["query" ] == {
355+ "valid" : False ,
356+ "error" : "Condition is missing on the right side of 'AND' operator" ,
357+ "fields" : [
358+ {"attrType" : "string" , "error" : None , "name" : "project" , "valid" : True },
359+ ],
360+ }
357361
358362 response = self .do_request (
359363 {
360364 "project" : [self .project .id ],
361365 "dataset" : "spans" ,
362366 "field" : ["span.duration" ],
363- "query" : "span.duration:> hello" ,
367+ "query" : "project:foo AND p90( hello" ,
364368 }
365369 )
366370
367371 assert response .status_code == 400 , response .content
368372 assert not response .data ["valid" ]
369- assert response .data ["query" ] == [
373+ assert response .data ["query" ] == {
374+ "valid" : False ,
375+ "error" : "Parse error at ' p90(hello' (column 20). This is commonly caused by unmatched parentheses. Enclose any text in double quotes." ,
376+ "fields" : [
377+ {"attrType" : "string" , "error" : None , "name" : "project" , "valid" : True },
378+ {"attrType" : "string" , "error" : None , "name" : "message" , "valid" : True },
379+ ],
380+ }
381+
382+ response = self .do_request (
370383 {
371- "valid" : False ,
372- "error" : "span.duration: Invalid number: >hello. Expected number then optional k, m, or b suffix (e.g. 500k)." ,
384+ "project" : [self .project .id ],
385+ "dataset" : "spans" ,
386+ "field" : ["span.duration" ],
387+ "query" : "span.duration:>hello" ,
373388 }
374- ]
389+ )
390+
391+ assert response .status_code == 400 , response .content
392+ assert not response .data ["valid" ]
393+ assert response .data ["query" ] == {
394+ "valid" : False ,
395+ "error" : "span.duration: Invalid number: >hello. Expected number then optional k, m, or b suffix (e.g. 500k)." ,
396+ "fields" : [],
397+ }
375398
376399 def test_valid_query (self ) -> None :
377400 response = self .do_request (
@@ -385,20 +408,24 @@ def test_valid_query(self) -> None:
385408
386409 assert response .status_code == 200 , response .content
387410 assert response .data ["valid" ]
388- assert response .data ["query" ] == [
389- {
390- "error" : None ,
391- "name" : "span.duration" ,
392- "valid" : True ,
393- "attrType" : "number" ,
394- },
395- {
396- "error" : None ,
397- "name" : "p95(span.duration)" ,
398- "valid" : True ,
399- "attrType" : "number" ,
400- },
401- ]
411+ assert response .data ["query" ] == {
412+ "valid" : True ,
413+ "error" : None ,
414+ "fields" : [
415+ {
416+ "error" : None ,
417+ "name" : "span.duration" ,
418+ "valid" : True ,
419+ "attrType" : "number" ,
420+ },
421+ {
422+ "error" : None ,
423+ "name" : "p95(span.duration)" ,
424+ "valid" : True ,
425+ "attrType" : "number" ,
426+ },
427+ ],
428+ }
402429
403430 def test_mixed_validity_query (self ) -> None :
404431 response = self .do_request (
@@ -412,32 +439,36 @@ def test_mixed_validity_query(self) -> None:
412439
413440 assert response .status_code == 400 , response .content
414441 assert not response .data ["valid" ]
415- assert response .data ["query" ] == [
416- {
417- "error" : None ,
418- "name" : "span.duration" ,
419- "valid" : True ,
420- "attrType" : "number" ,
421- },
422- {
423- "error" : "Unknown attribute" ,
424- "name" : "hello" ,
425- "valid" : False ,
426- "attrType" : None ,
427- },
428- {
429- "error" : "Unknown attribute" ,
430- "name" : "world" ,
431- "valid" : False ,
432- "attrType" : None ,
433- },
434- {
435- "error" : "Unknown attribute" ,
436- "name" : "or" ,
437- "valid" : False ,
438- "attrType" : None ,
439- },
440- ]
442+ assert response .data ["query" ] == {
443+ "error" : "Unknown attribute" ,
444+ "valid" : False ,
445+ "fields" : [
446+ {
447+ "error" : None ,
448+ "name" : "span.duration" ,
449+ "valid" : True ,
450+ "attrType" : "number" ,
451+ },
452+ {
453+ "error" : "Unknown attribute" ,
454+ "name" : "hello" ,
455+ "valid" : False ,
456+ "attrType" : None ,
457+ },
458+ {
459+ "error" : "Unknown attribute" ,
460+ "name" : "world" ,
461+ "valid" : False ,
462+ "attrType" : None ,
463+ },
464+ {
465+ "error" : "Unknown attribute" ,
466+ "name" : "or" ,
467+ "valid" : False ,
468+ "attrType" : None ,
469+ },
470+ ],
471+ }
441472
442473 def test_user_tags_in_storage_for_query (self ) -> None :
443474 self .store_spans (
@@ -460,9 +491,13 @@ def test_user_tags_in_storage_for_query(self) -> None:
460491
461492 assert response .status_code == 200 , response .content
462493 assert response .data ["valid" ]
463- assert response .data ["query" ] == [
464- {"error" : None , "name" : "my.custom.tag" , "valid" : True , "attrType" : "string" },
465- ]
494+ assert response .data ["query" ] == {
495+ "error" : None ,
496+ "valid" : True ,
497+ "fields" : [
498+ {"error" : None , "name" : "my.custom.tag" , "valid" : True , "attrType" : "string" },
499+ ],
500+ }
466501
467502 def test_invalid_field_in_fields_and_query (self ) -> None :
468503 response = self .do_request (
@@ -484,14 +519,18 @@ def test_invalid_field_in_fields_and_query(self) -> None:
484519 "attrType" : None ,
485520 },
486521 ]
487- assert response .data ["query" ] == [
488- {
489- "error" : "Unknown attribute" ,
490- "name" : "hello" ,
491- "valid" : False ,
492- "attrType" : None ,
493- },
494- ]
522+ assert response .data ["query" ] == {
523+ "error" : "Unknown attribute" ,
524+ "valid" : False ,
525+ "fields" : [
526+ {
527+ "error" : "Unknown attribute" ,
528+ "name" : "hello" ,
529+ "valid" : False ,
530+ "attrType" : None ,
531+ },
532+ ],
533+ }
495534
496535 def test_multiple_invalid_issues (self ) -> None :
497536 response = self .do_request (
@@ -514,14 +553,18 @@ def test_multiple_invalid_issues(self) -> None:
514553 "attrType" : None ,
515554 },
516555 ]
517- assert response .data ["query" ] == [
518- {
519- "error" : "Unknown attribute" ,
520- "name" : "hello" ,
521- "valid" : False ,
522- "attrType" : None ,
523- },
524- ]
556+ assert response .data ["query" ] == {
557+ "error" : "Unknown attribute" ,
558+ "valid" : False ,
559+ "fields" : [
560+ {
561+ "error" : "Unknown attribute" ,
562+ "name" : "hello" ,
563+ "valid" : False ,
564+ "attrType" : None ,
565+ },
566+ ],
567+ }
525568 assert response .data ["orderby" ] == [
526569 {
527570 "error" : "Orderby must also be a selected field" ,
0 commit comments