diff --git a/sandbox/build.gradle b/sandbox/build.gradle index 4a14d0a11a0d7..1ee3608a4bc10 100644 --- a/sandbox/build.gradle +++ b/sandbox/build.gradle @@ -41,6 +41,7 @@ def patchedCalciteVersion = "${libVersions['calcite']}-opensearch-${libVersions[ subprojects { group = 'org.opensearch.sandbox' + ext.patchedCalciteVersion = patchedCalciteVersion // The patched calcite-core / calcite-linq4j live in the OpenSearch // snapshots Maven repo; analytics-framework advertises them as `api`, diff --git a/sandbox/libs/analytics-api/build.gradle b/sandbox/libs/analytics-api/build.gradle new file mode 100644 index 0000000000000..1d39a279f02b9 --- /dev/null +++ b/sandbox/libs/analytics-api/build.gradle @@ -0,0 +1,30 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +/* + * Analytics Engine API surface consumable from JDK 21 code paths. + */ + +java { sourceCompatibility = JavaVersion.toVersion(21); targetCompatibility = JavaVersion.toVersion(21) } + +// no test for now, so disable +testingConventions.enabled = false + +dependencies { + compileOnly project(':server') + // Declared compileOnly rather than api because analytics-api is never + // loaded standalone — downstream consumers should declare Calcite themselves. + compileOnly "org.apache.calcite:calcite-core:${patchedCalciteVersion}" + compileOnly "org.apache.calcite:calcite-linq4j:${patchedCalciteVersion}" + + // Calcite bytecode references annotations from apiguardian (@API) and + // checker-framework (@EnsuresNonNullIf). compileOnlyApi propagates to + // consumers' compile/javadoc classpath without becoming a runtime dep. + compileOnlyApi 'org.apiguardian:apiguardian-api:1.1.2' + compileOnlyApi 'org.checkerframework:checker-qual:3.43.0' +} diff --git a/sandbox/libs/analytics-framework/src/main/java/org/opensearch/analytics/exec/QueryPlanExecutor.java b/sandbox/libs/analytics-api/src/main/java/org/opensearch/analytics/exec/QueryPlanExecutor.java similarity index 100% rename from sandbox/libs/analytics-framework/src/main/java/org/opensearch/analytics/exec/QueryPlanExecutor.java rename to sandbox/libs/analytics-api/src/main/java/org/opensearch/analytics/exec/QueryPlanExecutor.java diff --git a/sandbox/libs/analytics-framework/src/main/java/org/opensearch/analytics/exec/package-info.java b/sandbox/libs/analytics-api/src/main/java/org/opensearch/analytics/exec/package-info.java similarity index 100% rename from sandbox/libs/analytics-framework/src/main/java/org/opensearch/analytics/exec/package-info.java rename to sandbox/libs/analytics-api/src/main/java/org/opensearch/analytics/exec/package-info.java diff --git a/sandbox/plugins/analytics-engine/src/main/java/org/opensearch/analytics/schema/OpenSearchSchemaBuilder.java b/sandbox/libs/analytics-api/src/main/java/org/opensearch/analytics/schema/OpenSearchSchemaBuilder.java similarity index 100% rename from sandbox/plugins/analytics-engine/src/main/java/org/opensearch/analytics/schema/OpenSearchSchemaBuilder.java rename to sandbox/libs/analytics-api/src/main/java/org/opensearch/analytics/schema/OpenSearchSchemaBuilder.java diff --git a/sandbox/plugins/analytics-engine/src/main/java/org/opensearch/analytics/schema/package-info.java b/sandbox/libs/analytics-api/src/main/java/org/opensearch/analytics/schema/package-info.java similarity index 100% rename from sandbox/plugins/analytics-engine/src/main/java/org/opensearch/analytics/schema/package-info.java rename to sandbox/libs/analytics-api/src/main/java/org/opensearch/analytics/schema/package-info.java diff --git a/sandbox/libs/analytics-framework/build.gradle b/sandbox/libs/analytics-framework/build.gradle index f22f55e23cb53..432aa4248e44c 100644 --- a/sandbox/libs/analytics-framework/build.gradle +++ b/sandbox/libs/analytics-framework/build.gradle @@ -16,8 +16,6 @@ // for Janino parent CL); API surface is identical to upstream. The OpenSearch // Snapshots repo and the resolutionStrategy.force for this coordinate are // declared centrally in sandbox/build.gradle's subprojects block. -def calciteVersion = "${versions.calcite}-opensearch-${versions.calcite_os_rev}" - java { sourceCompatibility = JavaVersion.toVersion(25); targetCompatibility = JavaVersion.toVersion(25) } configurations { @@ -39,9 +37,9 @@ dependencies { // interfaces declares its own runtime arrow dep (see analytics-backend-datafusion). compileOnly "org.apache.arrow:arrow-vector:${versions.arrow}" compileOnly "org.apache.arrow:arrow-memory-core:${versions.arrow}" - api "org.apache.calcite:calcite-core:${calciteVersion}" + api "org.apache.calcite:calcite-core:${patchedCalciteVersion}" // Calcite's expression tree and Enumerable runtime — required by calcite-core API - api "org.apache.calcite:calcite-linq4j:${calciteVersion}" + api "org.apache.calcite:calcite-linq4j:${patchedCalciteVersion}" // Calcite's JDBC abstraction layer — required by calcite-core internals runtimeOnly 'org.apache.calcite.avatica:avatica-core:1.27.0' // Guava — required by Calcite internally, forbidden on compile classpaths by OpenSearch policy diff --git a/sandbox/plugins/analytics-engine/build.gradle b/sandbox/plugins/analytics-engine/build.gradle index 5f7986c74a2cf..0058df4b6eb68 100644 --- a/sandbox/plugins/analytics-engine/build.gradle +++ b/sandbox/plugins/analytics-engine/build.gradle @@ -45,8 +45,9 @@ tasks.named('missingJavadoc').configure { } dependencies { - // Shared types and SPI interfaces (QueryPlanExecutor, EngineBridge, AnalyticsBackEndPlugin, etc.) - // Also provides calcite-core transitively via api. + implementation project(':sandbox:libs:analytics-api') + + // Shared SPI interfaces (EngineBridge, AnalyticsBackEndPlugin, etc.) + calcite-core transitively. api project(':sandbox:libs:analytics-framework') // Arrow — provided at runtime by the extended arrow-flight-rpc plugin (same classloader). diff --git a/sandbox/plugins/dsl-query-executor/build.gradle b/sandbox/plugins/dsl-query-executor/build.gradle index 539a8e9e16b25..b4ed60fa568b7 100644 --- a/sandbox/plugins/dsl-query-executor/build.gradle +++ b/sandbox/plugins/dsl-query-executor/build.gradle @@ -29,6 +29,7 @@ sourceSets.test.compileClasspath += configurations.calciteCompile dependencies { compileOnly project(':server') + compileOnly project(':sandbox:libs:analytics-api') compileOnly project(':sandbox:libs:analytics-framework') compileOnly project(':sandbox:plugins:analytics-engine') // TODO: Consume Calcite dependency from Analytics Framework instead of declaring it separately. diff --git a/sandbox/plugins/test-ppl-frontend/build.gradle b/sandbox/plugins/test-ppl-frontend/build.gradle index ce908cabd515b..9c2d79c306c9c 100644 --- a/sandbox/plugins/test-ppl-frontend/build.gradle +++ b/sandbox/plugins/test-ppl-frontend/build.gradle @@ -52,6 +52,7 @@ sourceSets.test.compileClasspath += configurations.calciteCompile dependencies { // Analytics framework + Calcite provided at runtime by analytics-engine (parent classloader via extendedPlugins) + compileOnly project(':sandbox:libs:analytics-api') compileOnly project(':sandbox:libs:analytics-framework') // Guava for compilation — Calcite API exposes guava types