[Sandbox] Add calcite-patched module: Gradle-driven patched Calcite build - #21501
Conversation
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit eebe687.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
6323fce to
eebe687
Compare
836ace7 to
3ad6909
Compare
PR Reviewer Guide 🔍(Review updated until commit e916936)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to a397777 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit a4126ad
Suggestions up to commit 8708379
Suggestions up to commit f731eed
Suggestions up to commit 57eb4ce
Suggestions up to commit ab8fe61
|
|
❌ Gradle check result for 3ad6909: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Persistent review updated to latest commit f8e0974 |
|
❌ Gradle check result for f8e0974: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
f8e0974 to
d8f2baf
Compare
|
Persistent review updated to latest commit d8f2baf |
|
❌ Gradle check result for d8f2baf: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
d8f2baf to
558479b
Compare
|
Persistent review updated to latest commit 558479b |
558479b to
f338687
Compare
|
Persistent review updated to latest commit f338687 |
f338687 to
a0edff1
Compare
|
Persistent review updated to latest commit a0edff1 |
a0edff1 to
df2de8b
Compare
|
Persistent review updated to latest commit df2de8b |
a397777 to
e8f5525
Compare
|
Persistent review updated to latest commit e8f5525 |
07754f5 to
8378fc0
Compare
|
Persistent review updated to latest commit 8378fc0 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21501 +/- ##
============================================
- Coverage 73.54% 73.53% -0.02%
- Complexity 74628 74633 +5
============================================
Files 5978 5978
Lines 338734 338734
Branches 48842 48842
============================================
- Hits 249127 249084 -43
- Misses 69784 69812 +28
- Partials 19823 19838 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
8378fc0 to
13b07cc
Compare
|
Persistent review updated to latest commit 13b07cc |
13b07cc to
0996b90
Compare
|
Persistent review updated to latest commit 0996b90 |
|
❌ Gradle check result for 0996b90: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Calcite hardcodes Janino's parent classloader, which breaks UDF resolution inside OpenSearch's plugin classloader hierarchy (CALCITE-3745). The fix requires a patched calcite-core / calcite-linq4j, but the patch only affects runtime classloader behavior — API surface, bytecode references, and license metadata are identical to vanilla. The patched jars are published at https://ci.opensearch.org/ci/dbc/snapshots/maven/ as org.apache.calcite:calcite-core:1.41.0-opensearch-1 (and calcite-linq4j). This change wires analytics-framework to consume that coordinate directly: - analytics-framework declares `api "org.apache.calcite:calcite-core:1.41.0-opensearch-1"` plus the OpenSearch Snapshots Maven repo. The patched jars flow through runtimeClasspath of every consumer (analytics-engine, downstream plugins) with no bespoke swap logic. - analytics-engine adds a resolutionStrategy.force for calcite-core and calcite-linq4j so unified-query-*'s transitive vanilla 1.41.0 reference (via calcite-babel) snaps to 1.41.0-opensearch-1, keeping a single Calcite on the classpath. - License SHA-1 files under sandbox/libs/analytics-framework/licenses/ carry the opensearch-1 coordinate. No changes to runtimeClasspath shape, no post-processing of the bundlePlugin Zip task — the patched artifact is just a dependency like any other. compileJava, test, forbiddenApis, thirdPartyAudit, dependencyLicenses all see the same jars the zip ships. Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>
0996b90 to
e916936
Compare
|
Persistent review updated to latest commit e916936 |
…pensearch-project#21501) Calcite hardcodes Janino's parent classloader, which breaks UDF resolution inside OpenSearch's plugin classloader hierarchy (CALCITE-3745). The fix requires a patched calcite-core / calcite-linq4j, but the patch only affects runtime classloader behavior — API surface, bytecode references, and license metadata are identical to vanilla. The patched jars are published at https://ci.opensearch.org/ci/dbc/snapshots/maven/ as org.apache.calcite:calcite-core:1.41.0-opensearch-1 (and calcite-linq4j). This change wires analytics-framework to consume that coordinate directly: - analytics-framework declares `api "org.apache.calcite:calcite-core:1.41.0-opensearch-1"` plus the OpenSearch Snapshots Maven repo. The patched jars flow through runtimeClasspath of every consumer (analytics-engine, downstream plugins) with no bespoke swap logic. - analytics-engine adds a resolutionStrategy.force for calcite-core and calcite-linq4j so unified-query-*'s transitive vanilla 1.41.0 reference (via calcite-babel) snaps to 1.41.0-opensearch-1, keeping a single Calcite on the classpath. - License SHA-1 files under sandbox/libs/analytics-framework/licenses/ carry the opensearch-1 coordinate. No changes to runtimeClasspath shape, no post-processing of the bundlePlugin Zip task — the patched artifact is just a dependency like any other. compileJava, test, forbiddenApis, thirdPartyAudit, dependencyLicenses all see the same jars the zip ships. Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>
…pensearch-project#21501) Calcite hardcodes Janino's parent classloader, which breaks UDF resolution inside OpenSearch's plugin classloader hierarchy (CALCITE-3745). The fix requires a patched calcite-core / calcite-linq4j, but the patch only affects runtime classloader behavior — API surface, bytecode references, and license metadata are identical to vanilla. The patched jars are published at https://ci.opensearch.org/ci/dbc/snapshots/maven/ as org.apache.calcite:calcite-core:1.41.0-opensearch-1 (and calcite-linq4j). This change wires analytics-framework to consume that coordinate directly: - analytics-framework declares `api "org.apache.calcite:calcite-core:1.41.0-opensearch-1"` plus the OpenSearch Snapshots Maven repo. The patched jars flow through runtimeClasspath of every consumer (analytics-engine, downstream plugins) with no bespoke swap logic. - analytics-engine adds a resolutionStrategy.force for calcite-core and calcite-linq4j so unified-query-*'s transitive vanilla 1.41.0 reference (via calcite-babel) snaps to 1.41.0-opensearch-1, keeping a single Calcite on the classpath. - License SHA-1 files under sandbox/libs/analytics-framework/licenses/ carry the opensearch-1 coordinate. No changes to runtimeClasspath shape, no post-processing of the bundlePlugin Zip task — the patched artifact is just a dependency like any other. compileJava, test, forbiddenApis, thirdPartyAudit, dependencyLicenses all see the same jars the zip ships. Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>
Depends on #21549 publish patched calcite here
What
Wires the
analytics-enginesandbox plugin to the pre-published patched Calcite atorg.apache.calcite:calcite-core:1.41.0-opensearch-1(andcalcite-linq4j) from OpenSearch's S3 Maven snapshots repo (version composed from thecalcite+calcite_os_revkeys ingradle/libs.versions.toml). No local Calcite build machinery required — it's just a Maven coordinate.Why
Fixes CALCITE-3745 — Calcite hardcodes Janino's parent classloader, which breaks UDF resolution in OpenSearch's plugin classloader hierarchy. The patch introduces a
TcclChainedClassLoaderso Janino-compiled code can see classes in child plugin classloaders. Only runtime classloader behavior changes; API surface and bytecode references are identical to vanilla.Design
sandbox/build.gradledeclares the OpenSearch Snapshots Maven repo and aresolutionStrategy.forceoncalcite-core/calcite-linq4jinside its existingsubprojects { }block. Every sandbox subproject inherits both — so there's no need for per-plugin duplication. The force uses"${libVersions['calcite']}-opensearch-${libVersions['calcite_os_rev']}", reading the keys fromgradle/libs.versions.tomlas the single source of truth (bumpcalcite_os_revthere and every sandbox plugin follows). The force also pinsunified-query-*'s transitive vanilla1.41.0(viacalcite-babel) to the patched revision.analytics-frameworkdeclaresapi "org.apache.calcite:calcite-core:${calciteVersion}"(andcalcite-linq4j), withcalciteVersioncomposed from the same twolibs.versions.tomlkeys. No local repo or force block — it inherits from the sandbox parent. The patched jars flow throughruntimeClasspathof every consumer; the zip naturally ships the patched coordinate.sandbox/libs/analytics-framework/licenses/carry the-opensearch-1coordinate:calcite-core-1.41.0-opensearch-1.jar.sha1→d4ac2aff0c76b2ea15f47940542999fa42e17d75calcite-linq4j-1.41.0-opensearch-1.jar.sha1→e9bcb0ec7ca38a4bff84283b39d4a736c5217645bundlePlugin.compileJava,test,forbiddenApis,thirdPartyAudit,dependencyLicenses, and thebundlePluginZip task all see the same calcite jars — the patched ones.Companion
SQL plugin side: sql#5302 (sets the TCCL before invoking Calcite).
E2e verification
Reproduced the failure with vanilla Calcite, then confirmed the patched build fixes it. Query under test:
source=t | eval u = upper(name) | fields u, which triggersSqlFunctions.<clinit>→ Janino code-gen → parent-CL lookup — the exact path CALCITE-3745 is about.Before / after (click to expand)
Companion branch for this run: sql#5403 (
analytics-optional), rebased on latestfeature/mustang-ppl-integration.Before — vanilla Calcite in the zip
Zip ships with vanilla:
Query returns HTTP 500:
{"error":{"reason":"There was internal problem at backend", "details":"Line 3, Column 3: Cannot determine simple type name \"org\"", "type":"CompileException"},"status":500}Node log shows Janino failing to resolve the fully-qualified
org.apache.calcite.runtime.SqlFunctionsreference in its own generated code — classic CALCITE-3745: Janino's parent CL is pinned to a classloader that can't see the Calcite package it was generated from.After — patched Calcite in the zip
Zip ships with patched:
Same query, same cluster:
{"schema":[{"name":"u","type":"string"}], "datarows":[["ITEM1"],["ITEM2"]], "total":2,"size":2}Log scan for
CompileException/ClassNotFoundException.*calcite/Janino.*classloaderacross both nodes: 0 hits.TcclChainedClassLoader(introduced by the patch) makes Janino's parent CL consult the thread context classloader first — which in the plugin CL hierarchy sees the Calcite package — before falling back to the original CL for anything else.Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.