Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 4 additions & 45 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,54 +55,11 @@ opensearchplugin {
name 'opensearch-sql'
description 'OpenSearch SQL'
classname 'org.opensearch.sql.plugin.SQLPlugin'
extendedPlugins = ['opensearch-job-scheduler', 'analytics-engine']
extendedPlugins = ['opensearch-job-scheduler', 'analytics-engine;optional=true']
licenseFile rootProject.file("LICENSE.txt")
noticeFile rootProject.file("NOTICE")
}

// Exclude jars provided by the analytics-engine plugin (shared via extendedPlugins classloader).
// MUST match what's actually in the analytics-engine ZIP to avoid both jar hell (when analytics-engine
// ships it) and ClassNotFoundException at runtime (when it doesn't). Last verified against
// analytics-engine-3.7.0-SNAPSHOT — keep this list aligned when bumping versions.
bundlePlugin {
exclude 'calcite-core-*.jar'
exclude 'calcite-linq4j-*.jar'
exclude 'avatica-core-*.jar'
exclude 'guava-*.jar'
exclude 'failureaccess-*.jar'
exclude 'slf4j-api-*.jar'
exclude 'commons-codec-*.jar'
exclude 'commons-compiler-*.jar'
exclude 'commons-io-*.jar'
exclude 'commons-lang3-*.jar'
exclude 'janino-*.jar'
exclude 'joou-java-6-*.jar'
exclude 'json-path-*.jar'
exclude 'jackson-annotations-*.jar'
exclude 'jackson-databind-*.jar'
exclude 'httpcore5-5*.jar'
// TODO: Remove the three httpcore5/httpclient5 exclusions below — and ideally this entire
// bundlePlugin exclusion block — once analytics-engine becomes an optional dependency via the
// AnalyticsFrontEndExtension SPI (opensearch-project/OpenSearch#21449). The shared-classloader
// jar deduplication that requires this hand-maintained list goes away with the SPI.
exclude 'httpcore5-h2-*.jar'
exclude 'httpcore5-reactive-*.jar'
exclude 'httpclient5-*.jar'
exclude 'commons-text-*.jar'
// Calcite transitive deps now bundled in analytics-engine 3.7 — exclude from sql to avoid jar hell.
exclude 'commons-math3-*.jar'
exclude 'commons-dbcp2-*.jar'
exclude 'commons-pool2-*.jar'
exclude 'uzaygezen-core-*.jar'
exclude 'sketches-core-*.jar'
exclude 'memory-0*.jar'
exclude 'jts-io-common-*.jar'
exclude 'proj4j-*.jar'
exclude 'json-smart-*.jar'
exclude 'accessors-smart-*.jar'
exclude 'asm-9*.jar'
}

publishing {
publications {
pluginZip(MavenPublication) { publication ->
Expand Down Expand Up @@ -204,7 +161,9 @@ dependencies {

api project(":ppl")
api project(':api')
compileOnly files("${rootDir}/libs/analytics-framework-3.7.0-SNAPSHOT.jar")
// Bundled: analytics-framework interfaces must resolve even when the plugin is absent.
api files("${rootDir}/libs/analytics-framework-3.7.0-SNAPSHOT.jar")
// Not bundled: classes here (e.g. OpenSearchSchemaBuilder) only load when the plugin is installed.
compileOnly files("${rootDir}/libs/analytics-engine-3.7.0-SNAPSHOT.jar")
api project(':legacy')
api project(':opensearch')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,23 @@ public class TransportPPLQueryAction

private final Supplier<Boolean> pplEnabled;

private final RestUnifiedQueryAction unifiedQueryHandler;
/** Null when analytics-engine plugin is absent; set via {@link #setQueryPlanExecutor}. */
private volatile RestUnifiedQueryAction unifiedQueryHandler;

private final NodeClient clientRef;
private final ClusterService clusterServiceRef;

/** Constructor of TransportPPLQueryAction. */
@Inject
public TransportPPLQueryAction(
TransportService transportService,
ActionFilters actionFilters,
NodeClient client,
ClusterService clusterService,
DataSourceServiceImpl dataSourceService,
org.opensearch.common.settings.Settings clusterSettings,
QueryPlanExecutor<RelNode, Iterable<Object[]>> queryPlanExecutor) {
org.opensearch.common.settings.Settings clusterSettings) {
super(PPLQueryAction.NAME, transportService, actionFilters, TransportPPLQueryRequest::new);
this.clientRef = client;
this.clusterServiceRef = clusterService;

ModulesBuilder modules = new ModulesBuilder();
modules.add(new OpenSearchPluginModule());
Expand All @@ -86,9 +90,6 @@ public TransportPPLQueryAction(
b.bind(DataSourceService.class).toInstance(dataSourceService);
});
this.injector = Guice.createInjector(modules);
AnalyticsExecutorHolder.set(queryPlanExecutor);
this.unifiedQueryHandler =
new RestUnifiedQueryAction(client, clusterService, queryPlanExecutor);
this.pplEnabled =
() ->
MULTI_ALLOW_EXPLICIT_INDEX.get(clusterSettings)
Expand All @@ -98,6 +99,15 @@ public TransportPPLQueryAction(
.getSettingValue(Settings.Key.PPL_ENABLED);
}

/** Invoked by Guice iff analytics-engine bound {@code QueryPlanExecutor}. */
@Inject(optional = true)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work?

public void setQueryPlanExecutor(
QueryPlanExecutor<RelNode, Iterable<Object[]>> queryPlanExecutor) {
AnalyticsExecutorHolder.set(queryPlanExecutor);
this.unifiedQueryHandler =
new RestUnifiedQueryAction(clientRef, clusterServiceRef, queryPlanExecutor);
}

/**
* {@inheritDoc} Transform the request and call super.doExecute() to support call from other
* plugins.
Expand Down Expand Up @@ -134,8 +144,9 @@ protected void doExecute(
QueryContext.setProfile(transformedRequest.profile());
ActionListener<TransportPPLQueryResponse> clearingListener = wrapWithProfilingClear(listener);

// Route to analytics engine for non-Lucene (e.g., Parquet-backed) indices
if (unifiedQueryHandler.isAnalyticsIndex(transformedRequest.getRequest(), QueryType.PPL)) {
// Route to analytics engine for non-Lucene (e.g., Parquet-backed) indices.
if (unifiedQueryHandler != null
&& unifiedQueryHandler.isAnalyticsIndex(transformedRequest.getRequest(), QueryType.PPL)) {
if (transformedRequest.isExplainRequest()) {
unifiedQueryHandler.explain(
transformedRequest.getRequest(),
Expand Down
Loading