Skip to content

Commit 89a8686

Browse files
update test
1 parent c8d4fe4 commit 89a8686

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/ReplaceRoundToWithQueryAndTagsTests.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
import static org.elasticsearch.index.query.QueryBuilders.rangeQuery;
4848
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
4949
import static org.elasticsearch.xpack.esql.EsqlTestUtils.as;
50+
import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.DEFAULT_DATE_NANOS_FORMATTER;
51+
import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.DEFAULT_DATE_TIME_FORMATTER;
5052
import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.dateNanosToLong;
5153
import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.dateTimeToLong;
5254
import static org.hamcrest.Matchers.is;
@@ -91,8 +93,12 @@ public ReplaceRoundToWithQueryAndTagsTests(String name, Configuration config) {
9193
Map.ofEntries(
9294
Map.entry("keyword == \"keyword\"", termQuery("keyword", "keyword").boost(0)),
9395
Map.entry(
94-
"keyword >= \"2023-10-19\" and keyword <= \"2023-10-24\"",
95-
rangeQuery("keyword").gte("2023-10-19").lte("2023-10-24").timeZone("Z").boost(0)
96+
"date >= \"2023-10-19\" and date <= \"2023-10-24\"",
97+
rangeQuery("date").gte("2023-10-19T00:00:00.000Z")
98+
.lte("2023-10-24T00:00:00.000Z")
99+
.timeZone("Z")
100+
.boost(0)
101+
.format(DEFAULT_DATE_TIME_FORMATTER.pattern())
96102
),
97103
Map.entry("keyword : \"keyword\"", matchQuery("keyword", "keyword").lenient(true))
98104
)
@@ -238,8 +244,8 @@ public void testDateTruncBucketTransformToQueryAndTagsWithOtherPushdownFunctions
238244
: wrapWithSingleQuery(
239245
query,
240246
qb,
241-
"keyword",
242-
new Source(2, 8, predicate.contains("and") ? predicate.substring(0, 23) : predicate)
247+
predicate.contains("and") ? "date" : "keyword",
248+
new Source(2, 8, predicate.contains("and") ? predicate.substring(0, 20) : predicate)
243249
);
244250

245251
PhysicalPlan plan = plannerOptimizer.plan(query, searchStats, makeAnalyzer("mapping-all-types.json"));
@@ -305,9 +311,9 @@ private static List<EsQueryExec.QueryBuilderAndTags> expectedQueryBuilderAndTags
305311
if (isNumericField) {
306312
rangeQueryBuilder = rangeQuery(fieldName).boost(0);
307313
} else if (isDateField) { // date
308-
rangeQueryBuilder = rangeQuery(fieldName).boost(0).timeZone("Z").format("strict_date_optional_time");
314+
rangeQueryBuilder = rangeQuery(fieldName).boost(0).timeZone("Z").format(DEFAULT_DATE_TIME_FORMATTER.pattern());
309315
} else { // date_nanos
310-
rangeQueryBuilder = rangeQuery(fieldName).boost(0).timeZone("Z").format("strict_date_optional_time_nanos");
316+
rangeQueryBuilder = rangeQuery(fieldName).boost(0).timeZone("Z").format(DEFAULT_DATE_NANOS_FORMATTER.pattern());
311317
}
312318
if (upper != null) {
313319
rangeQueryBuilder = rangeQueryBuilder.lt(upper);

0 commit comments

Comments
 (0)