-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SQL: Perform lazy evaluation of mismatched mappings
Move away from performing eager, fail-fast validation of mismatched mapping to a lazy evaluation based on the fields actually used in the query. This allows queries to run on the parts of the indices that "work" which is not just convenient but also a necessity for large mappings (like logging) where alignment is hard/impossible to achieve. Fix #35659
- Loading branch information
Showing
5 changed files
with
227 additions
and
53 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
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
57 changes: 57 additions & 0 deletions
57
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/type/InvalidMappedField.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,57 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.sql.type; | ||
|
||
import org.elasticsearch.xpack.sql.analysis.index.MappingException; | ||
|
||
import java.util.Objects; | ||
|
||
import static java.util.Collections.emptyMap; | ||
|
||
/** | ||
* Representation of field mapped differently across indices. | ||
* Used during mapping discovery only. | ||
*/ | ||
public class InvalidMappedField extends EsField { | ||
|
||
private final String errorMessage; | ||
|
||
public InvalidMappedField(String name, String errorMessage) { | ||
super(name, DataType.UNSUPPORTED, emptyMap(), false); | ||
this.errorMessage = errorMessage; | ||
} | ||
|
||
public String errorMessage() { | ||
return errorMessage; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(super.hashCode(), errorMessage); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (super.equals(obj)) { | ||
InvalidMappedField other = (InvalidMappedField) obj; | ||
return Objects.equals(errorMessage, other.errorMessage); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
@Override | ||
public EsField getExactField() { | ||
throw new MappingException("Field [" + getName() + "] is invalid, cannot access it"); | ||
|
||
} | ||
|
||
@Override | ||
public boolean isExact() { | ||
return false; | ||
} | ||
} |
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
Oops, something went wrong.