-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for inline array aggregate filters
- Loading branch information
1 parent
c13172b
commit fac4858
Showing
13 changed files
with
486 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
tests/integration/query/inline_array/with_average_filter_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2022 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package inline_array | ||
|
||
import ( | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration" | ||
) | ||
|
||
func TestQueryInlineIntegerArrayWithAverageWithFilter(t *testing.T) { | ||
test := testUtils.QueryTestCase{ | ||
Description: "Simple inline array, filtered average of integer array", | ||
Query: `query { | ||
users { | ||
Name | ||
_avg(FavouriteIntegers: {filter: {_gt: 0}}) | ||
} | ||
}`, | ||
Docs: map[int][]string{ | ||
0: { | ||
`{ | ||
"Name": "Shahzad", | ||
"FavouriteIntegers": [-1, 2, -1, 1, 0] | ||
}`, | ||
}, | ||
}, | ||
Results: []map[string]interface{}{ | ||
{ | ||
"Name": "Shahzad", | ||
"_avg": float64(1.5), | ||
}, | ||
}, | ||
} | ||
|
||
executeTestCase(t, test) | ||
} | ||
|
||
func TestQueryInlineFloatArrayWithAverageWithFilter(t *testing.T) { | ||
test := testUtils.QueryTestCase{ | ||
Description: "Simple inline array, filtered average of float array", | ||
Query: `query { | ||
users { | ||
Name | ||
_avg(FavouriteFloats: {filter: {_lt: 9}}) | ||
} | ||
}`, | ||
Docs: map[int][]string{ | ||
0: { | ||
`{ | ||
"Name": "Shahzad", | ||
"FavouriteFloats": [3.4, 3.6, 10] | ||
}`, | ||
}, | ||
}, | ||
Results: []map[string]interface{}{ | ||
{ | ||
"Name": "Shahzad", | ||
"_avg": 3.5, | ||
}, | ||
}, | ||
} | ||
|
||
executeTestCase(t, test) | ||
} |
Oops, something went wrong.