Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7fcb1d6
WIP Start supporting DATE_NANOS in LOOKUP JOIN
craigtaverner May 9, 2025
68aaa6d
Update docs/changelog/127962.yaml
craigtaverner May 9, 2025
9c13833
Update docs/changelog/127962.yaml
craigtaverner May 9, 2025
657f1c0
Possible solution with passing tests
craigtaverner May 20, 2025
5592bb5
Merge branch 'main' into lookup_join_date_nanos
craigtaverner May 22, 2025
23bf41a
Use lookup-prefix index name to avoid clash with union-types tests
craigtaverner May 22, 2025
b9a7134
More correct date_nanos support by minimizing date rendering and parsing
craigtaverner May 27, 2025
9a582f9
Merge remote-tracking branch 'origin/main' into lookup_join_date_nanos
craigtaverner May 27, 2025
bb81b8a
Improved solution, rather have date parsing entirely skipped in DateF…
craigtaverner May 28, 2025
adf53f9
Merge remote-tracking branch 'origin/main' into lookup_join_date_nanos
craigtaverner May 30, 2025
71b056f
Add EsqlCapabilities to block csv-spec tests in mixed clusters
craigtaverner May 30, 2025
f211158
Make csv-spec test multi-node and serverless safe with a SORT
craigtaverner Jun 1, 2025
b906e3f
Merge remote-tracking branch 'origin/main' into lookup_join_date_nanos
craigtaverner Jun 1, 2025
dd39363
Merge branch 'main' into lookup_join_date_nanos
craigtaverner Jun 2, 2025
9c02a93
Merge branch 'main' into lookup_join_date_nanos
craigtaverner Jun 2, 2025
fd01818
After merging with main, fixed compile error
craigtaverner Jun 2, 2025
e5cdf7c
Reverted temporary change
craigtaverner Jun 2, 2025
cfbfecd
Merge branch 'main' into lookup_join_date_nanos
craigtaverner Jun 3, 2025
31d0375
Add tests asserting datetime/date_nanos cannot be mixed in joins
craigtaverner Jun 3, 2025
3b0e70f
Merge remote-tracking branch 'origin/main' into lookup_join_date_nanos
craigtaverner Jun 3, 2025
f478122
Fix after merging main
craigtaverner Jun 3, 2025
7de8ee7
Add unit tests for new DateFieldType methods
craigtaverner Jun 4, 2025
b61a325
Merge remote-tracking branch 'origin/main' into lookup_join_date_nanos
craigtaverner Jun 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/127962.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 127962
summary: Support DATE_NANOS in LOOKUP JOIN
area: ES|QL
type: bug
issues:
- 127249
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ public DateFieldType(String name) {
);
}

public DateFieldType(String name, boolean isIndexed) {
public DateFieldType(String name, boolean isIndexed, Resolution resolution) {
this(
name,
isIndexed,
Expand All @@ -599,13 +599,17 @@ public DateFieldType(String name, boolean isIndexed) {
false,
false,
DEFAULT_DATE_TIME_FORMATTER,
Resolution.MILLISECONDS,
resolution,
null,
null,
Collections.emptyMap()
);
}

public DateFieldType(String name, boolean isIndexed) {
this(name, isIndexed, Resolution.MILLISECONDS);
}

public DateFieldType(String name, DateFormatter dateFormatter) {
this(name, true, true, false, true, false, false, dateFormatter, Resolution.MILLISECONDS, null, null, Collections.emptyMap());
}
Expand Down Expand Up @@ -821,6 +825,54 @@ public static long parseToLong(
return resolution.convert(dateParser.parse(BytesRefs.toString(value), now, roundUp, zone));
}

/**
* Similar to the {@link DateFieldType#termQuery} method, but works on dates that are already parsed to a long
* in the same precision as the field mapper.
*/
public Query equalityQuery(Long value, @Nullable SearchExecutionContext context) {
return rangeQuery(value, value, true, true, context);
}

/**
* Similar to the existing
* {@link DateFieldType#rangeQuery(Object, Object, boolean, boolean, ShapeRelation, ZoneId, DateMathParser, SearchExecutionContext)}
* method, but works on dates that are already parsed to a long in the same precision as the field mapper.
*/
public Query rangeQuery(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth adding a couple of unit tests to DateFieldTypeTests just so we can be sure these do reasonable things. These methods are so much simpler than the others, but it'd be nice to have something really simple to read the exercises it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Long lowerTerm,
Long upperTerm,
boolean includeLower,
boolean includeUpper,
SearchExecutionContext context
) {
failIfNotIndexedNorDocValuesFallback(context);
long l, u;
if (lowerTerm == null) {
l = Long.MIN_VALUE;
} else {
l = (includeLower == false) ? lowerTerm + 1 : lowerTerm;
}
if (upperTerm == null) {
u = Long.MAX_VALUE;
} else {
u = (includeUpper == false) ? upperTerm - 1 : upperTerm;
}
Query query;
if (isIndexed()) {
query = LongPoint.newRangeQuery(name(), l, u);
if (hasDocValues()) {
Query dvQuery = SortedNumericDocValuesField.newSlowRangeQuery(name(), l, u);
query = new IndexOrDocValuesQuery(query, dvQuery);
}
} else {
query = SortedNumericDocValuesField.newSlowRangeQuery(name(), l, u);
}
if (hasDocValues() && context.indexSortedOnField(name())) {
query = new XIndexSortSortedNumericDocValuesRangeQuery(name(), l, u, query);
}
return query;
}

@Override
public Query distanceFeatureQuery(Object origin, String pivot, SearchExecutionContext context) {
failIfNotIndexedNorDocValuesFallback(context);
Expand Down
Loading
Loading