Class FormatNameResolver
Both the optimizer (PushFiltersToSource) and execution (FileSourceFactory)
need to resolve which format reader to use for a given query. This class centralises that
logic so the two code paths cannot diverge.
Resolution priority:
readerconfig key — reader alias mapped to format nameformatconfig key: explicit format override (the sentinelFORMAT_AUTOand an empty value mean "no override" and fall through to the extension)- File extension extracted from the source path
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final FeatureFlagGates the prototype parquet-rs native reader and its publicreader=parquet-rsselector.static final StringSentinelformatvalue meaning "no explicit override, infer from the resource extension".static final StringFormat name registered by the Java parquet reader.static final StringFormat name registered by the parquet-rs native reader.static final StringReader alias accepted inWITH {"reader": "..."}for the Java parquet reader.static final StringReader alias accepted inWITH {"reader": "..."}for the parquet-rs native reader. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringNormalizes a rawformatvalue to its canonical stored form —trim()thentoLowerCase(Locale.ROOT)— ornullwhen the value is absent.static booleanThe parquet-rs reader is live iff the parquet-rs sub-flag is on.static StringResolves a rawformatconfig value into a usable format name, or returnsnullwhen the value means "infer from the resource extension" (blank, or theFORMAT_AUTOsentinel).static StringreaderAliasToFormat(String alias) Maps a reader alias to its format name.static StringResolves the format name from the WITH config map and/or the source path.static StringresolveFormatName(Map<String, Object> config, String objectName, FormatReaderRegistry registry) Resolves the format name (e.g.static FormatReaderresolveReader(Map<String, Object> config, String objectName, FormatReaderRegistry registry) Resolves the format reader using config and source path, looking up the result in the registry.
-
Field Details
-
CONFIG_FORMAT
- See Also:
-
FORMAT_AUTO
Sentinelformatvalue meaning "no explicit override, infer from the resource extension". Shared with the dataset CRUD validator so the create path and this read path treatautoidentically. Without this, a stored or EXTERNALformat=autowould reachregistry.byName("auto")and throw.- See Also:
-
READER_PARQUET_RS
Reader alias accepted inWITH {"reader": "..."}for the parquet-rs native reader.- See Also:
-
READER_JAVA
Reader alias accepted inWITH {"reader": "..."}for the Java parquet reader.- See Also:
-
FORMAT_PARQUET
Format name registered by the Java parquet reader.- See Also:
-
FORMAT_PARQUET_RS
Format name registered by the parquet-rs native reader.- See Also:
-
ESQL_EXTERNAL_PARQUET_RS_FEATURE_FLAG
Gates the prototype parquet-rs native reader and its publicreader=parquet-rsselector. Snapshot-on, release-off; override in release with-Des.esql_external_parquet_rs_feature_flag_enabled=true. Lives here (and not in the parquet-rs plugin module) so this esql-core resolver can gate the alias whileParquetRsPlugin— which already depends on this class — reuses the same flag for format registration.
-
-
Method Details
-
parquetRsEnabled
public static boolean parquetRsEnabled()The parquet-rs reader is live iff the parquet-rs sub-flag is on. -
normalizeFormatValue
Normalizes a rawformatvalue to its canonical stored form —trim()thentoLowerCase(Locale.ROOT)— ornullwhen the value is absent. This is the single source of the normalization, so the create-time storage representation and the query-time resolution cannot drift. UnlikeparseExplicitFormat(java.lang.Object)it does not collapse theFORMAT_AUTOsentinel: the CRUD validator storesautoverbatim so it round-trips, whereas the read path treats it as "infer from the extension". -
parseExplicitFormat
Resolves a rawformatconfig value into a usable format name, or returnsnullwhen the value means "infer from the resource extension" (blank, or theFORMAT_AUTOsentinel). Normalizes vianormalizeFormatValue(java.lang.Object), so a value accepted here resolves identically at query time.This is the single source of truth for
formatsentinel handling. Both the CRUD validator (FileDataSourceValidator.explicitFormat) and the query-time resolvers (resolve(java.util.Map<java.lang.String, java.lang.Object>, java.lang.String),resolveReader(java.util.Map<java.lang.String, java.lang.Object>, java.lang.String, org.elasticsearch.xpack.esql.datasources.FormatReaderRegistry)) delegate here so new sentinels only need one edit. -
resolve
Resolves the format name from the WITH config map and/or the source path.Not compound-extension aware: the extension fallback here is a naive last-dot, so a compound name like
hits.csv.gzresolves to the codec suffix"gz", not"csv". A caller that keys operator dispatch or reader lookup on the format over a possibly-compressed resource must useresolveFormatName(java.util.Map<java.lang.String, java.lang.Object>, java.lang.String, org.elasticsearch.xpack.esql.datasources.FormatReaderRegistry)(orresolveReader(java.util.Map<java.lang.String, java.lang.Object>, java.lang.String, org.elasticsearch.xpack.esql.datasources.FormatReaderRegistry)), which routes through the compound-aware registry. Kept for the config-override-only path (FileSourceFactorypasses an empty source path);PushFiltersToSourcestill calls it over the exec source path and so misses filter pushdown on compressed text — migrating that caller is tracked separately.- Returns:
- the format name (e.g. "parquet", "parquet-rs", "orc"), or null if undetermined
-
readerAliasToFormat
Maps a reader alias to its format name.- Returns:
- the format name, or null if the alias is not recognised
-
supportedReaderAliases
-
resolveFormatName
public static String resolveFormatName(Map<String, Object> config, String objectName, FormatReaderRegistry registry) Resolves the format name (e.g."csv","parquet") using config and source path, routed through the registry so it is compound-extension aware. Unlikeresolve(java.util.Map<java.lang.String, java.lang.Object>, java.lang.String), which last-dots the path and would yield the compression codec suffix ("gz") for a compound name likehits.csv.gz, this delegates toresolveReader(java.util.Map<java.lang.String, java.lang.Object>, java.lang.String, org.elasticsearch.xpack.esql.datasources.FormatReaderRegistry)and reads backFormatReader.formatName()—FormatReader.formatName()returns the wrapped format, so the result equals the format name the inferred read path (FileSourceFactory) would produce. The strict resolver keys operator-factory dispatch on the result, so it uses this rather thanresolve(java.util.Map<java.lang.String, java.lang.Object>, java.lang.String)to avoid diverging from the read path over a compressed resource. -
resolveReader
public static FormatReader resolveReader(Map<String, Object> config, String objectName, FormatReaderRegistry registry) Resolves the format reader using config and source path, looking up the result in the registry.Config-based overrides (
reader,format) are resolved viaresolve(java.util.Map<java.lang.String, java.lang.Object>, java.lang.String)and looked up by name. Extension-based resolution delegates toFormatReaderRegistry.byExtensionwhich handles compound extensions (e.g..ndjson.bz) and compression codecs.
-