Skip to content

Commit 4e77c92

Browse files
committed
Review fixes
1 parent 156754e commit 4e77c92

File tree

11 files changed

+39
-43
lines changed

11 files changed

+39
-43
lines changed

server/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import java.util.Objects;
5353
import java.util.Set;
5454

55+
import static org.elasticsearch.index.mapper.MappedFieldType.FieldExtractPreference.DOC_VALUES;
5556
import static org.elasticsearch.index.query.RangeQueryBuilder.GTE_FIELD;
5657
import static org.elasticsearch.index.query.RangeQueryBuilder.GT_FIELD;
5758
import static org.elasticsearch.index.query.RangeQueryBuilder.LTE_FIELD;
@@ -369,7 +370,10 @@ public AllReader reader(LeafReaderContext context) throws IOException {
369370

370371
@Override
371372
public BlockLoader blockLoader(BlockLoaderContext blContext) {
372-
if (hasDocValues()) {
373+
if (rangeType != RangeType.DATE) {
374+
throw new UnsupportedOperationException("loading blocks is only supported for date fields");
375+
}
376+
if (blContext.fieldExtractPreference() == DOC_VALUES && hasDocValues()) {
373377
return new DateRangeDocValuesLoader(name());
374378
}
375379
throw new IllegalStateException("Cannot load blocks without doc values");

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypeResolutions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static TypeResolution isRepresentableExceptCountersDenseVectorAndAggregat
9393
);
9494
}
9595

96-
public static TypeResolution isRepresentableExceptCountersSpatialDenseVectorAndAggregateMetricDouble(
96+
public static TypeResolution isRepresentableExceptUnsortableTypes(
9797
Expression e,
9898
String operationName,
9999
ParamOrdinal paramOrd

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/BlockFactory.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,6 @@ public LongRangeBlock newConstantLongRangeBlock(LongRangeBlockBuilder.LongRange
503503
}
504504
}
505505

506-
public LongRangeBlock newLongRangeBlock(long[] fromValues, long[] toValues, int positions) {
507-
var from = newLongArrayVector(fromValues, positions).asBlock();
508-
var to = newLongArrayVector(toValues, positions).asBlock();
509-
return new LongRangeArrayBlock(from, to);
510-
}
511-
512506
/**
513507
* Returns the maximum number of bytes that a Block should be backed by a primitive array before switching to using BigArrays.
514508
*/

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/LongRangeBlock.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.elasticsearch.core.ReleasableIterator;
1212

1313
/**
14-
* Block that stores aggregate_metric_double values.
14+
* Block that stores long ranges.
1515
*/
1616
public sealed interface LongRangeBlock extends Block permits LongRangeArrayBlock, ConstantNullBlock {
1717
@Override
@@ -30,7 +30,7 @@ public sealed interface LongRangeBlock extends Block permits LongRangeArrayBlock
3030
* Returns {@code true} if the given blocks are equal to each other, otherwise {@code false}.
3131
* Two blocks are considered equal if they have the same position count, and contain the same
3232
* values (including absent null values) in the same order. This definition ensures that the
33-
* equals method works properly across different implementations of the AggregateMetricDoubleBlock interface.
33+
* equals method works properly across different implementations of the LongRangeBlock interface.
3434
*/
3535
static boolean equals(LongRangeBlock lhs, LongRangeBlock rhs) {
3636
if (lhs == rhs) {

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/LongRangeBlockBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public record LongRange(Long from, Long to) implements GenericNamedWriteable {
165165
);
166166

167167
public LongRange(StreamInput in) throws IOException {
168-
this(in.readOptionalLong(), in.readOptionalLong());
168+
this(in.readLong(), in.readLong());
169169
}
170170

171171
@Override

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/AllSupportedFieldsTestCase.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,7 @@ private static boolean supportedInIndex(DataType t) {
472472
// You can't index these - they are just constants.
473473
DATE_PERIOD, TIME_DURATION, GEOTILE, GEOHASH, GEOHEX,
474474
// TODO fix geo
475-
CARTESIAN_POINT, CARTESIAN_SHAPE,
476-
// Excluded for now, until a proper workaround
477-
DATE_RANGE -> false;
475+
CARTESIAN_POINT, CARTESIAN_SHAPE -> false;
478476
default -> true;
479477
};
480478
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
age_range:integer_range, description:keyword
2-
0..2, Baby
3-
2..4, Toddler
4-
3..5, Preschooler
5-
5..12, Child
6-
13..20, Adolescent
7-
20..40, Young Adult
8-
40..60, Middle-aged
9-
60..80, Senior
10-
80..100, Elderly
11-
100..200, Incredible
2+
0..2 , Baby
3+
2..4 , Toddler
4+
3..5 , Preschooler
5+
5..12 , Child
6+
13..20 , Adolescent
7+
20..40 , Young Adult
8+
40..60 , Middle-aged
9+
60..80 , Senior
10+
80..100, Elderly
11+
100..200, Incredible
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
date_range:date_range, decade:integer, description:keyword
2-
1900-01-01..1910-01-01, 1900, Edwardian Era
3-
1910-01-01..1920-01-01, 1910, Ragtime Era
4-
1920-01-01..1930-01-01, 1920, Roaring Twenties
5-
1930-01-01..1940-01-01, 1930, Dirty Thirties
6-
1940-01-01..1950-01-01, 1940, Fabulous Forties
7-
1950-01-01..1960-01-01, 1950, Nifty Fifties
8-
1960-01-01..1970-01-01, 1960, Swinging Sixties
9-
1970-01-01..1980-01-01, 1970, Groovy Seventies
10-
1980-01-01..1990-01-01, 1980, Radical Eighties
11-
1990-01-01..2000-01-01, 1990, Nineties Nostalgia
12-
2000-01-01..2010-01-01, 2000, Innovation Explosion Decade
13-
2010-01-01..2020-01-01, 2010, Renaissance Decade
14-
2020-01-01..2030-01-01, 2020, Empowerment Era
1+
date_range:date_range, decade:integer, description:keyword
2+
1900-01-01..1910-01-01, 1900, Edwardian Era
3+
1910-01-01..1920-01-01, 1910, Ragtime Era
4+
1920-01-01..1930-01-01, 1920, Roaring Twenties
5+
1930-01-01..1940-01-01, 1930, Dirty Thirties
6+
1940-01-01..1950-01-01, 1940, Fabulous Forties
7+
1950-01-01..1960-01-01, 1950, Nifty Fifties
8+
1960-01-01..1970-01-01, 1960, Swinging Sixties
9+
1970-01-01..1980-01-01, 1970, Groovy Seventies
10+
1980-01-01..1990-01-01, 1980, Radical Eighties
11+
1990-01-01..2000-01-01, 1990, Nineties Nostalgia
12+
2000-01-01..2010-01-01, 2000, Innovation Explosion Decade
13+
2010-01-01..2020-01-01, 2010, Renaissance Decade
14+
2020-01-01..2030-01-01, 2020, Empowerment Era

x-pack/plugin/esql/qa/testFixtures/src/main/resources/date.csv-spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,7 @@ emp_no:integer | birth_date:date | hire_date:date
20312031

20322032
dateRange
20332033
required_capability: date_range_field_type
2034-
from date_ranges;
2034+
FROM date_ranges;
20352035

20362036
date_range:date_range | decade:integer | description:keyword
20372037
1900-01-01..1910-01-01 | 1900 | Edwardian Era

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMax.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import java.util.List;
2727

2828
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.DEFAULT;
29-
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentableExceptCountersSpatialDenseVectorAndAggregateMetricDouble;
29+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentableExceptUnsortableTypes;
3030

3131
/**
3232
* Reduce a multivalued field to a single valued field containing the maximum value.
@@ -68,7 +68,7 @@ public String getWriteableName() {
6868

6969
@Override
7070
protected TypeResolution resolveFieldType() {
71-
return isRepresentableExceptCountersSpatialDenseVectorAndAggregateMetricDouble(field(), sourceText(), DEFAULT);
71+
return isRepresentableExceptUnsortableTypes(field(), sourceText(), DEFAULT);
7272
}
7373

7474
@Override

0 commit comments

Comments
 (0)