Record Class DeclaredReadSpec
java.lang.Object
java.lang.Record
org.elasticsearch.xpack.esql.datasources.DeclaredReadSpec
- All Implemented Interfaces:
Writeable
public record DeclaredReadSpec(Map<String,String> renames, String idPath, Map<String,String> dateFormats, Set<String> declaredTypeColumns)
extends Record
implements Writeable
The read-instructions a declared dataset mapping derives for the data node. Carried as a first-class field along the
resolution → plan → operator seam (
ExternalSourceResolution.ResolvedSource →
ExternalRelation
→ ExternalSourceExec →
SourceOperatorContext → the operator factory), so a new
declared read-instruction is one typed field rather than another string key fenced and sniffed out of the config map.
renames— the declared logical→physical column renames apathmove produces. Consumed at the reader-facing boundary viaPhysicalNames(projection + read schema physicalization) and by the pushdown planner rules. Empty when the mapping renames nothing.idPath— the declaredmappings._id.path(a single logical column name), ornull. When present the data node stamps_idfrom that column instead of the synthetic (file+row-position) identity (VirtualColumnIterator).dateFormats— per-column date parse-patterns, keyed by logical column name. The text readers parse that column's timestamps with the given pattern (via the ESDateFormatter) instead of the ISO default / file-leveldatetime_format. Physicalized to file-column names at the reader boundary (FileSourceFactory). Empty when no column declares aformat.declaredTypeColumns— the logical names of the columns whose target type came from an explicit declaration (as opposed to inference). A declared type licenses a lossy read-time coercion toward it — e.g. a declaredintegerover anint64file column narrows per value (null on overflow). An inferred target must never narrow: a cross-file clash widens-or-nulls. The by-name columnar readers (Parquet/ORC) key their whole-column incompatibility null-fill on this set — a declared column keeps the coercion escape, an inferred one null-fills whenever the file type is not widening-compatible. Physicalized to file-column names at the reader boundary (FileSourceFactory); the text readers ignore it (they parse straight into the target). Empty when the mapping declares no column types.
Writeable: its wire gate lives on the enclosing plan nodes, which only read/write it when the
dataset_declared_schema transport version is supported (mirrors how DatasetMapping.Mappings is gated
by its container rather than self-gating).-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DeclaredReadSpecThe empty spec — nothing declared. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thedateFormatsrecord component.Returns the value of thedeclaredTypeColumnsrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.idPath()Returns the value of theidPathrecord component.booleanisEmpty()True when the mapping declared nothing for the data node to apply — no rename,_id.path, format, or type.static DeclaredReadSpecConvenience for a spec with no declared date formats and no declared column types.static DeclaredReadSpecof(Map<String, String> renames, String idPath, Map<String, String> dateFormats, Set<String> declaredTypeColumns) Canonical factory: collapses an all-empty spec to theNONEsingleton so an absent declaration always serializes identically.static DeclaredReadSpecreadFrom(StreamInput in) renames()Returns the value of therenamesrecord component.final StringtoString()Returns a string representation of this record class.voidwriteTo(StreamOutput out)
-
Field Details
-
NONE
The empty spec — nothing declared. The default carried on every non-declared read.
-
-
Constructor Details
-
DeclaredReadSpec
public DeclaredReadSpec(Map<String, String> renames, @Nullable String idPath, Map<String, String> dateFormats, Set<String> declaredTypeColumns) Creates an instance of aDeclaredReadSpecrecord class.- Parameters:
renames- the value for therenamesrecord componentidPath- the value for theidPathrecord componentdateFormats- the value for thedateFormatsrecord componentdeclaredTypeColumns- the value for thedeclaredTypeColumnsrecord component
-
-
Method Details
-
of
public static DeclaredReadSpec of(@Nullable Map<String, String> renames, @Nullable String idPath, @Nullable Map<String, String> dateFormats, @Nullable Set<String> declaredTypeColumns) Canonical factory: collapses an all-empty spec to theNONEsingleton so an absent declaration always serializes identically. The emptiness test is delegated toisEmpty()(the single source of truth), so a future field added to this record only has to updateisEmpty()for the collapse to stay correct. -
of
Convenience for a spec with no declared date formats and no declared column types. -
isEmpty
public boolean isEmpty()True when the mapping declared nothing for the data node to apply — no rename,_id.path, format, or type. -
writeTo
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
readFrom
- Throws:
IOException
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
renames
Returns the value of therenamesrecord component.- Returns:
- the value of the
renamesrecord component
-
idPath
Returns the value of theidPathrecord component.- Returns:
- the value of the
idPathrecord component
-
dateFormats
Returns the value of thedateFormatsrecord component.- Returns:
- the value of the
dateFormatsrecord component
-
declaredTypeColumns
Returns the value of thedeclaredTypeColumnsrecord component.- Returns:
- the value of the
declaredTypeColumnsrecord component
-