Class DeclaredSchemaResolver
java.lang.Object
org.elasticsearch.xpack.esql.datasources.DeclaredSchemaResolver
Bridges a
DatasetMapping (the String-typed, server-side declaration) into the ES|QL currency the
external-source resolver speaks: Attributes typed with DataType, plus the logical→physical
rename map. This is the one place the declared type String becomes a DataType; everything
downstream (planner, reader, output) sees logical names only.
Used by the resolver for both supply modes: in strict mode (dynamic: false) declaredAttributes(org.elasticsearch.cluster.metadata.DatasetMapping)
is the entire resolved schema (no file is read); in non-strict mode the declared attributes overlay (and beat) the
inferred ones of the same column. The renameMap(org.elasticsearch.cluster.metadata.DatasetMapping) rides the typed DeclaredReadSpec to the data node
and is consumed at the reader-facing boundaries via PhysicalNames; ColumnMapping/reconciliation stay
in logical space. It carries only renamed columns.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordResult of a non-strict overlay: the user-facingoutput(declared columns renamed to their logical name and retyped, undeclared columns untouched) and the per-filefileSchemathe reader resolves against the file. -
Method Summary
Modifier and TypeMethodDescriptiondeclaredAttributes(DatasetMapping mapping) The declared columns as ES|QL attributes, keyed by logical name and in declaration order.overlayNonStrict(List<Attribute> inferred, DatasetMapping mapping) Apply a non-strict (dynamic: true) mapping over an inferred schema: every declared column overrides the inferred column of the same physical name — renamed to its logical name and pinned to its declared type — while undeclared inferred columns pass through unchanged.overlayNonStrict(List<Attribute> inferred, DatasetMapping mapping, boolean lenient) AsoverlayNonStrict(List, DatasetMapping)butlenientcontrols the unmatched-declared-column policy: strict (false) errors when a declared column is absent frominferred(used against the unified schema, where every declared column must appear); lenient (true) skips it (used per-file, where a column may legitimately be absent from one file under union-by-name).renameMap(DatasetMapping mapping) Logical→physical name map for the columns that declare apathmove (logical name ≠ physical name).
-
Method Details
-
declaredAttributes
The declared columns as ES|QL attributes, keyed by logical name and in declaration order. Returns an empty list when there is nomappingsblock (an _id-only mappings block contributes no columns). -
renameMap
Logical→physical name map for the columns that declare apathmove (logical name ≠ physical name). Empty when nothing renames. The map is 1:1 (a physical is claimed by at most one logical — validation enforces it), so itsPhysicalNames.inverse(java.util.Map<java.lang.String, java.lang.String>)is well-defined.PhysicalNamesuses this at the last-mile reader-facing boundaries; the reader andColumnMappingstay rename-agnostic. -
overlayNonStrict
public static DeclaredSchemaResolver.Overlaid overlayNonStrict(List<Attribute> inferred, DatasetMapping mapping) Apply a non-strict (dynamic: true) mapping over an inferred schema: every declared column overrides the inferred column of the same physical name — renamed to its logical name and pinned to its declared type — while undeclared inferred columns pass through unchanged. A declared column whose physical name is absent from the inferred schema is an error (it references a column the source does not have). -
overlayNonStrict
public static DeclaredSchemaResolver.Overlaid overlayNonStrict(List<Attribute> inferred, DatasetMapping mapping, boolean lenient) AsoverlayNonStrict(List, DatasetMapping)butlenientcontrols the unmatched-declared-column policy: strict (false) errors when a declared column is absent frominferred(used against the unified schema, where every declared column must appear); lenient (true) skips it (used per-file, where a column may legitimately be absent from one file under union-by-name).
-