From 43b2e877e0b937d491745081479e6a1b2edf93cc Mon Sep 17 00:00:00 2001
From: Patrick Doyle <810052+prdoyle@users.noreply.github.com>
Date: Wed, 19 Jun 2024 18:10:50 -0400
Subject: [PATCH 01/16] Revert "Move PluginsService to its own internal package
(#109872)" (#109946)
This reverts commit b9e7965184efb6da6b06de56821db13911803c3a.
---
.../script/ScriptScoreBenchmark.java | 2 +-
.../resources/checkstyle_suppressions.xml | 2 +-
.../plugin-cli/src/main/java/module-info.java | 25 ------------------
.../plugins/cli/InstallPluginAction.java | 2 +-
.../plugins/cli/RemovePluginAction.java | 2 +-
.../plugins/cli/InstallPluginActionTests.java | 2 +-
.../plugins/cli/ListPluginsCommandTests.java | 2 +-
.../plugins/cli/RemovePluginActionTests.java | 2 +-
.../plugins/cli/SyncPluginsActionTests.java | 2 +-
.../datastreams/DataStreamAutoshardingIT.java | 2 +-
.../AbstractFeatureMigrationIntegTest.java | 2 +-
.../s3/S3BlobStoreRepositoryMetricsTests.java | 2 +-
.../s3/S3BlobStoreRepositoryTests.java | 2 +-
.../s3/S3RepositoryThirdPartyTests.java | 2 +-
.../s3/RepositoryCredentialsTests.java | 2 +-
.../bootstrap/SpawnerNoBootstrapTests.java | 2 +-
.../http/HealthRestCancellationIT.java | 2 +-
.../http/SearchRestCancellationIT.java | 2 +-
.../action/IndicesRequestIT.java | 2 +-
.../action/admin/ReloadSecureSettingsIT.java | 2 +-
.../admin/cluster/tasks/ListTasksIT.java | 2 +-
...tReplicationActionRetryOnClosedNodeIT.java | 2 +-
.../coordination/RestHandlerNodesIT.java | 2 +-
.../cluster/routing/ShardRoutingRoleIT.java | 2 +-
.../indices/recovery/IndexRecoveryIT.java | 2 +-
.../indices/recovery/TaskRecoveryIT.java | 2 +-
.../metrics/NodeIndexingMetricsIT.java | 2 +-
.../IndexFoldersDeletionListenerIT.java | 1 -
.../threadpool/SimpleThreadPoolIT.java | 2 +-
server/src/main/java/module-info.java | 1 -
...nsportNodesReloadSecureSettingsAction.java | 2 +-
.../org/elasticsearch/bootstrap/Security.java | 2 +-
.../org/elasticsearch/bootstrap/Spawner.java | 2 +-
.../metadata/DataStreamFactoryRetention.java | 2 +-
.../common/settings/ClusterSettings.java | 2 +-
.../elasticsearch/indices/IndicesService.java | 2 +-
.../indices/IndicesServiceBuilder.java | 2 +-
.../java/org/elasticsearch/node/Node.java | 2 +-
.../elasticsearch/node/NodeConstruction.java | 2 +-
.../org/elasticsearch/node/NodeService.java | 2 +-
.../node/NodeServiceProvider.java | 2 +-
.../plugins/{loading => }/ModuleSupport.java | 2 +-
.../plugins/{loading => }/PluginBundle.java | 4 +--
.../{loading => }/PluginIntrospector.java | 23 +---------------
.../PluginLoaderIndirection.java | 2 +-
.../plugins/{loading => }/PluginsService.java | 7 +----
.../plugins/{loading => }/PluginsUtils.java | 3 +--
.../StablePluginPlaceHolder.java | 4 +--
.../{loading => }/UberModuleClassLoader.java | 2 +-
.../plugins/internal/ReloadAwarePlugin.java | 3 +--
.../scanners/NamedComponentReader.java | 2 +-
.../scanners/StablePluginsRegistry.java | 2 +-
...HierarchyCircuitBreakerTelemetryTests.java | 2 +-
.../org/elasticsearch/node/NodeTests.java | 2 +-
.../plugins/PluginDescriptorTests.java | 2 --
.../PluginIntrospectorTests.java | 23 +---------------
.../{loading => }/PluginsServiceTests.java | 15 ++++-------
.../{loading => }/PluginsUtilsTests.java | 3 +--
.../UberModuleClassLoaderTests.java | 2 +-
.../internal/ReloadAwarePluginTests.java | 2 +-
.../scanners/StablePluginsRegistryTests.java | 2 +-
.../SearchTookTimeTelemetryTests.java | 2 +-
.../SearchTransportTelemetryTests.java | 2 +-
.../snapshots/SnapshotResiliencyTests.java | 2 +-
...ns.PluginsServiceTests$TestExtensionPoint} | 4 +--
.../plugins/{loading => }/dummy-plugin.jar | Bin
.../{loading => }/non-extensible-plugin.jar | Bin
.../support/CancellableActionTestPlugin.java | 2 +-
.../bootstrap/BootstrapForTesting.java | 2 +-
.../java/org/elasticsearch/node/MockNode.java | 4 +--
.../{loading => }/MockPluginsService.java | 5 +---
.../plugins/{loading => }/PluginTestUtil.java | 3 +--
.../test/AbstractBuilderTestCase.java | 4 +--
.../AbstractSearchCancellationTestCase.java | 2 +-
.../plugins/MockPluginsServiceTests.java | 1 -
...AutoscalingCapacityRestCancellationIT.java | 2 +-
.../TransportNodeDeprecationCheckAction.java | 2 +-
...nsportNodeDeprecationCheckActionTests.java | 2 +-
.../DownsampleActionSingleNodeTests.java | 2 +-
.../AbstractEqlBlockingIntegTestCase.java | 2 +-
.../exporter/http/HttpExporterIT.java | 2 +-
.../profiling/action/CancellationIT.java | 2 +-
...archableSnapshotsPrewarmingIntegTests.java | 2 +-
.../authc/jwt/JwtRealmSingleNodeTests.java | 2 +-
.../ProfileCancellationIntegTests.java | 2 +-
.../AbstractSqlBlockingIntegTestCase.java | 2 +-
.../WriteLoadForecasterIT.java | 2 +-
87 files changed, 87 insertions(+), 180 deletions(-)
delete mode 100644 distribution/tools/plugin-cli/src/main/java/module-info.java
rename server/src/main/java/org/elasticsearch/plugins/{loading => }/ModuleSupport.java (99%)
rename server/src/main/java/org/elasticsearch/plugins/{loading => }/PluginBundle.java (96%)
rename server/src/main/java/org/elasticsearch/plugins/{loading => }/PluginIntrospector.java (87%)
rename server/src/main/java/org/elasticsearch/plugins/{loading => }/PluginLoaderIndirection.java (95%)
rename server/src/main/java/org/elasticsearch/plugins/{loading => }/PluginsService.java (99%)
rename server/src/main/java/org/elasticsearch/plugins/{loading => }/PluginsUtils.java (99%)
rename server/src/main/java/org/elasticsearch/plugins/{loading => }/StablePluginPlaceHolder.java (85%)
rename server/src/main/java/org/elasticsearch/plugins/{loading => }/UberModuleClassLoader.java (99%)
rename server/src/test/java/org/elasticsearch/plugins/{loading => }/PluginIntrospectorTests.java (93%)
rename server/src/test/java/org/elasticsearch/plugins/{loading => }/PluginsServiceTests.java (98%)
rename server/src/test/java/org/elasticsearch/plugins/{loading => }/PluginsUtilsTests.java (99%)
rename server/src/test/java/org/elasticsearch/plugins/{loading => }/UberModuleClassLoaderTests.java (99%)
rename server/src/test/resources/META-INF/services/{org.elasticsearch.plugins.loading.PluginsServiceTests$TestExtensionPoint => org.elasticsearch.plugins.PluginsServiceTests$TestExtensionPoint} (71%)
rename server/src/test/resources/org/elasticsearch/plugins/{loading => }/dummy-plugin.jar (100%)
rename server/src/test/resources/org/elasticsearch/plugins/{loading => }/non-extensible-plugin.jar (100%)
rename test/framework/src/main/java/org/elasticsearch/plugins/{loading => }/MockPluginsService.java (97%)
rename test/framework/src/main/java/org/elasticsearch/plugins/{loading => }/PluginTestUtil.java (96%)
diff --git a/benchmarks/src/main/java/org/elasticsearch/benchmark/script/ScriptScoreBenchmark.java b/benchmarks/src/main/java/org/elasticsearch/benchmark/script/ScriptScoreBenchmark.java
index fb502302be8f0..5a27abe8be2a4 100644
--- a/benchmarks/src/main/java/org/elasticsearch/benchmark/script/ScriptScoreBenchmark.java
+++ b/benchmarks/src/main/java/org/elasticsearch/benchmark/script/ScriptScoreBenchmark.java
@@ -33,8 +33,8 @@
import org.elasticsearch.index.mapper.NumberFieldMapper.NumberType;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.plugins.ScriptPlugin;
-import org.elasticsearch.plugins.loading.PluginsService;
import org.elasticsearch.script.DocReader;
import org.elasticsearch.script.DocValuesDocReader;
import org.elasticsearch.script.ScoreScript;
diff --git a/build-tools-internal/src/main/resources/checkstyle_suppressions.xml b/build-tools-internal/src/main/resources/checkstyle_suppressions.xml
index de5a8aea34980..fd01993951959 100644
--- a/build-tools-internal/src/main/resources/checkstyle_suppressions.xml
+++ b/build-tools-internal/src/main/resources/checkstyle_suppressions.xml
@@ -20,7 +20,7 @@
-
+
diff --git a/distribution/tools/plugin-cli/src/main/java/module-info.java b/distribution/tools/plugin-cli/src/main/java/module-info.java
deleted file mode 100644
index 4898125790e37..0000000000000
--- a/distribution/tools/plugin-cli/src/main/java/module-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import org.elasticsearch.cli.CliToolProvider;
-
-module org.elasticsearch.plugins.cli {
- requires jopt.simple;
- requires org.apache.lucene.core;
- requires org.apache.lucene.suggest;
- requires org.bouncycastle.fips.core;
- requires org.bouncycastle.pg;
- requires org.elasticsearch.base;
- requires org.elasticsearch.cli;
- requires org.elasticsearch.plugin.scanner;
- requires org.elasticsearch.server;
- requires org.elasticsearch.xcontent;
- requires org.objectweb.asm;
-
- provides CliToolProvider with org.elasticsearch.plugins.cli.PluginCliProvider, org.elasticsearch.plugins.cli.SyncPluginsCliProvider;
-}
diff --git a/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/InstallPluginAction.java b/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/InstallPluginAction.java
index 9bfe000feb81e..c7bee4a6c172d 100644
--- a/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/InstallPluginAction.java
+++ b/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/InstallPluginAction.java
@@ -41,7 +41,7 @@
import org.elasticsearch.plugin.scanner.NamedComponentScanner;
import org.elasticsearch.plugins.Platforms;
import org.elasticsearch.plugins.PluginDescriptor;
-import org.elasticsearch.plugins.loading.PluginsUtils;
+import org.elasticsearch.plugins.PluginsUtils;
import org.objectweb.asm.ClassReader;
import java.io.BufferedReader;
diff --git a/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/RemovePluginAction.java b/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/RemovePluginAction.java
index 6d19641fb372a..4714ef202b258 100644
--- a/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/RemovePluginAction.java
+++ b/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/RemovePluginAction.java
@@ -13,7 +13,7 @@
import org.elasticsearch.cli.UserException;
import org.elasticsearch.core.IOUtils;
import org.elasticsearch.env.Environment;
-import org.elasticsearch.plugins.loading.PluginsUtils;
+import org.elasticsearch.plugins.PluginsUtils;
import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;
diff --git a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/InstallPluginActionTests.java b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/InstallPluginActionTests.java
index fe18507398e1c..3dc7af07d4d83 100644
--- a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/InstallPluginActionTests.java
+++ b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/InstallPluginActionTests.java
@@ -50,7 +50,7 @@
import org.elasticsearch.plugin.scanner.NamedComponentScanner;
import org.elasticsearch.plugins.Platforms;
import org.elasticsearch.plugins.PluginDescriptor;
-import org.elasticsearch.plugins.loading.PluginTestUtil;
+import org.elasticsearch.plugins.PluginTestUtil;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.PosixPermissionsResetter;
import org.elasticsearch.test.compiler.InMemoryJavaCompiler;
diff --git a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/ListPluginsCommandTests.java b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/ListPluginsCommandTests.java
index cec6b2c7881b1..b225bc441794a 100644
--- a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/ListPluginsCommandTests.java
+++ b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/ListPluginsCommandTests.java
@@ -18,7 +18,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.TestEnvironment;
-import org.elasticsearch.plugins.loading.PluginTestUtil;
+import org.elasticsearch.plugins.PluginTestUtil;
import org.junit.Before;
import java.io.IOException;
diff --git a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/RemovePluginActionTests.java b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/RemovePluginActionTests.java
index 9d9300155e9cb..73e89fc948029 100644
--- a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/RemovePluginActionTests.java
+++ b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/RemovePluginActionTests.java
@@ -17,7 +17,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.TestEnvironment;
-import org.elasticsearch.plugins.loading.PluginTestUtil;
+import org.elasticsearch.plugins.PluginTestUtil;
import org.elasticsearch.test.ESTestCase;
import org.junit.Before;
diff --git a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/SyncPluginsActionTests.java b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/SyncPluginsActionTests.java
index 1e9002a7db392..9802b4039bb7b 100644
--- a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/SyncPluginsActionTests.java
+++ b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/cli/SyncPluginsActionTests.java
@@ -14,8 +14,8 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.TestEnvironment;
+import org.elasticsearch.plugins.PluginTestUtil;
import org.elasticsearch.plugins.cli.SyncPluginsAction.PluginChanges;
-import org.elasticsearch.plugins.loading.PluginTestUtil;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.VersionUtils;
import org.hamcrest.Matchers;
diff --git a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamAutoshardingIT.java b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamAutoshardingIT.java
index 7bc0192b723ce..a4c9a9d3e1c67 100644
--- a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamAutoshardingIT.java
+++ b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamAutoshardingIT.java
@@ -51,7 +51,7 @@
import org.elasticsearch.index.shard.ShardPath;
import org.elasticsearch.index.store.StoreStats;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.telemetry.InstrumentType;
import org.elasticsearch.telemetry.Measurement;
diff --git a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/AbstractFeatureMigrationIntegTest.java b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/AbstractFeatureMigrationIntegTest.java
index f7e07a82e00fb..3bbc8e4b969ee 100644
--- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/AbstractFeatureMigrationIntegTest.java
+++ b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/AbstractFeatureMigrationIntegTest.java
@@ -28,8 +28,8 @@
import org.elasticsearch.indices.AssociatedIndexDescriptor;
import org.elasticsearch.indices.SystemIndexDescriptor;
import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.plugins.SystemIndexPlugin;
-import org.elasticsearch.plugins.loading.PluginsService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.index.IndexVersionUtils;
import org.elasticsearch.xcontent.XContentBuilder;
diff --git a/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryMetricsTests.java b/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryMetricsTests.java
index d88cf885ef921..f8503bca3ec67 100644
--- a/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryMetricsTests.java
+++ b/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryMetricsTests.java
@@ -20,7 +20,7 @@
import org.elasticsearch.common.collect.Iterators;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.SuppressForbidden;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
import org.elasticsearch.repositories.s3.S3BlobStore.Operation;
diff --git a/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryTests.java b/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryTests.java
index 3b9eff683dbbf..88f0e01db3e6a 100644
--- a/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryTests.java
+++ b/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryTests.java
@@ -38,7 +38,7 @@
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.indices.recovery.RecoverySettings;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.repositories.Repository;
import org.elasticsearch.repositories.RepositoryData;
diff --git a/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3RepositoryThirdPartyTests.java b/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3RepositoryThirdPartyTests.java
index 8ff9fb478c402..5064910723ab6 100644
--- a/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3RepositoryThirdPartyTests.java
+++ b/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3RepositoryThirdPartyTests.java
@@ -30,7 +30,7 @@
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.indices.recovery.RecoverySettings;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.repositories.AbstractThirdPartyRepositoryTestCase;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.repositories.blobstore.RequestedRangeNotSatisfiedException;
diff --git a/modules/repository-s3/src/test/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java b/modules/repository-s3/src/test/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java
index bd7827be1cca4..9a1d12fab0af5 100644
--- a/modules/repository-s3/src/test/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java
+++ b/modules/repository-s3/src/test/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java
@@ -21,7 +21,7 @@
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.env.Environment;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.rest.AbstractRestChannel;
import org.elasticsearch.rest.RestRequest;
diff --git a/qa/no-bootstrap-tests/src/test/java/org/elasticsearch/bootstrap/SpawnerNoBootstrapTests.java b/qa/no-bootstrap-tests/src/test/java/org/elasticsearch/bootstrap/SpawnerNoBootstrapTests.java
index 96de064424312..6369e02e1f605 100644
--- a/qa/no-bootstrap-tests/src/test/java/org/elasticsearch/bootstrap/SpawnerNoBootstrapTests.java
+++ b/qa/no-bootstrap-tests/src/test/java/org/elasticsearch/bootstrap/SpawnerNoBootstrapTests.java
@@ -22,7 +22,7 @@
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.plugins.Platforms;
-import org.elasticsearch.plugins.loading.PluginTestUtil;
+import org.elasticsearch.plugins.PluginTestUtil;
import org.elasticsearch.test.GraalVMThreadsFilter;
import org.elasticsearch.test.MockLog;
diff --git a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/HealthRestCancellationIT.java b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/HealthRestCancellationIT.java
index 6da08b71a6d58..dc298fc616506 100644
--- a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/HealthRestCancellationIT.java
+++ b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/HealthRestCancellationIT.java
@@ -24,7 +24,7 @@
import org.elasticsearch.health.node.HealthInfo;
import org.elasticsearch.plugins.HealthPlugin;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import java.util.ArrayList;
import java.util.Collection;
diff --git a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/SearchRestCancellationIT.java b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/SearchRestCancellationIT.java
index 462be7eb85283..73dd1525f8a08 100644
--- a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/SearchRestCancellationIT.java
+++ b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/SearchRestCancellationIT.java
@@ -27,7 +27,7 @@
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.script.MockScriptPlugin;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptType;
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java
index 7969e401d1677..920677e8c4b4a 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java
@@ -73,7 +73,7 @@
import org.elasticsearch.indices.TestIndexNameExpressionResolver;
import org.elasticsearch.plugins.NetworkPlugin;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.script.MockScriptPlugin;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptType;
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/ReloadSecureSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/ReloadSecureSettingsIT.java
index 9eb603ad894d3..5d4a922ec3e11 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/ReloadSecureSettingsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/ReloadSecureSettingsIT.java
@@ -23,8 +23,8 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.plugins.ReloadablePlugin;
-import org.elasticsearch.plugins.loading.PluginsService;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.BeforeClass;
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/tasks/ListTasksIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/tasks/ListTasksIT.java
index 0b0344187c8c6..4a076cb3b6e66 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/tasks/ListTasksIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/tasks/ListTasksIT.java
@@ -21,7 +21,7 @@
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.elasticsearch.threadpool.ThreadPool;
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/support/replication/TransportReplicationActionRetryOnClosedNodeIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/support/replication/TransportReplicationActionRetryOnClosedNodeIT.java
index 29abeb8badf90..b89cea7dff089 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/support/replication/TransportReplicationActionRetryOnClosedNodeIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/support/replication/TransportReplicationActionRetryOnClosedNodeIT.java
@@ -27,7 +27,7 @@
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.NetworkPlugin;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.threadpool.ThreadPool;
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RestHandlerNodesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RestHandlerNodesIT.java
index 08ae42c57fff1..5a7f4609a7d0f 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RestHandlerNodesIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RestHandlerNodesIT.java
@@ -18,7 +18,7 @@
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.test.ESIntegTestCase;
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/ShardRoutingRoleIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/ShardRoutingRoleIT.java
index 8aacf625e82cf..bb9324dd7d10c 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/ShardRoutingRoleIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/ShardRoutingRoleIT.java
@@ -48,7 +48,7 @@
import org.elasticsearch.plugins.ClusterPlugin;
import org.elasticsearch.plugins.EnginePlugin;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.search.builder.PointInTimeBuilder;
import org.elasticsearch.snapshots.SnapshotState;
import org.elasticsearch.test.ESIntegTestCase;
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java
index ea7df1cacf3e2..4f15b82ca1f16 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java
@@ -104,7 +104,7 @@
import org.elasticsearch.node.NodeClosedException;
import org.elasticsearch.plugins.AnalysisPlugin;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.repositories.Repository;
import org.elasticsearch.repositories.RepositoryData;
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/TaskRecoveryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/TaskRecoveryIT.java
index 833bd3a8c9e3c..16905dc5b4d37 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/TaskRecoveryIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/TaskRecoveryIT.java
@@ -16,7 +16,7 @@
import org.elasticsearch.index.engine.InternalEngine;
import org.elasticsearch.plugins.EnginePlugin;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.tasks.TaskInfo;
import org.elasticsearch.test.ESIntegTestCase;
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/monitor/metrics/NodeIndexingMetricsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/monitor/metrics/NodeIndexingMetricsIT.java
index ce0d7419e96e1..7b26cc5edf1bc 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/monitor/metrics/NodeIndexingMetricsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/monitor/metrics/NodeIndexingMetricsIT.java
@@ -19,7 +19,7 @@
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.telemetry.Measurement;
import org.elasticsearch.telemetry.TestTelemetryPlugin;
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/plugins/IndexFoldersDeletionListenerIT.java b/server/src/internalClusterTest/java/org/elasticsearch/plugins/IndexFoldersDeletionListenerIT.java
index 2d1b829b2e2dd..542a4cd2c4c92 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/plugins/IndexFoldersDeletionListenerIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/plugins/IndexFoldersDeletionListenerIT.java
@@ -21,7 +21,6 @@
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.indices.IndicesService;
-import org.elasticsearch.plugins.loading.PluginsService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.junit.annotations.TestLogging;
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/threadpool/SimpleThreadPoolIT.java b/server/src/internalClusterTest/java/org/elasticsearch/threadpool/SimpleThreadPoolIT.java
index a0bc6dd933756..44b6ef1d51ce0 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/threadpool/SimpleThreadPoolIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/threadpool/SimpleThreadPoolIT.java
@@ -12,7 +12,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.telemetry.InstrumentType;
import org.elasticsearch.telemetry.Measurement;
import org.elasticsearch.telemetry.TestTelemetryPlugin;
diff --git a/server/src/main/java/module-info.java b/server/src/main/java/module-info.java
index 4138036cbcea1..db7e3d40518ba 100644
--- a/server/src/main/java/module-info.java
+++ b/server/src/main/java/module-info.java
@@ -460,5 +460,4 @@
org.elasticsearch.serverless.shardhealth,
org.elasticsearch.serverless.apifiltering;
exports org.elasticsearch.lucene.spatial;
- exports org.elasticsearch.plugins.loading to org.elasticsearch.deprecation, org.elasticsearch.plugins.cli;
}
diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java
index 559bf803ef62a..f906b7d659b7b 100644
--- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java
+++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java
@@ -24,8 +24,8 @@
import org.elasticsearch.common.settings.KeyStoreWrapper;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.plugins.ReloadablePlugin;
-import org.elasticsearch.plugins.loading.PluginsService;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Security.java b/server/src/main/java/org/elasticsearch/bootstrap/Security.java
index 7b05e974f18dc..12edf344c72a2 100644
--- a/server/src/main/java/org/elasticsearch/bootstrap/Security.java
+++ b/server/src/main/java/org/elasticsearch/bootstrap/Security.java
@@ -19,7 +19,7 @@
import org.elasticsearch.jdk.JarHell;
import org.elasticsearch.logging.LogManager;
import org.elasticsearch.logging.Logger;
-import org.elasticsearch.plugins.loading.PluginsUtils;
+import org.elasticsearch.plugins.PluginsUtils;
import org.elasticsearch.secure_sm.SecureSM;
import org.elasticsearch.transport.TcpTransport;
diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Spawner.java b/server/src/main/java/org/elasticsearch/bootstrap/Spawner.java
index 0910b75563dbc..2d37da1d10245 100644
--- a/server/src/main/java/org/elasticsearch/bootstrap/Spawner.java
+++ b/server/src/main/java/org/elasticsearch/bootstrap/Spawner.java
@@ -16,7 +16,7 @@
import org.elasticsearch.nativeaccess.NativeAccess;
import org.elasticsearch.plugins.Platforms;
import org.elasticsearch.plugins.PluginDescriptor;
-import org.elasticsearch.plugins.loading.PluginsUtils;
+import org.elasticsearch.plugins.PluginsUtils;
import java.io.BufferedReader;
import java.io.Closeable;
diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamFactoryRetention.java b/server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamFactoryRetention.java
index 8f4b48aff6be5..5b96f92193e98 100644
--- a/server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamFactoryRetention.java
+++ b/server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamFactoryRetention.java
@@ -11,7 +11,7 @@
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.TimeValue;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
/**
* Holds the factory retention configuration. Factory retention is the global retention configuration meant to be
diff --git a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
index 944f0967456e3..d5f770ebb95fc 100644
--- a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
+++ b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
@@ -106,7 +106,7 @@
import org.elasticsearch.node.NodeRoleSettings;
import org.elasticsearch.persistent.PersistentTasksClusterService;
import org.elasticsearch.persistent.decider.EnableAssignmentDecider;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.readiness.ReadinessService;
import org.elasticsearch.repositories.fs.FsRepository;
import org.elasticsearch.rest.BaseRestHandler;
diff --git a/server/src/main/java/org/elasticsearch/indices/IndicesService.java b/server/src/main/java/org/elasticsearch/indices/IndicesService.java
index 79e1334211a2d..199bbc54fa3d6 100644
--- a/server/src/main/java/org/elasticsearch/indices/IndicesService.java
+++ b/server/src/main/java/org/elasticsearch/indices/IndicesService.java
@@ -133,7 +133,7 @@
import org.elasticsearch.node.Node;
import org.elasticsearch.plugins.FieldPredicate;
import org.elasticsearch.plugins.IndexStorePlugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
diff --git a/server/src/main/java/org/elasticsearch/indices/IndicesServiceBuilder.java b/server/src/main/java/org/elasticsearch/indices/IndicesServiceBuilder.java
index 0ba62ccc7aa41..d56cf3c2c1e1a 100644
--- a/server/src/main/java/org/elasticsearch/indices/IndicesServiceBuilder.java
+++ b/server/src/main/java/org/elasticsearch/indices/IndicesServiceBuilder.java
@@ -29,7 +29,7 @@
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.plugins.EnginePlugin;
import org.elasticsearch.plugins.IndexStorePlugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
import org.elasticsearch.search.internal.ShardSearchRequest;
diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java
index bbc0a4183c3b6..11eb8760b2dbb 100644
--- a/server/src/main/java/org/elasticsearch/node/Node.java
+++ b/server/src/main/java/org/elasticsearch/node/Node.java
@@ -68,7 +68,7 @@
import org.elasticsearch.plugins.ClusterPlugin;
import org.elasticsearch.plugins.MetadataUpgrader;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.readiness.ReadinessService;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.reservedstate.service.FileSettingsService;
diff --git a/server/src/main/java/org/elasticsearch/node/NodeConstruction.java b/server/src/main/java/org/elasticsearch/node/NodeConstruction.java
index 8b6b0a6d9c992..bcf8451e5fe54 100644
--- a/server/src/main/java/org/elasticsearch/node/NodeConstruction.java
+++ b/server/src/main/java/org/elasticsearch/node/NodeConstruction.java
@@ -156,6 +156,7 @@
import org.elasticsearch.plugins.NetworkPlugin;
import org.elasticsearch.plugins.PersistentTaskPlugin;
import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.plugins.RecoveryPlannerPlugin;
import org.elasticsearch.plugins.ReloadablePlugin;
import org.elasticsearch.plugins.RepositoryPlugin;
@@ -170,7 +171,6 @@
import org.elasticsearch.plugins.internal.ReloadAwarePlugin;
import org.elasticsearch.plugins.internal.RestExtension;
import org.elasticsearch.plugins.internal.SettingsExtension;
-import org.elasticsearch.plugins.loading.PluginsService;
import org.elasticsearch.readiness.ReadinessService;
import org.elasticsearch.repositories.RepositoriesModule;
import org.elasticsearch.repositories.RepositoriesService;
diff --git a/server/src/main/java/org/elasticsearch/node/NodeService.java b/server/src/main/java/org/elasticsearch/node/NodeService.java
index ee99a1bba19e1..059b05091a6ae 100644
--- a/server/src/main/java/org/elasticsearch/node/NodeService.java
+++ b/server/src/main/java/org/elasticsearch/node/NodeService.java
@@ -31,7 +31,7 @@
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.ingest.IngestService;
import org.elasticsearch.monitor.MonitorService;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.search.aggregations.support.AggregationUsageService;
diff --git a/server/src/main/java/org/elasticsearch/node/NodeServiceProvider.java b/server/src/main/java/org/elasticsearch/node/NodeServiceProvider.java
index 9114f2da6f43c..914dd51d0c6b2 100644
--- a/server/src/main/java/org/elasticsearch/node/NodeServiceProvider.java
+++ b/server/src/main/java/org/elasticsearch/node/NodeServiceProvider.java
@@ -26,7 +26,7 @@
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.indices.recovery.RecoverySettings;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.readiness.ReadinessService;
import org.elasticsearch.script.ScriptContext;
import org.elasticsearch.script.ScriptEngine;
diff --git a/server/src/main/java/org/elasticsearch/plugins/loading/ModuleSupport.java b/server/src/main/java/org/elasticsearch/plugins/ModuleSupport.java
similarity index 99%
rename from server/src/main/java/org/elasticsearch/plugins/loading/ModuleSupport.java
rename to server/src/main/java/org/elasticsearch/plugins/ModuleSupport.java
index 5072f21ec0552..e5f0004431b0e 100644
--- a/server/src/main/java/org/elasticsearch/plugins/loading/ModuleSupport.java
+++ b/server/src/main/java/org/elasticsearch/plugins/ModuleSupport.java
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-package org.elasticsearch.plugins.loading;
+package org.elasticsearch.plugins;
import org.elasticsearch.core.SuppressForbidden;
diff --git a/server/src/main/java/org/elasticsearch/plugins/loading/PluginBundle.java b/server/src/main/java/org/elasticsearch/plugins/PluginBundle.java
similarity index 96%
rename from server/src/main/java/org/elasticsearch/plugins/loading/PluginBundle.java
rename to server/src/main/java/org/elasticsearch/plugins/PluginBundle.java
index 4c9c25a71d994..154ffce6ba05f 100644
--- a/server/src/main/java/org/elasticsearch/plugins/loading/PluginBundle.java
+++ b/server/src/main/java/org/elasticsearch/plugins/PluginBundle.java
@@ -6,9 +6,7 @@
* Side Public License, v 1.
*/
-package org.elasticsearch.plugins.loading;
-
-import org.elasticsearch.plugins.PluginDescriptor;
+package org.elasticsearch.plugins;
import java.io.IOException;
import java.net.URL;
diff --git a/server/src/main/java/org/elasticsearch/plugins/loading/PluginIntrospector.java b/server/src/main/java/org/elasticsearch/plugins/PluginIntrospector.java
similarity index 87%
rename from server/src/main/java/org/elasticsearch/plugins/loading/PluginIntrospector.java
rename to server/src/main/java/org/elasticsearch/plugins/PluginIntrospector.java
index e3fb9e9c2e07d..8b7e4faa1f226 100644
--- a/server/src/main/java/org/elasticsearch/plugins/loading/PluginIntrospector.java
+++ b/server/src/main/java/org/elasticsearch/plugins/PluginIntrospector.java
@@ -6,30 +6,9 @@
* Side Public License, v 1.
*/
-package org.elasticsearch.plugins.loading;
+package org.elasticsearch.plugins;
import org.elasticsearch.core.SuppressForbidden;
-import org.elasticsearch.plugins.ActionPlugin;
-import org.elasticsearch.plugins.AnalysisPlugin;
-import org.elasticsearch.plugins.CircuitBreakerPlugin;
-import org.elasticsearch.plugins.ClusterPlugin;
-import org.elasticsearch.plugins.DiscoveryPlugin;
-import org.elasticsearch.plugins.EnginePlugin;
-import org.elasticsearch.plugins.ExtensiblePlugin;
-import org.elasticsearch.plugins.HealthPlugin;
-import org.elasticsearch.plugins.IndexStorePlugin;
-import org.elasticsearch.plugins.IngestPlugin;
-import org.elasticsearch.plugins.MapperPlugin;
-import org.elasticsearch.plugins.NetworkPlugin;
-import org.elasticsearch.plugins.PersistentTaskPlugin;
-import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.RecoveryPlannerPlugin;
-import org.elasticsearch.plugins.ReloadablePlugin;
-import org.elasticsearch.plugins.RepositoryPlugin;
-import org.elasticsearch.plugins.ScriptPlugin;
-import org.elasticsearch.plugins.SearchPlugin;
-import org.elasticsearch.plugins.ShutdownAwarePlugin;
-import org.elasticsearch.plugins.SystemIndexPlugin;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
diff --git a/server/src/main/java/org/elasticsearch/plugins/loading/PluginLoaderIndirection.java b/server/src/main/java/org/elasticsearch/plugins/PluginLoaderIndirection.java
similarity index 95%
rename from server/src/main/java/org/elasticsearch/plugins/loading/PluginLoaderIndirection.java
rename to server/src/main/java/org/elasticsearch/plugins/PluginLoaderIndirection.java
index d0f41eb1cbaf2..d4a703c163025 100644
--- a/server/src/main/java/org/elasticsearch/plugins/loading/PluginLoaderIndirection.java
+++ b/server/src/main/java/org/elasticsearch/plugins/PluginLoaderIndirection.java
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-package org.elasticsearch.plugins.loading;
+package org.elasticsearch.plugins;
import org.elasticsearch.plugins.loader.ExtendedPluginsClassLoader;
diff --git a/server/src/main/java/org/elasticsearch/plugins/loading/PluginsService.java b/server/src/main/java/org/elasticsearch/plugins/PluginsService.java
similarity index 99%
rename from server/src/main/java/org/elasticsearch/plugins/loading/PluginsService.java
rename to server/src/main/java/org/elasticsearch/plugins/PluginsService.java
index 2f6b6ed3ab0e1..038b03c5dd93f 100644
--- a/server/src/main/java/org/elasticsearch/plugins/loading/PluginsService.java
+++ b/server/src/main/java/org/elasticsearch/plugins/PluginsService.java
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-package org.elasticsearch.plugins.loading;
+package org.elasticsearch.plugins;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -28,11 +28,6 @@
import org.elasticsearch.jdk.JarHell;
import org.elasticsearch.jdk.ModuleQualifiedExportsService;
import org.elasticsearch.node.ReportingService;
-import org.elasticsearch.plugins.ExtensiblePlugin;
-import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.PluginApiInfo;
-import org.elasticsearch.plugins.PluginDescriptor;
-import org.elasticsearch.plugins.PluginRuntimeInfo;
import org.elasticsearch.plugins.scanners.StablePluginsRegistry;
import org.elasticsearch.plugins.spi.SPIClassIterator;
diff --git a/server/src/main/java/org/elasticsearch/plugins/loading/PluginsUtils.java b/server/src/main/java/org/elasticsearch/plugins/PluginsUtils.java
similarity index 99%
rename from server/src/main/java/org/elasticsearch/plugins/loading/PluginsUtils.java
rename to server/src/main/java/org/elasticsearch/plugins/PluginsUtils.java
index 8c90e8abc1818..becc5ef05e846 100644
--- a/server/src/main/java/org/elasticsearch/plugins/loading/PluginsUtils.java
+++ b/server/src/main/java/org/elasticsearch/plugins/PluginsUtils.java
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-package org.elasticsearch.plugins.loading;
+package org.elasticsearch.plugins;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -14,7 +14,6 @@
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.FileSystemUtils;
import org.elasticsearch.jdk.JarHell;
-import org.elasticsearch.plugins.PluginDescriptor;
import java.io.IOException;
import java.net.URL;
diff --git a/server/src/main/java/org/elasticsearch/plugins/loading/StablePluginPlaceHolder.java b/server/src/main/java/org/elasticsearch/plugins/StablePluginPlaceHolder.java
similarity index 85%
rename from server/src/main/java/org/elasticsearch/plugins/loading/StablePluginPlaceHolder.java
rename to server/src/main/java/org/elasticsearch/plugins/StablePluginPlaceHolder.java
index 09bff29977686..c1bc8fcfd12b7 100644
--- a/server/src/main/java/org/elasticsearch/plugins/loading/StablePluginPlaceHolder.java
+++ b/server/src/main/java/org/elasticsearch/plugins/StablePluginPlaceHolder.java
@@ -6,9 +6,7 @@
* Side Public License, v 1.
*/
-package org.elasticsearch.plugins.loading;
-
-import org.elasticsearch.plugins.Plugin;
+package org.elasticsearch.plugins;
class StablePluginPlaceHolder extends Plugin {
private final String name;
diff --git a/server/src/main/java/org/elasticsearch/plugins/loading/UberModuleClassLoader.java b/server/src/main/java/org/elasticsearch/plugins/UberModuleClassLoader.java
similarity index 99%
rename from server/src/main/java/org/elasticsearch/plugins/loading/UberModuleClassLoader.java
rename to server/src/main/java/org/elasticsearch/plugins/UberModuleClassLoader.java
index 6e0d33f7081af..dca3afb2ed745 100644
--- a/server/src/main/java/org/elasticsearch/plugins/loading/UberModuleClassLoader.java
+++ b/server/src/main/java/org/elasticsearch/plugins/UberModuleClassLoader.java
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-package org.elasticsearch.plugins.loading;
+package org.elasticsearch.plugins;
import org.elasticsearch.core.SuppressForbidden;
diff --git a/server/src/main/java/org/elasticsearch/plugins/internal/ReloadAwarePlugin.java b/server/src/main/java/org/elasticsearch/plugins/internal/ReloadAwarePlugin.java
index 3463d3ec64498..71228efe227c5 100644
--- a/server/src/main/java/org/elasticsearch/plugins/internal/ReloadAwarePlugin.java
+++ b/server/src/main/java/org/elasticsearch/plugins/internal/ReloadAwarePlugin.java
@@ -10,7 +10,6 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.ReloadablePlugin;
-import org.elasticsearch.plugins.loading.PluginsService;
/**
* A plugin that may receive a {@link ReloadablePlugin} in order to
@@ -23,7 +22,7 @@ public interface ReloadAwarePlugin {
*
*
This callback is in the form of an implementation of {@link ReloadablePlugin},
* but the implementation does not need to be a {@link org.elasticsearch.plugins.Plugin},
- * or be registered with {@link PluginsService}.
+ * or be registered with {@link org.elasticsearch.plugins.PluginsService}.
*
* @param reloadablePlugin A plugin that this plugin may be able to reload
*/
diff --git a/server/src/main/java/org/elasticsearch/plugins/scanners/NamedComponentReader.java b/server/src/main/java/org/elasticsearch/plugins/scanners/NamedComponentReader.java
index 96ddba9f2a175..ed32bd245977a 100644
--- a/server/src/main/java/org/elasticsearch/plugins/scanners/NamedComponentReader.java
+++ b/server/src/main/java/org/elasticsearch/plugins/scanners/NamedComponentReader.java
@@ -11,7 +11,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.core.Strings;
-import org.elasticsearch.plugins.loading.PluginBundle;
+import org.elasticsearch.plugins.PluginBundle;
import org.elasticsearch.xcontent.XContentParserConfiguration;
import java.io.BufferedInputStream;
diff --git a/server/src/main/java/org/elasticsearch/plugins/scanners/StablePluginsRegistry.java b/server/src/main/java/org/elasticsearch/plugins/scanners/StablePluginsRegistry.java
index 5c56f040a75a3..6e2780a08251f 100644
--- a/server/src/main/java/org/elasticsearch/plugins/scanners/StablePluginsRegistry.java
+++ b/server/src/main/java/org/elasticsearch/plugins/scanners/StablePluginsRegistry.java
@@ -8,7 +8,7 @@
package org.elasticsearch.plugins.scanners;
-import org.elasticsearch.plugins.loading.PluginBundle;
+import org.elasticsearch.plugins.PluginBundle;
import java.util.Collection;
import java.util.Collections;
diff --git a/server/src/test/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerTelemetryTests.java b/server/src/test/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerTelemetryTests.java
index 4e94827380a6e..2cbe1202520df 100644
--- a/server/src/test/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerTelemetryTests.java
+++ b/server/src/test/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerTelemetryTests.java
@@ -13,7 +13,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.telemetry.Measurement;
import org.elasticsearch.telemetry.RecordingInstruments;
diff --git a/server/src/test/java/org/elasticsearch/node/NodeTests.java b/server/src/test/java/org/elasticsearch/node/NodeTests.java
index dcee2f3cf9a8b..b36cafd694378 100644
--- a/server/src/test/java/org/elasticsearch/node/NodeTests.java
+++ b/server/src/test/java/org/elasticsearch/node/NodeTests.java
@@ -36,8 +36,8 @@
import org.elasticsearch.plugins.CircuitBreakerPlugin;
import org.elasticsearch.plugins.ClusterCoordinationPlugin;
import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.plugins.PluginsServiceTests;
import org.elasticsearch.plugins.RecoveryPlannerPlugin;
-import org.elasticsearch.plugins.loading.PluginsServiceTests;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.test.ESTestCase;
diff --git a/server/src/test/java/org/elasticsearch/plugins/PluginDescriptorTests.java b/server/src/test/java/org/elasticsearch/plugins/PluginDescriptorTests.java
index bc14f87f5b580..7ed4d975fe3be 100644
--- a/server/src/test/java/org/elasticsearch/plugins/PluginDescriptorTests.java
+++ b/server/src/test/java/org/elasticsearch/plugins/PluginDescriptorTests.java
@@ -12,8 +12,6 @@
import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules;
import org.elasticsearch.common.io.stream.ByteBufferStreamInput;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
-import org.elasticsearch.plugins.loading.PluginTestUtil;
-import org.elasticsearch.plugins.loading.PluginsUtils;
import org.elasticsearch.test.ESTestCase;
import java.io.IOException;
diff --git a/server/src/test/java/org/elasticsearch/plugins/loading/PluginIntrospectorTests.java b/server/src/test/java/org/elasticsearch/plugins/PluginIntrospectorTests.java
similarity index 93%
rename from server/src/test/java/org/elasticsearch/plugins/loading/PluginIntrospectorTests.java
rename to server/src/test/java/org/elasticsearch/plugins/PluginIntrospectorTests.java
index d341ecd72273d..5e80b6d217a55 100644
--- a/server/src/test/java/org/elasticsearch/plugins/loading/PluginIntrospectorTests.java
+++ b/server/src/test/java/org/elasticsearch/plugins/PluginIntrospectorTests.java
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-package org.elasticsearch.plugins.loading;
+package org.elasticsearch.plugins;
import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata;
import org.elasticsearch.cluster.routing.allocation.allocator.ShardsAllocator;
@@ -22,27 +22,6 @@
import org.elasticsearch.indices.recovery.plan.RecoveryPlannerService;
import org.elasticsearch.indices.recovery.plan.ShardSnapshotsService;
import org.elasticsearch.ingest.Processor;
-import org.elasticsearch.plugins.ActionPlugin;
-import org.elasticsearch.plugins.AnalysisPlugin;
-import org.elasticsearch.plugins.CircuitBreakerPlugin;
-import org.elasticsearch.plugins.ClusterPlugin;
-import org.elasticsearch.plugins.DiscoveryPlugin;
-import org.elasticsearch.plugins.EnginePlugin;
-import org.elasticsearch.plugins.ExtensiblePlugin;
-import org.elasticsearch.plugins.HealthPlugin;
-import org.elasticsearch.plugins.IndexStorePlugin;
-import org.elasticsearch.plugins.IngestPlugin;
-import org.elasticsearch.plugins.MapperPlugin;
-import org.elasticsearch.plugins.NetworkPlugin;
-import org.elasticsearch.plugins.PersistentTaskPlugin;
-import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.RecoveryPlannerPlugin;
-import org.elasticsearch.plugins.ReloadablePlugin;
-import org.elasticsearch.plugins.RepositoryPlugin;
-import org.elasticsearch.plugins.ScriptPlugin;
-import org.elasticsearch.plugins.SearchPlugin;
-import org.elasticsearch.plugins.ShutdownAwarePlugin;
-import org.elasticsearch.plugins.SystemIndexPlugin;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.PrivilegedOperations;
import org.elasticsearch.test.compiler.InMemoryJavaCompiler;
diff --git a/server/src/test/java/org/elasticsearch/plugins/loading/PluginsServiceTests.java b/server/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java
similarity index 98%
rename from server/src/test/java/org/elasticsearch/plugins/loading/PluginsServiceTests.java
rename to server/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java
index 6e4984e2dcf6d..28ebed88e8f3c 100644
--- a/server/src/test/java/org/elasticsearch/plugins/loading/PluginsServiceTests.java
+++ b/server/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-package org.elasticsearch.plugins.loading;
+package org.elasticsearch.plugins;
import org.apache.lucene.tests.util.LuceneTestCase;
import org.apache.lucene.util.Constants;
@@ -19,11 +19,6 @@
import org.elasticsearch.index.IndexModule;
import org.elasticsearch.jdk.ModuleQualifiedExportsService;
import org.elasticsearch.plugin.analysis.CharFilterFactory;
-import org.elasticsearch.plugins.ExtensiblePlugin;
-import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.PluginDescriptor;
-import org.elasticsearch.plugins.PluginRuntimeInfo;
-import org.elasticsearch.plugins.ScriptPlugin;
import org.elasticsearch.plugins.scanners.PluginInfo;
import org.elasticsearch.plugins.spi.BarPlugin;
import org.elasticsearch.plugins.spi.BarTestService;
@@ -318,18 +313,18 @@ public void testNonExtensibleDep() throws Exception {
public void testPassingMandatoryPluginCheck() {
PluginsService.checkMandatoryPlugins(
- Set.of("org.elasticsearch.plugins.loading.PluginsServiceTests$FakePlugin"),
- Set.of("org.elasticsearch.plugins.loading.PluginsServiceTests$FakePlugin")
+ Set.of("org.elasticsearch.plugins.PluginsServiceTests$FakePlugin"),
+ Set.of("org.elasticsearch.plugins.PluginsServiceTests$FakePlugin")
);
}
public void testFailingMandatoryPluginCheck() {
IllegalStateException e = expectThrows(
IllegalStateException.class,
- () -> PluginsService.checkMandatoryPlugins(Set.of(), Set.of("org.elasticsearch.plugins.loading.PluginsServiceTests$FakePlugin"))
+ () -> PluginsService.checkMandatoryPlugins(Set.of(), Set.of("org.elasticsearch.plugins.PluginsServiceTests$FakePlugin"))
);
assertEquals(
- "missing mandatory plugins [org.elasticsearch.plugins.loading.PluginsServiceTests$FakePlugin], found plugins []",
+ "missing mandatory plugins [org.elasticsearch.plugins.PluginsServiceTests$FakePlugin], found plugins []",
e.getMessage()
);
}
diff --git a/server/src/test/java/org/elasticsearch/plugins/loading/PluginsUtilsTests.java b/server/src/test/java/org/elasticsearch/plugins/PluginsUtilsTests.java
similarity index 99%
rename from server/src/test/java/org/elasticsearch/plugins/loading/PluginsUtilsTests.java
rename to server/src/test/java/org/elasticsearch/plugins/PluginsUtilsTests.java
index f44de9ac1c704..a7cc74582afdc 100644
--- a/server/src/test/java/org/elasticsearch/plugins/loading/PluginsUtilsTests.java
+++ b/server/src/test/java/org/elasticsearch/plugins/PluginsUtilsTests.java
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-package org.elasticsearch.plugins.loading;
+package org.elasticsearch.plugins;
import org.apache.logging.log4j.Level;
import org.apache.lucene.tests.util.LuceneTestCase;
@@ -14,7 +14,6 @@
import org.elasticsearch.Version;
import org.elasticsearch.core.PathUtils;
import org.elasticsearch.jdk.JarHell;
-import org.elasticsearch.plugins.PluginDescriptor;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
diff --git a/server/src/test/java/org/elasticsearch/plugins/loading/UberModuleClassLoaderTests.java b/server/src/test/java/org/elasticsearch/plugins/UberModuleClassLoaderTests.java
similarity index 99%
rename from server/src/test/java/org/elasticsearch/plugins/loading/UberModuleClassLoaderTests.java
rename to server/src/test/java/org/elasticsearch/plugins/UberModuleClassLoaderTests.java
index 6a12009acce41..e3cd11c8f3b68 100644
--- a/server/src/test/java/org/elasticsearch/plugins/loading/UberModuleClassLoaderTests.java
+++ b/server/src/test/java/org/elasticsearch/plugins/UberModuleClassLoaderTests.java
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-package org.elasticsearch.plugins.loading;
+package org.elasticsearch.plugins;
import org.elasticsearch.common.Strings;
import org.elasticsearch.test.ESTestCase;
diff --git a/server/src/test/java/org/elasticsearch/plugins/internal/ReloadAwarePluginTests.java b/server/src/test/java/org/elasticsearch/plugins/internal/ReloadAwarePluginTests.java
index 4553a65944d30..2401ad25193a2 100644
--- a/server/src/test/java/org/elasticsearch/plugins/internal/ReloadAwarePluginTests.java
+++ b/server/src/test/java/org/elasticsearch/plugins/internal/ReloadAwarePluginTests.java
@@ -11,8 +11,8 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.MockNode;
import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.plugins.ReloadablePlugin;
-import org.elasticsearch.plugins.loading.PluginsService;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.transport.netty4.Netty4Plugin;
diff --git a/server/src/test/java/org/elasticsearch/plugins/scanners/StablePluginsRegistryTests.java b/server/src/test/java/org/elasticsearch/plugins/scanners/StablePluginsRegistryTests.java
index b37da49034f78..276cbdbc1a452 100644
--- a/server/src/test/java/org/elasticsearch/plugins/scanners/StablePluginsRegistryTests.java
+++ b/server/src/test/java/org/elasticsearch/plugins/scanners/StablePluginsRegistryTests.java
@@ -8,7 +8,7 @@
package org.elasticsearch.plugins.scanners;
-import org.elasticsearch.plugins.loading.PluginBundle;
+import org.elasticsearch.plugins.PluginBundle;
import org.elasticsearch.test.ESTestCase;
import org.mockito.Mockito;
diff --git a/server/src/test/java/org/elasticsearch/search/TelemetryMetrics/SearchTookTimeTelemetryTests.java b/server/src/test/java/org/elasticsearch/search/TelemetryMetrics/SearchTookTimeTelemetryTests.java
index 5dad16c5be397..850af7f85f76a 100644
--- a/server/src/test/java/org/elasticsearch/search/TelemetryMetrics/SearchTookTimeTelemetryTests.java
+++ b/server/src/test/java/org/elasticsearch/search/TelemetryMetrics/SearchTookTimeTelemetryTests.java
@@ -12,7 +12,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.telemetry.Measurement;
import org.elasticsearch.telemetry.TestTelemetryPlugin;
import org.elasticsearch.test.ESSingleNodeTestCase;
diff --git a/server/src/test/java/org/elasticsearch/search/TelemetryMetrics/SearchTransportTelemetryTests.java b/server/src/test/java/org/elasticsearch/search/TelemetryMetrics/SearchTransportTelemetryTests.java
index 5edb7147ea259..c7fc11e81483f 100644
--- a/server/src/test/java/org/elasticsearch/search/TelemetryMetrics/SearchTransportTelemetryTests.java
+++ b/server/src/test/java/org/elasticsearch/search/TelemetryMetrics/SearchTransportTelemetryTests.java
@@ -13,7 +13,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.telemetry.Measurement;
import org.elasticsearch.telemetry.TestTelemetryPlugin;
import org.elasticsearch.test.ESSingleNodeTestCase;
diff --git a/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java b/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java
index 3100bdd6db529..f4aa44f143c40 100644
--- a/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java
+++ b/server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java
@@ -162,8 +162,8 @@
import org.elasticsearch.ingest.IngestService;
import org.elasticsearch.monitor.StatusInfo;
import org.elasticsearch.node.ResponseCollectorService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.plugins.internal.DocumentParsingProvider;
-import org.elasticsearch.plugins.loading.PluginsService;
import org.elasticsearch.plugins.scanners.StablePluginsRegistry;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.repositories.Repository;
diff --git a/server/src/test/resources/META-INF/services/org.elasticsearch.plugins.loading.PluginsServiceTests$TestExtensionPoint b/server/src/test/resources/META-INF/services/org.elasticsearch.plugins.PluginsServiceTests$TestExtensionPoint
similarity index 71%
rename from server/src/test/resources/META-INF/services/org.elasticsearch.plugins.loading.PluginsServiceTests$TestExtensionPoint
rename to server/src/test/resources/META-INF/services/org.elasticsearch.plugins.PluginsServiceTests$TestExtensionPoint
index 20654d4496c23..65ca6fbcac9a5 100644
--- a/server/src/test/resources/META-INF/services/org.elasticsearch.plugins.loading.PluginsServiceTests$TestExtensionPoint
+++ b/server/src/test/resources/META-INF/services/org.elasticsearch.plugins.PluginsServiceTests$TestExtensionPoint
@@ -6,5 +6,5 @@
# Side Public License, v 1.
#
-org.elasticsearch.plugins.loading.PluginsServiceTests$TestExtension1
-org.elasticsearch.plugins.loading.PluginsServiceTests$TestExtension2
+org.elasticsearch.plugins.PluginsServiceTests$TestExtension1
+org.elasticsearch.plugins.PluginsServiceTests$TestExtension2
diff --git a/server/src/test/resources/org/elasticsearch/plugins/loading/dummy-plugin.jar b/server/src/test/resources/org/elasticsearch/plugins/dummy-plugin.jar
similarity index 100%
rename from server/src/test/resources/org/elasticsearch/plugins/loading/dummy-plugin.jar
rename to server/src/test/resources/org/elasticsearch/plugins/dummy-plugin.jar
diff --git a/server/src/test/resources/org/elasticsearch/plugins/loading/non-extensible-plugin.jar b/server/src/test/resources/org/elasticsearch/plugins/non-extensible-plugin.jar
similarity index 100%
rename from server/src/test/resources/org/elasticsearch/plugins/loading/non-extensible-plugin.jar
rename to server/src/test/resources/org/elasticsearch/plugins/non-extensible-plugin.jar
diff --git a/test/framework/src/main/java/org/elasticsearch/action/support/CancellableActionTestPlugin.java b/test/framework/src/main/java/org/elasticsearch/action/support/CancellableActionTestPlugin.java
index d46e95aaef328..dad0e3b613efb 100644
--- a/test/framework/src/main/java/org/elasticsearch/action/support/CancellableActionTestPlugin.java
+++ b/test/framework/src/main/java/org/elasticsearch/action/support/CancellableActionTestPlugin.java
@@ -14,7 +14,7 @@
import org.elasticsearch.core.Releasable;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.tasks.CancellableTask;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.tasks.TaskCancelledException;
diff --git a/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java b/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java
index 1b3ef22db7a86..8ef80c08517de 100644
--- a/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java
+++ b/test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java
@@ -215,7 +215,7 @@ public boolean implies(ProtectionDomain domain, Permission permission) {
static Map getCodebases() {
Map codebases = PolicyUtil.getCodebaseJarMap(JarHell.parseClassPath());
// when testing server, the main elasticsearch code is not yet in a jar, so we need to manually add it
- addClassCodebase(codebases, "elasticsearch", "org.elasticsearch.plugins.loading.PluginsService");
+ addClassCodebase(codebases, "elasticsearch", "org.elasticsearch.plugins.PluginsService");
addClassCodebase(codebases, "elasticsearch-plugin-classloader", "org.elasticsearch.plugins.loader.ExtendedPluginsClassLoader");
addClassCodebase(codebases, "elasticsearch-nio", "org.elasticsearch.nio.ChannelFactory");
addClassCodebase(codebases, "elasticsearch-secure-sm", "org.elasticsearch.secure_sm.SecureSM");
diff --git a/test/framework/src/main/java/org/elasticsearch/node/MockNode.java b/test/framework/src/main/java/org/elasticsearch/node/MockNode.java
index a348be75d0449..520aff77497ba 100644
--- a/test/framework/src/main/java/org/elasticsearch/node/MockNode.java
+++ b/test/framework/src/main/java/org/elasticsearch/node/MockNode.java
@@ -28,9 +28,9 @@
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.indices.recovery.RecoverySettings;
+import org.elasticsearch.plugins.MockPluginsService;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.MockPluginsService;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.readiness.MockReadinessService;
import org.elasticsearch.readiness.ReadinessService;
import org.elasticsearch.script.MockScriptService;
diff --git a/test/framework/src/main/java/org/elasticsearch/plugins/loading/MockPluginsService.java b/test/framework/src/main/java/org/elasticsearch/plugins/MockPluginsService.java
similarity index 97%
rename from test/framework/src/main/java/org/elasticsearch/plugins/loading/MockPluginsService.java
rename to test/framework/src/main/java/org/elasticsearch/plugins/MockPluginsService.java
index a393953ca2f99..9d8e7dedcc06d 100644
--- a/test/framework/src/main/java/org/elasticsearch/plugins/loading/MockPluginsService.java
+++ b/test/framework/src/main/java/org/elasticsearch/plugins/MockPluginsService.java
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-package org.elasticsearch.plugins.loading;
+package org.elasticsearch.plugins;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -16,9 +16,6 @@
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
import org.elasticsearch.env.Environment;
import org.elasticsearch.jdk.ModuleQualifiedExportsService;
-import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.PluginDescriptor;
-import org.elasticsearch.plugins.PluginRuntimeInfo;
import org.elasticsearch.plugins.spi.SPIClassIterator;
import java.lang.reflect.Constructor;
diff --git a/test/framework/src/main/java/org/elasticsearch/plugins/loading/PluginTestUtil.java b/test/framework/src/main/java/org/elasticsearch/plugins/PluginTestUtil.java
similarity index 96%
rename from test/framework/src/main/java/org/elasticsearch/plugins/loading/PluginTestUtil.java
rename to test/framework/src/main/java/org/elasticsearch/plugins/PluginTestUtil.java
index 4418208a10272..7edb46d3e3786 100644
--- a/test/framework/src/main/java/org/elasticsearch/plugins/loading/PluginTestUtil.java
+++ b/test/framework/src/main/java/org/elasticsearch/plugins/PluginTestUtil.java
@@ -6,10 +6,9 @@
* Side Public License, v 1.
*/
-package org.elasticsearch.plugins.loading;
+package org.elasticsearch.plugins;
import org.elasticsearch.Version;
-import org.elasticsearch.plugins.PluginDescriptor;
import java.io.IOException;
import java.io.OutputStream;
diff --git a/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java
index 42332500a83a8..271df2a971fb1 100644
--- a/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java
+++ b/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java
@@ -65,11 +65,11 @@
import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache;
import org.elasticsearch.node.InternalSettingsPreparer;
import org.elasticsearch.plugins.MapperPlugin;
+import org.elasticsearch.plugins.MockPluginsService;
import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.plugins.ScriptPlugin;
import org.elasticsearch.plugins.SearchPlugin;
-import org.elasticsearch.plugins.loading.MockPluginsService;
-import org.elasticsearch.plugins.loading.PluginsService;
import org.elasticsearch.plugins.scanners.StablePluginsRegistry;
import org.elasticsearch.script.MockScriptEngine;
import org.elasticsearch.script.MockScriptService;
diff --git a/test/framework/src/main/java/org/elasticsearch/test/AbstractSearchCancellationTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/AbstractSearchCancellationTestCase.java
index c4683bacc75c6..5dc707e94bdd7 100644
--- a/test/framework/src/main/java/org/elasticsearch/test/AbstractSearchCancellationTestCase.java
+++ b/test/framework/src/main/java/org/elasticsearch/test/AbstractSearchCancellationTestCase.java
@@ -21,7 +21,7 @@
import org.elasticsearch.index.IndexModule;
import org.elasticsearch.index.shard.SearchOperationListener;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.script.MockScriptPlugin;
import org.elasticsearch.search.SearchService;
diff --git a/test/framework/src/test/java/org/elasticsearch/plugins/MockPluginsServiceTests.java b/test/framework/src/test/java/org/elasticsearch/plugins/MockPluginsServiceTests.java
index b8f8cecd3615d..055e56db3fb33 100644
--- a/test/framework/src/test/java/org/elasticsearch/plugins/MockPluginsServiceTests.java
+++ b/test/framework/src/test/java/org/elasticsearch/plugins/MockPluginsServiceTests.java
@@ -12,7 +12,6 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.TestEnvironment;
-import org.elasticsearch.plugins.loading.MockPluginsService;
import org.elasticsearch.test.ESTestCase;
import org.junit.Before;
diff --git a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingCapacityRestCancellationIT.java b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingCapacityRestCancellationIT.java
index e14ebcd0930be..5b2803c8f4186 100644
--- a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingCapacityRestCancellationIT.java
+++ b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingCapacityRestCancellationIT.java
@@ -16,7 +16,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.tasks.CancellableTask;
import org.elasticsearch.tasks.TaskManager;
import org.elasticsearch.test.ESIntegTestCase;
diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TransportNodeDeprecationCheckAction.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TransportNodeDeprecationCheckAction.java
index 19b306868738a..ba72be655a7ff 100644
--- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TransportNodeDeprecationCheckAction.java
+++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TransportNodeDeprecationCheckAction.java
@@ -26,7 +26,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.license.XPackLicenseState;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TransportNodeDeprecationCheckActionTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TransportNodeDeprecationCheckActionTests.java
index a153b40f730f0..80692efb7474a 100644
--- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TransportNodeDeprecationCheckActionTests.java
+++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TransportNodeDeprecationCheckActionTests.java
@@ -20,7 +20,7 @@
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.XPackLicenseState;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
diff --git a/x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java b/x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java
index 44367b7de51ea..80bb0368a1afc 100644
--- a/x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java
+++ b/x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java
@@ -57,7 +57,7 @@
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.persistent.PersistentTasksService;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchResponseUtils;
diff --git a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java
index efa19266a38fd..414705aff0b79 100644
--- a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java
+++ b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java
@@ -22,7 +22,7 @@
import org.elasticsearch.index.shard.SearchOperationListener;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.search.internal.ReaderContext;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.tasks.TaskId;
diff --git a/x-pack/plugin/monitoring/src/internalClusterTest/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java b/x-pack/plugin/monitoring/src/internalClusterTest/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java
index ef4f179bb93a2..5250a1f764e5c 100644
--- a/x-pack/plugin/monitoring/src/internalClusterTest/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java
+++ b/x-pack/plugin/monitoring/src/internalClusterTest/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java
@@ -29,7 +29,7 @@
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.license.TestUtils;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.rest.RestUtils;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.Scope;
diff --git a/x-pack/plugin/profiling/src/internalClusterTest/java/org/elasticsearch/xpack/profiling/action/CancellationIT.java b/x-pack/plugin/profiling/src/internalClusterTest/java/org/elasticsearch/xpack/profiling/action/CancellationIT.java
index dc71c8fd46f79..183ef3786a62d 100644
--- a/x-pack/plugin/profiling/src/internalClusterTest/java/org/elasticsearch/xpack/profiling/action/CancellationIT.java
+++ b/x-pack/plugin/profiling/src/internalClusterTest/java/org/elasticsearch/xpack/profiling/action/CancellationIT.java
@@ -19,7 +19,7 @@
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.script.MockScriptPlugin;
import org.elasticsearch.search.lookup.LeafStoredFieldsLookup;
import org.elasticsearch.tasks.CancellableTask;
diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPrewarmingIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPrewarmingIntegTests.java
index ece12dd4d1167..42542b63c80d1 100644
--- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPrewarmingIntegTests.java
+++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPrewarmingIntegTests.java
@@ -38,8 +38,8 @@
import org.elasticsearch.indices.recovery.RecoveryState;
import org.elasticsearch.license.LicenseSettings;
import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.plugins.RepositoryPlugin;
-import org.elasticsearch.plugins.loading.PluginsService;
import org.elasticsearch.repositories.IndexId;
import org.elasticsearch.repositories.RepositoriesMetrics;
import org.elasticsearch.repositories.RepositoriesService;
diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/jwt/JwtRealmSingleNodeTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/jwt/JwtRealmSingleNodeTests.java
index 9aa0201d6b4cc..2ced54a513146 100644
--- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/jwt/JwtRealmSingleNodeTests.java
+++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/jwt/JwtRealmSingleNodeTests.java
@@ -31,7 +31,7 @@
import org.elasticsearch.core.Strings;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.test.SecuritySettingsSource;
import org.elasticsearch.test.SecuritySingleNodeTestCase;
import org.elasticsearch.test.junit.annotations.TestLogging;
diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ProfileCancellationIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ProfileCancellationIntegTests.java
index 5e004b9c048e5..87a5146113f72 100644
--- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ProfileCancellationIntegTests.java
+++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/profile/ProfileCancellationIntegTests.java
@@ -24,7 +24,7 @@
import org.elasticsearch.index.shard.SearchOperationListener;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.search.internal.ReaderContext;
import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.tasks.CancellableTask;
diff --git a/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java b/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java
index a562c379b301d..7ad54901e2d06 100644
--- a/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java
+++ b/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java
@@ -22,7 +22,7 @@
import org.elasticsearch.license.LicenseSettings;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.search.internal.ReaderContext;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.tasks.TaskId;
diff --git a/x-pack/plugin/write-load-forecaster/src/internalClusterTest/java/org/elasticsearch/xpack/writeloadforecaster/WriteLoadForecasterIT.java b/x-pack/plugin/write-load-forecaster/src/internalClusterTest/java/org/elasticsearch/xpack/writeloadforecaster/WriteLoadForecasterIT.java
index 4b6e31ae7105f..cb93725b320d1 100644
--- a/x-pack/plugin/write-load-forecaster/src/internalClusterTest/java/org/elasticsearch/xpack/writeloadforecaster/WriteLoadForecasterIT.java
+++ b/x-pack/plugin/write-load-forecaster/src/internalClusterTest/java/org/elasticsearch/xpack/writeloadforecaster/WriteLoadForecasterIT.java
@@ -32,7 +32,7 @@
import org.elasticsearch.index.mapper.DateFieldMapper;
import org.elasticsearch.index.shard.IndexingStats;
import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.loading.PluginsService;
+import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.xcontent.XContentType;
import org.junit.Before;
From 674fea275b50939dc99b6679c1051bb8f30f2ee9 Mon Sep 17 00:00:00 2001
From: Rene Groeschke
Date: Thu, 20 Jun 2024 12:28:06 +0200
Subject: [PATCH 02/16] Fix classpath for
:test:fixtures:krb5kdc-fixture:cacheTestFixtures (#109952)
---
test/fixtures/krb5kdc-fixture/build.gradle | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/test/fixtures/krb5kdc-fixture/build.gradle b/test/fixtures/krb5kdc-fixture/build.gradle
index c671d58e1e395..c4bb4237a5b6e 100644
--- a/test/fixtures/krb5kdc-fixture/build.gradle
+++ b/test/fixtures/krb5kdc-fixture/build.gradle
@@ -21,9 +21,6 @@ dockerFixtures {
}
configurations {
- all {
- transitive = false
- }
krb5ConfHdfsFile {
canBeConsumed = true
canBeResolved = false
@@ -36,21 +33,18 @@ configurations {
dependencies {
testImplementation project(':test:framework')
-
api "junit:junit:${versions.junit}"
api project(':test:fixtures:testcontainer-utils')
- api "org.testcontainers:testcontainers:${versions.testcontainer}"
- implementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
+ api("org.testcontainers:testcontainers:${versions.testcontainer}") {
+ transitive = false
+ }
+ implementation("com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"){
+ transitive = false
+ }
implementation "org.slf4j:slf4j-api:${versions.slf4j}"
implementation "com.github.docker-java:docker-java-api:${versions.dockerJava}"
implementation "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
- runtimeOnly "com.github.docker-java:docker-java-transport-zerodep:${versions.dockerJava}"
- runtimeOnly "com.github.docker-java:docker-java-transport:${versions.dockerJava}"
- runtimeOnly "com.github.docker-java:docker-java-core:${versions.dockerJava}"
- runtimeOnly "org.apache.commons:commons-compress:${versions.commonsCompress}"
- runtimeOnly "org.rnorth.duct-tape:duct-tape:${versions.ductTape}"
-
// ensure we have proper logging during when used in tests
runtimeOnly "org.slf4j:slf4j-simple:${versions.slf4j}"
runtimeOnly "org.hamcrest:hamcrest:${versions.hamcrest}"
From 00f4c1320fcb497945ef917bf3c7765047b5b3fb Mon Sep 17 00:00:00 2001
From: Rene Groeschke
Date: Thu, 20 Jun 2024 12:33:31 +0200
Subject: [PATCH 03/16] Revert "Fix classpath for
:test:fixtures:krb5kdc-fixture:cacheTestFixtures (#109952)" (#109960)
This reverts commit 674fea275b50939dc99b6679c1051bb8f30f2ee9.
---
test/fixtures/krb5kdc-fixture/build.gradle | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/test/fixtures/krb5kdc-fixture/build.gradle b/test/fixtures/krb5kdc-fixture/build.gradle
index c4bb4237a5b6e..c671d58e1e395 100644
--- a/test/fixtures/krb5kdc-fixture/build.gradle
+++ b/test/fixtures/krb5kdc-fixture/build.gradle
@@ -21,6 +21,9 @@ dockerFixtures {
}
configurations {
+ all {
+ transitive = false
+ }
krb5ConfHdfsFile {
canBeConsumed = true
canBeResolved = false
@@ -33,18 +36,21 @@ configurations {
dependencies {
testImplementation project(':test:framework')
+
api "junit:junit:${versions.junit}"
api project(':test:fixtures:testcontainer-utils')
- api("org.testcontainers:testcontainers:${versions.testcontainer}") {
- transitive = false
- }
- implementation("com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"){
- transitive = false
- }
+ api "org.testcontainers:testcontainers:${versions.testcontainer}"
+ implementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
implementation "org.slf4j:slf4j-api:${versions.slf4j}"
implementation "com.github.docker-java:docker-java-api:${versions.dockerJava}"
implementation "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
+ runtimeOnly "com.github.docker-java:docker-java-transport-zerodep:${versions.dockerJava}"
+ runtimeOnly "com.github.docker-java:docker-java-transport:${versions.dockerJava}"
+ runtimeOnly "com.github.docker-java:docker-java-core:${versions.dockerJava}"
+ runtimeOnly "org.apache.commons:commons-compress:${versions.commonsCompress}"
+ runtimeOnly "org.rnorth.duct-tape:duct-tape:${versions.ductTape}"
+
// ensure we have proper logging during when used in tests
runtimeOnly "org.slf4j:slf4j-simple:${versions.slf4j}"
runtimeOnly "org.hamcrest:hamcrest:${versions.hamcrest}"
From 4a0b026276613cd48895e3b35cb266a2abdcfa12 Mon Sep 17 00:00:00 2001
From: Rene Groeschke
Date: Thu, 20 Jun 2024 13:01:35 +0200
Subject: [PATCH 04/16] Fix krb5 fixture classpath (#109962)
* Fix krb5dc fixture classpath and handling
---
test/fixtures/krb5kdc-fixture/build.gradle | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/test/fixtures/krb5kdc-fixture/build.gradle b/test/fixtures/krb5kdc-fixture/build.gradle
index c671d58e1e395..733bfd1d4bd29 100644
--- a/test/fixtures/krb5kdc-fixture/build.gradle
+++ b/test/fixtures/krb5kdc-fixture/build.gradle
@@ -22,7 +22,7 @@ dockerFixtures {
configurations {
all {
- transitive = false
+ exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
krb5ConfHdfsFile {
canBeConsumed = true
@@ -36,21 +36,18 @@ configurations {
dependencies {
testImplementation project(':test:framework')
-
api "junit:junit:${versions.junit}"
api project(':test:fixtures:testcontainer-utils')
- api "org.testcontainers:testcontainers:${versions.testcontainer}"
- implementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
+ api("org.testcontainers:testcontainers:${versions.testcontainer}") {
+ transitive = false
+ }
+ implementation("com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"){
+ transitive = false
+ }
implementation "org.slf4j:slf4j-api:${versions.slf4j}"
- implementation "com.github.docker-java:docker-java-api:${versions.dockerJava}"
+ // implementation "com.github.docker-java:docker-java-api:${versions.dockerJava}"
implementation "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
- runtimeOnly "com.github.docker-java:docker-java-transport-zerodep:${versions.dockerJava}"
- runtimeOnly "com.github.docker-java:docker-java-transport:${versions.dockerJava}"
- runtimeOnly "com.github.docker-java:docker-java-core:${versions.dockerJava}"
- runtimeOnly "org.apache.commons:commons-compress:${versions.commonsCompress}"
- runtimeOnly "org.rnorth.duct-tape:duct-tape:${versions.ductTape}"
-
// ensure we have proper logging during when used in tests
runtimeOnly "org.slf4j:slf4j-simple:${versions.slf4j}"
runtimeOnly "org.hamcrest:hamcrest:${versions.hamcrest}"
From 7b81e0c91a224c84dbd92f752d6e574292d51b6c Mon Sep 17 00:00:00 2001
From: Nik Everett
Date: Thu, 20 Jun 2024 07:25:27 -0400
Subject: [PATCH 05/16] ESQL: Move more function serialization (#109950)
This moves yet more of the function serialization code from
`PlanNamedTypes` into `NamedWriteable` to line up better with the rest
of Elasticsearch. This moves 13 more functions including all
"configuration" functions and all date functions and all varags
functions. There are 38 left.
---
.../function/scalar/UnaryScalarFunction.java | 20 ++-
.../expression/predicate/logical/Not.java | 14 ++
.../expression/predicate/nulls/IsNotNull.java | 18 +++
.../expression/predicate/nulls/IsNull.java | 14 ++
.../function/scalar/EsqlScalarFunction.java | 34 +++-
.../function/scalar/UnaryScalarFunction.java | 6 +
.../function/scalar/conditional/Case.java | 30 ++++
.../function/scalar/conditional/Greatest.java | 30 ++++
.../function/scalar/conditional/Least.java | 30 ++++
.../function/scalar/date/DateDiff.java | 41 +++++
.../function/scalar/date/DateExtract.java | 40 +++++
.../function/scalar/date/DateFormat.java | 40 +++++
.../function/scalar/date/DateParse.java | 31 ++++
.../function/scalar/date/DateTrunc.java | 36 +++++
.../expression/function/scalar/date/Now.java | 21 ++-
.../function/scalar/nulls/Coalesce.java | 30 ++++
.../function/scalar/string/Concat.java | 29 ++++
.../function/scalar/string/ToLower.java | 21 +++
.../function/scalar/string/ToUpper.java | 21 +++
.../xpack/esql/io/stream/PlanNamedTypes.java | 146 +-----------------
.../AbstractExpressionSerializationTests.java | 4 +
.../AbstractVarargsSerializationTests.java | 39 +++++
.../scalar/NotSerializationTests.java | 36 +++++
.../conditional/CaseSerializationTests.java | 28 ++++
.../GreatestSerializationTests.java | 28 ++++
.../conditional/LeastSerializationTests.java | 28 ++++
.../date/DateDiffSerializationTests.java | 52 +++++++
.../date/DateExtractSerializationTests.java | 45 ++++++
.../date/DateFormatSerializationTests.java | 45 ++++++
.../date/DateParseSerializationTests.java | 45 ++++++
.../date/DateTruncSerializationTests.java | 45 ++++++
.../scalar/date/NowSerializationTests.java | 37 +++++
.../scalar/{math => date}/NowTests.java | 3 +-
.../nulls/CoalesceSerializationTests.java | 28 ++++
.../nulls/IsNotNullSerializationTests.java | 37 +++++
.../nulls/IsNullSerializationTests.java | 37 +++++
.../string/ConcatSerializationTests.java | 28 ++++
.../string/ToLowerSerializationTests.java | 41 +++++
.../string/ToUpperSerializationTests.java | 41 +++++
39 files changed, 1143 insertions(+), 156 deletions(-)
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractVarargsSerializationTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/NotSerializationTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/CaseSerializationTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestSerializationTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastSerializationTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffSerializationTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractSerializationTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatSerializationTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseSerializationTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncSerializationTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowSerializationTests.java
rename x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/{math => date}/NowTests.java (97%)
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/CoalesceSerializationTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullSerializationTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullSerializationTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ConcatSerializationTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerSerializationTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperSerializationTests.java
diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/UnaryScalarFunction.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/UnaryScalarFunction.java
index 2ef0b892138de..e5c2cedfd087b 100644
--- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/UnaryScalarFunction.java
+++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/function/scalar/UnaryScalarFunction.java
@@ -6,10 +6,15 @@
*/
package org.elasticsearch.xpack.esql.core.expression.function.scalar;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.xpack.esql.core.expression.Expression;
import org.elasticsearch.xpack.esql.core.expression.gen.processor.Processor;
import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.core.util.PlanStreamInput;
+import org.elasticsearch.xpack.esql.core.util.PlanStreamOutput;
+import java.io.IOException;
import java.util.List;
import static java.util.Collections.singletonList;
@@ -18,16 +23,21 @@ public abstract class UnaryScalarFunction extends ScalarFunction {
private final Expression field;
- protected UnaryScalarFunction(Source source) {
- super(source);
- this.field = null;
- }
-
protected UnaryScalarFunction(Source source, Expression field) {
super(source, singletonList(field));
this.field = field;
}
+ protected UnaryScalarFunction(StreamInput in) throws IOException {
+ this(Source.readFrom((StreamInput & PlanStreamInput) in), ((PlanStreamInput) in).readExpression());
+ }
+
+ @Override
+ public final void writeTo(StreamOutput out) throws IOException {
+ source().writeTo(out);
+ ((PlanStreamOutput) out).writeExpression(field);
+ }
+
@Override
public final UnaryScalarFunction replaceChildren(List newChildren) {
return replaceChild(newChildren.get(0));
diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/predicate/logical/Not.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/predicate/logical/Not.java
index 31c63393afaea..5f183a1cc26ea 100644
--- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/predicate/logical/Not.java
+++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/predicate/logical/Not.java
@@ -6,6 +6,8 @@
*/
package org.elasticsearch.xpack.esql.core.expression.predicate.logical;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.xpack.esql.core.expression.Expression;
import org.elasticsearch.xpack.esql.core.expression.function.scalar.UnaryScalarFunction;
import org.elasticsearch.xpack.esql.core.expression.gen.processor.Processor;
@@ -14,15 +16,27 @@
import org.elasticsearch.xpack.esql.core.tree.Source;
import org.elasticsearch.xpack.esql.core.type.DataType;
+import java.io.IOException;
+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.DEFAULT;
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isBoolean;
public class Not extends UnaryScalarFunction implements Negatable {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Not", Not::new);
public Not(Source source, Expression child) {
super(source, child);
}
+ private Not(StreamInput in) throws IOException {
+ super(in);
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
+ }
+
@Override
protected NodeInfo info() {
return NodeInfo.create(this, Not::new, field());
diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/predicate/nulls/IsNotNull.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/predicate/nulls/IsNotNull.java
index 52375c5db01a1..e365480a6fd79 100644
--- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/predicate/nulls/IsNotNull.java
+++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/predicate/nulls/IsNotNull.java
@@ -6,6 +6,8 @@
*/
package org.elasticsearch.xpack.esql.core.expression.predicate.nulls;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.xpack.esql.core.expression.Expression;
import org.elasticsearch.xpack.esql.core.expression.Nullability;
import org.elasticsearch.xpack.esql.core.expression.function.scalar.UnaryScalarFunction;
@@ -16,12 +18,28 @@
import org.elasticsearch.xpack.esql.core.tree.Source;
import org.elasticsearch.xpack.esql.core.type.DataType;
+import java.io.IOException;
+
public class IsNotNull extends UnaryScalarFunction implements Negatable {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(
+ Expression.class,
+ "IsNotNull",
+ IsNotNull::new
+ );
public IsNotNull(Source source, Expression field) {
super(source, field);
}
+ private IsNotNull(StreamInput in) throws IOException {
+ super(in);
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
+ }
+
@Override
protected NodeInfo info() {
return NodeInfo.create(this, IsNotNull::new, field());
diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/predicate/nulls/IsNull.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/predicate/nulls/IsNull.java
index d52eec9114df6..8b6eb5d4404b0 100644
--- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/predicate/nulls/IsNull.java
+++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/predicate/nulls/IsNull.java
@@ -6,6 +6,8 @@
*/
package org.elasticsearch.xpack.esql.core.expression.predicate.nulls;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.xpack.esql.core.expression.Expression;
import org.elasticsearch.xpack.esql.core.expression.Nullability;
import org.elasticsearch.xpack.esql.core.expression.function.scalar.UnaryScalarFunction;
@@ -16,12 +18,24 @@
import org.elasticsearch.xpack.esql.core.tree.Source;
import org.elasticsearch.xpack.esql.core.type.DataType;
+import java.io.IOException;
+
public class IsNull extends UnaryScalarFunction implements Negatable {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "IsNull", IsNull::new);
public IsNull(Source source, Expression field) {
super(source, field);
}
+ private IsNull(StreamInput in) throws IOException {
+ super(in);
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
+ }
+
@Override
protected NodeInfo info() {
return NodeInfo.create(this, IsNull::new, field());
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/EsqlScalarFunction.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/EsqlScalarFunction.java
index 4f991af54ecff..17934c1729ad7 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/EsqlScalarFunction.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/EsqlScalarFunction.java
@@ -7,10 +7,25 @@
package org.elasticsearch.xpack.esql.expression.function.scalar;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.xpack.esql.core.expression.Expression;
import org.elasticsearch.xpack.esql.core.expression.function.scalar.ScalarFunction;
import org.elasticsearch.xpack.esql.core.tree.Source;
import org.elasticsearch.xpack.esql.evaluator.mapper.EvaluatorMapper;
+import org.elasticsearch.xpack.esql.expression.function.scalar.conditional.Case;
+import org.elasticsearch.xpack.esql.expression.function.scalar.conditional.Greatest;
+import org.elasticsearch.xpack.esql.expression.function.scalar.conditional.Least;
+import org.elasticsearch.xpack.esql.expression.function.scalar.date.DateDiff;
+import org.elasticsearch.xpack.esql.expression.function.scalar.date.DateExtract;
+import org.elasticsearch.xpack.esql.expression.function.scalar.date.DateFormat;
+import org.elasticsearch.xpack.esql.expression.function.scalar.date.DateParse;
+import org.elasticsearch.xpack.esql.expression.function.scalar.date.DateTrunc;
+import org.elasticsearch.xpack.esql.expression.function.scalar.date.Now;
+import org.elasticsearch.xpack.esql.expression.function.scalar.nulls.Coalesce;
+import org.elasticsearch.xpack.esql.expression.function.scalar.string.Concat;
+import org.elasticsearch.xpack.esql.expression.function.scalar.string.ToLower;
+import org.elasticsearch.xpack.esql.expression.function.scalar.string.ToUpper;
+import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.InsensitiveEquals;
import java.util.List;
@@ -25,6 +40,24 @@
*
*/
public abstract class EsqlScalarFunction extends ScalarFunction implements EvaluatorMapper {
+ public static List getNamedWriteables() {
+ return List.of(
+ Case.ENTRY,
+ Coalesce.ENTRY,
+ Concat.ENTRY,
+ Greatest.ENTRY,
+ InsensitiveEquals.ENTRY,
+ DateExtract.ENTRY,
+ DateDiff.ENTRY,
+ DateFormat.ENTRY,
+ DateParse.ENTRY,
+ DateTrunc.ENTRY,
+ Least.ENTRY,
+ Now.ENTRY,
+ ToLower.ENTRY,
+ ToUpper.ENTRY
+ );
+ }
protected EsqlScalarFunction(Source source) {
super(source);
@@ -38,5 +71,4 @@ protected EsqlScalarFunction(Source source, List fields) {
public Object fold() {
return EvaluatorMapper.super.fold();
}
-
}
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/UnaryScalarFunction.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/UnaryScalarFunction.java
index 0866f97b67724..eb2e5ab94487f 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/UnaryScalarFunction.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/UnaryScalarFunction.java
@@ -12,6 +12,9 @@
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.xpack.esql.core.expression.Expression;
import org.elasticsearch.xpack.esql.core.expression.TypeResolutions;
+import org.elasticsearch.xpack.esql.core.expression.predicate.logical.Not;
+import org.elasticsearch.xpack.esql.core.expression.predicate.nulls.IsNotNull;
+import org.elasticsearch.xpack.esql.core.expression.predicate.nulls.IsNull;
import org.elasticsearch.xpack.esql.core.tree.Source;
import org.elasticsearch.xpack.esql.core.type.DataType;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.FromBase64;
@@ -76,10 +79,13 @@ public static List getNamedWriteables() {
Cosh.ENTRY,
Floor.ENTRY,
FromBase64.ENTRY,
+ IsNotNull.ENTRY,
+ IsNull.ENTRY,
Length.ENTRY,
Log10.ENTRY,
LTrim.ENTRY,
Neg.ENTRY,
+ Not.ENTRY,
RTrim.ENTRY,
Signum.ENTRY,
Sin.ENTRY,
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Case.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Case.java
index f98f5c45acd16..50d0e5484756e 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Case.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Case.java
@@ -7,6 +7,9 @@
package org.elasticsearch.xpack.esql.expression.function.scalar.conditional;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.compute.data.Block;
import org.elasticsearch.compute.data.BooleanBlock;
import org.elasticsearch.compute.data.ElementType;
@@ -27,8 +30,11 @@
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
import org.elasticsearch.xpack.esql.expression.function.Param;
import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput;
import org.elasticsearch.xpack.esql.planner.PlannerUtils;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
@@ -37,8 +43,12 @@
import static org.elasticsearch.common.logging.LoggerMessageFormat.format;
import static org.elasticsearch.xpack.esql.core.type.DataType.NULL;
+import static org.elasticsearch.xpack.esql.io.stream.PlanNameRegistry.PlanReader.readerFromPlanReader;
+import static org.elasticsearch.xpack.esql.io.stream.PlanNameRegistry.PlanWriter.writerFromPlanWriter;
public final class Case extends EsqlScalarFunction {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Case", Case::new);
+
record Condition(Expression condition, Expression value) {}
private final List conditions;
@@ -110,6 +120,26 @@ public Case(
elseValue = elseValueIsExplicit() ? children().get(children().size() - 1) : new Literal(source, null, NULL);
}
+ private Case(StreamInput in) throws IOException {
+ this(
+ Source.readFrom((PlanStreamInput) in),
+ ((PlanStreamInput) in).readExpression(),
+ in.readCollectionAsList(readerFromPlanReader(PlanStreamInput::readExpression))
+ );
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ source().writeTo(out);
+ ((PlanStreamOutput) out).writeExpression(children().get(0));
+ out.writeCollection(children().subList(1, children().size()), writerFromPlanWriter(PlanStreamOutput::writeExpression));
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
+ }
+
private boolean elseValueIsExplicit() {
return children().size() % 2 == 1;
}
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Greatest.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Greatest.java
index 8062019b4c51c..580e2f9900208 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Greatest.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Greatest.java
@@ -8,6 +8,9 @@
package org.elasticsearch.xpack.esql.expression.function.scalar.conditional;
import org.apache.lucene.util.BytesRef;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.compute.operator.EvalOperator.ExpressionEvaluator;
import org.elasticsearch.xpack.esql.EsqlIllegalArgumentException;
@@ -23,17 +26,24 @@
import org.elasticsearch.xpack.esql.expression.function.Param;
import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvMax;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput;
+import java.io.IOException;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Stream;
import static org.elasticsearch.xpack.esql.core.type.DataType.NULL;
+import static org.elasticsearch.xpack.esql.io.stream.PlanNameRegistry.PlanReader.readerFromPlanReader;
+import static org.elasticsearch.xpack.esql.io.stream.PlanNameRegistry.PlanWriter.writerFromPlanWriter;
/**
* Returns the maximum value of multiple columns.
*/
public class Greatest extends EsqlScalarFunction implements OptionalArgument {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Greatest", Greatest::new);
+
private DataType dataType;
@FunctionInfo(
@@ -61,6 +71,26 @@ public Greatest(
super(source, Stream.concat(Stream.of(first), rest.stream()).toList());
}
+ private Greatest(StreamInput in) throws IOException {
+ this(
+ Source.readFrom((PlanStreamInput) in),
+ ((PlanStreamInput) in).readExpression(),
+ in.readCollectionAsList(readerFromPlanReader(PlanStreamInput::readExpression))
+ );
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ source().writeTo(out);
+ ((PlanStreamOutput) out).writeExpression(children().get(0));
+ out.writeCollection(children().subList(1, children().size()), writerFromPlanWriter(PlanStreamOutput::writeExpression));
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
+ }
+
@Override
public DataType dataType() {
if (dataType == null) {
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Least.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Least.java
index f983e0125a4db..2255fed9d4947 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Least.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Least.java
@@ -8,6 +8,9 @@
package org.elasticsearch.xpack.esql.expression.function.scalar.conditional;
import org.apache.lucene.util.BytesRef;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.compute.operator.EvalOperator.ExpressionEvaluator;
import org.elasticsearch.xpack.esql.EsqlIllegalArgumentException;
@@ -23,17 +26,24 @@
import org.elasticsearch.xpack.esql.expression.function.Param;
import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvMin;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput;
+import java.io.IOException;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Stream;
import static org.elasticsearch.xpack.esql.core.type.DataType.NULL;
+import static org.elasticsearch.xpack.esql.io.stream.PlanNameRegistry.PlanReader.readerFromPlanReader;
+import static org.elasticsearch.xpack.esql.io.stream.PlanNameRegistry.PlanWriter.writerFromPlanWriter;
/**
* Returns the minimum value of multiple columns.
*/
public class Least extends EsqlScalarFunction implements OptionalArgument {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Least", Least::new);
+
private DataType dataType;
@FunctionInfo(
@@ -59,6 +69,26 @@ public Least(
super(source, Stream.concat(Stream.of(first), rest.stream()).toList());
}
+ private Least(StreamInput in) throws IOException {
+ this(
+ Source.readFrom((PlanStreamInput) in),
+ ((PlanStreamInput) in).readExpression(),
+ in.readCollectionAsList(readerFromPlanReader(PlanStreamInput::readExpression))
+ );
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ source().writeTo(out);
+ ((PlanStreamOutput) out).writeExpression(children().get(0));
+ out.writeCollection(children().subList(1, children().size()), writerFromPlanWriter(PlanStreamOutput::writeExpression));
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
+ }
+
@Override
public DataType dataType() {
if (dataType == null) {
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiff.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiff.java
index 42e20a9a4615e..2a224598253f9 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiff.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiff.java
@@ -8,6 +8,9 @@
package org.elasticsearch.xpack.esql.expression.function.scalar.date;
import org.apache.lucene.util.BytesRef;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.compute.ann.Fixed;
import org.elasticsearch.compute.operator.EvalOperator.ExpressionEvaluator;
@@ -20,7 +23,10 @@
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
import org.elasticsearch.xpack.esql.expression.function.Param;
import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput;
+import java.io.IOException;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
@@ -47,6 +53,7 @@
* If the second argument (start) is greater than the third argument (end), then negative values are returned.
*/
public class DateDiff extends EsqlScalarFunction {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "DateDiff", DateDiff::new);
public static final ZoneId UTC = ZoneId.of("Z");
@@ -166,6 +173,40 @@ public DateDiff(
this.endTimestamp = endTimestamp;
}
+ private DateDiff(StreamInput in) throws IOException {
+ this(
+ Source.readFrom((PlanStreamInput) in),
+ ((PlanStreamInput) in).readExpression(),
+ ((PlanStreamInput) in).readExpression(),
+ ((PlanStreamInput) in).readExpression()
+ );
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ Source.EMPTY.writeTo(out);
+ ((PlanStreamOutput) out).writeExpression(unit);
+ ((PlanStreamOutput) out).writeExpression(startTimestamp);
+ ((PlanStreamOutput) out).writeExpression(endTimestamp);
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
+ }
+
+ Expression unit() {
+ return unit;
+ }
+
+ Expression startTimestamp() {
+ return startTimestamp;
+ }
+
+ Expression endTimestamp() {
+ return endTimestamp;
+ }
+
@Evaluator(extraName = "Constant", warnExceptions = { IllegalArgumentException.class, InvalidArgumentException.class })
static int process(@Fixed Part datePartFieldUnit, long startTimestamp, long endTimestamp) throws IllegalArgumentException {
ZonedDateTime zdtStart = ZonedDateTime.ofInstant(Instant.ofEpochMilli(startTimestamp), UTC);
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtract.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtract.java
index c28c5e417c152..f3448a2b7c5ff 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtract.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtract.java
@@ -8,6 +8,9 @@
package org.elasticsearch.xpack.esql.expression.function.scalar.date;
import org.apache.lucene.util.BytesRef;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.compute.ann.Fixed;
import org.elasticsearch.compute.operator.EvalOperator.ExpressionEvaluator;
@@ -22,8 +25,11 @@
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
import org.elasticsearch.xpack.esql.expression.function.Param;
import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlConfigurationFunction;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput;
import org.elasticsearch.xpack.esql.type.EsqlDataTypes;
+import java.io.IOException;
import java.time.ZoneId;
import java.time.temporal.ChronoField;
import java.util.List;
@@ -35,6 +41,11 @@
import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.chronoToLong;
public class DateExtract extends EsqlConfigurationFunction {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(
+ Expression.class,
+ "DateExtract",
+ DateExtract::new
+ );
private ChronoField chronoField;
@@ -69,6 +80,35 @@ public DateExtract(
super(source, List.of(chronoFieldExp, field), configuration);
}
+ private DateExtract(StreamInput in) throws IOException {
+ this(
+ Source.readFrom((PlanStreamInput) in),
+ ((PlanStreamInput) in).readExpression(),
+ ((PlanStreamInput) in).readExpression(),
+ ((PlanStreamInput) in).configuration()
+ );
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ source().writeTo(out);
+ ((PlanStreamOutput) out).writeExpression(datePart());
+ ((PlanStreamOutput) out).writeExpression(field());
+ }
+
+ Expression datePart() {
+ return children().get(0);
+ }
+
+ Expression field() {
+ return children().get(1);
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
+ }
+
@Override
public ExpressionEvaluator.Factory toEvaluator(Function toEvaluator) {
var fieldEvaluator = toEvaluator.apply(children().get(1));
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormat.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormat.java
index bcc5d7cb16050..9a789c2bb6fb2 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormat.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormat.java
@@ -8,6 +8,9 @@
package org.elasticsearch.xpack.esql.expression.function.scalar.date;
import org.apache.lucene.util.BytesRef;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.compute.ann.Fixed;
@@ -22,9 +25,12 @@
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
import org.elasticsearch.xpack.esql.expression.function.Param;
import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlConfigurationFunction;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput;
import org.elasticsearch.xpack.esql.session.EsqlConfiguration;
import org.elasticsearch.xpack.esql.type.EsqlDataTypes;
+import java.io.IOException;
import java.util.List;
import java.util.Locale;
import java.util.function.Function;
@@ -37,6 +43,11 @@
import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.dateTimeToString;
public class DateFormat extends EsqlConfigurationFunction implements OptionalArgument {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(
+ Expression.class,
+ "DateFormat",
+ DateFormat::new
+ );
private final Expression field;
private final Expression format;
@@ -59,6 +70,35 @@ Date format (optional). If no format is specified, the `yyyy-MM-dd'T'HH:mm:ss.S
this.format = date != null ? format : null;
}
+ private DateFormat(StreamInput in) throws IOException {
+ this(
+ Source.readFrom((PlanStreamInput) in),
+ ((PlanStreamInput) in).readExpression(),
+ in.readOptionalWriteable(i -> ((PlanStreamInput) i).readExpression()),
+ ((PlanStreamInput) in).configuration()
+ );
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ source().writeTo(out);
+ ((PlanStreamOutput) out).writeExpression(children().get(0));
+ out.writeOptionalWriteable(children().size() == 1 ? null : o -> ((PlanStreamOutput) o).writeExpression(children().get(1)));
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
+ }
+
+ Expression field() {
+ return field;
+ }
+
+ Expression format() {
+ return format;
+ }
+
@Override
public DataType dataType() {
return DataType.KEYWORD;
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParse.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParse.java
index d68664afe8418..12ffe092287ed 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParse.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParse.java
@@ -8,6 +8,9 @@
package org.elasticsearch.xpack.esql.expression.function.scalar.date;
import org.apache.lucene.util.BytesRef;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.compute.ann.Fixed;
@@ -22,8 +25,11 @@
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
import org.elasticsearch.xpack.esql.expression.function.Param;
import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput;
import org.elasticsearch.xpack.esql.type.EsqlDataTypes;
+import java.io.IOException;
import java.time.ZoneId;
import java.util.List;
import java.util.function.Function;
@@ -38,6 +44,11 @@
import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.dateTimeToLong;
public class DateParse extends EsqlScalarFunction implements OptionalArgument {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(
+ Expression.class,
+ "DateParse",
+ DateParse::new
+ );
private final Expression field;
private final Expression format;
@@ -64,6 +75,26 @@ public DateParse(
this.format = second != null ? first : null;
}
+ private DateParse(StreamInput in) throws IOException {
+ this(
+ Source.readFrom((PlanStreamInput) in),
+ ((PlanStreamInput) in).readExpression(),
+ in.readOptionalWriteable(i -> ((PlanStreamInput) i).readExpression())
+ );
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ source().writeTo(out);
+ ((PlanStreamOutput) out).writeExpression(children().get(0));
+ out.writeOptionalWriteable(children().size() == 2 ? o -> ((PlanStreamOutput) out).writeExpression(children().get(1)) : null);
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
+ }
+
@Override
public DataType dataType() {
return DataType.DATETIME;
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTrunc.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTrunc.java
index ddd51d281105d..995e525dda9ec 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTrunc.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTrunc.java
@@ -8,6 +8,9 @@
package org.elasticsearch.xpack.esql.expression.function.scalar.date;
import org.elasticsearch.common.Rounding;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.compute.ann.Fixed;
import org.elasticsearch.compute.operator.EvalOperator.ExpressionEvaluator;
@@ -20,8 +23,11 @@
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
import org.elasticsearch.xpack.esql.expression.function.Param;
import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput;
import org.elasticsearch.xpack.esql.type.EsqlDataTypes;
+import java.io.IOException;
import java.time.Duration;
import java.time.Period;
import java.time.ZoneId;
@@ -36,6 +42,12 @@
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isType;
public class DateTrunc extends EsqlScalarFunction {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(
+ Expression.class,
+ "DateTrunc",
+ DateTrunc::new
+ );
+
private final Expression interval;
private final Expression timestampField;
protected static final ZoneId DEFAULT_TZ = ZoneOffset.UTC;
@@ -69,6 +81,30 @@ public DateTrunc(
this.timestampField = field;
}
+ private DateTrunc(StreamInput in) throws IOException {
+ this(Source.readFrom((PlanStreamInput) in), ((PlanStreamInput) in).readExpression(), ((PlanStreamInput) in).readExpression());
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ source().writeTo(out);
+ ((PlanStreamOutput) out).writeExpression(interval);
+ ((PlanStreamOutput) out).writeExpression(timestampField);
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
+ }
+
+ Expression interval() {
+ return interval;
+ }
+
+ Expression field() {
+ return timestampField;
+ }
+
@Override
protected TypeResolution resolveType() {
if (childrenResolved() == false) {
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/Now.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/Now.java
index fe54cfd186fec..0f401e3de8045 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/Now.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/Now.java
@@ -7,6 +7,9 @@
package org.elasticsearch.xpack.esql.expression.function.scalar.date;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.compute.ann.Fixed;
import org.elasticsearch.compute.operator.EvalOperator.ExpressionEvaluator;
@@ -18,11 +21,14 @@
import org.elasticsearch.xpack.esql.expression.function.Example;
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlConfigurationFunction;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
+import java.io.IOException;
import java.util.List;
import java.util.function.Function;
public class Now extends EsqlConfigurationFunction {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Now", Now::new);
private final long now;
@@ -38,13 +44,18 @@ public Now(Source source, Configuration configuration) {
this.now = configuration.now() == null ? System.currentTimeMillis() : configuration.now().toInstant().toEpochMilli();
}
- private Now(Source source, long now) {
- super(source, List.of(), null);
- this.now = now;
+ private Now(StreamInput in) throws IOException {
+ this(Source.readFrom((PlanStreamInput) in), ((PlanStreamInput) in).configuration());
}
- public static Now newInstance(Source source, long now) {
- return new Now(source, now);
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ Source.EMPTY.writeTo(out);
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
}
@Override
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/Coalesce.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/Coalesce.java
index ff7cd83eedbe2..6a02eb4b94f12 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/Coalesce.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/Coalesce.java
@@ -7,6 +7,9 @@
package org.elasticsearch.xpack.esql.expression.function.scalar.nulls;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.compute.data.Block;
import org.elasticsearch.compute.data.ElementType;
import org.elasticsearch.compute.data.Page;
@@ -27,19 +30,26 @@
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
import org.elasticsearch.xpack.esql.expression.function.Param;
import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput;
import org.elasticsearch.xpack.esql.planner.PlannerUtils;
+import java.io.IOException;
import java.util.List;
import java.util.function.Function;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import static org.elasticsearch.xpack.esql.core.type.DataType.NULL;
+import static org.elasticsearch.xpack.esql.io.stream.PlanNameRegistry.PlanReader.readerFromPlanReader;
+import static org.elasticsearch.xpack.esql.io.stream.PlanNameRegistry.PlanWriter.writerFromPlanWriter;
/**
* Function returning the first non-null value.
*/
public class Coalesce extends EsqlScalarFunction implements OptionalArgument {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Coalesce", Coalesce::new);
+
private DataType dataType;
@FunctionInfo(
@@ -100,6 +110,26 @@ public Coalesce(
super(source, Stream.concat(Stream.of(first), rest.stream()).toList());
}
+ private Coalesce(StreamInput in) throws IOException {
+ this(
+ Source.readFrom((PlanStreamInput) in),
+ ((PlanStreamInput) in).readExpression(),
+ in.readCollectionAsList(readerFromPlanReader(PlanStreamInput::readExpression))
+ );
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ source().writeTo(out);
+ ((PlanStreamOutput) out).writeExpression(children().get(0));
+ out.writeCollection(children().subList(1, children().size()), writerFromPlanWriter(PlanStreamOutput::writeExpression));
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
+ }
+
@Override
public DataType dataType() {
if (dataType == null) {
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Concat.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Concat.java
index d01edbe7024e8..69464787f9288 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Concat.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Concat.java
@@ -8,6 +8,9 @@
package org.elasticsearch.xpack.esql.expression.function.scalar.string;
import org.apache.lucene.util.BytesRef;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.compute.ann.Fixed;
import org.elasticsearch.compute.operator.BreakingBytesRefBuilder;
@@ -22,7 +25,10 @@
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
import org.elasticsearch.xpack.esql.expression.function.Param;
import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput;
+import java.io.IOException;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Stream;
@@ -30,11 +36,14 @@
import static org.elasticsearch.common.unit.ByteSizeUnit.MB;
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.DEFAULT;
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isString;
+import static org.elasticsearch.xpack.esql.io.stream.PlanNameRegistry.PlanReader.readerFromPlanReader;
+import static org.elasticsearch.xpack.esql.io.stream.PlanNameRegistry.PlanWriter.writerFromPlanWriter;
/**
* Join strings.
*/
public class Concat extends EsqlScalarFunction {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Concat", Concat::new);
static final long MAX_CONCAT_LENGTH = MB.toBytes(1);
@@ -51,6 +60,26 @@ public Concat(
super(source, Stream.concat(Stream.of(first), rest.stream()).toList());
}
+ private Concat(StreamInput in) throws IOException {
+ this(
+ Source.readFrom((PlanStreamInput) in),
+ ((PlanStreamInput) in).readExpression(),
+ in.readCollectionAsList(readerFromPlanReader(PlanStreamInput::readExpression))
+ );
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ source().writeTo(out);
+ ((PlanStreamOutput) out).writeExpression(children().get(0));
+ out.writeCollection(children().subList(1, children().size()), writerFromPlanWriter(PlanStreamOutput::writeExpression));
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
+ }
+
@Override
public DataType dataType() {
return DataType.KEYWORD;
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLower.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLower.java
index f14df4f56929a..aadb0b3ac7886 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLower.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLower.java
@@ -8,6 +8,9 @@
package org.elasticsearch.xpack.esql.expression.function.scalar.string;
import org.apache.lucene.util.BytesRef;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.lucene.BytesRefs;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.compute.ann.Fixed;
@@ -17,12 +20,15 @@
import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
import org.elasticsearch.xpack.esql.core.tree.Source;
import org.elasticsearch.xpack.esql.core.type.DataType;
+import org.elasticsearch.xpack.esql.core.util.PlanStreamOutput;
import org.elasticsearch.xpack.esql.expression.function.Example;
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
import org.elasticsearch.xpack.esql.expression.function.Param;
import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlConfigurationFunction;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
import org.elasticsearch.xpack.esql.session.EsqlConfiguration;
+import java.io.IOException;
import java.util.List;
import java.util.Locale;
import java.util.function.Function;
@@ -31,6 +37,7 @@
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isString;
public class ToLower extends EsqlConfigurationFunction {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "ToLower", ToLower::new);
private final Expression field;
@@ -52,6 +59,20 @@ public ToLower(
this.field = field;
}
+ private ToLower(StreamInput in) throws IOException {
+ this(Source.EMPTY, ((PlanStreamInput) in).readExpression(), ((PlanStreamInput) in).configuration());
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ ((PlanStreamOutput) out).writeExpression(field());
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
+ }
+
@Override
public DataType dataType() {
return field.dataType();
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpper.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpper.java
index 6c903b4bfddeb..398fe1c76a49f 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpper.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpper.java
@@ -8,6 +8,9 @@
package org.elasticsearch.xpack.esql.expression.function.scalar.string;
import org.apache.lucene.util.BytesRef;
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.lucene.BytesRefs;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.compute.ann.Fixed;
@@ -17,12 +20,15 @@
import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
import org.elasticsearch.xpack.esql.core.tree.Source;
import org.elasticsearch.xpack.esql.core.type.DataType;
+import org.elasticsearch.xpack.esql.core.util.PlanStreamOutput;
import org.elasticsearch.xpack.esql.expression.function.Example;
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
import org.elasticsearch.xpack.esql.expression.function.Param;
import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlConfigurationFunction;
+import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
import org.elasticsearch.xpack.esql.session.EsqlConfiguration;
+import java.io.IOException;
import java.util.List;
import java.util.Locale;
import java.util.function.Function;
@@ -31,6 +37,7 @@
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isString;
public class ToUpper extends EsqlConfigurationFunction {
+ public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "ToUpper", ToUpper::new);
private final Expression field;
@@ -52,6 +59,20 @@ public ToUpper(
this.field = field;
}
+ private ToUpper(StreamInput in) throws IOException {
+ this(Source.EMPTY, ((PlanStreamInput) in).readExpression(), ((PlanStreamInput) in).configuration());
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ ((PlanStreamOutput) out).writeExpression(field());
+ }
+
+ @Override
+ public String getWriteableName() {
+ return ENTRY.name;
+ }
+
@Override
public DataType dataType() {
return field.dataType();
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanNamedTypes.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanNamedTypes.java
index 831d105a89076..74e8661596e41 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanNamedTypes.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanNamedTypes.java
@@ -62,16 +62,8 @@
import org.elasticsearch.xpack.esql.expression.function.aggregate.Values;
import org.elasticsearch.xpack.esql.expression.function.grouping.Bucket;
import org.elasticsearch.xpack.esql.expression.function.grouping.GroupingFunction;
+import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
import org.elasticsearch.xpack.esql.expression.function.scalar.UnaryScalarFunction;
-import org.elasticsearch.xpack.esql.expression.function.scalar.conditional.Case;
-import org.elasticsearch.xpack.esql.expression.function.scalar.conditional.Greatest;
-import org.elasticsearch.xpack.esql.expression.function.scalar.conditional.Least;
-import org.elasticsearch.xpack.esql.expression.function.scalar.date.DateDiff;
-import org.elasticsearch.xpack.esql.expression.function.scalar.date.DateExtract;
-import org.elasticsearch.xpack.esql.expression.function.scalar.date.DateFormat;
-import org.elasticsearch.xpack.esql.expression.function.scalar.date.DateParse;
-import org.elasticsearch.xpack.esql.expression.function.scalar.date.DateTrunc;
-import org.elasticsearch.xpack.esql.expression.function.scalar.date.Now;
import org.elasticsearch.xpack.esql.expression.function.scalar.ip.CIDRMatch;
import org.elasticsearch.xpack.esql.expression.function.scalar.ip.IpPrefix;
import org.elasticsearch.xpack.esql.expression.function.scalar.math.Atan2;
@@ -82,13 +74,11 @@
import org.elasticsearch.xpack.esql.expression.function.scalar.math.Round;
import org.elasticsearch.xpack.esql.expression.function.scalar.math.Tau;
import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.AbstractMultivalueFunction;
-import org.elasticsearch.xpack.esql.expression.function.scalar.nulls.Coalesce;
import org.elasticsearch.xpack.esql.expression.function.scalar.spatial.SpatialContains;
import org.elasticsearch.xpack.esql.expression.function.scalar.spatial.SpatialDisjoint;
import org.elasticsearch.xpack.esql.expression.function.scalar.spatial.SpatialIntersects;
import org.elasticsearch.xpack.esql.expression.function.scalar.spatial.SpatialRelatesFunction;
import org.elasticsearch.xpack.esql.expression.function.scalar.spatial.SpatialWithin;
-import org.elasticsearch.xpack.esql.expression.function.scalar.string.Concat;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.EndsWith;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.Left;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.Locate;
@@ -99,13 +89,10 @@
import org.elasticsearch.xpack.esql.expression.function.scalar.string.Split;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.StartsWith;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.Substring;
-import org.elasticsearch.xpack.esql.expression.function.scalar.string.ToLower;
-import org.elasticsearch.xpack.esql.expression.function.scalar.string.ToUpper;
import org.elasticsearch.xpack.esql.expression.function.scalar.string.WildcardLike;
import org.elasticsearch.xpack.esql.expression.predicate.operator.arithmetic.EsqlArithmeticOperation;
import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.EsqlBinaryComparison;
import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.In;
-import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.InsensitiveEquals;
import org.elasticsearch.xpack.esql.plan.logical.Aggregate;
import org.elasticsearch.xpack.esql.plan.logical.Dissect;
import org.elasticsearch.xpack.esql.plan.logical.Dissect.Parser;
@@ -246,27 +233,12 @@ public static List namedTypeEntries() {
// BinaryLogic
of(BinaryLogic.class, And.class, PlanNamedTypes::writeBinaryLogic, PlanNamedTypes::readBinaryLogic),
of(BinaryLogic.class, Or.class, PlanNamedTypes::writeBinaryLogic, PlanNamedTypes::readBinaryLogic),
- // UnaryScalarFunction
- of(QL_UNARY_SCLR_CLS, IsNotNull.class, PlanNamedTypes::writeQLUnaryScalar, PlanNamedTypes::readQLUnaryScalar),
- of(QL_UNARY_SCLR_CLS, IsNull.class, PlanNamedTypes::writeQLUnaryScalar, PlanNamedTypes::readQLUnaryScalar),
- of(QL_UNARY_SCLR_CLS, Not.class, PlanNamedTypes::writeQLUnaryScalar, PlanNamedTypes::readQLUnaryScalar),
// ScalarFunction
of(ScalarFunction.class, Atan2.class, PlanNamedTypes::writeAtan2, PlanNamedTypes::readAtan2),
- of(ScalarFunction.class, Case.class, PlanNamedTypes::writeVararg, PlanNamedTypes::readVarag),
of(ScalarFunction.class, CIDRMatch.class, PlanNamedTypes::writeCIDRMatch, PlanNamedTypes::readCIDRMatch),
- of(ScalarFunction.class, Coalesce.class, PlanNamedTypes::writeVararg, PlanNamedTypes::readVarag),
- of(ScalarFunction.class, Concat.class, PlanNamedTypes::writeVararg, PlanNamedTypes::readVarag),
- of(ScalarFunction.class, DateDiff.class, PlanNamedTypes::writeDateDiff, PlanNamedTypes::readDateDiff),
- of(ScalarFunction.class, DateExtract.class, PlanNamedTypes::writeDateExtract, PlanNamedTypes::readDateExtract),
- of(ScalarFunction.class, DateFormat.class, PlanNamedTypes::writeDateFormat, PlanNamedTypes::readDateFormat),
- of(ScalarFunction.class, DateParse.class, PlanNamedTypes::writeDateTimeParse, PlanNamedTypes::readDateTimeParse),
- of(ScalarFunction.class, DateTrunc.class, PlanNamedTypes::writeDateTrunc, PlanNamedTypes::readDateTrunc),
of(ScalarFunction.class, E.class, PlanNamedTypes::writeNoArgScalar, PlanNamedTypes::readNoArgScalar),
- of(ScalarFunction.class, Greatest.class, PlanNamedTypes::writeVararg, PlanNamedTypes::readVarag),
of(ScalarFunction.class, IpPrefix.class, (out, prefix) -> prefix.writeTo(out), IpPrefix::readFrom),
- of(ScalarFunction.class, Least.class, PlanNamedTypes::writeVararg, PlanNamedTypes::readVarag),
of(ScalarFunction.class, Log.class, PlanNamedTypes::writeLog, PlanNamedTypes::readLog),
- of(ScalarFunction.class, Now.class, PlanNamedTypes::writeNow, PlanNamedTypes::readNow),
of(ScalarFunction.class, Pi.class, PlanNamedTypes::writeNoArgScalar, PlanNamedTypes::readNoArgScalar),
of(ScalarFunction.class, Round.class, PlanNamedTypes::writeRound, PlanNamedTypes::readRound),
of(ScalarFunction.class, Pow.class, PlanNamedTypes::writePow, PlanNamedTypes::readPow),
@@ -284,8 +256,6 @@ public static List namedTypeEntries() {
of(ScalarFunction.class, Split.class, PlanNamedTypes::writeSplit, PlanNamedTypes::readSplit),
of(ScalarFunction.class, Tau.class, PlanNamedTypes::writeNoArgScalar, PlanNamedTypes::readNoArgScalar),
of(ScalarFunction.class, Replace.class, PlanNamedTypes::writeReplace, PlanNamedTypes::readReplace),
- of(ScalarFunction.class, ToLower.class, PlanNamedTypes::writeToLower, PlanNamedTypes::readToLower),
- of(ScalarFunction.class, ToUpper.class, PlanNamedTypes::writeToUpper, PlanNamedTypes::readToUpper),
// GroupingFunctions
of(GroupingFunction.class, Bucket.class, PlanNamedTypes::writeBucket, PlanNamedTypes::readBucket),
// AggregateFunctions
@@ -309,10 +279,11 @@ public static List namedTypeEntries() {
AbstractMultivalueFunction.getNamedWriteables(),
EsqlArithmeticOperation.getNamedWriteables(),
EsqlBinaryComparison.getNamedWriteables(),
+ EsqlScalarFunction.getNamedWriteables(),
FullTextPredicate.getNamedWriteables(),
NamedExpression.getNamedWriteables(),
UnaryScalarFunction.getNamedWriteables(),
- List.of(UnsupportedAttribute.ENTRY, InsensitiveEquals.ENTRY, Literal.ENTRY, org.elasticsearch.xpack.esql.expression.Order.ENTRY)
+ List.of(UnsupportedAttribute.ENTRY, Literal.ENTRY, org.elasticsearch.xpack.esql.expression.Order.ENTRY)
)) {
for (NamedWriteableRegistry.Entry e : ee) {
entries.add(of(Expression.class, e));
@@ -1081,32 +1052,6 @@ static void writeBucket(PlanStreamOutput out, Bucket bucket) throws IOException
out.writeOptionalExpression(bucket.to());
}
- static final Map, ScalarFunction>> VARARG_CTORS = Map.ofEntries(
- entry(name(Case.class), Case::new),
- entry(name(Coalesce.class), Coalesce::new),
- entry(name(Concat.class), Concat::new),
- entry(name(Greatest.class), Greatest::new),
- entry(name(Least.class), Least::new)
- );
-
- static ScalarFunction readVarag(PlanStreamInput in, String name) throws IOException {
- return VARARG_CTORS.get(name)
- .apply(
- Source.readFrom(in),
- in.readExpression(),
- in.readCollectionAsList(readerFromPlanReader(PlanStreamInput::readExpression))
- );
- }
-
- static void writeVararg(PlanStreamOutput out, ScalarFunction vararg) throws IOException {
- vararg.source().writeTo(out);
- out.writeExpression(vararg.children().get(0));
- out.writeCollection(
- vararg.children().subList(1, vararg.children().size()),
- writerFromPlanWriter(PlanStreamOutput::writeExpression)
- );
- }
-
static CountDistinct readCountDistinct(PlanStreamInput in) throws IOException {
return new CountDistinct(Source.readFrom(in), in.readExpression(), in.readOptionalNamed(Expression.class));
}
@@ -1119,67 +1064,6 @@ static void writeCountDistinct(PlanStreamOutput out, CountDistinct countDistinct
out.writeOptionalWriteable(fields.size() == 2 ? o -> out.writeExpression(fields.get(1)) : null);
}
- static DateDiff readDateDiff(PlanStreamInput in) throws IOException {
- return new DateDiff(Source.readFrom(in), in.readExpression(), in.readExpression(), in.readExpression());
- }
-
- static void writeDateDiff(PlanStreamOutput out, DateDiff function) throws IOException {
- Source.EMPTY.writeTo(out);
- List fields = function.children();
- assert fields.size() == 3;
- out.writeExpression(fields.get(0));
- out.writeExpression(fields.get(1));
- out.writeExpression(fields.get(2));
- }
-
- static DateExtract readDateExtract(PlanStreamInput in) throws IOException {
- return new DateExtract(Source.readFrom(in), in.readExpression(), in.readExpression(), in.configuration());
- }
-
- static void writeDateExtract(PlanStreamOutput out, DateExtract function) throws IOException {
- function.source().writeTo(out);
- List fields = function.children();
- assert fields.size() == 2;
- out.writeExpression(fields.get(0));
- out.writeExpression(fields.get(1));
- }
-
- static DateFormat readDateFormat(PlanStreamInput in) throws IOException {
- return new DateFormat(Source.readFrom(in), in.readExpression(), in.readOptionalNamed(Expression.class), in.configuration());
- }
-
- static void writeDateFormat(PlanStreamOutput out, DateFormat dateFormat) throws IOException {
- dateFormat.source().writeTo(out);
- List fields = dateFormat.children();
- assert fields.size() == 1 || fields.size() == 2;
- out.writeExpression(fields.get(0));
- out.writeOptionalWriteable(fields.size() == 2 ? o -> out.writeExpression(fields.get(1)) : null);
- }
-
- static DateParse readDateTimeParse(PlanStreamInput in) throws IOException {
- return new DateParse(Source.readFrom(in), in.readExpression(), in.readOptionalNamed(Expression.class));
- }
-
- static void writeDateTimeParse(PlanStreamOutput out, DateParse function) throws IOException {
- function.source().writeTo(out);
- List fields = function.children();
- assert fields.size() == 1 || fields.size() == 2;
- out.writeExpression(fields.get(0));
- out.writeOptionalWriteable(fields.size() == 2 ? o -> out.writeExpression(fields.get(1)) : null);
- }
-
- static DateTrunc readDateTrunc(PlanStreamInput in) throws IOException {
- return new DateTrunc(Source.readFrom(in), in.readExpression(), in.readExpression());
- }
-
- static void writeDateTrunc(PlanStreamOutput out, DateTrunc dateTrunc) throws IOException {
- dateTrunc.source().writeTo(out);
- List fields = dateTrunc.children();
- assert fields.size() == 2;
- out.writeExpression(fields.get(0));
- out.writeExpression(fields.get(1));
- }
-
static SpatialIntersects readIntersects(PlanStreamInput in) throws IOException {
return new SpatialIntersects(Source.EMPTY, in.readExpression(), in.readExpression());
}
@@ -1201,14 +1085,6 @@ static void writeSpatialRelatesFunction(PlanStreamOutput out, SpatialRelatesFunc
out.writeExpression(spatialRelatesFunction.right());
}
- static Now readNow(PlanStreamInput in) throws IOException {
- return new Now(Source.readFrom(in), in.configuration());
- }
-
- static void writeNow(PlanStreamOutput out, Now function) throws IOException {
- Source.EMPTY.writeTo(out);
- }
-
static Round readRound(PlanStreamInput in) throws IOException {
return new Round(Source.readFrom(in), in.readExpression(), in.readOptionalNamed(Expression.class));
}
@@ -1303,22 +1179,6 @@ static void writeReplace(PlanStreamOutput out, Replace replace) throws IOExcepti
out.writeExpression(fields.get(2));
}
- static ToLower readToLower(PlanStreamInput in) throws IOException {
- return new ToLower(Source.EMPTY, in.readExpression(), in.configuration());
- }
-
- static void writeToLower(PlanStreamOutput out, ToLower toLower) throws IOException {
- out.writeExpression(toLower.field());
- }
-
- static ToUpper readToUpper(PlanStreamInput in) throws IOException {
- return new ToUpper(Source.EMPTY, in.readExpression(), in.configuration());
- }
-
- static void writeToUpper(PlanStreamOutput out, ToUpper toUpper) throws IOException {
- out.writeExpression(toUpper.field());
- }
-
static Left readLeft(PlanStreamInput in) throws IOException {
return new Left(Source.readFrom(in), in.readExpression(), in.readExpression());
}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractExpressionSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractExpressionSerializationTests.java
index 9b33af9f0a2e0..33f9cb3123b8d 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractExpressionSerializationTests.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractExpressionSerializationTests.java
@@ -78,6 +78,10 @@ protected boolean alwaysEmptySource() {
protected abstract List getNamedWriteables();
+ public EsqlConfiguration configuration() {
+ return config;
+ }
+
@Override
protected final NamedWriteableRegistry getNamedWriteableRegistry() {
List entries = new ArrayList<>(NamedExpression.getNamedWriteables());
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractVarargsSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractVarargsSerializationTests.java
new file mode 100644
index 0000000000000..67195fa99114b
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractVarargsSerializationTests.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression;
+
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+
+import java.io.IOException;
+import java.util.List;
+
+public abstract class AbstractVarargsSerializationTests extends AbstractExpressionSerializationTests {
+ protected abstract T create(Source source, Expression first, List rest);
+
+ @Override
+ protected final T createTestInstance() {
+ Source source = randomSource();
+ Expression first = randomChild();
+ List rest = randomList(0, 10, AbstractExpressionSerializationTests::randomChild);
+ return create(source, first, rest);
+ }
+
+ @Override
+ protected final T mutateInstance(T instance) throws IOException {
+ Source source = instance.source();
+ Expression first = instance.children().get(0);
+ List rest = instance.children().subList(1, instance.children().size());
+ if (randomBoolean()) {
+ first = randomValueOtherThan(first, AbstractExpressionSerializationTests::randomChild);
+ } else {
+ rest = randomValueOtherThan(rest, () -> randomList(0, 10, AbstractExpressionSerializationTests::randomChild));
+ }
+ return create(instance.source(), first, rest);
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/NotSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/NotSerializationTests.java
new file mode 100644
index 0000000000000..61e3690f1633f
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/NotSerializationTests.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.expression.predicate.logical.Not;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests;
+
+import java.io.IOException;
+import java.util.List;
+
+public class NotSerializationTests extends AbstractExpressionSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return UnaryScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected Not createTestInstance() {
+ return new Not(randomSource(), randomChild());
+ }
+
+ @Override
+ protected Not mutateInstance(Not instance) throws IOException {
+ Source source = instance.source();
+ Expression child = randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild);
+ return new Not(source, child);
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/CaseSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/CaseSerializationTests.java
new file mode 100644
index 0000000000000..69bbf2f76937f
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/CaseSerializationTests.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.conditional;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.expression.AbstractVarargsSerializationTests;
+import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+
+import java.util.List;
+
+public class CaseSerializationTests extends AbstractVarargsSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return EsqlScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected Case create(Source source, Expression first, List rest) {
+ return new Case(source, first, rest);
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestSerializationTests.java
new file mode 100644
index 0000000000000..43e1fe405911a
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestSerializationTests.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.conditional;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.expression.AbstractVarargsSerializationTests;
+import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+
+import java.util.List;
+
+public class GreatestSerializationTests extends AbstractVarargsSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return EsqlScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected Greatest create(Source source, Expression first, List rest) {
+ return new Greatest(source, first, rest);
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastSerializationTests.java
new file mode 100644
index 0000000000000..f552713af4dbe
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastSerializationTests.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.conditional;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.expression.AbstractVarargsSerializationTests;
+import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+
+import java.util.List;
+
+public class LeastSerializationTests extends AbstractVarargsSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return EsqlScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected Least create(Source source, Expression first, List rest) {
+ return new Least(source, first, rest);
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffSerializationTests.java
new file mode 100644
index 0000000000000..b1dc1b064ae5a
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffSerializationTests.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.date;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests;
+import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+
+import java.io.IOException;
+import java.util.List;
+
+public class DateDiffSerializationTests extends AbstractExpressionSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return EsqlScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected DateDiff createTestInstance() {
+ Source source = randomSource();
+ Expression unit = randomChild();
+ Expression startTimestamp = randomChild();
+ Expression endTimestamp = randomChild();
+ return new DateDiff(source, unit, startTimestamp, endTimestamp);
+ }
+
+ @Override
+ protected DateDiff mutateInstance(DateDiff instance) throws IOException {
+ Source source = instance.source();
+ Expression unit = instance.unit();
+ Expression startTimestamp = instance.startTimestamp();
+ Expression endTimestamp = instance.endTimestamp();
+ switch (between(0, 2)) {
+ case 0 -> unit = randomValueOtherThan(unit, AbstractExpressionSerializationTests::randomChild);
+ case 1 -> startTimestamp = randomValueOtherThan(startTimestamp, AbstractExpressionSerializationTests::randomChild);
+ case 2 -> endTimestamp = randomValueOtherThan(endTimestamp, AbstractExpressionSerializationTests::randomChild);
+ }
+ return new DateDiff(source, unit, startTimestamp, endTimestamp);
+ }
+
+ @Override
+ protected boolean alwaysEmptySource() {
+ return true;
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractSerializationTests.java
new file mode 100644
index 0000000000000..6e1c061c84f2e
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractSerializationTests.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.date;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests;
+import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+
+import java.io.IOException;
+import java.util.List;
+
+public class DateExtractSerializationTests extends AbstractExpressionSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return EsqlScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected DateExtract createTestInstance() {
+ Source source = randomSource();
+ Expression datePart = randomChild();
+ Expression field = randomChild();
+ return new DateExtract(source, datePart, field, configuration());
+ }
+
+ @Override
+ protected DateExtract mutateInstance(DateExtract instance) throws IOException {
+ Source source = instance.source();
+ Expression datePart = instance.datePart();
+ Expression field = instance.field();
+ if (randomBoolean()) {
+ datePart = randomValueOtherThan(field, AbstractExpressionSerializationTests::randomChild);
+ } else {
+ field = randomValueOtherThan(field, AbstractExpressionSerializationTests::randomChild);
+ }
+ return new DateExtract(source, datePart, field, configuration());
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatSerializationTests.java
new file mode 100644
index 0000000000000..4dff735318558
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatSerializationTests.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.date;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests;
+import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+
+import java.io.IOException;
+import java.util.List;
+
+public class DateFormatSerializationTests extends AbstractExpressionSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return EsqlScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected DateFormat createTestInstance() {
+ Source source = randomSource();
+ Expression field = randomChild();
+ Expression format = randomBoolean() ? null : randomChild();
+ return new DateFormat(source, field, format, configuration());
+ }
+
+ @Override
+ protected DateFormat mutateInstance(DateFormat instance) throws IOException {
+ Source source = instance.source();
+ Expression field = instance.field();
+ Expression format = instance.format();
+ if (randomBoolean()) {
+ field = randomValueOtherThan(field, AbstractExpressionSerializationTests::randomChild);
+ } else {
+ format = randomValueOtherThan(format, () -> randomBoolean() ? null : randomChild());
+ }
+ return new DateFormat(source, field, format, configuration());
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseSerializationTests.java
new file mode 100644
index 0000000000000..e816f2c4a20fb
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseSerializationTests.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.date;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests;
+import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+
+import java.io.IOException;
+import java.util.List;
+
+public class DateParseSerializationTests extends AbstractExpressionSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return EsqlScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected DateParse createTestInstance() {
+ Source source = randomSource();
+ Expression first = randomChild();
+ Expression second = randomBoolean() ? null : randomChild();
+ return new DateParse(source, first, second);
+ }
+
+ @Override
+ protected DateParse mutateInstance(DateParse instance) throws IOException {
+ Source source = instance.source();
+ Expression first = instance.children().get(0);
+ Expression second = instance.children().size() == 1 ? null : instance.children().get(1);
+ if (randomBoolean()) {
+ first = randomValueOtherThan(first, AbstractExpressionSerializationTests::randomChild);
+ } else {
+ second = randomValueOtherThan(second, () -> randomBoolean() ? null : randomChild());
+ }
+ return new DateParse(source, first, second);
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncSerializationTests.java
new file mode 100644
index 0000000000000..09d2e06003128
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncSerializationTests.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.date;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests;
+import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+
+import java.io.IOException;
+import java.util.List;
+
+public class DateTruncSerializationTests extends AbstractExpressionSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return EsqlScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected DateTrunc createTestInstance() {
+ Source source = randomSource();
+ Expression interval = randomChild();
+ Expression field = randomChild();
+ return new DateTrunc(source, interval, field);
+ }
+
+ @Override
+ protected DateTrunc mutateInstance(DateTrunc instance) throws IOException {
+ Source source = instance.source();
+ Expression interval = instance.interval();
+ Expression field = instance.field();
+ if (randomBoolean()) {
+ interval = randomValueOtherThan(interval, AbstractExpressionSerializationTests::randomChild);
+ } else {
+ field = randomValueOtherThan(field, AbstractExpressionSerializationTests::randomChild);
+ }
+ return new DateTrunc(source, interval, field);
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowSerializationTests.java
new file mode 100644
index 0000000000000..3bb8c2f260561
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowSerializationTests.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.date;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests;
+import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+
+import java.io.IOException;
+import java.util.List;
+
+public class NowSerializationTests extends AbstractExpressionSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return EsqlScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected Now createTestInstance() {
+ return new Now(randomSource(), configuration());
+ }
+
+ @Override
+ protected Now mutateInstance(Now instance) throws IOException {
+ return null;
+ }
+
+ @Override
+ protected boolean alwaysEmptySource() {
+ return true;
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/NowTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowTests.java
similarity index 97%
rename from x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/NowTests.java
rename to x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowTests.java
index 2c1322abf8cda..8edc21db427d2 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/NowTests.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowTests.java
@@ -5,7 +5,7 @@
* 2.0.
*/
-package org.elasticsearch.xpack.esql.expression.function.scalar.math;
+package org.elasticsearch.xpack.esql.expression.function.scalar.date;
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
@@ -18,7 +18,6 @@
import org.elasticsearch.xpack.esql.core.type.DataType;
import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier;
import org.elasticsearch.xpack.esql.expression.function.scalar.AbstractConfigurationFunctionTestCase;
-import org.elasticsearch.xpack.esql.expression.function.scalar.date.Now;
import org.elasticsearch.xpack.esql.session.EsqlConfiguration;
import org.hamcrest.Matcher;
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/CoalesceSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/CoalesceSerializationTests.java
new file mode 100644
index 0000000000000..7cab0a957b235
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/CoalesceSerializationTests.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.nulls;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.expression.AbstractVarargsSerializationTests;
+import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+
+import java.util.List;
+
+public class CoalesceSerializationTests extends AbstractVarargsSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return EsqlScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected Coalesce create(Source source, Expression first, List rest) {
+ return new Coalesce(source, first, rest);
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullSerializationTests.java
new file mode 100644
index 0000000000000..23545b3627a1a
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullSerializationTests.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.nulls;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.expression.predicate.nulls.IsNotNull;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests;
+import org.elasticsearch.xpack.esql.expression.function.scalar.UnaryScalarFunction;
+
+import java.io.IOException;
+import java.util.List;
+
+public class IsNotNullSerializationTests extends AbstractExpressionSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return UnaryScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected IsNotNull createTestInstance() {
+ return new IsNotNull(randomSource(), randomChild());
+ }
+
+ @Override
+ protected IsNotNull mutateInstance(IsNotNull instance) throws IOException {
+ Source source = instance.source();
+ Expression child = randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild);
+ return new IsNotNull(source, child);
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullSerializationTests.java
new file mode 100644
index 0000000000000..354a2129d7ec0
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullSerializationTests.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.nulls;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.expression.predicate.nulls.IsNull;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests;
+import org.elasticsearch.xpack.esql.expression.function.scalar.UnaryScalarFunction;
+
+import java.io.IOException;
+import java.util.List;
+
+public class IsNullSerializationTests extends AbstractExpressionSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return UnaryScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected IsNull createTestInstance() {
+ return new IsNull(randomSource(), randomChild());
+ }
+
+ @Override
+ protected IsNull mutateInstance(IsNull instance) throws IOException {
+ Source source = instance.source();
+ Expression child = randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild);
+ return new IsNull(source, child);
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ConcatSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ConcatSerializationTests.java
new file mode 100644
index 0000000000000..30f6acffbaf8a
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ConcatSerializationTests.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.string;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.expression.AbstractVarargsSerializationTests;
+import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+
+import java.util.List;
+
+public class ConcatSerializationTests extends AbstractVarargsSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return EsqlScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected Concat create(Source source, Expression first, List rest) {
+ return new Concat(source, first, rest);
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerSerializationTests.java
new file mode 100644
index 0000000000000..f2dbdbd74470a
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerSerializationTests.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.string;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests;
+import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+
+import java.io.IOException;
+import java.util.List;
+
+public class ToLowerSerializationTests extends AbstractExpressionSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return EsqlScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected ToLower createTestInstance() {
+ return new ToLower(randomSource(), randomChild(), configuration());
+ }
+
+ @Override
+ protected ToLower mutateInstance(ToLower instance) throws IOException {
+ Source source = instance.source();
+ Expression child = randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild);
+ return new ToLower(source, child, configuration());
+ }
+
+ @Override
+ protected boolean alwaysEmptySource() {
+ return true;
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperSerializationTests.java
new file mode 100644
index 0000000000000..e57aedd79fdfd
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperSerializationTests.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.string;
+
+import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests;
+import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
+
+import java.io.IOException;
+import java.util.List;
+
+public class ToUpperSerializationTests extends AbstractExpressionSerializationTests {
+ @Override
+ protected List getNamedWriteables() {
+ return EsqlScalarFunction.getNamedWriteables();
+ }
+
+ @Override
+ protected ToUpper createTestInstance() {
+ return new ToUpper(randomSource(), randomChild(), configuration());
+ }
+
+ @Override
+ protected ToUpper mutateInstance(ToUpper instance) throws IOException {
+ Source source = instance.source();
+ Expression child = randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild);
+ return new ToUpper(source, child, configuration());
+ }
+
+ @Override
+ protected boolean alwaysEmptySource() {
+ return true;
+ }
+}
From 4eaaf9c4951603b025574c9321bc66f95814455b Mon Sep 17 00:00:00 2001
From: Andrei Stefan
Date: Thu, 20 Jun 2024 14:49:48 +0300
Subject: [PATCH 06/16] ESQL: Adds a test and fixes running the
CsvTestsDataLoader.main (#109836)
---
x-pack/plugin/esql/build.gradle | 4 +++-
.../plugin/esql/qa/testFixtures/build.gradle | 13 ++++++++---
.../xpack/esql/CsvTestsDataLoaderTests.java | 22 +++++++++++++++++++
3 files changed, 35 insertions(+), 4 deletions(-)
create mode 100644 x-pack/plugin/esql/qa/testFixtures/src/test/java/org/elasticsearch/xpack/esql/CsvTestsDataLoaderTests.java
diff --git a/x-pack/plugin/esql/build.gradle b/x-pack/plugin/esql/build.gradle
index 92071543aa27e..dbec0963d1aab 100644
--- a/x-pack/plugin/esql/build.gradle
+++ b/x-pack/plugin/esql/build.gradle
@@ -28,7 +28,9 @@ dependencies {
// Also contains a dummy processor to allow compilation with unused annotations.
annotationProcessor project('compute:gen')
- testImplementation project('qa:testFixtures')
+ testImplementation(project('qa:testFixtures')) {
+ exclude(group:"org.elasticsearch.plugin", module: "esql")
+ }
testImplementation project(':test:framework')
testImplementation(testArtifact(project(xpackModule('core'))))
testImplementation project(path: xpackModule('enrich'))
diff --git a/x-pack/plugin/esql/qa/testFixtures/build.gradle b/x-pack/plugin/esql/qa/testFixtures/build.gradle
index 520873a6cb03e..e8a95011100f5 100644
--- a/x-pack/plugin/esql/qa/testFixtures/build.gradle
+++ b/x-pack/plugin/esql/qa/testFixtures/build.gradle
@@ -1,9 +1,9 @@
apply plugin: 'elasticsearch.java'
-
+apply plugin: org.elasticsearch.gradle.dependencies.CompileOnlyResolvePlugin
dependencies {
implementation project(':x-pack:plugin:esql:compute')
- compileOnly project(':x-pack:plugin:esql')
+ implementation project(':x-pack:plugin:esql')
compileOnly project(path: xpackModule('core'))
implementation project(":libs:elasticsearch-x-content")
implementation project(':client:rest')
@@ -11,7 +11,14 @@ dependencies {
implementation project(':test:framework')
api(testArtifact(project(xpackModule('esql-core'))))
implementation project(':server')
- api "net.sf.supercsv:super-csv:${versions.supercsv}"
+ implementation "net.sf.supercsv:super-csv:${versions.supercsv}"
+}
+
+/**
+ * This is needed for CsvTestsDataLoaderTests to reflect the classpath that CsvTestsDataLoader actually uses when "main" method is executed.
+ */
+tasks.named("test").configure {
+ classpath = classpath - (configurations.resolveableCompileOnly - configurations.runtimeClasspath)
}
/**
diff --git a/x-pack/plugin/esql/qa/testFixtures/src/test/java/org/elasticsearch/xpack/esql/CsvTestsDataLoaderTests.java b/x-pack/plugin/esql/qa/testFixtures/src/test/java/org/elasticsearch/xpack/esql/CsvTestsDataLoaderTests.java
new file mode 100644
index 0000000000000..5b40e1d03e92f
--- /dev/null
+++ b/x-pack/plugin/esql/qa/testFixtures/src/test/java/org/elasticsearch/xpack/esql/CsvTestsDataLoaderTests.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql;
+
+import org.elasticsearch.test.ESTestCase;
+
+import java.net.ConnectException;
+
+import static org.hamcrest.Matchers.startsWith;
+
+public class CsvTestsDataLoaderTests extends ESTestCase {
+
+ public void testCsvTestsDataLoaderExecution() {
+ ConnectException ce = expectThrows(ConnectException.class, () -> CsvTestsDataLoader.main(new String[] {}));
+ assertThat(ce.getMessage(), startsWith("Connection refused"));
+ }
+}
From a692aeded973ef8b89eae560f85b3b2244169cac Mon Sep 17 00:00:00 2001
From: Niels Bauman <33722607+nielsbauman@users.noreply.github.com>
Date: Thu, 20 Jun 2024 14:21:20 +0200
Subject: [PATCH 07/16] Include component templates in retention validaiton
(#109779)
We shouldn't disregard a component template's lifecycle
configuration if the index template has one during retention
validation.
---
docs/changelog/109779.yaml | 5 +++
.../MetadataIndexTemplateService.java | 4 +-
...amLifecycleWithRetentionWarningsTests.java | 42 +++++++++++++++++++
3 files changed, 48 insertions(+), 3 deletions(-)
create mode 100644 docs/changelog/109779.yaml
diff --git a/docs/changelog/109779.yaml b/docs/changelog/109779.yaml
new file mode 100644
index 0000000000000..4ccd8d475ec8d
--- /dev/null
+++ b/docs/changelog/109779.yaml
@@ -0,0 +1,5 @@
+pr: 109779
+summary: Include component templates in retention validaiton
+area: Data streams
+type: bug
+issues: []
diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateService.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateService.java
index affc331c5ab49..6d99874fd2edb 100644
--- a/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateService.java
+++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateService.java
@@ -805,9 +805,7 @@ static void validateLifecycle(
ComposableIndexTemplate template,
@Nullable DataStreamGlobalRetention globalRetention
) {
- DataStreamLifecycle lifecycle = template.template() != null && template.template().lifecycle() != null
- ? template.template().lifecycle()
- : resolveLifecycle(template, metadata.componentTemplates());
+ DataStreamLifecycle lifecycle = resolveLifecycle(template, metadata.componentTemplates());
if (lifecycle != null) {
if (template.getDataStreamTemplate() == null) {
throw new IllegalArgumentException(
diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamLifecycleWithRetentionWarningsTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamLifecycleWithRetentionWarningsTests.java
index 7e338c52a0a17..922a1405bddff 100644
--- a/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamLifecycleWithRetentionWarningsTests.java
+++ b/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamLifecycleWithRetentionWarningsTests.java
@@ -191,6 +191,48 @@ public void testValidateLifecycleIndexTemplateWithWarning() {
);
}
+ /**
+ * Make sure we still take into account component templates during validation (and not just the index template).
+ */
+ public void testValidateLifecycleComponentTemplateWithWarning() {
+ ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
+ HeaderWarning.setThreadContext(threadContext);
+ TimeValue defaultRetention = randomTimeValue(2, 100, TimeUnit.DAYS);
+ MetadataIndexTemplateService.validateLifecycle(
+ Metadata.builder()
+ .componentTemplates(
+ Map.of(
+ "component-template",
+ new ComponentTemplate(
+ new Template(
+ null,
+ null,
+ null,
+ new DataStreamLifecycle(
+ new DataStreamLifecycle.Retention(randomTimeValue(2, 100, TimeUnit.DAYS)),
+ null,
+ null
+ )
+ ),
+ null,
+ null
+ )
+ )
+ )
+ .build(),
+ randomAlphaOfLength(10),
+ ComposableIndexTemplate.builder()
+ .template(new Template(null, null, null, DataStreamLifecycle.DEFAULT))
+ .dataStreamTemplate(new ComposableIndexTemplate.DataStreamTemplate())
+ .indexPatterns(List.of(randomAlphaOfLength(10)))
+ .componentTemplates(List.of("component-template"))
+ .build(),
+ new DataStreamGlobalRetention(defaultRetention, null)
+ );
+ Map> responseHeaders = threadContext.getResponseHeaders();
+ assertThat(responseHeaders.size(), is(0));
+ }
+
public void testValidateLifecycleInComponentTemplate() throws Exception {
IndicesService indicesService = mock(IndicesService.class);
IndexService indexService = mock(IndexService.class);
From e79ee173b2c593ba15c8e77c0b286ecda762b5d1 Mon Sep 17 00:00:00 2001
From: Alexander Spies
Date: Thu, 20 Jun 2024 14:38:20 +0200
Subject: [PATCH 08/16] ESQL: Unmute
MedianAbsoluteDeviationDoubleGroupingAggregatorFunctionTests
testMulitvaluedNullGroup (#109942)
Already fixed in #100556.
---
.../aggregation/GroupingAggregatorFunctionTestCase.java | 2 +-
...soluteDeviationDoubleGroupingAggregatorFunctionTests.java | 5 -----
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/GroupingAggregatorFunctionTestCase.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/GroupingAggregatorFunctionTestCase.java
index d10e1bada5580..65cd2585b8182 100644
--- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/GroupingAggregatorFunctionTestCase.java
+++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/GroupingAggregatorFunctionTestCase.java
@@ -276,7 +276,7 @@ public final void testMulitvaluedNullGroupsAndValues() {
assertSimpleOutput(origInput, results);
}
- public void testMulitvaluedNullGroup() {
+ public final void testMulitvaluedNullGroup() {
DriverContext driverContext = driverContext();
BlockFactory blockFactory = driverContext.blockFactory();
int end = between(1, 2); // TODO revert
diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationDoubleGroupingAggregatorFunctionTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationDoubleGroupingAggregatorFunctionTests.java
index 8eba1842d688d..a6ca769036e54 100644
--- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationDoubleGroupingAggregatorFunctionTests.java
+++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationDoubleGroupingAggregatorFunctionTests.java
@@ -76,9 +76,4 @@ static double median(DoubleStream s) {
int c = data.length / 2;
return data.length % 2 == 0 ? (data[c - 1] + data[c]) / 2 : data[c];
}
-
- @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/101569")
- public void testMulitvaluedNullGroup() {
- // only here for muting it
- }
}
From 3566ee9a0129394cb23cc40c6af1f19a7fa68193 Mon Sep 17 00:00:00 2001
From: Artem Prigoda
Date: Thu, 20 Jun 2024 15:22:41 +0200
Subject: [PATCH 09/16] Track RequestedRangeNotSatisfiedException separately in
S3 Metrics (#109657)
Due to RCO changes, we started getting a lot of `RequestedRangeNotSatisfiedExceptions` which are expected. We would like track them separately.
This change adds two new metrics to track all client errors analogous to other S3 errors.
* es.repositories.exceptions.request_range_not_satisfied.total
* es.repositories.exceptions.request_range_not_satisfied.histogram
In the future, we can add the error code as an attribute to the metrics, so we can adapt it to all client errors.
---
docs/changelog/109657.yaml | 5 ++
.../s3/S3BlobStoreRepositoryMetricsTests.java | 68 ++++++++++++++++---
.../repositories/s3/S3BlobStore.java | 18 +++++
.../repositories/RepositoriesMetrics.java | 8 +++
4 files changed, 88 insertions(+), 11 deletions(-)
create mode 100644 docs/changelog/109657.yaml
diff --git a/docs/changelog/109657.yaml b/docs/changelog/109657.yaml
new file mode 100644
index 0000000000000..35b315b7568c9
--- /dev/null
+++ b/docs/changelog/109657.yaml
@@ -0,0 +1,5 @@
+pr: 109657
+summary: Track `RequestedRangeNotSatisfiedException` separately in S3 Metrics
+area: Snapshot/Restore
+type: enhancement
+issues: []
diff --git a/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryMetricsTests.java b/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryMetricsTests.java
index f8503bca3ec67..640293ecb80b0 100644
--- a/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryMetricsTests.java
+++ b/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryMetricsTests.java
@@ -14,7 +14,6 @@
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.blobstore.BlobContainer;
import org.elasticsearch.common.blobstore.BlobPath;
-import org.elasticsearch.common.blobstore.BlobStore;
import org.elasticsearch.common.blobstore.OperationPurpose;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.collect.Iterators;
@@ -23,6 +22,7 @@
import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
+import org.elasticsearch.repositories.blobstore.RequestedRangeNotSatisfiedException;
import org.elasticsearch.repositories.s3.S3BlobStore.Operation;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.telemetry.Measurement;
@@ -39,6 +39,7 @@
import static org.elasticsearch.repositories.RepositoriesMetrics.HTTP_REQUEST_TIME_IN_MICROS_HISTOGRAM;
import static org.elasticsearch.repositories.RepositoriesMetrics.METRIC_EXCEPTIONS_HISTOGRAM;
+import static org.elasticsearch.repositories.RepositoriesMetrics.METRIC_EXCEPTIONS_REQUEST_RANGE_NOT_SATISFIED_TOTAL;
import static org.elasticsearch.repositories.RepositoriesMetrics.METRIC_EXCEPTIONS_TOTAL;
import static org.elasticsearch.repositories.RepositoriesMetrics.METRIC_OPERATIONS_TOTAL;
import static org.elasticsearch.repositories.RepositoriesMetrics.METRIC_REQUESTS_TOTAL;
@@ -47,8 +48,10 @@
import static org.elasticsearch.repositories.RepositoriesMetrics.METRIC_UNSUCCESSFUL_OPERATIONS_TOTAL;
import static org.elasticsearch.rest.RestStatus.INTERNAL_SERVER_ERROR;
import static org.elasticsearch.rest.RestStatus.NOT_FOUND;
+import static org.elasticsearch.rest.RestStatus.REQUESTED_RANGE_NOT_SATISFIED;
import static org.elasticsearch.rest.RestStatus.TOO_MANY_REQUESTS;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
@SuppressForbidden(reason = "this test uses a HttpServer to emulate an S3 endpoint")
// Need to set up a new cluster for each test because cluster settings use randomized authentication settings
@@ -80,22 +83,29 @@ protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
.build();
}
- public void testMetricsWithErrors() throws IOException {
- final String repository = createRepository(randomRepositoryName());
-
- final String dataNodeName = internalCluster().getNodeNameThat(DiscoveryNode::canContainData);
- final var blobStoreRepository = (BlobStoreRepository) internalCluster().getInstance(RepositoriesService.class, dataNodeName)
- .repository(repository);
- final BlobStore blobStore = blobStoreRepository.blobStore();
- final TestTelemetryPlugin plugin = internalCluster().getInstance(PluginsService.class, dataNodeName)
+ private static TestTelemetryPlugin getPlugin(String dataNodeName) {
+ var plugin = internalCluster().getInstance(PluginsService.class, dataNodeName)
.filterPlugins(TestTelemetryPlugin.class)
.findFirst()
.orElseThrow();
-
plugin.resetMeter();
+ return plugin;
+ }
+
+ private static BlobContainer getBlobContainer(String dataNodeName, String repository) {
+ final var blobStoreRepository = (BlobStoreRepository) internalCluster().getInstance(RepositoriesService.class, dataNodeName)
+ .repository(repository);
+ return blobStoreRepository.blobStore().blobContainer(BlobPath.EMPTY.add(randomIdentifier()));
+ }
+
+ public void testMetricsWithErrors() throws IOException {
+ final String repository = createRepository(randomRepositoryName());
+
+ final String dataNodeName = internalCluster().getNodeNameThat(DiscoveryNode::canContainData);
+ final TestTelemetryPlugin plugin = getPlugin(dataNodeName);
final OperationPurpose purpose = randomFrom(OperationPurpose.values());
- final BlobContainer blobContainer = blobStore.blobContainer(BlobPath.EMPTY.add(randomIdentifier()));
+ final BlobContainer blobContainer = getBlobContainer(dataNodeName, repository);
final String blobName = randomIdentifier();
// Put a blob
@@ -132,6 +142,9 @@ public void testMetricsWithErrors() throws IOException {
assertThat(getLongHistogramValue(plugin, METRIC_EXCEPTIONS_HISTOGRAM, Operation.GET_OBJECT), equalTo(batch));
assertThat(getLongHistogramValue(plugin, METRIC_THROTTLES_HISTOGRAM, Operation.GET_OBJECT), equalTo(batch));
assertThat(getNumberOfMeasurements(plugin, HTTP_REQUEST_TIME_IN_MICROS_HISTOGRAM, Operation.GET_OBJECT), equalTo(batch));
+
+ // Make sure we don't hit the request range not satisfied counters
+ assertThat(getLongCounterValue(plugin, METRIC_EXCEPTIONS_REQUEST_RANGE_NOT_SATISFIED_TOTAL, Operation.GET_OBJECT), equalTo(0L));
}
// List retry exhausted
@@ -166,6 +179,39 @@ public void testMetricsWithErrors() throws IOException {
assertThat(getNumberOfMeasurements(plugin, HTTP_REQUEST_TIME_IN_MICROS_HISTOGRAM, Operation.DELETE_OBJECTS), equalTo(1L));
}
+ public void testMetricsForRequestRangeNotSatisfied() {
+ final String repository = createRepository(randomRepositoryName());
+ final String dataNodeName = internalCluster().getNodeNameThat(DiscoveryNode::canContainData);
+ final BlobContainer blobContainer = getBlobContainer(dataNodeName, repository);
+ final TestTelemetryPlugin plugin = getPlugin(dataNodeName);
+
+ final OperationPurpose purpose = randomFrom(OperationPurpose.values());
+ final String blobName = randomIdentifier();
+
+ for (int i = 0; i < randomIntBetween(1, 3); i++) {
+ final long batch = i + 1;
+ addErrorStatus(TOO_MANY_REQUESTS, TOO_MANY_REQUESTS, REQUESTED_RANGE_NOT_SATISFIED);
+ try {
+ blobContainer.readBlob(purpose, blobName).close();
+ } catch (Exception e) {
+ assertThat(e, instanceOf(RequestedRangeNotSatisfiedException.class));
+ }
+
+ assertThat(getLongCounterValue(plugin, METRIC_REQUESTS_TOTAL, Operation.GET_OBJECT), equalTo(3 * batch));
+ assertThat(getLongCounterValue(plugin, METRIC_OPERATIONS_TOTAL, Operation.GET_OBJECT), equalTo(batch));
+ assertThat(getLongCounterValue(plugin, METRIC_UNSUCCESSFUL_OPERATIONS_TOTAL, Operation.GET_OBJECT), equalTo(batch));
+ assertThat(getLongCounterValue(plugin, METRIC_EXCEPTIONS_TOTAL, Operation.GET_OBJECT), equalTo(batch));
+ assertThat(getLongHistogramValue(plugin, METRIC_EXCEPTIONS_HISTOGRAM, Operation.GET_OBJECT), equalTo(batch));
+ assertThat(
+ getLongCounterValue(plugin, METRIC_EXCEPTIONS_REQUEST_RANGE_NOT_SATISFIED_TOTAL, Operation.GET_OBJECT),
+ equalTo(batch)
+ );
+ assertThat(getLongCounterValue(plugin, METRIC_THROTTLES_TOTAL, Operation.GET_OBJECT), equalTo(2 * batch));
+ assertThat(getLongHistogramValue(plugin, METRIC_THROTTLES_HISTOGRAM, Operation.GET_OBJECT), equalTo(2 * batch));
+ assertThat(getNumberOfMeasurements(plugin, HTTP_REQUEST_TIME_IN_MICROS_HISTOGRAM, Operation.GET_OBJECT), equalTo(batch));
+ }
+ }
+
private void addErrorStatus(RestStatus... statuses) {
errorStatusQueue.addAll(Arrays.asList(statuses));
}
diff --git a/modules/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3BlobStore.java b/modules/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3BlobStore.java
index 2aff610dc82e9..5af53364fb765 100644
--- a/modules/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3BlobStore.java
+++ b/modules/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3BlobStore.java
@@ -52,6 +52,7 @@
import java.util.stream.Collectors;
import static org.elasticsearch.core.Strings.format;
+import static org.elasticsearch.rest.RestStatus.REQUESTED_RANGE_NOT_SATISFIED;
class S3BlobStore implements BlobStore {
@@ -177,6 +178,23 @@ public final void collectMetrics(Request> request, Response> response) {
.map(List::size)
.orElse(0);
+ if (exceptionCount > 0) {
+ final List