diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-11-15 12:54:06 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-11-15 12:54:06 +0100 |
commit | 85ba752c81148e0076bdc00248d7a2b75632a3c8 (patch) | |
tree | 450272695d1077c4d1c3a2395d521797efbc118a /container-search | |
parent | 61050a1678c5e2da424f6e8d21d5fa4b63fe114f (diff) |
Handle single value string buckets correctly
Diffstat (limited to 'container-search')
2 files changed, 13 insertions, 5 deletions
diff --git a/container-search/src/main/javacc/com/yahoo/search/grouping/request/parser/GroupingParser.jj b/container-search/src/main/javacc/com/yahoo/search/grouping/request/parser/GroupingParser.jj index e1df35bb24a..a7e471b99b9 100644 --- a/container-search/src/main/javacc/com/yahoo/search/grouping/request/parser/GroupingParser.jj +++ b/container-search/src/main/javacc/com/yahoo/search/grouping/request/parser/GroupingParser.jj @@ -926,7 +926,7 @@ void bucket(GroupingOperation grp, BucketResolver resolver) : ( rbracket() { inclusiveTo = true; } ) ) ) - { resolver.push(from, inclusiveFrom); resolver.push((to == null) ? from : to, inclusiveTo); } + { resolver.push(from, inclusiveFrom); resolver.push((to == null) ? from : to, inclusiveTo || to == null); } } Number signedNumber() : diff --git a/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java index 5d311361edf..cd080405a7d 100644 --- a/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java @@ -539,7 +539,7 @@ public class GroupingParserTestCase { "max(55) output(count()) each(each(output(summary())))))"); assertParse("all(group(artist) max(13) each(group(predefined(year, bucket(7.1, 19.0), bucket(90.7, 300.0))) " + "max(55) output(count()) each(each(output(summary())))))"); - assertParse("all(group(artist) max(13) each(group(predefined(year, bucket('a', 'b'), bucket('cd', 'cde'))) " + + assertParse("all(group(artist) max(13) each(group(predefined(year, bucket('a', 'b'), bucket('cd'))) " + "max(55) output(count()) each(each(output(summary())))))"); assertParse("all(output(count()))"); @@ -581,6 +581,14 @@ public class GroupingParserTestCase { } @Test + public void testBucket() { + List<GroupingOperation> operations = assertParse("all(group(predefined(artist, bucket('a'), bucket('c', 'z'))))"); + assertEquals(1, operations.size()); + assertEquals("all(group(predefined(artist, bucket[\"a\", \"a \">, bucket[\"c\", \"z\">)))", + operations.get(0).toString()); + } + + @Test public void requireThatParseExceptionMessagesContainErrorMarker() { assertIllegalArgument("foo", "Encountered \" <IDENTIFIER> \"foo\"\" at line 1, column 1.\n\n" + @@ -605,12 +613,10 @@ public class GroupingParserTestCase { } // -------------------------------------------------------------------------------- - // // Utilities. - // // -------------------------------------------------------------------------------- - private static void assertParse(String request, String... expectedOperations) { + private static List<GroupingOperation> assertParse(String request, String... expectedOperations) { List<GroupingOperation> operations = GroupingOperation.fromStringAsList(request); List<String> actual = new ArrayList<>(operations.size()); for (GroupingOperation operation : operations) { @@ -628,6 +634,7 @@ public class GroupingParserTestCase { // make sure that yql+ is capable of handling request assertYqlParsable(request, expectedOperations); + return operations; } private static void assertYqlParsable(String request, String... expectedOperations) { @@ -653,4 +660,5 @@ public class GroupingParserTestCase { } } } + } |