Skip to content

Commit 8f72a95

Browse files
Extract analytics-api module for JDK 21 downstream consumers (opensearch-project#21574)
Creates sandbox/libs/analytics-api targeting JDK 21, containing only the interface surface that downstream plugins (e.g. opensearch-sql) need to compile against: - org.opensearch.analytics.exec.QueryPlanExecutor (moved from analytics-framework) - org.opensearch.analytics.schema.OpenSearchSchemaBuilder (moved from analytics-engine) Motivation: analytics-framework and analytics-engine use java.lang.foreign (FFM) APIs that finalize only in JDK 22, so those modules must target JDK 25. Their published Gradle Module Metadata declares org.gradle.jvm.version=25, which blocks consumption from projects that target JVM 21 — most notably opensearch-sql, which uses QueryPlanExecutor and OpenSearchSchemaBuilder but does not touch FFM types. Extracting these two interfaces into a JVM-21-targeted module unblocks those consumers without forcing the whole sandbox to downgrade (FFM is load-bearing for the engine). Packages are unchanged (org.opensearch.analytics.{exec,schema}), so existing imports in sandbox consumers (analytics-framework, analytics-engine, dsl-query-executor, test-ppl-frontend) continue to resolve transitively via the new `api project(':sandbox:libs:analytics-api')` edge in analytics-framework/build.gradle. thirdPartyAudit is disabled on analytics-api: it is a compile-time API surface consumed transitively with the full Calcite runtime provided by analytics-framework or analytics-engine, so there is no standalone runtime where Calcite's optional references could load. Verification: - ./gradlew check -p sandbox -Dsandbox.enabled=true (full sandbox check: BUILD SUCCESSFUL) - analytics-api jar bytecode is class version 65 (JDK 21) as expected. - Published Gradle Module Metadata declares org.gradle.jvm.version=21. - Downstream sql prototype compiles against the new artifact from mavenLocal. Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>
1 parent 2380af7 commit 8f72a95

10 files changed

Lines changed: 38 additions & 6 deletions

File tree

sandbox/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def patchedCalciteVersion = "${libVersions['calcite']}-opensearch-${libVersions[
4141

4242
subprojects {
4343
group = 'org.opensearch.sandbox'
44+
ext.patchedCalciteVersion = patchedCalciteVersion
4445

4546
// The patched calcite-core / calcite-linq4j live in the OpenSearch
4647
// snapshots Maven repo; analytics-framework advertises them as `api`,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
/*
10+
* Analytics Engine API surface consumable from JDK 21 code paths.
11+
*/
12+
13+
java { sourceCompatibility = JavaVersion.toVersion(21); targetCompatibility = JavaVersion.toVersion(21) }
14+
15+
// no test for now, so disable
16+
testingConventions.enabled = false
17+
18+
dependencies {
19+
compileOnly project(':server')
20+
// Declared compileOnly rather than api because analytics-api is never
21+
// loaded standalone — downstream consumers should declare Calcite themselves.
22+
compileOnly "org.apache.calcite:calcite-core:${patchedCalciteVersion}"
23+
compileOnly "org.apache.calcite:calcite-linq4j:${patchedCalciteVersion}"
24+
25+
// Calcite bytecode references annotations from apiguardian (@API) and
26+
// checker-framework (@EnsuresNonNullIf). compileOnlyApi propagates to
27+
// consumers' compile/javadoc classpath without becoming a runtime dep.
28+
compileOnlyApi 'org.apiguardian:apiguardian-api:1.1.2'
29+
compileOnlyApi 'org.checkerframework:checker-qual:3.43.0'
30+
}

sandbox/libs/analytics-framework/src/main/java/org/opensearch/analytics/exec/QueryPlanExecutor.java renamed to sandbox/libs/analytics-api/src/main/java/org/opensearch/analytics/exec/QueryPlanExecutor.java

File renamed without changes.

sandbox/libs/analytics-framework/src/main/java/org/opensearch/analytics/exec/package-info.java renamed to sandbox/libs/analytics-api/src/main/java/org/opensearch/analytics/exec/package-info.java

File renamed without changes.

sandbox/plugins/analytics-engine/src/main/java/org/opensearch/analytics/schema/OpenSearchSchemaBuilder.java renamed to sandbox/libs/analytics-api/src/main/java/org/opensearch/analytics/schema/OpenSearchSchemaBuilder.java

File renamed without changes.

sandbox/plugins/analytics-engine/src/main/java/org/opensearch/analytics/schema/package-info.java renamed to sandbox/libs/analytics-api/src/main/java/org/opensearch/analytics/schema/package-info.java

File renamed without changes.

sandbox/libs/analytics-framework/build.gradle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// for Janino parent CL); API surface is identical to upstream. The OpenSearch
1717
// Snapshots repo and the resolutionStrategy.force for this coordinate are
1818
// declared centrally in sandbox/build.gradle's subprojects block.
19-
def calciteVersion = "${versions.calcite}-opensearch-${versions.calcite_os_rev}"
20-
2119
java { sourceCompatibility = JavaVersion.toVersion(25); targetCompatibility = JavaVersion.toVersion(25) }
2220

2321
configurations {
@@ -39,9 +37,9 @@ dependencies {
3937
// interfaces declares its own runtime arrow dep (see analytics-backend-datafusion).
4038
compileOnly "org.apache.arrow:arrow-vector:${versions.arrow}"
4139
compileOnly "org.apache.arrow:arrow-memory-core:${versions.arrow}"
42-
api "org.apache.calcite:calcite-core:${calciteVersion}"
40+
api "org.apache.calcite:calcite-core:${patchedCalciteVersion}"
4341
// Calcite's expression tree and Enumerable runtime — required by calcite-core API
44-
api "org.apache.calcite:calcite-linq4j:${calciteVersion}"
42+
api "org.apache.calcite:calcite-linq4j:${patchedCalciteVersion}"
4543
// Calcite's JDBC abstraction layer — required by calcite-core internals
4644
runtimeOnly 'org.apache.calcite.avatica:avatica-core:1.27.0'
4745
// Guava — required by Calcite internally, forbidden on compile classpaths by OpenSearch policy

sandbox/plugins/analytics-engine/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ tasks.named('missingJavadoc').configure {
4545
}
4646

4747
dependencies {
48-
// Shared types and SPI interfaces (QueryPlanExecutor, EngineBridge, AnalyticsBackEndPlugin, etc.)
49-
// Also provides calcite-core transitively via api.
48+
implementation project(':sandbox:libs:analytics-api')
49+
50+
// Shared SPI interfaces (EngineBridge, AnalyticsBackEndPlugin, etc.) + calcite-core transitively.
5051
api project(':sandbox:libs:analytics-framework')
5152

5253
// Arrow — provided at runtime by the extended arrow-flight-rpc plugin (same classloader).

sandbox/plugins/dsl-query-executor/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ sourceSets.test.compileClasspath += configurations.calciteCompile
2929

3030
dependencies {
3131
compileOnly project(':server')
32+
compileOnly project(':sandbox:libs:analytics-api')
3233
compileOnly project(':sandbox:libs:analytics-framework')
3334
compileOnly project(':sandbox:plugins:analytics-engine')
3435
// TODO: Consume Calcite dependency from Analytics Framework instead of declaring it separately.

sandbox/plugins/test-ppl-frontend/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ sourceSets.test.compileClasspath += configurations.calciteCompile
5252

5353
dependencies {
5454
// Analytics framework + Calcite provided at runtime by analytics-engine (parent classloader via extendedPlugins)
55+
compileOnly project(':sandbox:libs:analytics-api')
5556
compileOnly project(':sandbox:libs:analytics-framework')
5657

5758
// Guava for compilation — Calcite API exposes guava types

0 commit comments

Comments
 (0)