-
Notifications
You must be signed in to change notification settings - Fork 53
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
28229df
commit c61e322
Showing
10 changed files
with
461 additions
and
12 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
71 changes: 71 additions & 0 deletions
71
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,71 @@ | ||
// 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 TestQueryInlineIntegerArrayWithsWithAverageWithFilter(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 TestQueryInlineFloatArrayWithsWithAverageWithFilter(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.