You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "diqiu50 (via GitHub)" <gi...@apache.org> on 2026/08/19 14:00:45 UTC
[PR] [#12526] feat(trino-connector): Support Starburst SPI compatibility [gravitino]
diqiu50 opened a new pull request, #12527:
URL: https://github.com/apache/gravitino/pull/12527
### What changes were proposed in this pull request?
Add compatibility handling for Starburst SPI variants in the Trino connector, including
`BlockEncodingManager` instantiation, SPI version parsing, and newer DynamicFilter/ConnectorFactory
SPI methods.
### Why are the changes needed?
Starburst SPI differs from baseline open-source Trino in several interfaces and internal
constructor signatures. Without these compatibility methods, the Gravitino connector may
fail to load or execute on Starburst.
Fix: #12526
### Does this PR introduce any user-facing change?
The Gravitino Trino connector can run with compatible Starburst SPI distributions. No new
configuration or public Gravitino API is introduced.
### How was this patch tested?
```text
./gradlew spotlessApply
./gradlew :trino-connector:trino-connector:test -PskipITs
```
Both commands completed successfully.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12526] feat(trino-connector): Support Starburst SPI compatibility [gravitino]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #12527:
URL: https://github.com/apache/gravitino/pull/12527#discussion_r3813796337
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/util/json/JsonCodec.java:
##########
@@ -103,14 +110,107 @@ static TypeManager createTypeManager(ClassLoader classLoader) {
static BlockEncodingSerde createBlockEncodingSerde(TypeManager typeManager) throws Exception {
ClassLoader classLoader = typeManager.getClass().getClassLoader();
- Class blockEncodingManagerClass =
+ Class<?> blockEncodingManagerClass =
classLoader.loadClass("io.trino.metadata.BlockEncodingManager");
- Class internalBlockEncodingSerdeClass =
+ Class<?> internalBlockEncodingSerdeClass =
classLoader.loadClass("io.trino.metadata.InternalBlockEncodingSerde");
+ Object blockEncodingManager =
+ instantiateBlockEncodingManager(blockEncodingManagerClass, classLoader);
return (BlockEncodingSerde)
internalBlockEncodingSerdeClass
.getConstructor(blockEncodingManagerClass, TypeManager.class)
- .newInstance(blockEncodingManagerClass.getConstructor().newInstance(), typeManager);
+ .newInstance(blockEncodingManager, typeManager);
+ }
+
+ /**
+ * Instantiate BlockEncodingManager across Trino/Starburst variants. OSS Trino exposes a public
+ * no-arg constructor; Starburst replaces it with BlockEncodingManager(FeaturesConfig) (used to
+ * gate type-specific encodings via feature flags). Newer Trino branches additionally publish a
+ * {@code Set<BlockEncoding>} variant for Guice multibindings. We probe each known signature in
+ * order, then fall back to a generic constructor scan that fills unknown reference parameters
+ * with default values as a last-resort compatibility mechanism.
+ */
+ private static Object instantiateBlockEncodingManager(
+ Class<?> blockEncodingManagerClass, ClassLoader classLoader) throws Exception {
+ try {
+ Object instance = blockEncodingManagerClass.getConstructor().newInstance();
+ LOG.debug("Instantiated BlockEncodingManager with its public no-argument constructor");
+ return instance;
+ } catch (NoSuchMethodException ignored) {
+ // fall through to parameterized variants
+ }
+
+ try {
+ Class<?> featuresConfigClass = classLoader.loadClass("io.trino.FeaturesConfig");
+ Constructor<?> ctor = blockEncodingManagerClass.getConstructor(featuresConfigClass);
+ Object featuresConfig = featuresConfigClass.getConstructor().newInstance();
+ Object instance = ctor.newInstance(featuresConfig);
+ LOG.debug("Instantiated BlockEncodingManager with FeaturesConfig");
+ return instance;
+ } catch (NoSuchMethodException | ClassNotFoundException ignored) {
+ // fall through
+ }
+
+ try {
+ Constructor<?> setCtor = blockEncodingManagerClass.getConstructor(Set.class);
+ Object instance = setCtor.newInstance(Collections.emptySet());
+ LOG.debug("Instantiated BlockEncodingManager with an empty BlockEncoding set");
+ return instance;
+ } catch (NoSuchMethodException ignored) {
+ // fall through to last-resort scan
+ }
+
+ NoSuchMethodException lastError = null;
+ for (Constructor<?> ctor : blockEncodingManagerClass.getDeclaredConstructors()) {
+ try {
+ ctor.setAccessible(true);
+ Class<?>[] paramTypes = ctor.getParameterTypes();
+ Object[] args = new Object[paramTypes.length];
+ for (int i = 0; i < paramTypes.length; i++) {
+ if (Set.class.isAssignableFrom(paramTypes[i])) {
+ args[i] = Collections.emptySet();
+ } else if (paramTypes[i].isPrimitive()) {
+ args[i] = defaultPrimitive(paramTypes[i]);
+ } else {
+ args[i] = tryDefaultInstance(paramTypes[i]);
+ }
+ }
+ Object instance = ctor.newInstance(args);
Review Comment:
The “last-resort” constructor scan may pass `null` for reference parameters without a no-arg constructor (`tryDefaultInstance` returns null). If a constructor accepts non-null dependencies, this can either (a) instantiate a subtly misconfigured `BlockEncodingManager` (hard-to-diagnose behavior differences) or (b) throw inside the constructor after partial initialization. Consider tightening the fallback: only attempt constructors where every non-primitive parameter is a `Set` or has an accessible no-arg constructor; otherwise skip that constructor and continue.
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/util/json/JsonCodec.java:
##########
@@ -103,14 +110,107 @@ static TypeManager createTypeManager(ClassLoader classLoader) {
static BlockEncodingSerde createBlockEncodingSerde(TypeManager typeManager) throws Exception {
ClassLoader classLoader = typeManager.getClass().getClassLoader();
- Class blockEncodingManagerClass =
+ Class<?> blockEncodingManagerClass =
classLoader.loadClass("io.trino.metadata.BlockEncodingManager");
- Class internalBlockEncodingSerdeClass =
+ Class<?> internalBlockEncodingSerdeClass =
classLoader.loadClass("io.trino.metadata.InternalBlockEncodingSerde");
+ Object blockEncodingManager =
+ instantiateBlockEncodingManager(blockEncodingManagerClass, classLoader);
return (BlockEncodingSerde)
internalBlockEncodingSerdeClass
.getConstructor(blockEncodingManagerClass, TypeManager.class)
- .newInstance(blockEncodingManagerClass.getConstructor().newInstance(), typeManager);
+ .newInstance(blockEncodingManager, typeManager);
+ }
+
+ /**
+ * Instantiate BlockEncodingManager across Trino/Starburst variants. OSS Trino exposes a public
+ * no-arg constructor; Starburst replaces it with BlockEncodingManager(FeaturesConfig) (used to
+ * gate type-specific encodings via feature flags). Newer Trino branches additionally publish a
+ * {@code Set<BlockEncoding>} variant for Guice multibindings. We probe each known signature in
+ * order, then fall back to a generic constructor scan that fills unknown reference parameters
+ * with default values as a last-resort compatibility mechanism.
+ */
+ private static Object instantiateBlockEncodingManager(
+ Class<?> blockEncodingManagerClass, ClassLoader classLoader) throws Exception {
+ try {
+ Object instance = blockEncodingManagerClass.getConstructor().newInstance();
+ LOG.debug("Instantiated BlockEncodingManager with its public no-argument constructor");
+ return instance;
+ } catch (NoSuchMethodException ignored) {
+ // fall through to parameterized variants
+ }
+
+ try {
+ Class<?> featuresConfigClass = classLoader.loadClass("io.trino.FeaturesConfig");
+ Constructor<?> ctor = blockEncodingManagerClass.getConstructor(featuresConfigClass);
+ Object featuresConfig = featuresConfigClass.getConstructor().newInstance();
+ Object instance = ctor.newInstance(featuresConfig);
+ LOG.debug("Instantiated BlockEncodingManager with FeaturesConfig");
+ return instance;
+ } catch (NoSuchMethodException | ClassNotFoundException ignored) {
+ // fall through
+ }
+
+ try {
+ Constructor<?> setCtor = blockEncodingManagerClass.getConstructor(Set.class);
+ Object instance = setCtor.newInstance(Collections.emptySet());
+ LOG.debug("Instantiated BlockEncodingManager with an empty BlockEncoding set");
+ return instance;
+ } catch (NoSuchMethodException ignored) {
+ // fall through to last-resort scan
+ }
+
+ NoSuchMethodException lastError = null;
+ for (Constructor<?> ctor : blockEncodingManagerClass.getDeclaredConstructors()) {
+ try {
+ ctor.setAccessible(true);
+ Class<?>[] paramTypes = ctor.getParameterTypes();
+ Object[] args = new Object[paramTypes.length];
+ for (int i = 0; i < paramTypes.length; i++) {
+ if (Set.class.isAssignableFrom(paramTypes[i])) {
+ args[i] = Collections.emptySet();
+ } else if (paramTypes[i].isPrimitive()) {
+ args[i] = defaultPrimitive(paramTypes[i]);
+ } else {
+ args[i] = tryDefaultInstance(paramTypes[i]);
+ }
+ }
+ Object instance = ctor.newInstance(args);
Review Comment:
`ctor.setAccessible(true)` can throw `InaccessibleObjectException` (a runtime exception) on newer JDKs / module boundaries, which is not caught by the current `catch (ReflectiveOperationException e)` and will abort the fallback scan. Prefer `ctor.trySetAccessible()` (skip if false), or catch `RuntimeException` around the accessibility call and continue scanning other constructors.
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/GravitinoConnectorFactory.java:
##########
@@ -192,6 +212,32 @@ private void checkTrinoSpiVersion(ConnectorContext context, GravitinoConfig conf
}
}
+ @VisibleForTesting
+ static boolean isSecuritySensitivePropertyName(String propertyName) {
+ String normalizedPropertyName = propertyName.toLowerCase(Locale.ROOT).replaceAll("[._-]", "");
+ return SECURITY_SENSITIVE_PROPERTY_SUFFIXES.stream().anyMatch(normalizedPropertyName::endsWith);
+ }
+
Review Comment:
`String#replaceAll` uses regex and will compile/execute a pattern on every call. Since this runs over config keys, consider replacing it with a simple character filter loop (drop `.`, `_`, `-`) to avoid regex overhead and reduce allocations.
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/GravitinoDynamicFilter.java:
##########
@@ -55,6 +56,14 @@ public boolean isAwaitable() {
return delegate.isAwaitable();
}
+ // Note: this method is not annotated with @Override because it does not exist in the
+ // DynamicFilter interface of the baseline open-source Trino SPI version this connector compiles
+ // against. It is present in newer Trino/Starburst SPI versions, where it is dispatched at
+ // runtime by signature, providing cross-version compatibility.
+ public OptionalLong getPreferredDynamicFilterTimeout() {
Review Comment:
Always returning `OptionalLong.empty()` ignores any timeout preference provided by the underlying `delegate` in newer Trino/Starburst SPI implementations, which can change planning/runtime behavior. To preserve semantics across versions, consider reflectively invoking `delegate.getPreferredDynamicFilterTimeout()` when present (same zero-arg signature) and falling back to `OptionalLong.empty()` only when the method doesn’t exist or fails.
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/util/json/JsonCodec.java:
##########
@@ -103,14 +110,107 @@ static TypeManager createTypeManager(ClassLoader classLoader) {
static BlockEncodingSerde createBlockEncodingSerde(TypeManager typeManager) throws Exception {
ClassLoader classLoader = typeManager.getClass().getClassLoader();
- Class blockEncodingManagerClass =
+ Class<?> blockEncodingManagerClass =
classLoader.loadClass("io.trino.metadata.BlockEncodingManager");
- Class internalBlockEncodingSerdeClass =
+ Class<?> internalBlockEncodingSerdeClass =
classLoader.loadClass("io.trino.metadata.InternalBlockEncodingSerde");
+ Object blockEncodingManager =
+ instantiateBlockEncodingManager(blockEncodingManagerClass, classLoader);
return (BlockEncodingSerde)
internalBlockEncodingSerdeClass
.getConstructor(blockEncodingManagerClass, TypeManager.class)
- .newInstance(blockEncodingManagerClass.getConstructor().newInstance(), typeManager);
+ .newInstance(blockEncodingManager, typeManager);
+ }
+
+ /**
+ * Instantiate BlockEncodingManager across Trino/Starburst variants. OSS Trino exposes a public
+ * no-arg constructor; Starburst replaces it with BlockEncodingManager(FeaturesConfig) (used to
+ * gate type-specific encodings via feature flags). Newer Trino branches additionally publish a
+ * {@code Set<BlockEncoding>} variant for Guice multibindings. We probe each known signature in
+ * order, then fall back to a generic constructor scan that fills unknown reference parameters
+ * with default values as a last-resort compatibility mechanism.
+ */
+ private static Object instantiateBlockEncodingManager(
+ Class<?> blockEncodingManagerClass, ClassLoader classLoader) throws Exception {
+ try {
+ Object instance = blockEncodingManagerClass.getConstructor().newInstance();
+ LOG.debug("Instantiated BlockEncodingManager with its public no-argument constructor");
+ return instance;
+ } catch (NoSuchMethodException ignored) {
+ // fall through to parameterized variants
+ }
Review Comment:
`instantiateBlockEncodingManager` introduces multiple constructor-selection branches (no-arg, `FeaturesConfig`, `Set`, and reflective fallback) but there are no unit tests covering these selection rules. Consider adding targeted tests using small in-test dummy classes (with matching constructor signatures) to validate selection order and failure behavior.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12526] feat(trino-connector): Support Starburst SPI compatibility [gravitino]
Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #12527:
URL: https://github.com/apache/gravitino/pull/12527#discussion_r3821969865
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/GravitinoDynamicFilter.java:
##########
@@ -55,6 +56,14 @@ public boolean isAwaitable() {
return delegate.isAwaitable();
}
+ // Note: this method is not annotated with @Override because it does not exist in the
+ // DynamicFilter interface of the baseline open-source Trino SPI version this connector compiles
+ // against. It is present in newer Trino/Starburst SPI versions, where it is dispatched at
+ // runtime by signature, providing cross-version compatibility.
+ public OptionalLong getPreferredDynamicFilterTimeout() {
Review Comment:
Fixed: `getPreferredDynamicFilterTimeout()` now reflectively forwards to `delegate.getPreferredDynamicFilterTimeout()` when present, falling back to `empty()` only if the delegate doesn't implement it.
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/util/json/JsonCodec.java:
##########
@@ -103,14 +110,107 @@ static TypeManager createTypeManager(ClassLoader classLoader) {
static BlockEncodingSerde createBlockEncodingSerde(TypeManager typeManager) throws Exception {
ClassLoader classLoader = typeManager.getClass().getClassLoader();
- Class blockEncodingManagerClass =
+ Class<?> blockEncodingManagerClass =
classLoader.loadClass("io.trino.metadata.BlockEncodingManager");
- Class internalBlockEncodingSerdeClass =
+ Class<?> internalBlockEncodingSerdeClass =
classLoader.loadClass("io.trino.metadata.InternalBlockEncodingSerde");
+ Object blockEncodingManager =
+ instantiateBlockEncodingManager(blockEncodingManagerClass, classLoader);
return (BlockEncodingSerde)
internalBlockEncodingSerdeClass
.getConstructor(blockEncodingManagerClass, TypeManager.class)
- .newInstance(blockEncodingManagerClass.getConstructor().newInstance(), typeManager);
+ .newInstance(blockEncodingManager, typeManager);
+ }
+
+ /**
+ * Instantiate BlockEncodingManager across Trino/Starburst variants. OSS Trino exposes a public
+ * no-arg constructor; Starburst replaces it with BlockEncodingManager(FeaturesConfig) (used to
+ * gate type-specific encodings via feature flags). Newer Trino branches additionally publish a
+ * {@code Set<BlockEncoding>} variant for Guice multibindings. We probe each known signature in
+ * order, then fall back to a generic constructor scan that fills unknown reference parameters
+ * with default values as a last-resort compatibility mechanism.
+ */
+ private static Object instantiateBlockEncodingManager(
+ Class<?> blockEncodingManagerClass, ClassLoader classLoader) throws Exception {
+ try {
+ Object instance = blockEncodingManagerClass.getConstructor().newInstance();
+ LOG.debug("Instantiated BlockEncodingManager with its public no-argument constructor");
+ return instance;
+ } catch (NoSuchMethodException ignored) {
+ // fall through to parameterized variants
+ }
Review Comment:
Added TestJsonCodec covering the no-arg / FeaturesConfig / Set / reflective-fallback constructor selection order, plus the no-usable-constructor error case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12526] feat(trino-connector): Support Starburst SPI compatibility [gravitino]
Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 merged PR #12527:
URL: https://github.com/apache/gravitino/pull/12527
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12526] feat(trino-connector): Support Starburst SPI compatibility [gravitino]
Posted by "Jesshuan (via GitHub)" <gi...@apache.org>.
Jesshuan commented on PR #12527:
URL: https://github.com/apache/gravitino/pull/12527#issuecomment-5981221983
Thanks for this work and this Starburst compatibility
Have you ever seen that i've proposed almost the same thing here in june :[merge request 11302]( https://github.com/apache/gravitino/pull/11302) ?
I was waiting for an action of you @jerryshao if i remember that
@diqiu50 The comments on the code are similar, but perhaps we 've used a similar ai model...
Despite of the sensation of having been excluded of this action (but it's probably not your fault, there are a huge numbers of issues and MR on this kind of projects), i've just test the new gravitino version with your Starburst compatibility contribution, and it perfectly works.
With my old proposition, the starburst users had to extract a private starburst spi jar to put it on the gravitino-trino-connector for building the project... It i was a rather cumbersome procedure to perform... But i don't really understand why , but with your version, nothing to do: it work without any jar manipulation. I think because i couldn't guess exactly what Starbust spi class was missing , and the jar manipulation was preventing some silent bug. And your version is more exhaustive. Good works ;)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12526] feat(trino-connector): Support Starburst SPI compatibility [gravitino]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12527:
URL: https://github.com/apache/gravitino/pull/12527#issuecomment-5346610008
<!-- coverage-report -->
### Code Coverage Report
|Overall Project|68.74% **`-0.16%`**|:green_circle:|
|:-|:-|:-:|
|Files changed|14.02%|:red_circle:|
<br>
|Module|Coverage||
|:-|:-|:-:|
|aliyun|1.72%|:red_circle:|
|api|49.18%|:green_circle:|
|authorization-common|85.96%|:green_circle:|
|aws|42.04%|:green_circle:|
|azure|2.47%|:red_circle:|
|catalog-common|9.92%|:red_circle:|
|catalog-fileset|79.77%|:green_circle:|
|catalog-glue|68.95%|:green_circle:|
|catalog-hive|82.96%|:green_circle:|
|catalog-jdbc-common|45.7%|:green_circle:|
|catalog-jdbc-doris|81.8%|:green_circle:|
|catalog-jdbc-mysql|79.33%|:green_circle:|
|catalog-jdbc-postgresql|83.39%|:green_circle:|
|catalog-jdbc-starrocks|79.16%|:green_circle:|
|catalog-kafka|77.01%|:green_circle:|
|catalog-lakehouse-generic|59.18%|:green_circle:|
|catalog-lakehouse-hudi|79.1%|:green_circle:|
|catalog-lakehouse-iceberg|85.86%|:green_circle:|
|catalog-lakehouse-paimon|84.23%|:green_circle:|
|catalog-model|77.72%|:green_circle:|
|cli|44.48%|:green_circle:|
|client-java|78.57%|:green_circle:|
|common|52.39%|:green_circle:|
|core|83.56%|:green_circle:|
|filesystem-hadoop3|77.28%|:green_circle:|
|flink|0.0%|:red_circle:|
|flink-common|48.68%|:green_circle:|
|flink-runtime|0.0%|:red_circle:|
|gcp|14.12%|:red_circle:|
|hadoop-auth|68.0%|:green_circle:|
|hadoop-common|12.7%|:red_circle:|
|hive-metastore-common|53.4%|:green_circle:|
|iceberg-aliyun-bundle|0.0%|:red_circle:|
|iceberg-common|64.75%|:green_circle:|
|iceberg-rest-server|75.0%|:green_circle:|
|idp-basic|85.98%|:green_circle:|
|integration-test-common|0.0%|:red_circle:|
|jobs|62.92%|:green_circle:|
|lance-common|31.63%|:red_circle:|
|lance-rest-server|63.47%|:green_circle:|
|lineage|53.02%|:green_circle:|
|optimizer|83.17%|:green_circle:|
|optimizer-api|21.95%|:red_circle:|
|server|87.44%|:green_circle:|
|server-common|79.57%|:green_circle:|
|spark|28.57%|:red_circle:|
|spark-common|45.89%|:green_circle:|
|tencent|69.84%|:green_circle:|
|trino-connector|41.28% **`-2.03%`**|:green_circle:|
<details>
<summary>Files</summary>
|Module|File|Coverage||
|:-|:-|:-|:-:|
|trino-connector|[GravitinoConnectorFactory.java](https://github.com/diqiu50/gravitino/blob/abf0df3eafd2d0f7551669119415f8c1c6357403/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/GravitinoConnectorFactory.java)|19.54%|:red_circle:|
||[JsonCodec.java](https://github.com/diqiu50/gravitino/blob/abf0df3eafd2d0f7551669119415f8c1c6357403/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/util/json/JsonCodec.java)|12.14%|:red_circle:|
||[GravitinoDynamicFilter.java](https://github.com/diqiu50/gravitino/blob/abf0df3eafd2d0f7551669119415f8c1c6357403/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/GravitinoDynamicFilter.java)|0.0%|:red_circle:|
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org