Class SynthesizeExternalSource

java.lang.Object
org.elasticsearch.xpack.esql.datasources.SynthesizeExternalSource

public final class SynthesizeExternalSource extends Object
Producer-side composition of the _source metadata column for external datasets. For each row, the bound data columns (<name, value> pairs at that row's position) are gathered into a Map, JSON-serialized via Source.fromMap(Map, XContentType), and emitted as a BytesRef of type DataType.SOURCE.

Renders via Source.fromMap(java.util.Map<java.lang.String, java.lang.Object>, org.elasticsearch.xcontent.XContentType) so the output matches what SourceLoader produces for natively-stored indexed documents — a downstream consumer that already knows how to parse _source (e.g. Kibana's row-detail view) works unchanged.

This is producer-side and per-row; callers project _source sparingly because the cost is linear in the bound data column count and dominated by JSON serialization. The upstream binding gates _source only on explicit METADATA _source.

  • Method Details

    • composePage

      public static BytesRefBlock composePage(String[] dataColumnNames, DataType[] dataColumnTypes, Block[] dataColumnBlocks, int positions, BlockFactory factory)
      Build a _source block of length positions by composing one JSON object per row from the supplied data columns. Each entry in dataColumnNames is paired positionally with the matching type in dataColumnTypes and block in dataColumnBlocks; columns named in SYNTHETIC_COLUMN_NAMES (framework-injected channels like ColumnExtractor.ROW_POSITION_COLUMN) are excluded. A leading underscore on its own is NOT a filter — user data columns named e.g. _corrupt_record or _status are legitimate data and pass through to the rendered object. Values render per their declared DataType, mirroring what the response layer (PositionToXContent) emits for the same columns — see ExternalScalarRenderer.render(java.lang.Object, org.elasticsearch.xpack.esql.core.type.DataType).