Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions docs/changelog/145924.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
area: ES|QL
issues: []
pr: 145924
summary: Fix filter pushdown review nits
type: enhancement
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ private FormatReader readerForFile(FileSplit fileSplit) {
fileColumnNames.add(name);
DataType castTarget = mapping.cast(i);
if (castTarget != null) {
DataType fileType = inferFileType(attributes.get(i).dataType(), castTarget);
DataType fileType = inferFileType(castTarget);
if (fileType != null) {
fileColumnTypes.put(name, fileType);
}
Expand All @@ -517,21 +517,16 @@ private FormatReader readerForFile(FileSplit fileSplit) {
return formatReader.withPushedFilter(null);
}

/**
* Infers the file's native type from the unified attribute type and the cast target.
* The cast target is the unified (wider) type; the file has the narrower type.
*/
/**
* Infers the file's native type from the cast target. Only returns a narrower type when
* the adaptation is safe for integral comparisons (LONG→INTEGER). DOUBLE→INTEGER narrowing
* is not supported because literal truncation can cause incorrect predicate semantics.
* the adaptation is safe for integral comparisons (LONG→INTEGER).
* DOUBLE→INTEGER narrowing is not supported because {@code Number.longValue()} truncates
* fractional values, which changes comparison semantics (e.g., {@code col < 2.7} vs {@code col < 2}).
*/
private static DataType inferFileType(DataType unifiedType, DataType castTarget) {
private static DataType inferFileType(DataType castTarget) {
if (castTarget == DataType.LONG) {
return DataType.INTEGER;
}
// DOUBLE→INTEGER narrowing is intentionally not supported: Number.longValue() truncates
// fractional values, which can change comparison semantics (e.g., col < 2.7 vs col < 2).
return null;
}

Expand Down
Loading