Skip to content

Commit 77ba749

Browse files
fix test
1 parent beca4fa commit 77ba749

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import static org.elasticsearch.index.query.QueryBuilders.existsQuery;
4949
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
5050
import static org.elasticsearch.index.query.QueryBuilders.rangeQuery;
51+
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
5152
import static org.elasticsearch.xpack.esql.EsqlTestUtils.as;
5253
import static org.elasticsearch.xpack.esql.core.util.Queries.Clause.MUST;
5354
import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.DEFAULT_DATE_NANOS_FORMATTER;
@@ -94,7 +95,7 @@ public ReplaceRoundToWithQueryAndTagsTests(String name, Configuration config) {
9495

9596
private static final Map<String, QueryBuilder> otherPushDownFunctions = new HashMap<>(
9697
Map.ofEntries(
97-
// Map.entry("where keyword == \"keyword\"", termQuery("keyword", "keyword").boost(0)),
98+
Map.entry("where keyword == \"keyword\"", termQuery("keyword", "keyword").boost(0)),
9899
Map.entry("where keyword : \"keyword\"", matchQuery("keyword", "keyword").lenient(true))
99100
)
100101
);
@@ -414,7 +415,7 @@ public void testRoundToFieldsIsNotNull() {
414415
public void testMergeRangePredicatesOnRoundToFieldWithOtherPushdownFunctions() {
415416
for (Map.Entry<String, List<Object>> roundTo : roundToAllTypes.entrySet()) {
416417
for (Map.Entry<String, QueryBuilder> otherPushDownFunction : otherPushDownFunctions.entrySet()) {
417-
String otherPredicate = " and " + otherPushDownFunction.getKey().substring(6);
418+
String otherPredicate = otherPushDownFunction.getKey();
418419
QueryBuilder otherQueryBuilder = otherPushDownFunction.getValue();
419420
String fieldName = roundTo.getKey();
420421
List<Object> roundingPoints = roundTo.getValue();
@@ -446,9 +447,9 @@ public void testMergeRangePredicatesOnRoundToFieldWithOtherPushdownFunctions() {
446447

447448
String query = LoggerMessageFormat.format(null, """
448449
from test
449-
| where {}{}
450+
| {} and {}
450451
| stats count(*) by x = {}
451-
""", rangePredicate, otherPredicate, roundToExpression);
452+
""", otherPredicate, rangePredicate, roundToExpression);
452453

453454
otherQueryBuilder = otherQueryBuilder instanceof MatchQueryBuilder
454455
? otherQueryBuilder
@@ -475,7 +476,7 @@ public void testMergeRangePredicatesOnRoundToFieldWithOtherPushdownFunctions() {
475476
query,
476477
rangeQueryBuilder,
477478
fieldName,
478-
new Source(2, 8, fieldName + " > " + lowerInPredicate)
479+
new Source(2, 7 + otherPredicate.length(), fieldName + " > " + lowerInPredicate)
479480
);
480481

481482
mainQueryBuilder = Queries.combine(MUST, List.of(otherQueryBuilder, mainQueryBuilder));
@@ -515,7 +516,7 @@ public void testMergeRangePredicatesOnRoundToFieldWithOtherPushdownFunctions() {
515516
public void testRoundToFieldsIsNotNullWithOtherPushDownFunctions() {
516517
for (Map.Entry<String, List<Object>> roundTo : roundToAllTypes.entrySet()) {
517518
for (Map.Entry<String, QueryBuilder> otherPushDownFunction : otherPushDownFunctions.entrySet()) {
518-
String otherPredicate = " and " + otherPushDownFunction.getKey().substring(6);
519+
String otherPredicate = otherPushDownFunction.getKey();
519520
QueryBuilder otherQueryBuilder = otherPushDownFunction.getValue();
520521
String fieldName = roundTo.getKey();
521522
List<Object> roundingPoints = roundTo.getValue();
@@ -527,17 +528,17 @@ public void testRoundToFieldsIsNotNullWithOtherPushDownFunctions() {
527528

528529
String query = LoggerMessageFormat.format(null, """
529530
from test
530-
| where {} is not null{}
531+
| {} and {} is not null
531532
| stats count(*) by x = {}
532-
""", fieldName, otherPredicate, roundToExpression);
533+
""", otherPredicate, fieldName, roundToExpression);
533534

534535
otherQueryBuilder = otherQueryBuilder instanceof MatchQueryBuilder
535536
? otherQueryBuilder
536537
: wrapWithSingleQuery(query, otherQueryBuilder, "keyword", new Source(2, 8, otherPredicate.substring(6)));
537538

538539
ExistsQueryBuilder existsQueryBuilder = existsQuery(fieldName).boost(0);
539540

540-
QueryBuilder mainQueryBuilder = Queries.combine(MUST, List.of(existsQueryBuilder, otherQueryBuilder));
541+
QueryBuilder mainQueryBuilder = Queries.combine(MUST, List.of(otherQueryBuilder, existsQueryBuilder));
541542

542543
PhysicalPlan plan = plannerOptimizer.plan(query, searchStats, makeAnalyzer("mapping-all-types.json"));
543544

0 commit comments

Comments
 (0)