-
Notifications
You must be signed in to change notification settings - Fork 507
METRON-656: Make Stellar 'in' closer to functioning like python #416
Conversation
@@ -418,6 +417,33 @@ public void testList() throws Exception { | |||
} | |||
|
|||
@Test | |||
public void testInMap() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a couple test cases for String values?
runPredicate("'foo' in { 'foo' : 5 }"...
bar = 'foo'
runPredicate("'foo' in { bar : 5 }"...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing. Done, let me know what you think about them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! +1
I like the semantics here. One small comment on the tests, +1 pending that adjustment and Travis. |
I think this is a great feature. I do have a few suggestions/questions:
|
Disregard number 2. It was an oversight on my part. Sorry about that. |
@jjmeyer0 Thanks so much for the comments!
|
I found one additional corner case that may need to be addressed. It looks the like expression, |
@jjmeyer0 Oh good one! |
1. `in` supports string contains. e.g. `'foo' in 'foobar' == true` | ||
2. `in` supports collection contains. e.g. `'foo' in [ 'foo', 'bar' ] == true` | ||
3. `in` supports map key contains. e.g. `'foo' in { 'foo' : 5} == true` | ||
4. `not in` is the negation of the in expression. e.g. `'grok' not in 'foobar' == true` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, one last comment. I was a bit curious as to how the expression 'grok' not in 'foobar' == true
would be evaluated by Stellar. I wasn't sure if it would be '(grok' not in 'foobar') == true
or 'grok' not in ('foobar' == true)
. Unfortunately when I tried to run a test it said it is not a valid expression. I think this may be an issue in the Stellar grammar. It is probably outside the scope of this ticket, but I thought I should mention it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's a stellar language bug. ('grok' not in 'foobar') == true
should work.
+1 (non-binding). I'll create a Jira based on the last comments between @cestella and me. (https://issues.apache.org/jira/browse/METRON-658) |
We have an
in
operator in stellar, but it could be much better. This should bring it at parity with thein
operator in python:in
should support string contains e.g.'foo' in 'foobar'
in
should support Collection contains e.g.'foo' in [ 'foo', 'bar' ]
. Legacy was to only support listsin
should support map contains e.g.'foo' in { 'foo' : 5 }