aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/grouping/request/DateFunction.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-08-14 11:15:12 +0200
committerJon Bratseth <bratseth@oath.com>2018-08-14 11:15:12 +0200
commit7b134d8ef30cc3bd6e0867ba3f47452d78d4fce0 (patch)
tree96ef67d3c9998c0f51c289d1e8cfb298b26f0e2f /container-search/src/main/java/com/yahoo/search/grouping/request/DateFunction.java
parent216feb84a135cbcd3e20cdb3240a63fdb53439e3 (diff)
Fix Select and grouping bugs
- Deep copy the grouping structure on query copy. It is mutable but we have neglected doing this right until now. - Fix a bug in the previous commit where the last constructed Query.Model was shared between all instances. - Fix a bug in the previous commit where the query string instead of the query tree was reset when a new select expression is set. - Don't use deprecated method. - Clean up Javadoc and formatting.
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/grouping/request/DateFunction.java')
-rw-r--r--container-search/src/main/java/com/yahoo/search/grouping/request/DateFunction.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/grouping/request/DateFunction.java b/container-search/src/main/java/com/yahoo/search/grouping/request/DateFunction.java
index b3a4c451b6b..0c2c4928a91 100644
--- a/container-search/src/main/java/com/yahoo/search/grouping/request/DateFunction.java
+++ b/container-search/src/main/java/com/yahoo/search/grouping/request/DateFunction.java
@@ -2,12 +2,14 @@
package com.yahoo.search.grouping.request;
import java.util.Arrays;
+import java.util.stream.Collectors;
/**
* This class represents a timestamp-formatter function in a {@link GroupingExpression}. It evaluates to a string on the
* form "YYYY-MM-DD" of the result of the argument.
*
* @author Simon Thoresen Hult
+ * @author bratseth
*/
public class DateFunction extends FunctionNode {
@@ -17,6 +19,18 @@ public class DateFunction extends FunctionNode {
* @param exp The expression to evaluate, must evaluate to a long.
*/
public DateFunction(GroupingExpression exp) {
- super("time.date", Arrays.asList(exp));
+ this(null, null, exp);
}
+
+ private DateFunction(String label, Integer level, GroupingExpression exp) {
+ super("time.date", label, level, Arrays.asList(exp));
+ }
+
+ @Override
+ public DateFunction copy() {
+ return new DateFunction(getLabel(),
+ getLevelOrNull(),
+ getArg(0).copy());
+ }
+
}