Record Class ErrorPolicy
java.lang.Object
java.lang.Record
org.elasticsearch.xpack.esql.datasources.spi.ErrorPolicy
- Record Components:
mode- how to handle rows with parse errorsmaxErrors- maximum number of errors to tolerate before failing (only meaningful forSKIP_ROWandNULL_FIELD)maxErrorRatio- maximum fraction of rows (0.0–1.0) that may be errors before failing; 0.0 disables ratio-based tolerance (only meaningful forSKIP_ROWandNULL_FIELD)logErrors- whether to log each skipped/null-filled row at WARN level
public record ErrorPolicy(ErrorPolicy.Mode mode, long maxErrors, double maxErrorRatio, boolean logErrors)
extends Record
Configures how format readers handle malformed or unparseable rows.
Error modes
| ES/ESQL | Spark | DuckDB | ClickHouse | Behaviour |
|---|---|---|---|---|
FAIL_FAST | FAILFAST | (default) | errors_num=0 | Abort on first error |
SKIP_ROW | DROPMALFORMED | ignore_errors | errors_num>0 | Drop the entire bad row |
NULL_FIELD | PERMISSIVE | — | — | Null-fill unparseable fields, keep the row |
Error budget
maxErrors and maxErrorRatio only apply to ErrorPolicy.Mode.SKIP_ROW and
ErrorPolicy.Mode.NULL_FIELD. They are ignored in ErrorPolicy.Mode.FAIL_FAST (which always aborts
on the first error). When both are set, whichever limit is hit first triggers failure.
| ES/ESQL | DuckDB | ClickHouse |
|---|---|---|
max_errors | rejects_limit | input_format_allow_errors_num |
max_error_ratio | — | input_format_allow_errors_ratio |
Usage
FROM s3://bucket/data.csv WITH {"max_errors": 100}
FROM s3://bucket/data.csv WITH {"error_mode": "skip_row", "max_error_ratio": 0.1}
FROM s3://bucket/data.csv WITH {"error_mode": "null_field"}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDetermines what happens to a row (or field) that fails to parse. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ErrorPolicySkip all malformed rows without limit, logging each one.static final ErrorPolicyFail immediately on any malformed row. -
Constructor Summary
ConstructorsConstructorDescriptionErrorPolicy(long maxErrors, boolean logErrors) Convenience constructor forErrorPolicy.Mode.SKIP_ROWwithout ratio-based tolerance.ErrorPolicy(long maxErrors, double maxErrorRatio, boolean logErrors) Convenience constructor forErrorPolicy.Mode.SKIP_ROWwith ratio-based tolerance.ErrorPolicy(ErrorPolicy.Mode mode, long maxErrors, double maxErrorRatio, boolean logErrors) Creates an instance of aErrorPolicyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisBudgetExceeded(long errorsSoFar, long rowsSoFar) Checks whether the error budget has been exceeded given the current counts.booleanbooleanisStrict()booleanReturns the value of thelogErrorsrecord component.doubleReturns the value of themaxErrorRatiorecord component.longReturns the value of themaxErrorsrecord component.mode()Returns the value of themoderecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
STRICT
Fail immediately on any malformed row. -
LENIENT
Skip all malformed rows without limit, logging each one.
-
-
Constructor Details
-
ErrorPolicy
Creates an instance of aErrorPolicyrecord class.- Parameters:
mode- the value for themoderecord componentmaxErrors- the value for themaxErrorsrecord componentmaxErrorRatio- the value for themaxErrorRatiorecord componentlogErrors- the value for thelogErrorsrecord component
-
ErrorPolicy
public ErrorPolicy(long maxErrors, boolean logErrors) Convenience constructor forErrorPolicy.Mode.SKIP_ROWwithout ratio-based tolerance. -
ErrorPolicy
public ErrorPolicy(long maxErrors, double maxErrorRatio, boolean logErrors) Convenience constructor forErrorPolicy.Mode.SKIP_ROWwith ratio-based tolerance.
-
-
Method Details
-
isStrict
public boolean isStrict() -
isPermissive
public boolean isPermissive() -
isBudgetExceeded
public boolean isBudgetExceeded(long errorsSoFar, long rowsSoFar) Checks whether the error budget has been exceeded given the current counts. Always returnsfalseforErrorPolicy.Mode.FAIL_FAST(which never reaches this check — it throws immediately in the caller).- Parameters:
errorsSoFar- total errors encountered so farrowsSoFar- total rows processed so far (including errors)- Returns:
- true if the budget is exceeded and processing should stop
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
mode
Returns the value of themoderecord component.- Returns:
- the value of the
moderecord component
-
maxErrors
public long maxErrors()Returns the value of themaxErrorsrecord component.- Returns:
- the value of the
maxErrorsrecord component
-
maxErrorRatio
public double maxErrorRatio()Returns the value of themaxErrorRatiorecord component.- Returns:
- the value of the
maxErrorRatiorecord component
-
logErrors
public boolean logErrors()Returns the value of thelogErrorsrecord component.- Returns:
- the value of the
logErrorsrecord component
-