@@ -3375,9 +3375,6 @@ var AggregationTests = []testdata.AggregationTestCase{
33753375 TestName : "IP range, with ranges as CIDR masks. In Kibana: Add panel > Aggregation Based > Area. Buckets: X-asis: IP Range" ,
33763376 QueryRequestJson : `
33773377 {
3378- "_source": {
3379- "excludes": []
3380- },
33813378 "aggs": {
33823379 "2": {
33833380 "ip_range": {
@@ -3451,7 +3448,7 @@ var AggregationTests = []testdata.AggregationTestCase{
34513448 }},
34523449 },
34533450 ExpectedPancakeSQL : `
3454- SELECT countIf("clientip">='255.255.255.252') AS "range_0__aggr__2__count",
3451+ SELECT countIf(( "clientip">='255.255.255.252' AND "clientip"<'::1:0:0:0') ) AS "range_0__aggr__2__count",
34553452 countIf("clientip">='128.129.130.131') AS "range_1__aggr__2__count",
34563453 countIf(("clientip">='10.0.7.96' AND "clientip"<'10.0.7.128')) AS
34573454 "range_2__aggr__2__count"
@@ -3461,9 +3458,6 @@ var AggregationTests = []testdata.AggregationTestCase{
34613458 TestName : "IP range, with ranges as CIDR masks, keyed=true. In Kibana: Add panel > Aggregation Based > Area. Buckets: X-asis: IP Range" ,
34623459 QueryRequestJson : `
34633460 {
3464- "_source": {
3465- "excludes": []
3466- },
34673461 "aggs": {
34683462 "2": {
34693463 "ip_range": {
@@ -3535,10 +3529,127 @@ var AggregationTests = []testdata.AggregationTestCase{
35353529 }},
35363530 },
35373531 ExpectedPancakeSQL : `
3538- SELECT countIf("clientip">='255.255.255.254') AS "range_0__aggr__2__count",
3532+ SELECT countIf(( "clientip">='255.255.255.254' AND "clientip"<'::1:0:0:0') ) AS "range_0__aggr__2__count",
35393533 countIf("clientip">='128.129.130.131') AS "range_1__aggr__2__count",
35403534 countIf(("clientip">='10.0.7.96' AND "clientip"<'10.0.7.128')) AS
35413535 "range_2__aggr__2__count"
35423536 FROM __quesma_table_name` ,
35433537 },
3538+ { // [27]
3539+ TestName : "IP range ipv6" ,
3540+ QueryRequestJson : `
3541+ {
3542+ "aggs": {
3543+ "2": {
3544+ "ip_range": {
3545+ "field": "clientip",
3546+ "ranges": [
3547+ {
3548+ "from": "1::132:13:21:23:122:22"
3549+ },
3550+ {
3551+ "to": "1::132:13:21:23:122:22"
3552+ },
3553+ {
3554+ "to": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"
3555+ }
3556+ ]
3557+ }
3558+ }
3559+ },
3560+ "size": 0,
3561+ "track_total_hits": true
3562+ }` ,
3563+ ExpectedResponse : `
3564+ {
3565+ "aggregations": {
3566+ "2": {
3567+ "buckets": [
3568+ {
3569+ "key": "1::132:13:21:23:122:22-*",
3570+ "from": "1::132:13:21:23:122:22",
3571+ "doc_count": 7290
3572+ },
3573+ {
3574+ "key": "*-1::132:13:21:23:122:22",
3575+ "to": "1::132:13:21:23:122:22",
3576+ "doc_count": 6784
3577+ },
3578+ {
3579+ "key": "*-ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
3580+ "to": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
3581+ "doc_count": 999999
3582+ }
3583+ ]
3584+ }
3585+ }
3586+ }` ,
3587+ ExpectedPancakeResults : []model.QueryResultRow {
3588+ {Cols : []model.QueryResultCol {
3589+ model .NewQueryResultCol ("range_0__aggr__2__count" , int64 (7290 )),
3590+ model .NewQueryResultCol ("range_1__aggr__2__count" , int64 (6784 )),
3591+ model .NewQueryResultCol ("range_2__aggr__2__count" , int64 (999999 )),
3592+ }},
3593+ },
3594+ ExpectedPancakeSQL : `
3595+ SELECT countIf("clientip">='1::132:13:21:23:122:22') AS
3596+ "range_0__aggr__2__count",
3597+ countIf("clientip"<'1::132:13:21:23:122:22') AS "range_1__aggr__2__count",
3598+ countIf("clientip"<'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff') AS
3599+ "range_2__aggr__2__count"
3600+ FROM __quesma_table_name` ,
3601+ },
3602+ { // [28]
3603+ TestName : "IP range ipv6 with mask" ,
3604+ QueryRequestJson : `
3605+ {
3606+ "aggs": {
3607+ "2": {
3608+ "ip_range": {
3609+ "field": "clientip",
3610+ "ranges": [
3611+ {
3612+ "mask": "::/2"
3613+ },
3614+ {
3615+ "mask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/127"
3616+ }
3617+ ]
3618+ }
3619+ }
3620+ },
3621+ "size": 0,
3622+ "track_total_hits": true
3623+ }` ,
3624+ ExpectedResponse : `
3625+ {
3626+ "aggregations": {
3627+ "2": {
3628+ "buckets": [
3629+ {
3630+ "key": "::/2",
3631+ "to": "4000::",
3632+ "doc_count": 1
3633+ },
3634+ {
3635+ "key": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/127",
3636+ "from": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe",
3637+ "doc_count": 0
3638+ }
3639+ ]
3640+ }
3641+ }
3642+ }` ,
3643+ ExpectedPancakeResults : []model.QueryResultRow {
3644+ {Cols : []model.QueryResultCol {
3645+ model .NewQueryResultCol ("range_0__aggr__2__count" , int64 (1 )),
3646+ model .NewQueryResultCol ("range_1__aggr__2__count" , int64 (0 )),
3647+ }},
3648+ },
3649+ ExpectedPancakeSQL : `
3650+ SELECT countIf("clientip"<'4000::') AS "range_0__aggr__2__count",
3651+ countIf("clientip">='ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe') AS
3652+ "range_1__aggr__2__count"
3653+ FROM __quesma_table_name` ,
3654+ },
35443655}
0 commit comments