Closed 0marperez closed 1 year ago
About the avg
function test for an empty list (EmptyIntegerListAvgNotEquals
). JMESPath doesn't have a way to check if something is null so I just compared it to a number and set the success criteria to false. You can verify this behavior by playing around with JMESPath on their website and I also tried it in a waiter btw.
JMESPath doesn't have a way to check if something is null...
I don't understand. The spec's section on equality seems to indicate that null
is only equal to itself. You weren't able to get an equality path to pass booleanEquals
?
matcher: {
output: {
path: "avg(lists.integers) == null",
expected: "true",
comparator: "booleanEquals"
}
}
You weren't able to get an equality path to pass booleanEquals?
No, when trying it in the waiter I get an error message:
6 | @waitable(
| ^
··|
94| operation GetFunctionAvgEquals {
Waiter `EmptyIntegerListAvgEquals`, acceptor 0: Problem found in JMESPath
expression (avg(lists.integers) == null): Object field 'null' does not exist in
object with properties [primitives, lists, twoDimensionalLists, maps] (1:24)
And in the JMESPath website you can see null is there:
But when comparing it to another null it doesn't work:
Kudos, SonarCloud Quality Gate passed!
0 Bugs
0 Vulnerabilities
0 Security Hotspots
0 Code Smells
No Coverage information
0.0% Duplication
No, when trying it in the waiter I get an error message:
6 | @waitable( | ^ ··| 94| operation GetFunctionAvgEquals { Waiter `EmptyIntegerListAvgEquals`, acceptor 0: Problem found in JMESPath expression (avg(lists.integers) == null): Object field 'null' does not exist in object with properties [primitives, lists, twoDimensionalLists, maps] (1:24)
Interesting. It looks like Smithy's JMESPath type checker is getting to visitField
when I'd expect it to be hitting visitLiteral
. I suspect this might be a bug in Smithy and I recommend you file an issue to them.
Looks like what you've got is the best we can do for now!
Issue \
Description of changes
Added: -Sum -Avg -Join -Starts with -Ends with
Refactored: -Separated operations from structures in smithy file -Wrote function to avoid code duplication in JMESPath visitor functions code
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.