Skip to content

Commit

Permalink
Add ZoneId getter for date histo filter rewrite canOptimize check.
Browse files Browse the repository at this point in the history
Signed-off-by: Finn Carroll <carrofin@amazon.com>
  • Loading branch information
finnegancarroll committed Jan 17, 2025
1 parent d6927fd commit a5086e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ public DateMathParser getDateMathParser() {
return parser;
}

public ZoneId getZoneId() {
return timeZone;
}

@Override
public String format(long value) {
return formatter.format(resolution.toInstant(value).atZone(timeZone));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.opensearch.common.Rounding;
import org.opensearch.index.mapper.DateFieldMapper;
import org.opensearch.index.mapper.MappedFieldType;
import org.opensearch.search.DocValueFormat;
import org.opensearch.search.aggregations.bucket.histogram.LongBounds;
import org.opensearch.search.aggregations.support.ValuesSourceConfig;
import org.opensearch.search.internal.SearchContext;
Expand All @@ -38,7 +39,9 @@ protected boolean canOptimize(ValuesSourceConfig config) {
* The filter rewrite optimized path does not support bucket intervals which are not fixed.
* For this reason we exclude non UTC timezones.
*/
if (!isUTCTimeZone(config.timezone())) {
if (config.format() instanceof DocValueFormat.DateTime &&
!isUTCTimeZone(((DocValueFormat.DateTime) config.format()).getZoneId())
) {
return false;
}

Expand Down

0 comments on commit a5086e2

Please sign in to comment.