select: add MISSING operator support (#14406)

Probably not full support, but for regular checks it should work.

Fixes #14358
This commit is contained in:
Klaus Post
2022-02-25 12:31:19 -08:00
committed by GitHub
parent e43cc316ff
commit 88fd1cba71
8 changed files with 153 additions and 29 deletions
+83
View File
@@ -479,6 +479,89 @@ func TestJSONQueries(t *testing.T) {
query: `select * from s3object[*] as s where s.request.header['User-Agent'] is not null`,
wantResult: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}`,
withJSON: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":{}}}`,
},
{
name: "is-not-missing",
query: `select * from s3object[*] as s where s.request.header['User-Agent'] is not missing`,
wantResult: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}`,
withJSON: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":{}}}`,
},
{
name: "is-not-missing-2",
query: `select * from s3object[*] as s where s.request.header is not missing`,
wantResult: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":{}}}`,
withJSON: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":{}}}`,
},
{
name: "is-not-missing-null",
query: `select * from s3object[*] as s where s.request.header is not missing`,
wantResult: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":null}}`,
withJSON: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":null}}`,
},
{
name: "is-not-missing",
query: `select * from s3object[*] as s where s.request.header['User-Agent'] is not missing`,
wantResult: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}`,
withJSON: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":{}}}`,
},
{
name: "is-not-missing-2",
query: `select * from s3object[*] as s where s.request.header is not missing`,
wantResult: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":{}}}`,
withJSON: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":{}}}`,
},
{
name: "is-not-missing-null",
query: `select * from s3object[*] as s where s.request.header is not missing`,
wantResult: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":null}}`,
withJSON: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":null}}`,
},
{
name: "is-missing",
query: `select * from s3object[*] as s where s.request.header['User-Agent'] is missing`,
wantResult: `{"request":{"uri":"/2","header":{}}}`,
withJSON: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":{}}}`,
},
{
name: "is-missing-2",
query: `select * from s3object[*] as s where s.request.header is missing`,
wantResult: ``,
withJSON: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":{}}}`,
},
{
name: "is-missing",
query: `select * from s3object[*] as s where s.request.header['User-Agent'] = missing`,
wantResult: `{"request":{"uri":"/2","header":{}}}`,
withJSON: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":{}}}`,
},
{
name: "is-missing-null",
query: `select * from s3object[*] as s where s.request.header is missing`,
wantResult: ``,
withJSON: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":null}}`,
},
{
name: "is-missing-select",
query: `select s.request.header['User-Agent'] as h from s3object[*] as s`,
wantResult: `{"h":"test"}
{}`,
withJSON: `{"request":{"uri":"/1","header":{"User-Agent":"test"}}}
{"request":{"uri":"/2","header":{}}}`,
},
}