-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ESQL: fix non-null value being returned for unsupported data types in…
… ValueSources (#100656) * Refine (and fix) all cases where an unsupported data type field's values are returned from SourceValues. * Improve unsupported data types handling in TopN
- Loading branch information
Showing
9 changed files
with
175 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 100656 | ||
summary: "ESQL: fix non-null value being returned for unsupported data types in `ValueSources`" | ||
area: ES|QL | ||
type: bug | ||
issues: | ||
- 100048 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...te/src/main/java/org/elasticsearch/compute/operator/topn/UnsupportedTypesTopNEncoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.compute.operator.topn; | ||
|
||
import org.apache.lucene.util.BytesRef; | ||
import org.elasticsearch.compute.operator.BreakingBytesRefBuilder; | ||
|
||
/** | ||
* TopNEncoder for data types that are unsupported. This is just a placeholder class, reaching the encode/decode methods here is a bug. | ||
* | ||
* While this class is needed to build the TopNOperator value and key extractors infrastructure, encoding/decoding is needed | ||
* when actually sorting on a field (which shouldn't be possible for unsupported data types) using key extractors, or when encoding/decoding | ||
* unsupported data types fields values (which should always be "null" by convention) using value extractors. | ||
*/ | ||
class UnsupportedTypesTopNEncoder extends SortableTopNEncoder { | ||
@Override | ||
public int encodeBytesRef(BytesRef value, BreakingBytesRefBuilder bytesRefBuilder) { | ||
throw new UnsupportedOperationException("Encountered a bug; trying to encode an unsupported data type value for TopN"); | ||
} | ||
|
||
@Override | ||
public BytesRef decodeBytesRef(BytesRef bytes, BytesRef scratch) { | ||
throw new UnsupportedOperationException("Encountered a bug; trying to decode an unsupported data type value for TopN"); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "UnsupportedTypesTopNEncoder"; | ||
} | ||
|
||
@Override | ||
public TopNEncoder toSortable() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public TopNEncoder toUnsortable() { | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters