Class FileDataSourceValidator
- All Implemented Interfaces:
DataSourceValidator
DataSourceValidator for file-based external sources (S3, GCS, Azure).
Plugins pass their supportedSchemes() (e.g. Set.of("s3", "s3a", "s3n"))
directly to the constructor — the validator appends "://" internally when
matching resource URIs, so plugins do not need to duplicate the scheme list with
URI suffixes.
The format dataset setting selects a file format explicitly (any
registered format name, or FormatNameResolver.FORMAT_AUTO / absent to infer
from the resource extension). Format-specific dataset fields (e.g. CSV's
delimiter, Parquet's optimized_reader) are validated against the
resolved format: explicit format → resource extension → unknown.
Both require a FileDataSourceValidator.FormatConfigKeyResolver set via
withFormatConfigKeyResolver(org.elasticsearch.xpack.esql.datasources.spi.FileDataSourceValidator.FormatConfigKeyResolver, java.util.Set<java.lang.String>). Without a resolver the validator cannot know
any format names, so format and all format-specific fields are rejected and
only the base dataset fields are accepted, preserving backward compatibility.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceResolves file-format metadata for dataset CRUD validation. -
Field Summary
FieldsModifier and TypeFieldDescriptionCoordinator-level data-shape keys accepted on a dataset, sourced from each owning component's ownCONFIG_KEYSplus theformatselector.static final StringError shown when a data source is provisioned with federated authentication settings while theesql.datasource.federated_identity.enabledcluster setting is disabled. -
Constructor Summary
ConstructorsConstructorDescriptionFileDataSourceValidator(String type, BiFunction<Map<String, Object>, Set<String>, DataSourceConfiguration> configFactory, Set<String> supportedSchemes) -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcannotDetermineFormatError(String resource, Set<String> formatSpecificKeys) The validation error reported when a format-specific setting is present but the resource's format cannot be determined (no usableformatvalue and an unknown or absent extension).type()Type identifier, e.g.static StringunknownFormatError(String format, Set<String> knownFormats) The validation error reported when an explicitformatvalue is not a registered format.validateDataset(Map<String, DataSourceSetting> datasourceSettings, String resource, Map<String, Object> datasetSettings) Validates dataset settings.validateDatasource(Map<String, Object> datasourceSettings) Validates settings and wraps them inDataSourceSettingso secret classification travels into cluster state.Merge-aware variant used when a PUT replaces an existing data source:existingSecretKeysnames secret fields already stored for it, so a request that omits one still satisfies credential-completeness checks.withFederatedIdentityEnabled(BooleanSupplier supplier) Returns a new validator that gates federated workload-identity authentication on the supplied boolean supplier.withFormatConfigKeyResolver(FileDataSourceValidator.FormatConfigKeyResolver resolver, Set<String> compressionExtensions) Returns a new validator that resolves a dataset's file format (from an explicitformatsetting or the resource extension) and validates format-specific fields against it.withManagedIdentityEnabled(BooleanSupplier supplier) Returns a new validator that gatesauth=managed_identityon the supplied boolean supplier.
-
Field Details
-
FEDERATED_IDENTITY_DISABLED_MESSAGE
Error shown when a data source is provisioned with federated authentication settings while theesql.datasource.federated_identity.enabledcluster setting is disabled. The federated fields themselves remain registered on each configuration regardless of the setting, so a PUT carrying them produces this explicit message rather than an "unknown setting" error.- See Also:
-
COORDINATOR_DATASET_KEYS
Coordinator-level data-shape keys accepted on a dataset, sourced from each owning component's ownCONFIG_KEYSplus theformatselector. This is exactlyFileSourceFactory.COORDINATOR_KEYSminus the EXTERNAL-only knob (reader) and the internal_datasourceenvelope, a relationship pinned byFileSourceFactoryValidationTests. Keeping it sourced from the components' constants holds the dataset vocabulary in lockstep with the query path, so a new coordinator key cannot silently regress to EXTERNAL-only.
-
-
Constructor Details
-
FileDataSourceValidator
public FileDataSourceValidator(String type, BiFunction<Map<String, Object>, Set<String>, DataSourceConfiguration> configFactory, Set<String> supportedSchemes)
-
-
Method Details
-
withFormatConfigKeyResolver
public FileDataSourceValidator withFormatConfigKeyResolver(FileDataSourceValidator.FormatConfigKeyResolver resolver, Set<String> compressionExtensions) Returns a new validator that resolves a dataset's file format (from an explicitformatsetting or the resource extension) and validates format-specific fields against it. The resolver maps a format name to its config keys, an extension to its format name, and enumerates the known format names for error messages.The
compressionExtensionsset restricts compound-extension fallback (e.g.data.csv.gz) to only known compression suffixes, mirroring the runtime resolution inFormatReaderRegistry/DecompressionCodecRegistry. -
withManagedIdentityEnabled
Returns a new validator that gatesauth=managed_identityon the supplied boolean supplier. The supplier is called on each validation. Pass a live supplier (e.g. backed by anAtomicBooleanupdated viaClusterSettings.addSettingsUpdateConsumer) so that operator changes toesql.datasource.managed_identity.enabledtake effect without a node restart. -
withFederatedIdentityEnabled
Returns a new validator that gates federated workload-identity authentication on the supplied boolean supplier. The supplier is called on each validation. Wire it toExternalSourceSettings#FEDERATED_IDENTITY_ENABLEDin production; tests pass a fixed supplier to exercise both states without depending on a live cluster setting. -
type
Description copied from interface:DataSourceValidatorType identifier, e.g."s3","gcs","azure".- Specified by:
typein interfaceDataSourceValidator
-
validateDatasource
Description copied from interface:DataSourceValidatorValidates settings and wraps them inDataSourceSettingso secret classification travels into cluster state. ThrowsValidationExceptionif invalid.- Specified by:
validateDatasourcein interfaceDataSourceValidator
-
validateDatasource
public Map<String,DataSourceSetting> validateDatasource(Map<String, Object> datasourceSettings, Set<String> existingSecretKeys) Description copied from interface:DataSourceValidatorMerge-aware variant used when a PUT replaces an existing data source:existingSecretKeysnames secret fields already stored for it, so a request that omits one still satisfies credential-completeness checks. The returned map, likeDataSourceValidator.validateDatasource(Map), contains only the fields present indatasourceSettings; carrying the omitted secret's stored value forward is the caller's job. The default ignoresexistingSecretKeysand delegates to the single-arg overload.- Specified by:
validateDatasourcein interfaceDataSourceValidator
-
validateDataset
public Map<String,Object> validateDataset(Map<String, DataSourceSetting> datasourceSettings, String resource, Map<String, Object> datasetSettings) Description copied from interface:DataSourceValidatorValidates dataset settings. Returns plain values — datasets carry no secrets. Parent passed for cross-checks. ThrowsValidationExceptionif invalid.- Specified by:
validateDatasetin interfaceDataSourceValidator
-
unknownFormatError
The validation error reported when an explicitformatvalue is not a registered format. Exposed so tests assert the exact message against the same literal production emits, rather than a brittle substring.knownFormatsis sorted for a deterministic message. -
cannotDetermineFormatError
The validation error reported when a format-specific setting is present but the resource's format cannot be determined (no usableformatvalue and an unknown or absent extension). Exposed so tests assert the exact message against the same literal production emits.formatSpecificKeysis sorted for a deterministic message.
-