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"}
Client-visible warnings
Whenever the non-strict modes (ErrorPolicy.Mode.SKIP_ROW and ErrorPolicy.Mode.NULL_FIELD) cause a row to be
dropped or a field to be null-filled, format readers emit response Warning headers via
SkipWarnings: a one-time summary identifying the file, plus per-event details capped at
SkipWarnings.MAX_ADDED_WARNINGS entries (further events collapse into a single
"further warnings suppressed" line). This is independent of logErrors, which still only
controls server-side WARN logging.-
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 Stringstatic final Stringstatic final Stringstatic final ErrorPolicySkip all malformed rows without limit, logging each one.static final ErrorPolicyNull-fill unparseable fields without limit, keeping every row — the opt-in leniency for a declared-type coercion failure (a bad per-value token nulls the cell and emits a responseWarningheader) viaerror_mode: null_field.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.static ErrorPolicyfromConfig(Map<String, Object> config, ErrorPolicy defaultPolicy) Resolves anErrorPolicyfrom the user'sWITHoptions.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.modeName()Lowercase, locale-insensitive name ofmode(), suitable for user-facing messages (e.g.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. -
PERMISSIVE
Null-fill unparseable fields without limit, keeping every row — the opt-in leniency for a declared-type coercion failure (a bad per-value token nulls the cell and emits a responseWarningheader) viaerror_mode: null_field. No format defaults to this: every reader inherits the baseFormatReader.defaultErrorPolicy()==STRICT. A columnar batch cannot drop a single row, soErrorPolicy.Mode.SKIP_ROWdegrades to this same null-field behavior there. -
CONFIG_MAX_ERRORS
Config keys recognised byfromConfig(java.util.Map<java.lang.String, java.lang.Object>, org.elasticsearch.xpack.esql.datasources.spi.ErrorPolicy). Mirrored as constants so format plugins do not have to hard-code the strings.- See Also:
-
CONFIG_MAX_ERROR_RATIO
- See Also:
-
CONFIG_ERROR_MODE
- See Also:
-
CONFIG_KEYS
-
-
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() -
modeName
Lowercase, locale-insensitive name ofmode(), suitable for user-facing messages (e.g."skip_row","null_field"). Matches the parser input accepted byErrorPolicy.Mode.parse(String). -
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
-
fromConfig
Resolves anErrorPolicyfrom the user'sWITHoptions. ReturnsdefaultPolicywhen none ofCONFIG_ERROR_MODE,CONFIG_MAX_ERRORS, orCONFIG_MAX_ERROR_RATIOare set.Validation matches what
FileSourceFactoryapplied historically: invalid mode strings, non-numeric budgets, andFAIL_FASTcombined with budget keys are all rejected withIllegalArgumentException. -
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
-