World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#8771] feat(spark-connector): Add Spark 4.0 support, drop 3.3 and 3.4 (#12414)
YangJiebcf36c7e694b
diff --git a/.github/workflows/backend-integration-test-action.yml b/.github/workflows/backend-integration-test-action.ymlindex abbccddf72..3d530026cf 100644--- a/.github/workflows/backend-integration-test-action.yml+++ b/.github/workflows/backend-integration-test-action.yml@@ -72,9 +72,8 @@ jobs:-x :flink-connector:flink-1.18:test -x :flink-connector:flink-runtime-1.18:test \-x :flink-connector:flink-1.19:test -x :flink-connector:flink-runtime-1.19:test \-x :flink-connector:flink-1.20:test -x :flink-connector:flink-runtime-1.20:test \- -x :spark-connector:spark-common:test \- -x :spark-connector:spark-3.3:test -x :spark-connector:spark-3.4:test -x :spark-connector:spark-3.5:test \- -x :spark-connector:spark-runtime-3.3:test -x :spark-connector:spark-runtime-3.4:test -x :spark-connector:spark-runtime-3.5:test \+ -x :spark-connector:spark-3.5:test -x :spark-connector:spark-4.0:test \+ -x :spark-connector:spark-runtime-3.5:test -x :spark-connector:spark-runtime-4.0:test \-x :trino-connector:integration-test:test -x :trino-connector:trino-connector:test \-x :iceberg:iceberg-rest-trino-it:test \-x :plugins:idp-basic:test \diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 2c3f5a5426..dd814543b7 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -133,8 +133,6 @@ jobs:- name: Build with Scala2.13run: |- ./gradlew :spark-connector:spark-3.3:build -PscalaVersion=2.13 -PskipITs -PskipDockerTests=false -PskipWeb=true- ./gradlew :spark-connector:spark-3.4:build -PscalaVersion=2.13 -PskipITs -PskipDockerTests=false -PskipWeb=true./gradlew :spark-connector:spark-3.5:build -PscalaVersion=2.13 -PskipITs -PskipDockerTests=false -PskipWeb=true- name: Upload unit tests reportdiff --git a/.github/workflows/cron-integration-test.yml b/.github/workflows/cron-integration-test.ymlindex 824ef9d414..51245b915d 100644--- a/.github/workflows/cron-integration-test.yml+++ b/.github/workflows/cron-integration-test.yml@@ -104,8 +104,7 @@ jobs:catalogs/**/*.logcatalogs/**/*.tardistribution/**/*.log- spark-connector/v3.3/spark/build/spark-3.3-integration-test.log- spark-connector/v3.4/spark/build/spark-3.4-integration-test.logspark-connector/v3.5/spark/build/spark-3.5-integration-test.log+ spark-connector/v4.0/spark/build/spark-4.0-integration-test.logflink-connector/build/flink-connector-integration-test.logflink-connector/build/*.tardiff --git a/.github/workflows/spark-integration-test-action.yml b/.github/workflows/spark-integration-test-action.ymlindex 39d679fda9..baa3eb9ad0 100644--- a/.github/workflows/spark-integration-test-action.yml+++ b/.github/workflows/spark-integration-test-action.yml@@ -25,6 +25,8 @@ jobs:start-runner:name: JDK${{ inputs.java-version }}-${{ inputs.test-mode }}-Scala${{ inputs.scala-version }}runs-on: ubuntu-latest+ # This job runs the integration suite once per supported Spark line, so its cost grows with the+ # matrix rather than with the number of jobs.timeout-minutes: 120env:PLATFORM: ${{ inputs.architecture }}@@ -56,11 +58,12 @@ jobs:- name: Spark Integration Testid: integrationTestrun: |- if [ "${{ inputs.scala-version }}" == "2.12" ];then- ./gradlew -PskipTests -PtestMode=${{ inputs.test-mode }} -PscalaVersion=${{ inputs.scala-version }} -PskipDockerTests=false -PskipWeb=true :spark-connector:spark-3.3:test --tests "org.apache.gravitino.spark.connector.integration.test.**"- fi- ./gradlew -PskipTests -PtestMode=${{ inputs.test-mode }} -PscalaVersion=${{ inputs.scala-version }} -PskipDockerTests=false -PskipWeb=true :spark-connector:spark-3.4:test --tests "org.apache.gravitino.spark.connector.integration.test.**"./gradlew -PskipTests -PtestMode=${{ inputs.test-mode }} -PscalaVersion=${{ inputs.scala-version }} -PskipDockerTests=false -PskipWeb=true :spark-connector:spark-3.5:test --tests "org.apache.gravitino.spark.connector.integration.test.**"+ # Spark 4 is Scala 2.13 only, so its module ignores -PscalaVersion. Guard on 2.12 so that+ # adding a 2.13 entry to the matrix later does not run the Spark 4 suite twice.+ if [ "${{ inputs.scala-version }}" == "2.12" ]; then+ ./gradlew -PskipTests -PtestMode=${{ inputs.test-mode }} -PskipDockerTests=false -PskipWeb=true :spark-connector:spark-4.0:test --tests "org.apache.gravitino.spark.connector.integration.test.**"+ fi- name: Upload integrate tests reportsuses: actions/upload-artifact@v7@@ -69,8 +72,7 @@ jobs:name: spark-connector-integrate-test-reports-${{ inputs.java-version }}-${{ inputs.test-mode }}path: |build/reports- spark-connector/v3.3/spark/build/spark-3.3-integration-test.log- spark-connector/v3.4/spark/build/spark-3.4-integration-test.logspark-connector/v3.5/spark/build/spark-3.5-integration-test.log+ spark-connector/v4.0/spark/build/spark-4.0-integration-test.logdistribution/package/logs/*.outdistribution/package/logs/*.logdiff --git a/.github/workflows/trino-integration-test.yml b/.github/workflows/trino-integration-test.ymlindex 5a60b65cd3..bf528eca3e 100644--- a/.github/workflows/trino-integration-test.yml+++ b/.github/workflows/trino-integration-test.yml@@ -87,9 +87,8 @@ jobs:-x :flink-connector:flink-runtime-1.19:build \-x :flink-connector:flink-1.20:build \-x :flink-connector:flink-runtime-1.20:build \- -x :spark-connector:spark-common:build \- -x :spark-connector:spark-3.3:build -x :spark-connector:spark-3.4:build -x :spark-connector:spark-3.5:build \- -x :spark-connector:spark-runtime-3.3:build -x :spark-connector:spark-runtime-3.4:build -x :spark-connector:spark-runtime-3.5:build \+ -x :spark-connector:spark-3.5:build -x :spark-connector:spark-4.0:build \+ -x :spark-connector:spark-runtime-3.5:build -x :spark-connector:spark-runtime-4.0:build \-x :mcp-server:build -x :lineage:build \-x :maintenance:optimizer:build -x :maintenance:jobs:build \-x :lance:lance-common:build -x :lance:lance-rest-server:builddiff --git a/.github/workflows/trino-multi-version-test.yml b/.github/workflows/trino-multi-version-test.ymlindex 6cf4484f07..b5b79081bf 100644--- a/.github/workflows/trino-multi-version-test.yml+++ b/.github/workflows/trino-multi-version-test.yml@@ -33,9 +33,8 @@ jobs:-x :flink-connector:flink-runtime-1.19:build \-x :flink-connector:flink-1.20:build \-x :flink-connector:flink-runtime-1.20:build \- -x :spark-connector:spark-common:build \- -x :spark-connector:spark-3.3:build -x :spark-connector:spark-3.4:build -x :spark-connector:spark-3.5:build \- -x :spark-connector:spark-runtime-3.3:build -x :spark-connector:spark-runtime-3.4:build -x :spark-connector:spark-runtime-3.5:build \+ -x :spark-connector:spark-3.5:build -x :spark-connector:spark-4.0:build \+ -x :spark-connector:spark-runtime-3.5:build -x :spark-connector:spark-runtime-4.0:build \-x :mcp-server:build -x :lineage:build \-x :maintenance:optimizer:build -x :maintenance:jobs:build \-x :lance:lance-common:build -x :lance:lance-rest-server:builddiff --git a/build.gradle.kts b/build.gradle.ktsindex a16276cfbd..583c1d3deb 100644--- a/build.gradle.kts+++ b/build.gradle.kts@@ -394,8 +394,18 @@ subprojects {":flink-connector")+ // Spark 4 requires JDK 17, so the Spark 4 connector modules opt out of the JDK 8 target even+ // though the rest of :spark-connector (3.x) stays on Java 8.+ val jdk17OnlyProjectPaths = setOf(+ ":spark-connector:spark-4.0",+ ":spark-connector:spark-runtime-4.0"+ )+fun compatibleWithJDK8(project: Project): Boolean {val path = project.path.lowercase()+ if (jdk17OnlyProjectPaths.any { path == it.lowercase() }) {+ return false+ }return jdk8CompatibleProjectPathPrefixes.any { path.startsWith(it) }}extensions.extraProperties.set("excludePackagesForSparkConnector", ::excludePackagesForSparkConnector)diff --git a/docs/how-to-build.md b/docs/how-to-build.mdindex e6bad80121..7643c786ce 100644--- a/docs/how-to-build.md+++ b/docs/how-to-build.md@@ -74,14 +74,12 @@ Gravitino builds from source on Linux and macOS natively, and on Windows throughIf you want to build a module on its own, like the Spark connector, you can use Gradle to build a module with a specific name, like so:```shell- ./gradlew spark-connector:spark-runtime-3.4:build -PscalaVersion=2.12+ ./gradlew spark-connector:spark-runtime-3.5:build -PscalaVersion=2.12```- This creates `gravitino-spark-connector-runtime-{sparkVersion}_{scalaVersion}-{version}.jar` under the `spark-connector/v3.4/spark-runtime/build/libs` directory. You could replace `3.4` with `3.3` or `3.5` to specify different Spark versions and replace `2.12` with `2.13` for different Scala versions. The default Scala version is `2.12` if `-PscalaVersion` is not specified.+ This creates `gravitino-spark-connector-runtime-{sparkVersion}_{scalaVersion}-{version}.jar` under the `spark-connector/v3.5/spark-runtime/build/libs` directory. Replace `2.12` with `2.13` to build against a different Scala version. The default Scala version is `2.12` if `-PscalaVersion` is not specified.- :::info- Gravitino Spark connector doesn't support Scala 2.13 for Spark 3.3.- :::+ Replace `spark-runtime-3.5` with `spark-runtime-4.0` for Spark 4. Spark 4 is Scala 2.13 only, so that module ignores `-PscalaVersion` and always builds against 2.13.:::noteThe first time you build the project, downloading the dependencies may take a while.diff --git a/docs/spark-connector/spark-catalog-glue.md b/docs/spark-connector/spark-catalog-glue.mdindex 716c31dced..0ee91190df 100644--- a/docs/spark-connector/spark-catalog-glue.md+++ b/docs/spark-connector/spark-catalog-glue.md@@ -34,10 +34,15 @@ Table routing is based on the `table-format` property in Glue table parameters.- Network access to the AWS Glue API and Amazon S3- AWS IAM credentials with necessary Glue and S3 permissions.See [AWS IAM permissions](../aws-glue-catalog.md#aws-iam-permissions) for the required policy-- Apache Spark 3.3, 3.4, or 3.5+- Apache Spark 3.5- Patched Hive and AWS Glue client JARs (see [Setup](#setup); pre-installed on Amazon EMR)- `iceberg-spark-runtime` and `iceberg-aws-bundle` JARs on the Spark classpath for Iceberg table support (not required on Amazon EMR)+:::note+The connector resolves a Glue catalog class on Spark 4 as well, but the patched Hive JARs this+catalog needs are only published for Spark 3, so Glue is verified on Spark 3.5 only.+:::+## SetupSpark's bundled Hive 2.3.9 does not include the `HiveMetaStoreClientFactory` interface@@ -75,7 +80,7 @@ that include the patched Hive 2.3.10 and the AWS Glue Data Catalog client for SpDownload all JARs from the `spark3/glue-3.4.0` directory of[spark-hive-glue-libs](https://github.com/datastrato/spark-hive-glue-libs).The directory name refers to the Glue client version (3.4.0), not the Spark version;-these JARs are compatible with Spark 3.3, 3.4, and 3.5.+these JARs are compatible with Spark 3.5.```bashmkdir -p /opt/glue-hive-jarsdiff --git a/docs/spark-connector/spark-catalog-iceberg.md b/docs/spark-connector/spark-catalog-iceberg.mdindex 056c70dbd4..15ecec1b75 100644--- a/docs/spark-connector/spark-catalog-iceberg.md+++ b/docs/spark-connector/spark-catalog-iceberg.md@@ -18,9 +18,8 @@ Spark clients use a different Iceberg version than the Gravitino server (1.11.0)| Spark version | Scala | Iceberg version | Iceberg client runtime artifact | Gravitino connector runtime artifact ||---------------|----------------|-----------------|---------------------------------------------------------|-----------------------------------------------------------------------------------|-| 3.3 | 2.12 or 2.13 | 1.8.1 | `iceberg-spark-runtime-3.3_${scala-version}-1.8.1.jar` | `gravitino-spark-connector-runtime-3.3_${scala-version}-${gravitino-version}.jar` |-| 3.4 | 2.12 or 2.13 | 1.11.0 | `iceberg-spark-runtime-3.4_${scala-version}-1.11.0.jar` | `gravitino-spark-connector-runtime-3.4_${scala-version}-${gravitino-version}.jar` || 3.5 | 2.12 or 2.13 | 1.11.0 | `iceberg-spark-runtime-3.5_${scala-version}-1.11.0.jar` | `gravitino-spark-connector-runtime-3.5_${scala-version}-${gravitino-version}.jar` |+| 4.0 | 2.13 | 1.11.0 | `iceberg-spark-runtime-4.0_2.13-1.11.0.jar` | `gravitino-spark-connector-runtime-4.0_2.13-${gravitino-version}.jar` |Replace `${scala-version}` with `2.12` or `2.13`, and `${gravitino-version}` with your Gravitino release version.diff --git a/docs/spark-connector/spark-catalog-paimon.md b/docs/spark-connector/spark-catalog-paimon.mdindex 5fcf67fd19..02dde3b683 100644--- a/docs/spark-connector/spark-catalog-paimon.md+++ b/docs/spark-connector/spark-catalog-paimon.md@@ -14,6 +14,12 @@ The Apache Gravitino Spark connector offers the capability to read and write Pai1. Set `spark.sql.gravitino.enablePaimonSupport` to `true` in Spark configuration.2. Download Paimon Spark runtime jar to Spark classpath.+:::info+The Paimon catalog is available on Spark 3.5 only. Paimon first published `paimon-spark-4.0` in+Paimon 1.3.0, above the version Gravitino currently depends on, so the Spark 4 connector builds+without the Paimon classes.+:::+## Capabilities### DDL and DML Operationsdiff --git a/docs/spark-connector/spark-connector.md b/docs/spark-connector/spark-connector.mdindex 433481864a..b51ca6c262 100644--- a/docs/spark-connector/spark-connector.md+++ b/docs/spark-connector/spark-connector.md@@ -17,13 +17,13 @@ The Apache Gravitino Spark connector leverages the Spark DataSourceV2 interface## Requirement-* Spark 3.3 or 3.4 or 3.5-* Scala 2.12 or 2.13-* JDK 8, 11 or 17+* Spark 3.5 or 4.0+* Scala 2.12 or 2.13 on Spark 3.5; Spark 4 is Scala 2.13 only+* JDK 8, 11 or 17 on Spark 3.5; Spark 4 requires JDK 17## Usage-1. [Build](../how-to-build.md) or download the package ([gravitino-spark-connector-runtime-3.3](https://mvnrepository.com/artifact/org.apache.gravitino/gravitino-spark-connector-runtime-3.3), [gravitino-spark-connector-runtime-3.4](https://mvnrepository.com/artifact/org.apache.gravitino/gravitino-spark-connector-runtime-3.4), [gravitino-spark-connector-runtime-3.5](https://mvnrepository.com/artifact/org.apache.gravitino/gravitino-spark-connector-runtime-3.5)), and place it to the classpath of Spark.+1. [Build](../how-to-build.md) or download the package matching your Spark minor version and Scala version ([gravitino-spark-connector-runtime-3.5_2.12](https://mvnrepository.com/artifact/org.apache.gravitino/gravitino-spark-connector-runtime-3.5_2.12), [gravitino-spark-connector-runtime-3.5_2.13](https://mvnrepository.com/artifact/org.apache.gravitino/gravitino-spark-connector-runtime-3.5_2.13), [gravitino-spark-connector-runtime-4.0_2.13](https://mvnrepository.com/artifact/org.apache.gravitino/gravitino-spark-connector-runtime-4.0_2.13)), and place it to the classpath of Spark.2. Configure the Spark session to use the Gravitino spark connector.| Property | Type | Default Value | Description | Required |@@ -132,7 +132,7 @@ Gravitino spark connector support the following datatype mapping between Spark a| `CharType` | `char` || `VarcharType` | `varchar` || `TimestampType` | `timestamp with time zone` |-| `TimestampNTZType` *(Spark 3.4+)* | `timestamp without time zone` |+| `TimestampNTZType` | `timestamp without time zone` || `DateType` | `date` || `BinaryType` | `binary` || `ArrayType` | `array` |diff --git a/docs/spark-connector/spark-integration-test.md b/docs/spark-connector/spark-integration-test.mdindex b8fb28d52e..4ede773044 100644--- a/docs/spark-connector/spark-integration-test.md+++ b/docs/spark-connector/spark-integration-test.md@@ -14,15 +14,17 @@ There are two types of integration tests in spark connector, normal integrationNormal integration test are mainly used to test the correctness of the metadata, it's enabled in the GitHub CI. You could run tests with specific Spark version like:```-./gradlew :spark-connector:spark-3.3:test --tests "org.apache.gravitino.spark.connector.integration.test.hive.SparkHiveCatalogIT33.testCreateHiveFormatPartitionTable"+./gradlew :spark-connector:spark-3.5:test --tests "org.apache.gravitino.spark.connector.integration.test.hive.SparkHiveCatalogIT35.testCreateHiveFormatPartitionTable"```+Every version module carries its own subclass of each shared IT, named after the Spark minor version, so the Spark 4.0 equivalent is `:spark-connector:spark-4.0:test --tests "...SparkHiveCatalogIT40.testCreateHiveFormatPartitionTable"`.+## Golden File Integration TestGolden file integration test are mainly to test the correctness of the SQL result with massive data, it's disabled in the GitHub CI, you could run tests with following command:```-./gradlew :spark-connector:spark-3.3:test --tests "org.apache.gravitino.spark.connector.integration.test.sql.SparkSQLRegressionTest33" -PenableSparkSQLITs+./gradlew :spark-connector:spark-3.5:test --tests "org.apache.gravitino.spark.connector.integration.test.sql.SparkSQLRegressionTest35" -PenableSparkSQLITs```Please change the Spark version number if you want to test other Spark versions.diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.tomlindex 6224b289d8..02d82c09a2 100644--- a/gradle/libs.versions.toml+++ b/gradle/libs.versions.toml@@ -68,14 +68,17 @@ commons-configuration1 = "1.6"commons-dbcp2 = "2.11.0"caffeine = "2.9.3"iceberg = '1.11.0'-# Last Iceberg release compatible with Spark 3.3; Spark 3.3 deploy ITs cover basic CRUD only.+# Last Iceberg release compatible with Spark 3.3.iceberg4spark33 = "1.8.1"-iceberg4spark34 = "1.11.0"iceberg4spark35 = "1.11.0"+iceberg4spark40 = "1.11.0"paimon = '1.2.0'+# spark33 and spark34 are pinned by modules other than the Spark connector for their own tests, so+# they stay after the connector dropped 3.3 and 3.4; they say nothing about connector support.spark33 = "3.3.4"spark34 = "3.4.3"spark35 = "3.5.3"+spark40 = "4.0.3"kyuubi4spark = "1.11.0"kyuubi4authz = "1.10.2"trino = '435'diff --git a/settings.gradle.kts b/settings.gradle.ktsindex 739f44ec89..39269c623c 100644--- a/settings.gradle.kts+++ b/settings.gradle.kts@@ -82,7 +82,6 @@ if (!skipTrinoConnector) {} else {println("Skipping trino-connector modules since skipTrinoConnector is set to true")}-include("spark-connector:spark-common")if (scalaVersion == "2.12") {// flink only support scala 2.12include("flink-connector:flink-common")@@ -104,14 +103,14 @@ if (scalaVersion == "2.12") {project(":flink-connector:flink-runtime-1.20").projectDir =file("flink-connector/v1.20/flink-runtime")}-include("spark-connector:spark-3.3", "spark-connector:spark-runtime-3.3")-project(":spark-connector:spark-3.3").projectDir = file("spark-connector/v3.3/spark")-project(":spark-connector:spark-runtime-3.3").projectDir = file("spark-connector/v3.3/spark-runtime")-include("spark-connector:spark-3.4", "spark-connector:spark-runtime-3.4", "spark-connector:spark-3.5", "spark-connector:spark-runtime-3.5")-project(":spark-connector:spark-3.4").projectDir = file("spark-connector/v3.4/spark")-project(":spark-connector:spark-runtime-3.4").projectDir = file("spark-connector/v3.4/spark-runtime")+include("spark-connector:spark-3.5", "spark-connector:spark-runtime-3.5")project(":spark-connector:spark-3.5").projectDir = file("spark-connector/v3.5/spark")project(":spark-connector:spark-runtime-3.5").projectDir = file("spark-connector/v3.5/spark-runtime")+// Spark 4.0 support (#8771). Spark 4 is Scala 2.13 only and needs JDK 17, so these modules pin+// 2.13 rather than reading -PscalaVersion.+include("spark-connector:spark-4.0", "spark-connector:spark-runtime-4.0")+project(":spark-connector:spark-4.0").projectDir = file("spark-connector/v4.0/spark")+project(":spark-connector:spark-runtime-4.0").projectDir = file("spark-connector/v4.0/spark-runtime")include("web:web", "web:integration-test")include("web-v2:web", "web-v2:integration-test")include("docs")diff --git a/spark-connector/build.gradle.kts b/spark-connector/build.gradle.ktsindex 043fbfec67..4c1bc74960 100644--- a/spark-connector/build.gradle.kts+++ b/spark-connector/build.gradle.kts@@ -16,7 +16,66 @@* specific language governing permissions and limitations* under the License.*/+import com.diffplug.gradle.spotless.SpotlessExtension+import java.net.URI+// This project builds nothing of its own; it groups the per-Spark-version modules and owns the+// pieces they share. `spark-common` is a source tree rather than a module, so the version modules+// compile it themselves and nothing here produces a jar. Two exceptions stay enabled: Spotless,+// which formats the shared tree below, and downloadGlueHiveJars, which the version modules'+// Glue ITs depend on.tasks.all {- enabled = false-}\ No newline at end of file+ enabled = name.startsWith("spotless") || name == "downloadGlueHiveJars"+}++// spark-common belongs to no project, so no module's Spotless picks it up. Format it from here,+// where it lives, and keep the version modules scoped to their own trees.+plugins.withId("com.diffplug.spotless") {+ configure<SpotlessExtension> {+ java {+ target(project.fileTree("spark-common/src") { include("**/*.java") })+ }+ }+}++// Jars for Spark's IsolatedClientLoader: patched Hive 2.3.10 + Glue datacatalog client.+// aws-java-sdk-glue 1.12.31 requires PropertyNamingStrategy$PascalCaseStrategy which was+// removed in Jackson 2.12. Jackson included here so the isolated classloader uses a compatible+// version instead of the app-level Jackson bundled with Spark (2.14+).+// Only set when AWS_ACCESS_KEY_ID is present so version-specific modules can skip the download+// when Glue tests are not enabled.+val glueHiveJarsDir: String? =+ if (System.getenv("AWS_ACCESS_KEY_ID") != null) "$buildDir/tmp/glue-hive-jars" else null+extra["glueHiveJarsDir"] = glueHiveJarsDir+val glueLibsApiUrl =+ "https://api.github.com/repos/datastrato/spark-hive-glue-libs/contents/spark3/glue-3.4.0"++val downloadGlueHiveJars by+tasks.registering {+ glueHiveJarsDir?.let { outputs.dir(it) }+ onlyIf {+ val outputDir = file(glueHiveJarsDir ?: return@onlyIf false)+ outputDir.listFiles()?.none { it.name.endsWith(".jar") } ?: true+ }+ doLast {+ val outputDir = file(glueHiveJarsDir ?: return@doLast)+ outputDir.mkdirs()+ val response = URI(glueLibsApiUrl).toURL().readText()++ @Suppress("UNCHECKED_CAST")+ val entries = groovy.json.JsonSlurper().parseText(response) as List<Map<String, Any>>+ entries+ .filter { (it["name"] as String).endsWith(".jar") }+ .forEach { entry ->+ val jarName = entry["name"] as String+ val downloadUrl = entry["download_url"] as String+ val dest = outputDir.resolve(jarName)+ if (!dest.exists()) {+ logger.lifecycle("Downloading $jarName ...")+ URI(downloadUrl).toURL().openStream().use { input ->+ dest.outputStream().use { output -> input.copyTo(output) }+ }+ }+ }+ }+}diff --git a/spark-connector/spark-common/build.gradle.kts b/spark-connector/spark-common/build.gradle.ktsdeleted file mode 100644index c7aceb9e16..0000000000--- a/spark-connector/spark-common/build.gradle.kts+++ /dev/null@@ -1,243 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-import java.net.URI--plugins {- `maven-publish`- id("java")- id("idea")- alias(libs.plugins.shadow)-}--repositories {- mavenCentral()-}--val scalaVersion: String = project.properties["scalaVersion"] as? String ?: extra["defaultScalaVersion"].toString()-val sparkVersion: String = libs.versions.spark33.get()-val sparkMajorVersion: String = sparkVersion.substringBeforeLast(".")-val icebergVersion: String = libs.versions.iceberg4spark33.get()-val paimonVersion: String = libs.versions.paimon.get()-val kyuubiVersion: String = libs.versions.kyuubi4spark.get()-val scalaJava8CompatVersion: String = libs.versions.scala.java.compat.get()-val scalaCollectionCompatVersion: String = libs.versions.scala.collection.compat.get()--if (hasProperty("excludePackagesForSparkConnector")) {- @Suppress("UNCHECKED_CAST")- val configureFunc = properties["excludePackagesForSparkConnector"] as? (Project) -> Unit- configureFunc?.invoke(project)-}--dependencies {- implementation(project(":catalogs:catalog-common")) {- exclude("org.apache.logging.log4j")- }- implementation(libs.guava)- implementation(libs.caffeine)-- compileOnly(project(":clients:client-java-runtime", configuration = "shadow"))- compileOnly("org.apache.iceberg:iceberg-spark-runtime-${sparkMajorVersion}_$scalaVersion:$icebergVersion")- compileOnly(libs.aws.glue)- compileOnly("org.apache.kyuubi:kyuubi-spark-connector-hive_$scalaVersion:$kyuubiVersion")- compileOnly("org.apache.spark:spark-catalyst_$scalaVersion:$sparkVersion")- compileOnly("org.apache.spark:spark-core_$scalaVersion:$sparkVersion")- compileOnly("org.apache.spark:spark-sql_$scalaVersion:$sparkVersion")- compileOnly("org.scala-lang.modules:scala-java8-compat_$scalaVersion:$scalaJava8CompatVersion")- if (scalaVersion == "2.12") {- compileOnly("org.apache.paimon:paimon-spark-$sparkMajorVersion:$paimonVersion") {- exclude("org.apache.spark")- }- }-- annotationProcessor(libs.lombok)- compileOnly(libs.lombok)-- testAnnotationProcessor(libs.lombok)- testCompileOnly(libs.lombok)-- // use log from spark, spark3.3 use low version of log4j, to avoid java.lang.NoSuchMethodError: org.apache.logging.slf4j.Log4jLoggerFactory: method <init>()V not found- testImplementation(project(":api")) {- exclude("org.apache.logging.log4j")- }- testImplementation(project(":clients:client-java")) {- exclude("org.apache.logging.log4j")- }- testImplementation(project(":core")) {- exclude("org.apache.logging.log4j")- }- testImplementation(project(":common")) {- exclude("org.apache.logging.log4j")- }- testImplementation(project(":server")) {- exclude("org.apache.logging.log4j")- }- testImplementation(project(":server-common")) {- exclude("org.apache.logging.log4j")- }- testImplementation(project(":catalogs:catalog-glue")) {- exclude("org.apache.logging.log4j")- }- // Iceberg's GlueCatalog (in iceberg-spark-runtime) references AWS Glue SDK classes at runtime.- // catalog-glue uses `implementation` (not `api`) so the SDK is not transitively exposed here.- testImplementation(libs.aws.glue)- testImplementation(project(":integration-test-common", "testArtifacts"))-- testImplementation(libs.hive2.common) {- exclude("org.apache.curator")- // use hadoop from Spark- exclude("org.apache.hadoop")- exclude("org.apache.logging.log4j")- exclude("org.eclipse.jetty.aggregate", "jetty-all")- exclude("org.eclipse.jetty.orbit", "javax.servlet")- }- testImplementation(libs.hive2.metastore) {- exclude("co.cask.tephra")- exclude("com.github.joshelser")- exclude("com.google.code.findbugs", "jsr305")- exclude("com.google.code.findbugs", "sr305")- exclude("com.tdunning", "json")- exclude("com.zaxxer", "HikariCP")- exclude("io.dropwizard.metrics")- exclude("javax.transaction", "transaction-api")- exclude("org.apache.avro")- exclude("org.apache.curator")- exclude("org.apache.hbase")- exclude("org.apache.hadoop")- exclude("org.apache.hive", "hive-common")- exclude("org.apache.hive", "hive-shims")- exclude("org.apache.logging.log4j")- exclude("org.apache.parquet", "parquet-hadoop-bundle")- exclude("org.apache.zookeeper")- exclude("org.eclipse.jetty.aggregate", "jetty-all")- exclude("org.eclipse.jetty.orbit", "javax.servlet")- exclude("org.slf4j")- }- testImplementation(libs.junit.jupiter.api)- testImplementation(libs.junit.jupiter.params)- testImplementation(libs.nimbus.jose.jwt)- testImplementation(libs.mysql.driver)- testImplementation(libs.postgresql.driver)- testImplementation(libs.mockito.core)- testImplementation(libs.mockito.inline)- testImplementation(libs.testcontainers)-- testImplementation("org.apache.iceberg:iceberg-core:$icebergVersion")- testImplementation("org.apache.iceberg:iceberg-hive-metastore:$icebergVersion")- testImplementation("org.apache.iceberg:iceberg-spark-runtime-${sparkMajorVersion}_$scalaVersion:$icebergVersion")- if (scalaVersion == "2.12") {- testImplementation("org.apache.paimon:paimon-spark-$sparkMajorVersion:$paimonVersion") {- exclude("org.apache.spark")- }- }- testImplementation("org.apache.kyuubi:kyuubi-spark-connector-hive_$scalaVersion:$kyuubiVersion")- // include spark-sql,spark-catalyst,hive-common,hdfs-client- testImplementation("org.apache.spark:spark-hive_$scalaVersion:$sparkVersion") {- // conflict with Gravitino server jersey- exclude("org.glassfish.jersey.core")- exclude("org.glassfish.jersey.containers")- exclude("org.glassfish.jersey.inject")- }- testImplementation("org.scala-lang.modules:scala-collection-compat_$scalaVersion:$scalaCollectionCompatVersion")- testImplementation("org.apache.spark:spark-catalyst_$scalaVersion:$sparkVersion")- testImplementation("org.apache.spark:spark-core_$scalaVersion:$sparkVersion")- testImplementation("org.apache.spark:spark-sql_$scalaVersion:$sparkVersion")-- testRuntimeOnly(libs.junit.jupiter.engine)-}--// Jars for Spark's IsolatedClientLoader: patched Hive 2.3.10 + Glue datacatalog client.-// aws-java-sdk-glue 1.12.31 requires PropertyNamingStrategy$PascalCaseStrategy which was-// removed in Jackson 2.12. Jackson included here so the isolated classloader uses a compatible-// version instead of the app-level Jackson bundled with Spark (2.14+).-// Only set when AWS_ACCESS_KEY_ID is present so version-specific modules can skip the download-// when Glue tests are not enabled.-val glueHiveJarsDir: String? =- if (System.getenv("AWS_ACCESS_KEY_ID") != null) "$buildDir/tmp/glue-hive-jars" else null-extra["glueHiveJarsDir"] = glueHiveJarsDir-val glueLibsApiUrl =- "https://api.github.com/repos/datastrato/spark-hive-glue-libs/contents/spark3/glue-3.4.0"--val downloadGlueHiveJars by-tasks.registering {- glueHiveJarsDir?.let { outputs.dir(it) }- onlyIf {- val outputDir = file(glueHiveJarsDir ?: return@onlyIf false)- outputDir.listFiles()?.none { it.name.endsWith(".jar") } ?: true- }- doLast {- val outputDir = file(glueHiveJarsDir ?: return@doLast)- outputDir.mkdirs()- val response = URI(glueLibsApiUrl).toURL().readText()-- @Suppress("UNCHECKED_CAST")- val entries = groovy.json.JsonSlurper().parseText(response) as List<Map<String, Any>>- entries- .filter { (it["name"] as String).endsWith(".jar") }- .forEach { entry ->- val jarName = entry["name"] as String- val downloadUrl = entry["download_url"] as String- val dest = outputDir.resolve(jarName)- if (!dest.exists()) {- logger.lifecycle("Downloading $jarName ...")- URI(downloadUrl).toURL().openStream().use { input ->- dest.outputStream().use { output -> input.copyTo(output) }- }- }- }- }-}--tasks.test {- val skipITs = project.hasProperty("skipITs")- if (skipITs) {- // Exclude integration tests- exclude("**/integration/test/**")- } else {- dependsOn(tasks.jar)- }-}--tasks.clean {- delete("spark-warehouse")-}--sourceSets {- named("test") {- resources {- exclude("**/*")- }- }-}--val testJar by tasks.registering(Jar::class) {- archiveClassifier.set("tests")- from(sourceSets["test"].output)-}--configurations {- create("testArtifacts")-}--artifacts {- add("testArtifacts", testJar)-}--tasks.named<Jar>("sourcesJar") {- duplicatesStrategy = DuplicatesStrategy.EXCLUDE-}diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/SparkTableChangeConverter.java b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/SparkTableChangeConverter.javaindex 1db82c2d8c..20205ac058 100644--- a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/SparkTableChangeConverter.java+++ b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/SparkTableChangeConverter.java@@ -19,6 +19,7 @@package org.apache.gravitino.spark.connector;import com.google.common.base.Preconditions;+import org.apache.gravitino.rel.expressions.literals.Literals;import org.apache.spark.sql.connector.catalog.TableChange;public class SparkTableChangeConverter {@@ -87,6 +88,12 @@ public class SparkTableChangeConverter {(TableChange.UpdateColumnNullability) change;return org.apache.gravitino.rel.TableChange.updateColumnNullability(updateColumnNullability.fieldNames(), updateColumnNullability.nullable());+ } else if (change instanceof TableChange.UpdateColumnDefaultValue) {+ TableChange.UpdateColumnDefaultValue updateColumnDefaultValue =+ (TableChange.UpdateColumnDefaultValue) change;+ return org.apache.gravitino.rel.TableChange.updateColumnDefaultValue(+ updateColumnDefaultValue.fieldNames(),+ Literals.stringLiteral(updateColumnDefaultValue.newDefaultValue()));} else {throw new UnsupportedOperationException(String.format("Unsupported table change %s", change.getClass().getName()));diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/SparkTypeConverter.java b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/SparkTypeConverter.javaindex 273087eff8..f15d98f95f 100644--- a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/SparkTypeConverter.java+++ b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/SparkTypeConverter.java@@ -45,6 +45,7 @@ import org.apache.spark.sql.types.ShortType;import org.apache.spark.sql.types.StringType;import org.apache.spark.sql.types.StructField;import org.apache.spark.sql.types.StructType;+import org.apache.spark.sql.types.TimestampNTZType;import org.apache.spark.sql.types.TimestampType;import org.apache.spark.sql.types.VarcharType;@@ -66,14 +67,17 @@ public class SparkTypeConverter {} else if (sparkType instanceof DecimalType) {DecimalType decimalType = (DecimalType) sparkType;return Types.DecimalType.of(decimalType.precision(), decimalType.scale());- } else if (sparkType instanceof StringType) {- return Types.StringType.get();} else if (sparkType instanceof VarcharType) {+ // Varchar and Char are checked before StringType because Spark 4 made both extend it; on 3.5+ // they extend AtomicType, so this order is correct for every supported version. Checking+ // StringType first would swallow both and silently drop the length.VarcharType varcharType = (VarcharType) sparkType;return Types.VarCharType.of(varcharType.length());} else if (sparkType instanceof CharType) {CharType charType = (CharType) sparkType;return Types.FixedCharType.of(charType.length());+ } else if (sparkType instanceof StringType) {+ return Types.StringType.get();} else if (sparkType instanceof BinaryType) {return Types.BinaryType.get();} else if (sparkType instanceof BooleanType) {@@ -82,6 +86,8 @@ public class SparkTypeConverter {return Types.DateType.get();} else if (sparkType instanceof TimestampType) {return Types.TimestampType.withTimeZone();+ } else if (sparkType instanceof TimestampNTZType) {+ return Types.TimestampType.withoutTimeZone();} else if (sparkType instanceof ArrayType) {ArrayType arrayType = (ArrayType) sparkType;return Types.ListType.of(toGravitinoType(arrayType.elementType()), arrayType.containsNull());@@ -160,9 +166,10 @@ public class SparkTypeConverter {return DataTypes.BooleanType;} else if (gravitinoType instanceof Types.DateType) {return DataTypes.DateType;- } else if (gravitinoType instanceof Types.TimestampType- && ((Types.TimestampType) gravitinoType).hasTimeZone()) {- return DataTypes.TimestampType;+ } else if (gravitinoType instanceof Types.TimestampType) {+ return ((Types.TimestampType) gravitinoType).hasTimeZone()+ ? DataTypes.TimestampType+ : DataTypes.TimestampNTZType;} else if (gravitinoType instanceof Types.ListType) {Types.ListType listType = (Types.ListType) gravitinoType;return DataTypes.createArrayType(diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/authorization/AuthorizationTable.java b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/authorization/AuthorizationTable.javaindex 73f94706e6..fc5885b2be 100644--- a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/authorization/AuthorizationTable.java+++ b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/authorization/AuthorizationTable.java@@ -125,6 +125,10 @@ public class AuthorizationTable implements Table, SupportsRead, SupportsWrite {}@Override+ // Table.schema() is deprecated from Spark 3.4 in favor of columns(); this table carries no+ // columns, so the deprecated form is the simplest way to report an empty schema on every+ // supported version.+ @SuppressWarnings("deprecation")public StructType schema() {return EMPTY_SCHEMA;}diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/catalog/BaseCatalog.java b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/catalog/BaseCatalog.javaindex b59fea1c7a..a9a9ffa186 100644--- a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/catalog/BaseCatalog.java+++ b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/catalog/BaseCatalog.java@@ -26,6 +26,7 @@ import java.util.Collections;import java.util.HashMap;import java.util.Map;import java.util.Optional;+import java.util.Set;import org.apache.commons.lang3.StringUtils;import org.apache.gravitino.Catalog;import org.apache.gravitino.NameIdentifier;@@ -64,6 +65,7 @@ import org.apache.spark.sql.connector.catalog.SupportsNamespaces;import org.apache.spark.sql.connector.catalog.Table;import org.apache.spark.sql.connector.catalog.TableCatalog;import org.apache.spark.sql.connector.catalog.TableChange;+import org.apache.spark.sql.connector.catalog.TableWritePrivilege;import org.apache.spark.sql.connector.catalog.functions.UnboundFunction;import org.apache.spark.sql.connector.expressions.Transform;import org.apache.spark.sql.types.StructField;@@ -196,6 +198,10 @@ public abstract class BaseCatalog implements TableCatalog, SupportsNamespaces, F}@Override+ // TableCatalog.createTable(Identifier, StructType, Transform[], Map) is deprecated from Spark 3.4+ // in favor of the Column[] overload. Overriding the deprecated form keeps one implementation that+ // every supported Spark version dispatches to.+ @SuppressWarnings("deprecation")public Table createTable(Identifier ident, StructType schema, Transform[] transforms, Map<String, String> properties)throws TableAlreadyExistsException, NoSuchNamespaceException {@@ -283,6 +289,12 @@ public abstract class BaseCatalog implements TableCatalog, SupportsNamespaces, FsparkTypeConverter);}+ @Override+ public Table loadTable(Identifier ident, Set<TableWritePrivilege> writePrivileges)+ throws NoSuchTableException {+ return loadTableForWriting(ident);+ }+@Overridepublic Table alterTable(Identifier ident, TableChange... changes) throws NoSuchTableException {org.apache.gravitino.rel.TableChange[] gravitinoTableChanges =diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/catalog/SparkCatalogKind.java b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/catalog/SparkCatalogKind.javanew file mode 100644index 0000000000..b9886aecce--- /dev/null+++ b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/catalog/SparkCatalogKind.java@@ -0,0 +1,83 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */+package org.apache.gravitino.spark.connector.catalog;++import com.google.common.collect.ImmutableMap;+import java.util.Locale;+import java.util.Map;+import java.util.Objects;+import javax.annotation.Nullable;++/**+ * The kinds of Spark catalog this connector implements, one per group of Gravitino catalog+ * providers that share an implementation.+ *+ * <p>Which kind a provider needs is the same on every Spark version, so that mapping lives here.+ * Which class implements a kind differs per version, so each version module binds that in its own+ * {@code GravitinoSparkPlugin}.+ */+public enum SparkCatalogKind {+ /** Hive catalogs, provider {@code hive}. */+ HIVE,+ /** Iceberg catalogs, provider {@code lakehouse-iceberg}. */+ LAKEHOUSE_ICEBERG,+ /** Paimon catalogs, provider {@code lakehouse-paimon}. */+ LAKEHOUSE_PAIMON,+ /** AWS Glue catalogs, provider {@code glue}. */+ GLUE,+ /** Every {@code jdbc-*} catalog except PostgreSQL, which has its own kind. */+ JDBC,+ /** PostgreSQL catalogs, provider {@code jdbc-postgresql}. */+ JDBC_POSTGRESQL;++ private static final String JDBC_PROVIDER_PREFIX = "jdbc";+ private static final String POSTGRESQL_PROVIDER_PREFIX = "jdbc-postgresql";++ private static final Map<String, SparkCatalogKind> KINDS_BY_PROVIDER =+ ImmutableMap.of(+ "hive",+ HIVE,+ "lakehouse-iceberg",+ LAKEHOUSE_ICEBERG,+ "lakehouse-paimon",+ LAKEHOUSE_PAIMON,+ "glue",+ GLUE);++ /**+ * Returns the kind of Spark catalog a Gravitino catalog provider needs.+ *+ * @param provider a Gravitino catalog provider, such as {@code hive} or {@code jdbc-mysql}+ * @return the matching kind, or null when this connector has no catalog for the provider+ * @throws NullPointerException if the provider is null. Callers hold a provider the server set,+ * and a catalog with none is a server-side problem worth its own message rather than a null+ * that quietly maps to no kind.+ */+ @Nullable+ public static SparkCatalogKind fromProvider(String provider) {+ Objects.requireNonNull(provider, "Catalog provider must not be null");+ String normalized = provider.toLowerCase(Locale.ROOT);+ // All JDBC backends share one Spark catalog, apart from PostgreSQL, whose type and property+ // conversions differ.+ if (normalized.startsWith(JDBC_PROVIDER_PREFIX)) {+ return normalized.startsWith(POSTGRESQL_PROVIDER_PREFIX) ? JDBC_POSTGRESQL : JDBC;+ }+ return KINDS_BY_PROVIDER.get(normalized);+ }+}diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/hive/SparkHiveTable.java b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/hive/SparkHiveTable.javaindex fbe684aefc..485737f623 100644--- a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/hive/SparkHiveTable.java+++ b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/hive/SparkHiveTable.java@@ -32,7 +32,7 @@ import org.apache.kyuubi.spark.connector.hive.HiveTableCatalog;import org.apache.spark.sql.SparkSession;import org.apache.spark.sql.catalyst.InternalRow;import org.apache.spark.sql.catalyst.analysis.NoSuchPartitionException;-import org.apache.spark.sql.catalyst.analysis.PartitionAlreadyExistsException;+import org.apache.spark.sql.catalyst.analysis.PartitionsAlreadyExistException;import org.apache.spark.sql.connector.catalog.Identifier;import org.apache.spark.sql.connector.catalog.SupportsPartitionManagement;import org.apache.spark.sql.connector.expressions.Transform;@@ -87,7 +87,7 @@ public class SparkHiveTable extends HiveTable implements SupportsPartitionManage@Overridepublic void createPartition(InternalRow ident, Map<String, String> properties)- throws PartitionAlreadyExistsException, UnsupportedOperationException {+ throws PartitionsAlreadyExistException, UnsupportedOperationException {hiveGravitinoOperationOperator.createPartition(ident, properties, partitionSchema());}diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/hive/SparkHiveTypeConverter.java b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/hive/SparkHiveTypeConverter.javaindex c2ae20f371..ec347c5f14 100644--- a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/hive/SparkHiveTypeConverter.java+++ b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/hive/SparkHiveTypeConverter.java@@ -24,6 +24,7 @@ import org.apache.gravitino.rel.types.Types;import org.apache.gravitino.spark.connector.SparkTypeConverter;import org.apache.spark.sql.types.DataType;import org.apache.spark.sql.types.DataTypes;+import org.apache.spark.sql.types.TimestampNTZType;import org.apache.spark.sql.types.TimestampType;public class SparkHiveTypeConverter extends SparkTypeConverter {@@ -35,6 +36,7 @@ public class SparkHiveTypeConverter extends SparkTypeConverter {** <ul>* <li>{@link TimestampType} ➔ {@link Types.TimestampType#withoutTimeZone()} (Hive limitation)+ * <li>{@link TimestampNTZType} is rejected: Hive has no equivalent type* <li>Other types follow base class conversion rules* </ul>*@@ -47,6 +49,9 @@ public class SparkHiveTypeConverter extends SparkTypeConverter {public Type toGravitinoType(DataType sparkType) {if (sparkType instanceof TimestampType) {return Types.TimestampType.withoutTimeZone();+ } else if (sparkType instanceof TimestampNTZType) {+ throw new UnsupportedOperationException(+ "Hive does not support 'timestamp_ntz' (timestamp without time zone), please use 'timestamp' instead.");} else {return super.toGravitinoType(sparkType);}diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalog.java b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalog.javaindex b97cdeeef4..80169829f5 100644--- a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalog.java+++ b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalog.java@@ -43,21 +43,17 @@ import org.apache.gravitino.spark.connector.catalog.BaseCatalog;import org.apache.gravitino.spark.connector.catalog.GravitinoCatalogManager;import org.apache.iceberg.catalog.Catalog;import org.apache.iceberg.spark.SparkCatalog;-import org.apache.iceberg.spark.procedures.SparkProcedures;import org.apache.iceberg.spark.source.HasIcebergCatalog;import org.apache.iceberg.spark.source.SparkTable;import org.apache.spark.SparkConf;import org.apache.spark.sql.SparkSession;import org.apache.spark.sql.catalyst.analysis.NoSuchFunctionException;import org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException;-import org.apache.spark.sql.catalyst.analysis.NoSuchProcedureException;import org.apache.spark.sql.catalyst.analysis.NoSuchTableException;import org.apache.spark.sql.connector.catalog.FunctionCatalog;import org.apache.spark.sql.connector.catalog.Identifier;import org.apache.spark.sql.connector.catalog.TableCatalog;import org.apache.spark.sql.connector.catalog.functions.UnboundFunction;-import org.apache.spark.sql.connector.iceberg.catalog.Procedure;-import org.apache.spark.sql.connector.iceberg.catalog.ProcedureCatalog;import org.apache.spark.sql.util.CaseInsensitiveStringMap;/**@@ -66,9 +62,14 @@ import org.apache.spark.sql.util.CaseInsensitiveStringMap;* Spark's ecosystem. This implementation can further adapt to specific interfaces such as* StagingTableCatalog and FunctionCatalog, allowing for advanced operations like table staging and* function management tailored to the needs of Iceberg tables.+ *+ * <p>{@code ProcedureCatalog} is not declared here. Spark 4 moved the procedure API out of+ * Iceberg's package into its own and changed the {@code loadProcedure} return type, so each version+ * module declares it against its own Spark API and reuses {@link #isSystemNamespace(String[])} for+ * the shared namespace check.*/public class GravitinoIcebergCatalog extends BaseCatalog- implements FunctionCatalog, ProcedureCatalog, HasIcebergCatalog {+ implements FunctionCatalog, HasIcebergCatalog {@Overrideprotected TableCatalog createAndInitSparkCatalog(@@ -270,34 +271,6 @@ public class GravitinoIcebergCatalog extends BaseCatalog: super.loadFunction(ident);}- /**- * Procedures will validate the equality of the catalog registered to Spark catalogManager and the- * catalog passed to `ProcedureBuilder` which invokes loadProcedure(). To meet the requirement ,- * override the method to pass `GravitinoIcebergCatalog` to the `ProcedureBuilder` instead of the- * internal spark catalog.- */- @Override- public Procedure loadProcedure(Identifier identifier) throws NoSuchProcedureException {- String[] namespace = identifier.namespace();- String name = identifier.name();-- try {- if (isSystemNamespace(namespace)) {- SparkProcedures.ProcedureBuilder builder = SparkProcedures.newBuilder(name);- if (builder != null) {- return builder.withTableCatalog(this).build();- }- }- } catch (NoSuchMethodException- | IllegalAccessException- | InvocationTargetException- | ClassNotFoundException e) {- throw new RuntimeException("Failed to load Iceberg Procedure " + identifier, e);- }-- throw new NoSuchProcedureException(identifier);- }-@Overridepublic Catalog icebergCatalog() {return ((SparkCatalog) sparkCatalog).icebergCatalog();@@ -354,7 +327,19 @@ public class GravitinoIcebergCatalog extends BaseCatalog}}- private boolean isSystemNamespace(String[] namespace)+ /**+ * Checks whether the namespace is the Iceberg system namespace, reflectively delegating to+ * Iceberg's {@code BaseCatalog#isSystemNamespace}. Exposed to the per-Spark-version subclasses so+ * their {@code loadProcedure} override can reuse it.+ *+ * @param namespace the namespace to check+ * @return true if it is the Iceberg system namespace+ * @throws NoSuchMethodException if the reflective lookup fails+ * @throws InvocationTargetException if the reflective call fails+ * @throws IllegalAccessException if the reflective call is not permitted+ * @throws ClassNotFoundException if Iceberg's BaseCatalog is not on the classpath+ */+ protected boolean isSystemNamespace(String[] namespace)throws NoSuchMethodException, InvocationTargetException, IllegalAccessException,ClassNotFoundException {Class<?> baseCatalog = Class.forName("org.apache.iceberg.spark.BaseCatalog");diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/jdbc/SparkJdbcTypeConverter.java b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/jdbc/SparkJdbcTypeConverter.javaindex 95a9c0c408..e7dccbf1c8 100644--- a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/jdbc/SparkJdbcTypeConverter.java+++ b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/jdbc/SparkJdbcTypeConverter.java@@ -29,11 +29,12 @@ public class SparkJdbcTypeConverter extends SparkTypeConverter {@Overridepublic DataType toSparkType(Type gravitinoType) {- // if spark version lower than 3.4.4, using VarCharType will throw an exception: Unsupported- // type varchar.if (gravitinoType instanceof Types.VarCharType) {+ // Spark's JDBC dialects reject VarcharType, so widen it to StringType.return DataTypes.StringType;} else if (gravitinoType instanceof Types.TimestampType) {+ // Both timestamp flavors map to TimestampType, never TimestampNTZType: the MySQL dialect only+ // pushes TimestampType literals down correctly, and NTZ literals produce invalid SQL.return DataTypes.TimestampType;} else {return super.toSparkType(gravitinoType);diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/plugin/GravitinoDriverPlugin.java b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/plugin/GravitinoDriverPlugin.javaindex c27f78dce4..85e6602b32 100644--- a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/plugin/GravitinoDriverPlugin.java+++ b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/plugin/GravitinoDriverPlugin.java@@ -36,8 +36,8 @@ import java.util.ArrayList;import java.util.Arrays;import java.util.Collections;import java.util.List;-import java.util.Locale;import java.util.Map;+import java.util.Objects;import java.util.Optional;import java.util.stream.Collectors;import java.util.stream.Stream;@@ -52,10 +52,9 @@ import org.apache.gravitino.client.GravitinoClient.ClientBuilder;import org.apache.gravitino.client.GravitinoClientConfiguration;import org.apache.gravitino.client.KerberosTokenProvider;import org.apache.gravitino.spark.connector.GravitinoSparkConfig;-import org.apache.gravitino.spark.connector.authorization.GravitinoAuthorizationSparkSessionExtensions;import org.apache.gravitino.spark.connector.catalog.GravitinoCatalogManager;+import org.apache.gravitino.spark.connector.catalog.SparkCatalogKind;import org.apache.gravitino.spark.connector.iceberg.extensions.GravitinoIcebergSparkSessionExtensions;-import org.apache.gravitino.spark.connector.version.CatalogNameAdaptor;import org.apache.hadoop.security.UserGroupInformation;import org.apache.spark.SparkConf;import org.apache.spark.SparkContext;@@ -70,11 +69,16 @@ import scala.Option;/*** GravitinoDriverPlugin creates GravitinoCatalogManager to fetch catalogs from Apache Gravitino and* register Gravitino catalogs to Apache Spark.+ *+ * <p>The classes it registers differ per Spark version, so it takes them as {@link SparkBindings}+ * from the version module's {@code GravitinoSparkPlugin} rather than naming them itself.*/public class GravitinoDriverPlugin implements DriverPlugin {private static final Logger LOG = LoggerFactory.getLogger(GravitinoDriverPlugin.class);+ @VisibleForTesting static final String PAIMON_PROVIDER = "lakehouse-paimon";+@VisibleForTestingstatic final String PAIMON_SPARK_EXTENSIONS ="org.apache.paimon.spark.extensions.PaimonSparkSessionExtensions";@@ -83,18 +87,28 @@ public class GravitinoDriverPlugin implements DriverPlugin {static final String ICEBERG_SPARK_EXTENSIONS ="org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions";- private GravitinoCatalogManager catalogManager;+ private final SparkBindings bindings;private final List<String> gravitinoIcebergExtensions =Arrays.asList(GravitinoIcebergSparkSessionExtensions.class.getName(), ICEBERG_SPARK_EXTENSIONS);private final List<String> gravitinoPaimonExtensions = Arrays.asList(PAIMON_SPARK_EXTENSIONS);- private final List<String> gravitinoDriverExtensions =- new ArrayList<>(- Collections.singletonList(GravitinoAuthorizationSparkSessionExtensions.class.getName()));+ private final List<String> gravitinoDriverExtensions;+ private GravitinoCatalogManager catalogManager;private boolean enableIcebergSupport = false;private boolean enablePaimonSupport = false;+ /**+ * Creates the plugin from the classes a connector build supplies.+ *+ * @param bindings the catalog and session extension classes of this build+ */+ public GravitinoDriverPlugin(SparkBindings bindings) {+ this.bindings = bindings;+ this.gravitinoDriverExtensions =+ new ArrayList<>(Collections.singletonList(bindings.authorizationExtension()));+ }+@Overridepublic Map<String, String> init(SparkContext sc, PluginContext pluginContext) {SparkConf conf = sc.conf();@@ -110,16 +124,7 @@ public class GravitinoDriverPlugin implements DriverPlugin {String.format("%s:%s, should not be empty", GravitinoSparkConfig.GRAVITINO_METALAKE, metalake));- this.enableIcebergSupport =- conf.getBoolean(GravitinoSparkConfig.GRAVITINO_ENABLE_ICEBERG_SUPPORT, false);- this.enablePaimonSupport =- conf.getBoolean(GravitinoSparkConfig.GRAVITINO_ENABLE_PAIMON_SUPPORT, false);- if (enablePaimonSupport) {- gravitinoDriverExtensions.addAll(gravitinoPaimonExtensions);- }- if (enableIcebergSupport) {- gravitinoDriverExtensions.addAll(gravitinoIcebergExtensions);- }+ registerOptInExtensions(conf);this.catalogManager =GravitinoCatalogManager.create(@@ -141,8 +146,8 @@ public class GravitinoDriverPlugin implements DriverPlugin {}}- private void registerGravitinoCatalogs(- SparkConf sparkConf, Map<String, Catalog> gravitinoCatalogs) {+ @VisibleForTesting+ void registerGravitinoCatalogs(SparkConf sparkConf, Map<String, Catalog> gravitinoCatalogs) {gravitinoCatalogs.entrySet().forEach(@@ -150,31 +155,47 @@ public class GravitinoDriverPlugin implements DriverPlugin {String catalogName = entry.getKey();Catalog gravitinoCatalog = entry.getValue();String provider = gravitinoCatalog.provider();- if ("lakehouse-iceberg".equals(provider.toLowerCase(Locale.ROOT))- && !enableIcebergSupport) {+ if (StringUtils.isBlank(provider)) {+ LOG.warn("Skip registering {} because catalog provider is empty.", catalogName);+ return;+ }+ // The provider is read once, here, and every decision below is made from the kind, so+ // no two places can disagree about what this catalog is.+ SparkCatalogKind kind = SparkCatalogKind.fromProvider(provider);+ if (kind == null) {+ LOG.warn(+ "Skip registering {} because {} is not supported yet.", catalogName, provider);+ return;+ }+ if (SparkCatalogKind.LAKEHOUSE_ICEBERG.equals(kind) && !enableIcebergSupport) {return;}- if ("lakehouse-paimon".equals(provider.toLowerCase(Locale.ROOT))- && !enablePaimonSupport) {+ if (SparkCatalogKind.LAKEHOUSE_PAIMON.equals(kind) && !enablePaimonSupport) {return;}try {- registerCatalog(sparkConf, catalogName, provider);+ registerCatalog(sparkConf, catalogName, kind);} catch (Exception e) {LOG.warn("Register catalog {} failed.", catalogName, e);}});}- private void registerCatalog(SparkConf sparkConf, String catalogName, String provider) {- if (StringUtils.isBlank(provider)) {- LOG.warn("Skip registering {} because catalog provider is empty.", catalogName);- return;- }-- String catalogClassName = CatalogNameAdaptor.getCatalogName(provider);- if (StringUtils.isBlank(catalogClassName)) {- LOG.warn("Skip registering {} because {} is not supported yet.", catalogName, provider);+ /**+ * Registers the Spark catalog class bound to {@code kind} under {@code catalogName}, or skips the+ * catalog when this build bound none.+ *+ * @param sparkConf the conf to register into+ * @param catalogName the Gravitino catalog name, which becomes the Spark catalog name+ * @param kind the kind of catalog to register+ * @throws NullPointerException if the kind is null. A provider that maps to no kind is the+ * caller's to report, since only the caller still has the provider name.+ */+ @VisibleForTesting+ void registerCatalog(SparkConf sparkConf, String catalogName, SparkCatalogKind kind) {+ String catalogClassName = catalogClassName(kind);+ if (catalogClassName == null) {+ LOG.warn("Skip registering {} because this build has no {} catalog.", catalogName, kind);return;}@@ -186,6 +207,57 @@ public class GravitinoDriverPlugin implements DriverPlugin {LOG.info("Register {} catalog to Spark catalog manager.", catalogName);}+ /**+ * Resolves the Spark catalog class bound to a kind, from the bindings this build supplied.+ * Returns null when the build bound no catalog for it, which is how a kind this build cannot+ * serve, such as Paimon on Spark 4, is skipped.+ */+ @Nullable+ @VisibleForTesting+ String catalogClassName(SparkCatalogKind kind) {+ Objects.requireNonNull(kind, "Catalog kind must not be null");+ return bindings.catalogClassNames().get(kind);+ }++ /**+ * Reads the two opt-in flags and queues the session extensions they ask for. Extracted from+ * {@link #init(SparkContext, PluginContext)} so a test can exercise the flags without a live+ * SparkContext, and takes the conf rather than two booleans so the config keys are covered too.+ *+ * @param conf the Spark conf to read the opt-in flags from+ */+ @VisibleForTesting+ void registerOptInExtensions(SparkConf conf) {+ this.enableIcebergSupport =+ conf.getBoolean(GravitinoSparkConfig.GRAVITINO_ENABLE_ICEBERG_SUPPORT, false);+ this.enablePaimonSupport =+ conf.getBoolean(GravitinoSparkConfig.GRAVITINO_ENABLE_PAIMON_SUPPORT, false);+ if (enablePaimonSupport) {+ registerPaimonExtensionsIfSupported();+ }+ if (enableIcebergSupport) {+ gravitinoDriverExtensions.addAll(gravitinoIcebergExtensions);+ }+ }++ /**+ * Queues the Paimon session extensions, unless this build has no Paimon catalog. Paimon publishes+ * no paimon-spark artifact for every Spark version and Scala version this connector supports, so+ * some builds omit the Paimon classes; registering the extension there would fail SparkSession+ * construction with a ClassNotFoundException. Skip it the way an unsupported catalog provider is+ * skipped, so a config carried over from another build degrades to a warning.+ */+ @VisibleForTesting+ void registerPaimonExtensionsIfSupported() {+ if (!bindings.catalogClassNames().containsKey(SparkCatalogKind.LAKEHOUSE_PAIMON)) {+ LOG.warn(+ "Skip registering Paimon session extensions because {} is not supported yet.",+ PAIMON_PROVIDER);+ return;+ }+ gravitinoDriverExtensions.addAll(gravitinoPaimonExtensions);+ }+@VisibleForTestingvoid registerSqlExtensions(SparkConf conf) {String extensionString = String.join(COMMA, gravitinoDriverExtensions);diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/plugin/SparkBindings.java b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/plugin/SparkBindings.javanew file mode 100644index 0000000000..fb158ba3b2--- /dev/null+++ b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/plugin/SparkBindings.java@@ -0,0 +1,169 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */+package org.apache.gravitino.spark.connector.plugin;++import com.google.common.base.Preconditions;+import com.google.common.collect.ImmutableMap;+import java.util.EnumMap;+import java.util.EnumSet;+import java.util.Map;+import java.util.Set;+import javax.annotation.Nullable;+import org.apache.commons.lang3.StringUtils;+import org.apache.gravitino.spark.connector.catalog.SparkCatalogKind;+import org.apache.spark.sql.SparkSessionExtensions;+import org.apache.spark.sql.connector.catalog.TableCatalog;+import scala.Function1;++/**+ * The classes a connector build supplies to {@link GravitinoDriverPlugin}: which class implements+ * each kind of catalog, and which session extension performs authorization checks.+ *+ * <p>Every one of these differs per Spark version, so each version module builds its own instance+ * in its {@code GravitinoSparkPlugin} and the shared plugin never names a version-specific class.+ * That keeps the dependency running from version module to shared code, and lets a test supply its+ * own bindings to exercise the registration logic.+ */+public final class SparkBindings {++ /**+ * The catalog kinds every connector build must supply. Paimon is absent because Paimon publishes+ * no artifact for every supported Spark and Scala version, so some builds legitimately ship no+ * Paimon catalog.+ */+ private static final Set<SparkCatalogKind> REQUIRED_KINDS =+ EnumSet.complementOf(EnumSet.of(SparkCatalogKind.LAKEHOUSE_PAIMON));++ private final Map<SparkCatalogKind, String> catalogClassNames;+ private final String authorizationExtension;++ private SparkBindings(Builder builder) {+ this.catalogClassNames = ImmutableMap.copyOf(builder.catalogClassNames);+ this.authorizationExtension = builder.authorizationExtension;+ }++ /**+ * Returns a builder for the bindings of one connector build.+ *+ * @return a new builder+ */+ public static Builder builder() {+ return new Builder();+ }++ /**+ * Returns the class name implementing each kind of catalog this build ships.+ *+ * @return catalog kind to Spark catalog class name+ */+ public Map<SparkCatalogKind, String> catalogClassNames() {+ return catalogClassNames;+ }++ /**+ * Returns the class name of the authorization session extension this build ships.+ *+ * @return the Spark session extension class name+ */+ public String authorizationExtension() {+ return authorizationExtension;+ }++ /** Collects the bindings of one connector build, and checks that none is missing. */+ public static final class Builder {++ private final Map<SparkCatalogKind, String> catalogClassNames =+ new EnumMap<>(SparkCatalogKind.class);+ @Nullable private String authorizationExtension;++ private Builder() {}++ /**+ * Binds a catalog kind to the class implementing it.+ *+ * @param kind the kind of catalog+ * @param catalogClass the class implementing it+ * @return this builder+ */+ public Builder catalog(SparkCatalogKind kind, Class<? extends TableCatalog> catalogClass) {+ return catalog(kind, catalogClass.getName());+ }++ /**+ * Binds a catalog kind to the class implementing it, by name. Prefer {@link+ * #catalog(SparkCatalogKind, Class)}, whose argument the compiler checks is a catalog at all;+ * this overload is for a catalog whose class a build may compile out, such as Paimon on Scala+ * 2.13.+ *+ * @param kind the kind of catalog+ * @param catalogClassName the name of the class implementing it+ * @return this builder+ */+ public Builder catalog(SparkCatalogKind kind, String catalogClassName) {+ Preconditions.checkArgument(+ StringUtils.isNotBlank(catalogClassName), "Blank catalog class name for %s", kind);+ Preconditions.checkState(+ !catalogClassNames.containsKey(kind), "Catalog kind %s was bound twice", kind);+ catalogClassNames.put(kind, catalogClassName);+ return this;+ }++ /**+ * Binds the session extension that performs authorization checks.+ *+ * @param extensionClass the session extension class+ * @return this builder+ */+ public Builder authorizationExtension(+ Class<? extends Function1<SparkSessionExtensions, Void>> extensionClass) {+ return authorizationExtension(extensionClass.getName());+ }++ /**+ * Binds the session extension that performs authorization checks, by name. Prefer {@link+ * #authorizationExtension(Class)}, whose argument the compiler checks is a session extension at+ * all.+ *+ * @param extensionClassName the name of the session extension class+ * @return this builder+ */+ public Builder authorizationExtension(String extensionClassName) {+ Preconditions.checkArgument(+ StringUtils.isNotBlank(extensionClassName), "Blank authorization session extension");+ Preconditions.checkState(+ authorizationExtension == null, "The authorization session extension was bound twice");+ this.authorizationExtension = extensionClassName;+ return this;+ }++ /**+ * Builds the bindings, failing if this build left one out.+ *+ * @return the bindings+ */+ public SparkBindings build() {+ Preconditions.checkState(+ authorizationExtension != null, "No authorization session extension was bound");+ Set<SparkCatalogKind> missing = EnumSet.copyOf(REQUIRED_KINDS);+ missing.removeAll(catalogClassNames.keySet());+ Preconditions.checkState(missing.isEmpty(), "No catalog was bound for %s", missing);+ return new SparkBindings(this);+ }+ }+}diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/utils/HiveGravitinoOperationOperator.java b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/utils/HiveGravitinoOperationOperator.javaindex 85af6800d6..8370200d72 100644--- a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/utils/HiveGravitinoOperationOperator.java+++ b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/utils/HiveGravitinoOperationOperator.java@@ -30,26 +30,31 @@ import org.apache.gravitino.rel.expressions.literals.Literal;import org.apache.gravitino.rel.partitions.Partition;import org.apache.gravitino.rel.partitions.Partitions;import org.apache.spark.sql.catalyst.InternalRow;-import org.apache.spark.sql.catalyst.analysis.PartitionAlreadyExistsException;+import org.apache.spark.sql.catalyst.analysis.PartitionsAlreadyExistException;import org.apache.spark.sql.catalyst.expressions.GenericInternalRow;import org.apache.spark.sql.types.DataType;import org.apache.spark.sql.types.StructField;import org.apache.spark.sql.types.StructType;import org.jetbrains.annotations.NotNull;+import org.slf4j.Logger;+import org.slf4j.LoggerFactory;public class HiveGravitinoOperationOperator {- private org.apache.gravitino.rel.Table gravitinoTable;+ private static final Logger LOG = LoggerFactory.getLogger(HiveGravitinoOperationOperator.class);+private static final String PARTITION_NAME_DELIMITER = "/";private static final String PARTITION_VALUE_DELIMITER = "=";+ private org.apache.gravitino.rel.Table gravitinoTable;+public HiveGravitinoOperationOperator(org.apache.gravitino.rel.Table gravitinoTable) {this.gravitinoTable = gravitinoTable;}public void createPartition(InternalRow ident, Map<String, String> properties, StructType partitionSchema)- throws PartitionAlreadyExistsException {+ throws PartitionsAlreadyExistException {List<String[]> fields = new ArrayList<>();List<Literal<?>> values = new ArrayList<>();@@ -68,8 +73,12 @@ public class HiveGravitinoOperationOperator {try {gravitinoTable.supportPartitions().addPartition(partition);} catch (org.apache.gravitino.exceptions.PartitionAlreadyExistsException e) {- throw new org.apache.spark.sql.catalyst.analysis.PartitionAlreadyExistsException(- e.getMessage());+ // Build the exception from (table, ident, schema): that is the only constructor present on+ // every supported Spark version, since Spark 4 dropped the single-String form this class used+ // to call. It produces Spark's documented PARTITIONS_ALREADY_EXIST message rather than+ // Gravitino's, so log the Gravitino-side detail, which the constructor takes no cause for.+ LOG.debug("Gravitino rejected addPartition for table {}", gravitinoTable.name(), e);+ throw new PartitionsAlreadyExistException(gravitinoTable.name(), ident, partitionSchema);}}diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/utils/SparkPartitionUtils.java b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/utils/SparkPartitionUtils.javaindex 21498f9af3..4d2f574d19 100644--- a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/utils/SparkPartitionUtils.java+++ b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/utils/SparkPartitionUtils.java@@ -71,14 +71,16 @@ public class SparkPartitionUtils {ident.getDecimal(ordinal, decimalType.precision(), decimalType.scale());return Literals.decimalLiteral(org.apache.gravitino.rel.types.Decimal.of(decimal.toJavaBigDecimal()));- } else if (sparkType instanceof StringType) {- return Literals.stringLiteral(ident.getString(ordinal));} else if (sparkType instanceof VarcharType) {+ // Varchar and Char are checked before StringType because Spark 4 made both extend it; on 3.5+ // they extend AtomicType, so this order is correct for every supported version.VarcharType varcharType = (VarcharType) sparkType;return Literals.varcharLiteral(varcharType.length(), ident.getString(ordinal));} else if (sparkType instanceof CharType) {CharType charType = (CharType) sparkType;return Literals.of(ident.get(ordinal, sparkType), Types.FixedCharType.of(charType.length()));+ } else if (sparkType instanceof StringType) {+ return Literals.stringLiteral(ident.getString(ordinal));} else if (sparkType instanceof BooleanType) {return Literals.booleanLiteral(ident.getBoolean(ordinal));} else if (sparkType instanceof DateType) {@@ -99,12 +101,12 @@ public class SparkPartitionUtils {return String.valueOf(ident.getShort(ordinal));} else if (dataType instanceof IntegerType) {return String.valueOf(ident.getInt(ordinal));+ } else if (dataType instanceof VarcharType || dataType instanceof CharType) {+ // Ahead of StringType for the same reason as above. Order matters here because each branch+ // uses a different getter, unlike getSparkPartitionValue where all three share one body.+ return ident.get(ordinal, dataType).toString();} else if (dataType instanceof StringType) {return ident.getUTF8String(ordinal).toString();- } else if (dataType instanceof VarcharType) {- return ident.get(ordinal, dataType).toString();- } else if (dataType instanceof CharType) {- return ident.get(ordinal, dataType).toString();} else if (dataType instanceof DateType) {// DateType spark use int store.LocalDate localDate = LocalDate.ofEpochDay(ident.getInt(ordinal));@@ -141,7 +143,11 @@ public class SparkPartitionUtils {return Integer.parseInt(hivePartitionValue);} else if (dataType instanceof LongType) {return Long.parseLong(hivePartitionValue);- } else if (dataType instanceof StringType) {+ } else if (dataType instanceof StringType+ || dataType instanceof VarcharType+ || dataType instanceof CharType) {+ // One branch for all three: they yield the same UTF8String from a string input, so order+ // does not matter. Spark 4 needs only the first check; 3.5 needs the other two.return UTF8String.fromString(hivePartitionValue);} else if (dataType instanceof DateType) {LocalDate localDate = LocalDate.parse(hivePartitionValue);@@ -155,10 +161,6 @@ public class SparkPartitionUtils {return Float.parseFloat(hivePartitionValue);} else if (dataType instanceof DecimalType) {return Decimal.apply(hivePartitionValue);- } else if (dataType instanceof VarcharType) {- return UTF8String.fromString(hivePartitionValue);- } else if (dataType instanceof CharType) {- return UTF8String.fromString(hivePartitionValue);} else {throw new UnsupportedOperationException("Unsupported partition type: " + dataType);}diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/version/CatalogNameAdaptor.java b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/version/CatalogNameAdaptor.javadeleted file mode 100644index 4583a8e0ea..0000000000--- a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/version/CatalogNameAdaptor.java+++ /dev/null@@ -1,106 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.version;--import com.google.common.collect.ImmutableMap;-import java.util.Locale;-import java.util.Map;-import org.apache.spark.package$;-import org.apache.spark.util.VersionUtils$;--public class CatalogNameAdaptor {- private static final Map<String, String> catalogNames;-- static {- ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();- catalogNames =- builder- .put(- "hive-3.3", "org.apache.gravitino.spark.connector.hive.GravitinoHiveCatalogSpark33")- .put(- "hive-3.4", "org.apache.gravitino.spark.connector.hive.GravitinoHiveCatalogSpark34")- .put(- "hive-3.5", "org.apache.gravitino.spark.connector.hive.GravitinoHiveCatalogSpark35")- .put(- "lakehouse-iceberg-3.3",- "org.apache.gravitino.spark.connector.iceberg.GravitinoIcebergCatalogSpark33")- .put(- "lakehouse-iceberg-3.4",- "org.apache.gravitino.spark.connector.iceberg.GravitinoIcebergCatalogSpark34")- .put(- "lakehouse-iceberg-3.5",- "org.apache.gravitino.spark.connector.iceberg.GravitinoIcebergCatalogSpark35")- .put(- "lakehouse-paimon-3.3",- "org.apache.gravitino.spark.connector.paimon.GravitinoPaimonCatalogSpark33")- .put(- "lakehouse-paimon-3.4",- "org.apache.gravitino.spark.connector.paimon.GravitinoPaimonCatalogSpark34")- .put(- "lakehouse-paimon-3.5",- "org.apache.gravitino.spark.connector.paimon.GravitinoPaimonCatalogSpark35")- .put(- "glue-3.3", "org.apache.gravitino.spark.connector.glue.GravitinoGlueCatalogSpark33")- .put(- "glue-3.4", "org.apache.gravitino.spark.connector.glue.GravitinoGlueCatalogSpark34")- .put(- "glue-3.5", "org.apache.gravitino.spark.connector.glue.GravitinoGlueCatalogSpark35")- .build();- }-- private static final Map<String, String> jdbcCatalogNames =- ImmutableMap.of(- "3.3",- "org.apache.gravitino.spark.connector.jdbc.GravitinoJdbcCatalogSpark33",- "3.4",- "org.apache.gravitino.spark.connector.jdbc.GravitinoJdbcCatalogSpark34",- "3.5",- "org.apache.gravitino.spark.connector.jdbc.GravitinoJdbcCatalogSpark35");-- private static final Map<String, String> pgCatalogNames =- ImmutableMap.of(- "3.3",- "org.apache.gravitino.spark.connector.jdbc.postgresql.GravitinoPostgreSqlCatalogSpark33",- "3.4",- "org.apache.gravitino.spark.connector.jdbc.postgresql.GravitinoPostgreSqlCatalogSpark34",- "3.5",- "org.apache.gravitino.spark.connector.jdbc.postgresql.GravitinoPostgreSqlCatalogSpark35");-- private static String sparkVersion() {- return package$.MODULE$.SPARK_VERSION();- }-- private static String getCatalogName(String provider, int majorVersion, int minorVersion) {- String versionKey = String.format("%d.%d", majorVersion, minorVersion);- if (provider.startsWith("jdbc")) {- if (provider.startsWith("jdbc-postgresql")) {- return pgCatalogNames.get(versionKey);- }- return jdbcCatalogNames.get(versionKey);- }- String key = String.format("%s-%s", provider.toLowerCase(Locale.ROOT), versionKey);- return catalogNames.get(key);- }-- public static String getCatalogName(String provider) {- int majorVersion = VersionUtils$.MODULE$.majorVersion(sparkVersion());- int minorVersion = VersionUtils$.MODULE$.minorVersion(sparkVersion());- return getCatalogName(provider, majorVersion, minorVersion);- }-}diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/paimon/GravitinoPaimonCatalog.java b/spark-connector/spark-common/src/main/spark35/org/apache/gravitino/spark/connector/paimon/GravitinoPaimonCatalog.javasimilarity index 100%rename from spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/paimon/GravitinoPaimonCatalog.javarename to spark-connector/spark-common/src/main/spark35/org/apache/gravitino/spark/connector/paimon/GravitinoPaimonCatalog.javadiff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/paimon/PaimonPropertiesConstants.java b/spark-connector/spark-common/src/main/spark35/org/apache/gravitino/spark/connector/paimon/PaimonPropertiesConstants.javasimilarity index 100%rename from spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/paimon/PaimonPropertiesConstants.javarename to spark-connector/spark-common/src/main/spark35/org/apache/gravitino/spark/connector/paimon/PaimonPropertiesConstants.javadiff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/paimon/PaimonPropertiesConverter.java b/spark-connector/spark-common/src/main/spark35/org/apache/gravitino/spark/connector/paimon/PaimonPropertiesConverter.javasimilarity index 100%rename from spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/paimon/PaimonPropertiesConverter.javarename to spark-connector/spark-common/src/main/spark35/org/apache/gravitino/spark/connector/paimon/PaimonPropertiesConverter.javadiff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/paimon/SparkPaimonTable.java b/spark-connector/spark-common/src/main/spark35/org/apache/gravitino/spark/connector/paimon/SparkPaimonTable.javasimilarity index 100%rename from spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/paimon/SparkPaimonTable.javarename to spark-connector/spark-common/src/main/spark35/org/apache/gravitino/spark/connector/paimon/SparkPaimonTable.javadiff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/TestSparkTypeConverter.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/TestSparkTypeConverter.javaindex 1abec840c3..0d009fc7c4 100644--- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/TestSparkTypeConverter.java+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/TestSparkTypeConverter.java@@ -78,6 +78,7 @@ public class TestSparkTypeConverter {gravitinoToSparkTypeMapper.put(BooleanType.get(), DataTypes.BooleanType);gravitinoToSparkTypeMapper.put(DateType.get(), DataTypes.DateType);gravitinoToSparkTypeMapper.put(TimestampType.withTimeZone(), DataTypes.TimestampType);+ gravitinoToSparkTypeMapper.put(TimestampType.withoutTimeZone(), DataTypes.TimestampNTZType);gravitinoToSparkTypeMapper.put(ListType.of(IntegerType.get(), true), DataTypes.createArrayType(DataTypes.IntegerType));gravitinoToSparkTypeMapper.put(diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/authorization/TestRequiredPrivilegesSparkResolution.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/authorization/TestRequiredPrivilegesSparkResolution.javaindex c6a41bc393..187beaf440 100644--- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/authorization/TestRequiredPrivilegesSparkResolution.java+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/authorization/TestRequiredPrivilegesSparkResolution.java@@ -161,6 +161,9 @@ public class TestRequiredPrivilegesSparkResolution {}@Override+ // Overriding the form deprecated in Spark 3.4 keeps this stub compiling on every supported+ // version; the test never calls it.+ @SuppressWarnings("deprecation")public Table createTable(Identifier ident, StructType schema, Transform[] partitions, Map<String, String> props) {throw new UnsupportedOperationException();diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/catalog/TestSparkCatalogKind.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/catalog/TestSparkCatalogKind.javanew file mode 100644index 0000000000..052746173b--- /dev/null+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/catalog/TestSparkCatalogKind.java@@ -0,0 +1,68 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */+package org.apache.gravitino.spark.connector.catalog;++import org.junit.jupiter.api.Assertions;+import org.junit.jupiter.api.Test;++/** Tests the provider to catalog kind mapping shared by every Spark version. */+public class TestSparkCatalogKind {++ @Test+ void testProvidersWithADedicatedCatalog() {+ Assertions.assertEquals(SparkCatalogKind.HIVE, SparkCatalogKind.fromProvider("hive"));+ Assertions.assertEquals(+ SparkCatalogKind.LAKEHOUSE_ICEBERG, SparkCatalogKind.fromProvider("lakehouse-iceberg"));+ Assertions.assertEquals(+ SparkCatalogKind.LAKEHOUSE_PAIMON, SparkCatalogKind.fromProvider("lakehouse-paimon"));+ Assertions.assertEquals(SparkCatalogKind.GLUE, SparkCatalogKind.fromProvider("glue"));+ }++ @Test+ void testEveryJdbcBackendSharesOneCatalogExceptPostgreSql() {+ Assertions.assertEquals(SparkCatalogKind.JDBC, SparkCatalogKind.fromProvider("jdbc-mysql"));+ Assertions.assertEquals(SparkCatalogKind.JDBC, SparkCatalogKind.fromProvider("jdbc-doris"));+ Assertions.assertEquals(SparkCatalogKind.JDBC, SparkCatalogKind.fromProvider("jdbc-starrocks"));+ Assertions.assertEquals(+ SparkCatalogKind.JDBC_POSTGRESQL, SparkCatalogKind.fromProvider("jdbc-postgresql"));+ }++ @Test+ void testProviderIsMatchedCaseInsensitively() {+ Assertions.assertEquals(SparkCatalogKind.HIVE, SparkCatalogKind.fromProvider("HIVE"));+ Assertions.assertEquals(+ SparkCatalogKind.JDBC_POSTGRESQL, SparkCatalogKind.fromProvider("JDBC-PostgreSQL"));+ }++ @Test+ void testUnknownProviderHasNoCatalog() {+ Assertions.assertNull(SparkCatalogKind.fromProvider("kafka"));+ Assertions.assertNull(SparkCatalogKind.fromProvider(""));+ }++ /**+ * A null provider is rejected rather than mapped to no kind. GravitinoDriverPlugin relies on that+ * to keep its own blank-provider branch load-bearing: were this to return null instead, dropping+ * that branch would go unnoticed, since a catalog with no kind is skipped anyway.+ */+ @Test+ void testANullProviderIsRejected() {+ Assertions.assertThrows(NullPointerException.class, () -> SparkCatalogKind.fromProvider(null));+ }+}diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/catalog/TestTransformTableChange.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/catalog/TestTransformTableChange.javaindex 523deb9021..d0e5777120 100644--- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/catalog/TestTransformTableChange.java+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/catalog/TestTransformTableChange.java@@ -20,6 +20,7 @@package org.apache.gravitino.spark.connector.catalog;import org.apache.gravitino.rel.TableChange.UpdateComment;+import org.apache.gravitino.rel.expressions.literals.Literals;import org.apache.gravitino.spark.connector.ConnectorConstants;import org.apache.gravitino.spark.connector.SparkTableChangeConverter;import org.apache.gravitino.spark.connector.SparkTypeConverter;@@ -44,6 +45,25 @@ public class TestTransformTableChange {Assertions.assertEquals("value", gravitinoSetProperty.getValue());}+ @Test+ void testTransformUpdateColumnDefaultValue() {+ String[] fieldNames = new String[] {"col"};+ String defaultValue = "col_default_value";+ TableChange.UpdateColumnDefaultValue sparkChange =+ (TableChange.UpdateColumnDefaultValue)+ TableChange.updateColumnDefaultValue(fieldNames, defaultValue);++ org.apache.gravitino.rel.TableChange gravitinoChange =+ sparkTableChangeConverter.toGravitinoTableChange(sparkChange);++ Assertions.assertInstanceOf(+ org.apache.gravitino.rel.TableChange.UpdateColumnDefaultValue.class, gravitinoChange);+ org.apache.gravitino.rel.TableChange.UpdateColumnDefaultValue converted =+ (org.apache.gravitino.rel.TableChange.UpdateColumnDefaultValue) gravitinoChange;+ Assertions.assertArrayEquals(sparkChange.fieldNames(), converted.fieldName());+ Assertions.assertEquals(Literals.stringLiteral(defaultValue), converted.getNewDefaultValue());+ }+@Testvoid testTransformRemoveProperty() {TableChange sparkRemoveProperty = TableChange.removeProperty("key");@@ -117,7 +137,8 @@ public class TestTransformTableChange {TableChange.AddColumn sparkAddColumnFirst =(TableChange.AddColumn)- TableChange.addColumn(new String[] {"col1"}, DataTypes.StringType, true, "", first);+ TableChange.addColumn(+ new String[] {"col1"}, DataTypes.StringType, true, "", first, null);org.apache.gravitino.rel.TableChange gravitinoChangeFirst =sparkTableChangeConverter.toGravitinoTableChange(sparkAddColumnFirst);@@ -136,7 +157,8 @@ public class TestTransformTableChange {TableChange.AddColumn sparkAddColumnAfter =(TableChange.AddColumn)- TableChange.addColumn(new String[] {"col1"}, DataTypes.StringType, true, "", after);+ TableChange.addColumn(+ new String[] {"col1"}, DataTypes.StringType, true, "", after, null);org.apache.gravitino.rel.TableChange gravitinoChangeAfter =sparkTableChangeConverter.toGravitinoTableChange(sparkAddColumnAfter);@@ -155,7 +177,8 @@ public class TestTransformTableChange {TableChange.AddColumn sparkAddColumnDefault =(TableChange.AddColumn)- TableChange.addColumn(new String[] {"col1"}, DataTypes.StringType, true, "", null);+ TableChange.addColumn(+ new String[] {"col1"}, DataTypes.StringType, true, "", null, null);org.apache.gravitino.rel.TableChange gravitinoChangeDefault =sparkTableChangeConverter.toGravitinoTableChange(sparkAddColumnDefault);diff --git a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/TestSparkHiveTypeConverter34.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/hive/TestSparkHiveTypeConverter.javasimilarity index 57%rename from spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/TestSparkHiveTypeConverter34.javarename to spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/hive/TestSparkHiveTypeConverter.javaindex e04a6f2371..2e49e1a3bd 100644--- a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/TestSparkHiveTypeConverter34.java+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/hive/TestSparkHiveTypeConverter.java@@ -16,33 +16,50 @@* specific language governing permissions and limitations* under the License.*/-package org.apache.gravitino.spark.connector;+package org.apache.gravitino.spark.connector.hive;import org.apache.gravitino.rel.types.Types;-import org.apache.gravitino.spark.connector.hive.SparkHiveTypeConverter34;+import org.apache.gravitino.spark.connector.SparkTypeConverter;import org.apache.spark.sql.types.DataTypes;+import org.apache.spark.sql.types.VarcharType;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.api.Test;-import org.junit.jupiter.api.TestInstance;-import org.junit.jupiter.api.TestInstance.Lifecycle;-@TestInstance(Lifecycle.PER_CLASS)-public class TestSparkHiveTypeConverter34 {- private SparkTypeConverter sparkHiveTypeConverter = new SparkHiveTypeConverter34();+/** Unit tests for {@link SparkHiveTypeConverter}. */+public class TestSparkHiveTypeConverter {++ private final SparkTypeConverter sparkHiveTypeConverter = new SparkHiveTypeConverter();++ @Test+ void testTimestampLosesTimeZone() {+ // Hive stores no timezone, so a Spark TimestampType has to come back without one.+ Assertions.assertEquals(+ Types.TimestampType.withoutTimeZone(),+ sparkHiveTypeConverter.toGravitinoType(DataTypes.TimestampType));+ Assertions.assertEquals(+ DataTypes.TimestampType,+ sparkHiveTypeConverter.toSparkType(Types.TimestampType.withoutTimeZone()));+ Assertions.assertEquals(+ DataTypes.TimestampType,+ sparkHiveTypeConverter.toSparkType(Types.TimestampType.withTimeZone()));+ }@Test- void testUnsupportedTimestampType() {+ void testTimestampNTZIsRejected() {+ // The base converter maps TimestampNTZType to a timezone-less Gravitino type, which would be+ // indistinguishable from a plain Hive timestamp; reject it instead of silently accepting.UnsupportedOperationException exception =Assertions.assertThrows(UnsupportedOperationException.class,() -> sparkHiveTypeConverter.toGravitinoType(DataTypes.TimestampNTZType));Assertions.assertTrue(exception.getMessage().contains("Hive does not support 'timestamp_ntz'"));+ }+ @Test+ void testOtherTypesDelegateToTheBaseConverter() {Assertions.assertEquals(- Types.TimestampType.withoutTimeZone(),- sparkHiveTypeConverter.toGravitinoType(DataTypes.TimestampType));+ DataTypes.IntegerType, sparkHiveTypeConverter.toSparkType(Types.IntegerType.get()));Assertions.assertEquals(- DataTypes.TimestampType,- sparkHiveTypeConverter.toSparkType(Types.TimestampType.withoutTimeZone()));+ Types.VarCharType.of(10), sparkHiveTypeConverter.toGravitinoType(VarcharType.apply(10)));}}diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT.javaindex 9f61a1eff5..07ead081ba 100644--- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT.java+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT.java@@ -92,10 +92,6 @@ public abstract class SparkAuthorizationIT extends BaseIT {protected final String TIME_ZONE_UTC = "UTC";- protected SparkSession getSparkSession() {- return normalUserSparkSession;- }-@BeforeAll@Overridepublic void startIntegrationTest() throws Exception {@@ -359,9 +355,14 @@ public abstract class SparkAuthorizationIT extends BaseIT {ImmutableList.of(JDBC_CATALOG, JDBC_DATABASE, testTable), MetadataObject.Type.TABLE),ImmutableList.of(Privileges.ModifyTable.deny()));- // Assert INSERT behavior - Spark 3.5+ should throw ForbiddenException,- // lower versions won't because they don't support TableWritePrivilege- assertInsertBehaviorWithoutModifyPrivilege(testTable);+ // INSERT must be rejected: BaseCatalog implements+ // loadTable(Identifier, Set<TableWritePrivilege>), so Spark routes the write through the+ // privilege-checking path.+ assertThrows(+ ForbiddenException.class,+ () ->+ normalUserSparkSession.sql(+ String.format("INSERT INTO %s VALUES (1, 'test')", testTable)));} finally {// Clean uptry {@@ -375,17 +376,6 @@ public abstract class SparkAuthorizationIT extends BaseIT {}}- /**- * Assert the behavior when user tries to INSERT without MODIFY_TABLE privilege. Spark 3.3/3.4- * don't support TableWritePrivilege, so INSERT will succeed. Spark 3.5+ supports it, so INSERT- * should throw ForbiddenException. Subclasses can override this method to assert the expected- * behavior.- */- protected void assertInsertBehaviorWithoutModifyPrivilege(String tableName) {- // Spark 3.3/3.4 don't support TableWritePrivilege, so INSERT will succeed- normalUserSparkSession.sql(String.format("INSERT INTO %s VALUES (1, 'test')", tableName));- }-private void assertEqualsRows(List<Row> exceptRows, List<Row> actualRows) {Assertions.assertEquals(exceptRows.size(), actualRows.size());for (int i = 0; i < exceptRows.size(); i++) {diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT.javaindex e5393b525c..1d70bdd708 100644--- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT.java+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT.java@@ -39,6 +39,7 @@ import org.apache.gravitino.spark.connector.integration.test.util.SparkTableInfoimport org.apache.gravitino.spark.connector.integration.test.util.SparkTableInfoChecker;import org.apache.hadoop.fs.Path;import org.apache.spark.sql.AnalysisException;+import org.apache.spark.sql.catalyst.analysis.PartitionsAlreadyExistException;import org.apache.spark.sql.connector.catalog.TableCatalog;import org.apache.spark.sql.types.DataTypes;import org.junit.jupiter.api.Assertions;@@ -185,13 +186,12 @@ public abstract class SparkHiveCatalogIT extends SparkCommonIT {Assertions.assertEquals(1, nullPartitionInfo.size());Assertions.assertTrue(String.valueOf(nullPartitionInfo.get(0)[0]).startsWith("dt="));- Exception exception =- Assertions.assertThrows(- Exception.class,- () -> {- sql("ALTER TABLE " + tableName + " ADD PARTITION (age_p1=21, age_p2='twenty one')");- });- Assertions.assertTrue(exception.getMessage().contains("Partition already exists"));+ // Adding a partition that already exists must surface Spark's PARTITIONS_ALREADY_EXIST. Assert+ // the type rather than the message: the connector builds the exception from (table, ident,+ // schema), the only constructor Spark 3.5 and 4.x share, so the wording is Spark's own.+ Assertions.assertThrows(+ PartitionsAlreadyExistException.class,+ () -> sql("ALTER TABLE " + tableName + " ADD PARTITION (age_p1=21, age_p2='twenty one')"));}@ParameterizedTestdiff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogIT.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogIT.javaindex aa3552a933..f94f1fe850 100644--- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogIT.java+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogIT.java@@ -18,6 +18,8 @@*/package org.apache.gravitino.spark.connector.integration.test.iceberg;+import static org.apache.spark.sql.functions.lit;+import com.google.common.collect.ImmutableList;import com.google.common.collect.ImmutableMap;import java.io.File;@@ -43,14 +45,12 @@ import org.apache.iceberg.NullOrder;import org.apache.iceberg.ReplaceSortOrder;import org.apache.iceberg.SortOrder;import org.apache.iceberg.exceptions.ValidationException;-import org.apache.spark.sql.Column;import org.apache.spark.sql.Dataset;import org.apache.spark.sql.Encoders;import org.apache.spark.sql.Row;import org.apache.spark.sql.catalyst.analysis.NoSuchFunctionException;import org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException;import org.apache.spark.sql.catalyst.analysis.NoSuchTableException;-import org.apache.spark.sql.catalyst.expressions.Literal;import org.apache.spark.sql.connector.catalog.CatalogPlugin;import org.apache.spark.sql.connector.catalog.FunctionCatalog;import org.apache.spark.sql.connector.catalog.Identifier;@@ -449,8 +449,8 @@ public abstract class SparkIcebergCatalogIT extends SparkCommonIT {getSparkSession().createDataset(ids, Encoders.INT()).withColumnRenamed("value", "id")- .withColumn("name", new Column(Literal.create("a", DataTypes.StringType)))- .withColumn("age", new Column(Literal.create(1, DataTypes.IntegerType)));+ .withColumn("name", lit("a"))+ .withColumn("age", lit(1));df.coalesce(1).writeTo(tableName).append();Assertions.assertEquals(200, getSparkSession().table(tableName).count());diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcPostgreSqlCatalogIT.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcPostgreSqlCatalogIT.javaindex c0615962cd..18a170986c 100644--- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcPostgreSqlCatalogIT.java+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcPostgreSqlCatalogIT.java@@ -29,7 +29,7 @@ import org.apache.gravitino.spark.connector.jdbc.JdbcPropertiesConstants;import org.junit.jupiter.api.Tag;@Tag("gravitino-docker-test")-public class SparkJdbcPostgreSqlCatalogIT extends SparkCommonIT {+public abstract class SparkJdbcPostgreSqlCatalogIT extends SparkCommonIT {protected String pgUrl;protected String pgUsername;diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkSQLRegressionTest.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkSQLRegressionTest.javaindex 336a244af2..20951c490b 100644--- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkSQLRegressionTest.java+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkSQLRegressionTest.java@@ -37,8 +37,8 @@ import org.slf4j.LoggerFactory;/*** The entrypoint to run SparkSQL regression test, you could run it with specific Spark version:- * ./gradlew :spark-connector:spark-3.4:test --tests- * "org.apache.gravitino.spark.connector.integration.test.sql.SparkSQLRegressionTest34"+ * ./gradlew :spark-connector:spark-3.5:test --tests+ * "org.apache.gravitino.spark.connector.integration.test.sql.SparkSQLRegressionTest35"* -PenableSparkSQLITs*/@Tag("gravitino-docker-test")diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/util/SparkTableInfo.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/util/SparkTableInfo.javaindex 058508c1bd..b498eafeef 100644--- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/util/SparkTableInfo.java+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/util/SparkTableInfo.java@@ -186,6 +186,9 @@ public class SparkTableInfo {return baseTable instanceof SparkIcebergTable && !(transform instanceof SortedBucketTransform);}+ // Table.schema() is deprecated from Spark 3.4 in favor of columns(); the Gravitino table wrappers+ // still implement the deprecated form, so the tests read it back the same way.+ @SuppressWarnings("deprecation")private static StructType getSchema(Table baseTable) {if (baseTable instanceof SparkHiveTable) {return ((SparkHiveTable) baseTable).schema();diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/util/SparkUtilIT.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/util/SparkUtilIT.javaindex 8bf9548768..809d900fee 100644--- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/util/SparkUtilIT.java+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/util/SparkUtilIT.java@@ -135,10 +135,9 @@ public abstract class SparkUtilIT extends BaseIT {}// Create SparkTableInfo from SparkBaseTable retrieved from LogicalPlan.- // In Spark 3.3/3.5: DESC TABLE EXTENDED returns DescribeRelation.- // In Spark 3.4: DESC TABLE EXTENDED returns DescribeTableCommand (different class hierarchy).- // Use the v2 Catalog API (CatalogManager + TableCatalog.loadTable) for cross-version- // compatibility.+ // Read the table through the v2 Catalog API (CatalogManager + TableCatalog.loadTable) rather than+ // parsing the DESC TABLE EXTENDED plan: the plan node that returns differs across Spark versions,+ // while the v2 API is stable.protected SparkTableInfo getTableInfo(String tableName) {CatalogManager catalogManager = getSparkSession().sessionState().catalogManager();@@ -149,9 +148,8 @@ public abstract class SparkUtilIT extends BaseIT {TableCatalog tableCatalog;if (parts.length == 1) {// Short table name: use current catalog + current V2 namespace.- // catalog().currentDatabase() returns the V1 Hive session catalog database and is NOT- // updated when USE <db> is issued against a V2 catalog (e.g. Glue) in Spark 3.3.- // catalogManager.currentNamespace() reflects the V2 namespace correctly.+ // catalog().currentDatabase() tracks the V1 session catalog and does not reliably follow+ // USE <db> against a V2 catalog; catalogManager.currentNamespace() does.CatalogPlugin currentCatalog = catalogManager.currentCatalog();String[] currentNamespace = catalogManager.currentNamespace();identifier = Identifier.of(currentNamespace, parts[0]);diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/plugin/TestGravitinoDriverPlugin.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/plugin/TestGravitinoDriverPlugin.javaindex da92012e3d..4ace94b2df 100644--- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/plugin/TestGravitinoDriverPlugin.java+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/plugin/TestGravitinoDriverPlugin.java@@ -20,15 +20,20 @@package org.apache.gravitino.spark.connector.plugin;import static org.junit.jupiter.api.Assertions.assertEquals;+import static org.junit.jupiter.api.Assertions.assertFalse;+import static org.junit.jupiter.api.Assertions.assertTrue;import com.google.common.collect.ImmutableMap;import java.io.IOException;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;+import java.util.Arrays;+import org.apache.gravitino.Catalog;import org.apache.gravitino.auth.AuthProperties;import org.apache.gravitino.spark.connector.GravitinoSparkConfig;-import org.apache.gravitino.spark.connector.authorization.GravitinoAuthorizationSparkSessionExtensions;+import org.apache.gravitino.spark.connector.catalog.SparkCatalogKind;+import org.apache.gravitino.spark.connector.iceberg.extensions.GravitinoIcebergSparkSessionExtensions;import org.apache.gravitino.spark.connector.plugin.GravitinoDriverPlugin.DynamicBearerTokenProvider;import org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions;import org.apache.spark.SparkConf;@@ -36,9 +41,24 @@ import org.apache.spark.sql.internal.StaticSQLConf;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.api.Test;import org.junit.jupiter.api.io.TempDir;+import org.mockito.Mockito;+/**+ * Tests what the plugin does with the bindings it is given. The bindings here are made up, so these+ * assertions hold on every Spark version and do not restate what the version modules declare.+ */public class TestGravitinoDriverPlugin {+ private static final String COMMA = ",";+ private static final String AUTHZ_EXTENSION = "org.example.AuthorizationExtensions";+ private static final String USER_EXTENSION = "org.example.UserExtensions";+ private static final String HIVE_CATALOG = "org.example.HiveCatalog";+ private static final String ICEBERG_CATALOG = "org.example.IcebergCatalog";+ private static final String PAIMON_CATALOG = "org.example.PaimonCatalog";+ private static final String GLUE_CATALOG = "org.example.GlueCatalog";+ private static final String JDBC_CATALOG = "org.example.JdbcCatalog";+ private static final String POSTGRESQL_CATALOG = "org.example.PostgreSqlCatalog";+@Testvoid testIcebergExtensionName() {Assertions.assertEquals(@@ -47,25 +67,246 @@ public class TestGravitinoDriverPlugin {}@Test- void testAlwaysRegistersAuthorizationExtension() {+ void testAlwaysRegistersTheBoundAuthorizationExtension() {SparkConf sparkConf = new SparkConf(false);- new GravitinoDriverPlugin().registerSqlExtensions(sparkConf);+ new GravitinoDriverPlugin(withoutPaimon()).registerSqlExtensions(sparkConf);- assertEquals(- GravitinoAuthorizationSparkSessionExtensions.class.getName(),- sparkConf.get(StaticSQLConf.SPARK_SESSION_EXTENSIONS().key()));+ assertEquals(AUTHZ_EXTENSION, sparkConf.get(StaticSQLConf.SPARK_SESSION_EXTENSIONS().key()));}@Testvoid testDoesNotDuplicateAuthorizationExtension() {SparkConf sparkConf = new SparkConf(false);- String extension = GravitinoAuthorizationSparkSessionExtensions.class.getName();- sparkConf.set(StaticSQLConf.SPARK_SESSION_EXTENSIONS().key(), extension);+ sparkConf.set(StaticSQLConf.SPARK_SESSION_EXTENSIONS().key(), AUTHZ_EXTENSION);++ new GravitinoDriverPlugin(withoutPaimon()).registerSqlExtensions(sparkConf);++ assertEquals(AUTHZ_EXTENSION, sparkConf.get(StaticSQLConf.SPARK_SESSION_EXTENSIONS().key()));+ }+ /**+ * Paimon publishes no paimon-spark artifact for every Spark version and Scala version this+ * connector supports, so some builds bind no Paimon catalog. Registering the Paimon session+ * extension there would fail SparkSession construction, so the plugin must skip it whenever the+ * binding is absent.+ */+ @Test+ void testPaimonExtensionIsSkippedWithoutAPaimonBinding() {+ assertFalse(registeredExtensions(withoutPaimon()).contains(paimonExtension()));+ }++ /**+ * The same skip, reached through the opt-in flag rather than by calling the guarded method+ * directly. This is the composition that matters in production: a user carries+ * enablePaimonSupport=true onto a build that bound no Paimon catalog, and the flag must not be+ * enough to queue the extension.+ */+ @Test+ void testThePaimonFlagAloneDoesNotQueueTheExtensionWithoutABinding() {+ SparkConf sparkConf = new SparkConf(false);+ sparkConf.set(GravitinoSparkConfig.GRAVITINO_ENABLE_PAIMON_SUPPORT, "true");+ GravitinoDriverPlugin plugin = new GravitinoDriverPlugin(withoutPaimon());++ plugin.registerOptInExtensions(sparkConf);+ plugin.registerSqlExtensions(sparkConf);++ String extensions = sparkConf.get(StaticSQLConf.SPARK_SESSION_EXTENSIONS().key());+ assertFalse(extensions.contains(paimonExtension()), extensions);+ }++ /**+ * A user may set spark.sql.extensions themselves. The plugin has to merge its own extensions into+ * that value rather than replace it, so seed a foreign extension: seeding only the one the plugin+ * is about to add cannot tell merging apart from overwriting.+ */+ @Test+ void testMergesIntoExtensionsTheUserAlreadySet() {+ SparkConf sparkConf = new SparkConf(false);+ sparkConf.set(+ StaticSQLConf.SPARK_SESSION_EXTENSIONS().key(), USER_EXTENSION + COMMA + AUTHZ_EXTENSION);++ new GravitinoDriverPlugin(withoutPaimon()).registerSqlExtensions(sparkConf);++ String extensions = sparkConf.get(StaticSQLConf.SPARK_SESSION_EXTENSIONS().key());+ assertTrue(extensions.contains(USER_EXTENSION), extensions);+ assertEquals(+ 1,+ Arrays.stream(extensions.split(COMMA)).filter(AUTHZ_EXTENSION::equals).count(),+ extensions);+ }++ /** The catalog every provider resolves to comes from the bindings, not from a fixed table. */+ @Test+ void testEveryProviderResolvesToTheClassBoundForItsKind() {+ GravitinoDriverPlugin plugin = new GravitinoDriverPlugin(withPaimon());++ assertEquals(HIVE_CATALOG, classFor(plugin, "hive"));+ assertEquals(ICEBERG_CATALOG, classFor(plugin, "lakehouse-iceberg"));+ assertEquals(PAIMON_CATALOG, classFor(plugin, "lakehouse-paimon"));+ assertEquals(GLUE_CATALOG, classFor(plugin, "glue"));+ assertEquals(POSTGRESQL_CATALOG, classFor(plugin, "jdbc-postgresql"));+ // Every other JDBC backend shares one catalog.+ assertEquals(JDBC_CATALOG, classFor(plugin, "jdbc-mysql"));+ assertEquals(JDBC_CATALOG, classFor(plugin, "jdbc-doris"));+ }++ @Test+ void testAKindThisBuildBoundNoCatalogForResolvesToNothing() {+ GravitinoDriverPlugin plugin = new GravitinoDriverPlugin(withoutPaimon());++ // Paimon is the one kind a build may legitimately omit, so it is the only kind that can reach+ // catalogClassName with nothing behind it. Providers that map to no kind at all are+ // TestSparkCatalogKind's subject.+ Assertions.assertNull(plugin.catalogClassName(SparkCatalogKind.LAKEHOUSE_PAIMON));+ }++ @Test+ void testRegisteringACatalogWritesTheBoundClassUnderItsName() {+ SparkConf sparkConf = new SparkConf(false);- new GravitinoDriverPlugin().registerSqlExtensions(sparkConf);+ new GravitinoDriverPlugin(withoutPaimon())+ .registerCatalog(sparkConf, "my_hive", SparkCatalogKind.HIVE);++ assertEquals(HIVE_CATALOG, sparkConf.get("spark.sql.catalog.my_hive"));+ }++ @Test+ void testACatalogThisBuildCannotServeIsNotRegistered() {+ SparkConf sparkConf = new SparkConf(false);+ GravitinoDriverPlugin plugin = new GravitinoDriverPlugin(withoutPaimon());++ plugin.registerCatalog(sparkConf, "my_paimon", SparkCatalogKind.LAKEHOUSE_PAIMON);++ // Asserting that nothing at all was written also catches a future edit that writes some+ // unrelated key.+ assertEquals(0, sparkConf.getAll().length, Arrays.toString(sparkConf.getAll()));+ }++ /**+ * registerCatalog takes a resolved kind and rejects a missing one rather than treating it as "no+ * catalog": a provider that maps to no kind has to be reported by the caller, which still has the+ * provider name in hand.+ */+ @Test+ void testRegisterCatalogRejectsAMissingKind() {+ SparkConf sparkConf = new SparkConf(false);+ GravitinoDriverPlugin plugin = new GravitinoDriverPlugin(withoutPaimon());++ Assertions.assertThrows(+ NullPointerException.class, () -> plugin.registerCatalog(sparkConf, "my_kafka", null));+ }++ /** Composes the two steps production takes: provider to kind, then kind to the bound class. */+ private static String classFor(GravitinoDriverPlugin plugin, String provider) {+ return plugin.catalogClassName(SparkCatalogKind.fromProvider(provider));+ }++ /**+ * Iceberg and Paimon are opt-in, in two respects: a catalog of either kind must not be registered+ * unless its flag is set, and neither one's session extensions may be queued. Both gates sit+ * above the methods the other tests call, so this goes through registerOptInExtensions and+ * registerGravitinoCatalogs, with the flags set through the conf keys users actually write, so a+ * key wired to the wrong flag fails here.+ */+ @Test+ void testAnOptInCatalogAndItsExtensionsAreRegisteredOnlyWhenItsFlagIsSet() {+ for (boolean iceberg : new boolean[] {false, true}) {+ for (boolean paimon : new boolean[] {false, true}) {+ SparkConf sparkConf = new SparkConf(false);+ sparkConf.set(+ GravitinoSparkConfig.GRAVITINO_ENABLE_ICEBERG_SUPPORT, String.valueOf(iceberg));+ sparkConf.set(GravitinoSparkConfig.GRAVITINO_ENABLE_PAIMON_SUPPORT, String.valueOf(paimon));+ GravitinoDriverPlugin plugin = new GravitinoDriverPlugin(withPaimon());+ plugin.registerOptInExtensions(sparkConf);++ plugin.registerGravitinoCatalogs(+ sparkConf,+ ImmutableMap.<String, Catalog>builder()+ .put("my_iceberg", catalogWithProvider("lakehouse-iceberg"))+ .put("my_paimon", catalogWithProvider("lakehouse-paimon"))+ .put("my_hive", catalogWithProvider("hive"))+ .put("my_mysql", catalogWithProvider("jdbc-mysql"))+ .put("my_postgresql", catalogWithProvider("jdbc-postgresql"))+ // Three shapes that must all be skipped. null and "" stop at the blank-provider+ // guard, null being the one that pins it since fromProvider rejects null; kafka is+ // the other shape, a non-blank provider this connector maps to no kind.+ .put("no_provider", catalogWithProvider(null))+ .put("blank_provider", catalogWithProvider(""))+ .put("my_kafka", catalogWithProvider("kafka"))+ .build());+ plugin.registerSqlExtensions(sparkConf);++ String flags = "iceberg=" + iceberg + " paimon=" + paimon;+ // Assert the class, not just the key: the kind reaching registerCatalog has to be the one+ // this catalog's own provider maps to, and only the value shows that.+ assertEquals(+ iceberg ? ICEBERG_CATALOG : null,+ sparkConf.get("spark.sql.catalog.my_iceberg", null),+ flags);+ assertEquals(+ paimon ? PAIMON_CATALOG : null,+ sparkConf.get("spark.sql.catalog.my_paimon", null),+ flags);+ // Catalogs behind no flag are registered either way.+ assertEquals(HIVE_CATALOG, sparkConf.get("spark.sql.catalog.my_hive", null), flags);+ assertEquals(JDBC_CATALOG, sparkConf.get("spark.sql.catalog.my_mysql", null), flags);+ assertEquals(+ POSTGRESQL_CATALOG, sparkConf.get("spark.sql.catalog.my_postgresql", null), flags);+ assertFalse(sparkConf.contains("spark.sql.catalog.no_provider"), flags);+ assertFalse(sparkConf.contains("spark.sql.catalog.blank_provider"), flags);+ assertFalse(sparkConf.contains("spark.sql.catalog.my_kafka"), flags);++ String extensions = sparkConf.get(StaticSQLConf.SPARK_SESSION_EXTENSIONS().key());+ assertEquals(+ iceberg,+ extensions.contains(GravitinoDriverPlugin.ICEBERG_SPARK_EXTENSIONS),+ flags + " -> " + extensions);+ assertEquals(+ iceberg,+ extensions.contains(GravitinoIcebergSparkSessionExtensions.class.getName()),+ flags + " -> " + extensions);+ assertEquals(+ paimon,+ extensions.contains(GravitinoDriverPlugin.PAIMON_SPARK_EXTENSIONS),+ flags + " -> " + extensions);+ }+ }+ }++ private static Catalog catalogWithProvider(String provider) {+ Catalog catalog = Mockito.mock(Catalog.class);+ Mockito.when(catalog.provider()).thenReturn(provider);+ return catalog;+ }++ private static String registeredExtensions(SparkBindings bindings) {+ SparkConf sparkConf = new SparkConf(false);+ GravitinoDriverPlugin plugin = new GravitinoDriverPlugin(bindings);+ plugin.registerPaimonExtensionsIfSupported();+ plugin.registerSqlExtensions(sparkConf);+ return sparkConf.get(StaticSQLConf.SPARK_SESSION_EXTENSIONS().key());+ }++ private static String paimonExtension() {+ return GravitinoDriverPlugin.PAIMON_SPARK_EXTENSIONS;+ }++ private static SparkBindings withoutPaimon() {+ return requiredCatalogs().build();+ }++ private static SparkBindings withPaimon() {+ return requiredCatalogs().catalog(SparkCatalogKind.LAKEHOUSE_PAIMON, PAIMON_CATALOG).build();+ }- assertEquals(extension, sparkConf.get(StaticSQLConf.SPARK_SESSION_EXTENSIONS().key()));+ private static SparkBindings.Builder requiredCatalogs() {+ return SparkBindings.builder()+ .authorizationExtension(AUTHZ_EXTENSION)+ .catalog(SparkCatalogKind.HIVE, HIVE_CATALOG)+ .catalog(SparkCatalogKind.LAKEHOUSE_ICEBERG, ICEBERG_CATALOG)+ .catalog(SparkCatalogKind.GLUE, GLUE_CATALOG)+ .catalog(SparkCatalogKind.JDBC, JDBC_CATALOG)+ .catalog(SparkCatalogKind.JDBC_POSTGRESQL, POSTGRESQL_CATALOG);}@Testdiff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/plugin/TestSparkBindings.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/plugin/TestSparkBindings.javanew file mode 100644index 0000000000..f60c169927--- /dev/null+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/plugin/TestSparkBindings.java@@ -0,0 +1,131 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.spark.connector.plugin;++import org.apache.gravitino.spark.connector.catalog.SparkCatalogKind;+import org.junit.jupiter.api.Assertions;+import org.junit.jupiter.api.Test;++/**+ * Tests that a version module's binding mistakes fail at build time rather than at use time: a+ * missing binding, a duplicate one, or a blank one.+ */+public class TestSparkBindings {++ @Test+ void testAMissingCatalogIsRejected() {+ SparkBindings.Builder builder =+ SparkBindings.builder()+ .authorizationExtension("org.example.AuthorizationExtensions")+ .catalog(SparkCatalogKind.HIVE, "org.example.HiveCatalog")+ .catalog(SparkCatalogKind.LAKEHOUSE_ICEBERG, "org.example.IcebergCatalog")+ .catalog(SparkCatalogKind.GLUE, "org.example.GlueCatalog")+ .catalog(SparkCatalogKind.JDBC, "org.example.JdbcCatalog");++ IllegalStateException e = Assertions.assertThrows(IllegalStateException.class, builder::build);+ Assertions.assertTrue(+ e.getMessage().contains(SparkCatalogKind.JDBC_POSTGRESQL.name()), e.getMessage());+ }++ @Test+ void testAMissingAuthorizationExtensionIsRejected() {+ SparkBindings.Builder builder = everyRequiredCatalog(SparkBindings.builder());++ Assertions.assertThrows(IllegalStateException.class, builder::build);+ }++ /**+ * Paimon is the one kind a build may legitimately omit, since Paimon publishes no artifact for+ * every supported Spark and Scala version.+ */+ @Test+ void testPaimonMayBeOmitted() {+ SparkBindings bindings =+ everyRequiredCatalog(SparkBindings.builder())+ .authorizationExtension("org.example.AuthorizationExtensions")+ .build();++ Assertions.assertFalse(+ bindings.catalogClassNames().containsKey(SparkCatalogKind.LAKEHOUSE_PAIMON));+ Assertions.assertEquals(5, bindings.catalogClassNames().size());+ }++ /**+ * Binding the same thing twice is a copy-paste error a version module can make, and the survivor+ * would be whichever line came last. Rejecting it matters most for the authorization extension,+ * where silently keeping the wrong one means sessions run unauthorized.+ */+ @Test+ void testBindingTheSameKindTwiceIsRejected() {+ SparkBindings.Builder builder =+ SparkBindings.builder().catalog(SparkCatalogKind.HIVE, "org.example.HiveCatalog");++ IllegalStateException e =+ Assertions.assertThrows(+ IllegalStateException.class,+ () -> builder.catalog(SparkCatalogKind.HIVE, "org.example.OtherHiveCatalog"));++ Assertions.assertTrue(e.getMessage().contains(SparkCatalogKind.HIVE.name()), e.getMessage());+ // The rejected binding must not have replaced the first one.+ SparkBindings bindings =+ builder+ .authorizationExtension("org.example.AuthorizationExtensions")+ .catalog(SparkCatalogKind.LAKEHOUSE_ICEBERG, "org.example.IcebergCatalog")+ .catalog(SparkCatalogKind.GLUE, "org.example.GlueCatalog")+ .catalog(SparkCatalogKind.JDBC, "org.example.JdbcCatalog")+ .catalog(SparkCatalogKind.JDBC_POSTGRESQL, "org.example.PostgreSqlCatalog")+ .build();+ Assertions.assertEquals(+ "org.example.HiveCatalog", bindings.catalogClassNames().get(SparkCatalogKind.HIVE));+ }++ @Test+ void testBindingTheAuthorizationExtensionTwiceIsRejected() {+ SparkBindings.Builder builder =+ SparkBindings.builder().authorizationExtension("org.example.AuthorizationExtensions");++ Assertions.assertThrows(+ IllegalStateException.class,+ () -> builder.authorizationExtension("org.example.OtherExtensions"));++ // The rejected binding must not have replaced the first one.+ Assertions.assertEquals(+ "org.example.AuthorizationExtensions",+ everyRequiredCatalog(builder).build().authorizationExtension());+ }++ @Test+ void testABlankBindingIsRejected() {+ Assertions.assertThrows(+ IllegalArgumentException.class,+ () -> SparkBindings.builder().catalog(SparkCatalogKind.HIVE, " "));+ Assertions.assertThrows(+ IllegalArgumentException.class, () -> SparkBindings.builder().authorizationExtension(""));+ }++ private static SparkBindings.Builder everyRequiredCatalog(SparkBindings.Builder builder) {+ return builder+ .catalog(SparkCatalogKind.HIVE, "org.example.HiveCatalog")+ .catalog(SparkCatalogKind.LAKEHOUSE_ICEBERG, "org.example.IcebergCatalog")+ .catalog(SparkCatalogKind.GLUE, "org.example.GlueCatalog")+ .catalog(SparkCatalogKind.JDBC, "org.example.JdbcCatalog")+ .catalog(SparkCatalogKind.JDBC_POSTGRESQL, "org.example.PostgreSqlCatalog");+ }+}diff --git a/spark-connector/v3.3/build.gradle.kts b/spark-connector/v3.3/build.gradle.ktsdeleted file mode 100644index 043fbfec67..0000000000--- a/spark-connector/v3.3/build.gradle.kts+++ /dev/null@@ -1,22 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */--tasks.all {- enabled = false-}\ No newline at end of filediff --git a/spark-connector/v3.3/spark/build.gradle.kts b/spark-connector/v3.3/spark/build.gradle.ktsdeleted file mode 100644index 3581801337..0000000000--- a/spark-connector/v3.3/spark/build.gradle.kts+++ /dev/null@@ -1,235 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-evaluationDependsOn(":spark-connector:spark-common")--plugins {- `maven-publish`- id("java")- id("idea")- alias(libs.plugins.shadow)-}--repositories {- mavenCentral()-}--val scalaVersion: String = project.properties["scalaVersion"] as? String ?: extra["defaultScalaVersion"].toString()-val sparkVersion: String = libs.versions.spark33.get()-val sparkMajorVersion: String = sparkVersion.substringBeforeLast(".")-val icebergVersion: String = libs.versions.iceberg4spark33.get()-val paimonVersion: String = libs.versions.paimon.get()-val kyuubiVersion: String = libs.versions.kyuubi4spark.get()-val scalaJava8CompatVersion: String = libs.versions.scala.java.compat.get()-val scalaCollectionCompatVersion: String = libs.versions.scala.collection.compat.get()-val slf4j17Version = "1.7.36"-val artifactName = "${rootProject.name}-spark-${sparkMajorVersion}_$scalaVersion"--if (hasProperty("excludePackagesForSparkConnector")) {- val configureFunc = properties["excludePackagesForSparkConnector"] as? (Project) -> Unit- configureFunc?.invoke(project)-}--configurations.matching { it.name in setOf("testRuntimeClasspath", "testCompileClasspath") }- .configureEach {- resolutionStrategy {- // Spark 3.3 pulls an SLF4J 1.7 binding; align slf4j-api to 1.7.x to avoid Log4j bridge conflicts.- force("org.slf4j:slf4j-api:$slf4j17Version")- }- exclude(group = "org.apache.logging.log4j", module = "log4j-slf4j2-impl")- }--dependencies {- implementation(project(":spark-connector:spark-common"))- compileOnly("org.apache.kyuubi:kyuubi-spark-connector-hive_$scalaVersion:$kyuubiVersion")- compileOnly("org.apache.spark:spark-catalyst_$scalaVersion:$sparkVersion") {- exclude("com.fasterxml.jackson")- }- compileOnly("org.apache.iceberg:iceberg-spark-runtime-${sparkMajorVersion}_$scalaVersion:$icebergVersion")- if (scalaVersion == "2.12") {- compileOnly("org.apache.paimon:paimon-spark-$sparkMajorVersion:$paimonVersion") {- exclude("org.apache.spark")- }- }-- testImplementation(project(":api")) {- exclude("org.apache.logging.log4j")- exclude("org.slf4j")- }- testImplementation(project(":catalogs:catalog-jdbc-common")) {- exclude("org.apache.logging.log4j")- }- testImplementation(project(":catalogs:hive-metastore-common")) {- exclude("*")- }- testImplementation(project(":clients:client-java")) {- exclude("org.apache.logging.log4j")- exclude("org.slf4j")- }- testImplementation(project(":core")) {- exclude("org.apache.logging.log4j")- exclude("org.slf4j")- }- testImplementation(project(":common")) {- exclude("org.apache.logging.log4j")- exclude("org.slf4j")- }- testImplementation(project(":integration-test-common", "testArtifacts")) {- exclude("org.apache.logging.log4j")- exclude("org.slf4j")- }- testImplementation(project(":server")) {- exclude("org.apache.logging.log4j")- exclude("org.slf4j")- }- testImplementation(project(":server-common")) {- exclude("org.apache.logging.log4j")- exclude("org.slf4j")- }- testImplementation(project(":spark-connector:spark-common", "testArtifacts")) {- exclude("com.fasterxml.jackson")- }-- testImplementation(libs.awaitility)- testImplementation(libs.hive2.common) {- exclude("com.sun.jersey")- exclude("org.apache.curator")- // use hadoop from Spark- exclude("org.apache.hadoop")- exclude("org.apache.logging.log4j")- exclude("org.eclipse.jetty.aggregate", "jetty-all")- exclude("org.eclipse.jetty.orbit", "javax.servlet")- exclude("org.slf4j")- }-- testImplementation(libs.hive2.metastore) {- exclude("co.cask.tephra")- exclude("com.github.joshelser")- exclude("com.google.code.findbugs", "jsr305")- exclude("com.google.code.findbugs", "sr305")- exclude("com.tdunning", "json")- exclude("com.zaxxer", "HikariCP")- exclude("com.sun.jersey")- exclude("io.dropwizard.metrics")- exclude("javax.transaction", "transaction-api")- exclude("org.apache.avro")- exclude("org.apache.curator")- exclude("org.apache.hbase")- exclude("org.apache.hadoop")- exclude("org.apache.hive", "hive-common")- exclude("org.apache.hive", "hive-shims")- exclude("org.apache.logging.log4j")- exclude("org.apache.parquet", "parquet-hadoop-bundle")- exclude("org.apache.zookeeper")- exclude("org.eclipse.jetty.aggregate", "jetty-all")- exclude("org.eclipse.jetty.orbit", "javax.servlet")- exclude("org.slf4j")- }- testImplementation(libs.junit.jupiter.api)- testImplementation(libs.junit.jupiter.params)- testImplementation(libs.mysql.driver)- testImplementation(libs.postgresql.driver)- testImplementation(libs.testcontainers)- testImplementation(libs.hadoop3.aws)- // hadoop-aws declares hadoop-client-api as provided; add it explicitly so S3AFileSystem can load- // org.apache.hadoop.fs.impl.prefetch.PrefetchingStatistics (added in 3.3.5) at runtime.- testImplementation(libs.hadoop3.client.api)- // Iceberg's GlueCatalog references several AWS SDK modules at runtime; must be on test classpath- testImplementation(libs.aws.dynamodb)- testImplementation(libs.aws.glue)- testImplementation(libs.aws.sts)- testImplementation(libs.aws.s3)- testImplementation(libs.aws.kms)-- // org.apache.iceberg.rest.RESTSerializers#registerAll(ObjectMapper) has different method signature for iceberg-core and iceberg-spark-runtime package, we must make sure iceberg-core is in front to start up MiniGravitino server.- testImplementation("org.apache.iceberg:iceberg-core:$icebergVersion")- testImplementation("org.apache.iceberg:iceberg-spark-runtime-${sparkMajorVersion}_$scalaVersion:$icebergVersion")- testImplementation("org.apache.iceberg:iceberg-hive-metastore:$icebergVersion")- if (scalaVersion == "2.12") {- testImplementation("org.apache.paimon:paimon-spark-$sparkMajorVersion:$paimonVersion") {- exclude("org.apache.spark")- }- }- testImplementation("org.apache.kyuubi:kyuubi-spark-connector-hive_$scalaVersion:$kyuubiVersion")- // include spark-sql,spark-catalyst,hive-common,hdfs-client- testImplementation("org.apache.spark:spark-hive_$scalaVersion:$sparkVersion") {- // conflict with Gravitino server jersey- exclude("org.glassfish.jersey.core")- exclude("org.glassfish.jersey.containers")- exclude("org.glassfish.jersey.inject")- exclude("com.sun.jersey")- exclude("com.fasterxml.jackson")- exclude("com.fasterxml.jackson.core")- }- testImplementation("org.scala-lang.modules:scala-collection-compat_$scalaVersion:$scalaCollectionCompatVersion")- testImplementation("org.apache.spark:spark-catalyst_$scalaVersion:$sparkVersion")- testImplementation("org.apache.spark:spark-core_$scalaVersion:$sparkVersion")- testImplementation("org.apache.spark:spark-sql_$scalaVersion:$sparkVersion")-- testRuntimeOnly(libs.junit.jupiter.engine)-}--val glueHiveJarsDir: String? =- project(":spark-connector:spark-common").extra["glueHiveJarsDir"] as String?--tasks.test {- val skipITs = project.hasProperty("skipITs")- val enableSparkSQLITs = project.hasProperty("enableSparkSQLITs")- if (!enableSparkSQLITs) {- exclude("**/integration/test/sql/**")- }- if (skipITs) {- // Exclude integration tests- exclude("**/integration/test/**")- } else {- if (glueHiveJarsDir != null) {- dependsOn(":spark-connector:spark-common:downloadGlueHiveJars")- jvmArgs("-Dglue.hive-jars-dir=$glueHiveJarsDir")- }- dependsOn(tasks.jar)- dependsOn(":catalogs:catalog-lakehouse-iceberg:jar")- dependsOn(":catalogs:catalog-hive:jar")- dependsOn(":iceberg:iceberg-rest-server:jar")- dependsOn(":lance:lance-rest-server:jar")- dependsOn(":catalogs:catalog-lakehouse-paimon:jar")- dependsOn(":catalogs:catalog-jdbc-mysql:jar")- dependsOn(":catalogs:catalog-jdbc-postgresql:jar")- }-}--tasks.withType<Jar> {- archiveBaseName.set(artifactName)-}--publishing {- publications {- withType<MavenPublication>().configureEach {- artifactId = artifactName- }- }-}--tasks.clean {- delete("derby.log")- delete("metastore_db")- delete("spark-warehouse")-}--tasks.named<Jar>("sourcesJar") {- duplicatesStrategy = DuplicatesStrategy.EXCLUDE-}diff --git a/spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalogSpark33.java b/spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalogSpark33.javadeleted file mode 100644index 557a87399d..0000000000--- a/spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalogSpark33.java+++ /dev/null@@ -1,21 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.iceberg;--public class GravitinoIcebergCatalogSpark33 extends GravitinoIcebergCatalog {}diff --git a/spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/postgresql/GravitinoPostgreSqlCatalogSpark33.java b/spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/postgresql/GravitinoPostgreSqlCatalogSpark33.javadeleted file mode 100644index 6614a1111c..0000000000--- a/spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/postgresql/GravitinoPostgreSqlCatalogSpark33.java+++ /dev/null@@ -1,30 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.jdbc.postgresql;--import org.apache.gravitino.spark.connector.PropertiesConverter;-import org.apache.gravitino.spark.connector.jdbc.GravitinoJdbcCatalogSpark33;-import org.apache.gravitino.spark.connector.jdbc.JdbcPropertiesConverter;--public class GravitinoPostgreSqlCatalogSpark33 extends GravitinoJdbcCatalogSpark33 {- @Override- protected PropertiesConverter getPropertiesConverter() {- return JdbcPropertiesConverter.getNoTablePropertiesInstance();- }-}diff --git a/spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/paimon/GravitinoPaimonCatalogSpark33.java b/spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/paimon/GravitinoPaimonCatalogSpark33.javadeleted file mode 100644index 2fef911a8b..0000000000--- a/spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/paimon/GravitinoPaimonCatalogSpark33.java+++ /dev/null@@ -1,21 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.paimon;--public class GravitinoPaimonCatalogSpark33 extends GravitinoPaimonCatalog {}diff --git a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT33.java b/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT33.javadeleted file mode 100644index 2ff6a1d839..0000000000--- a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT33.java+++ /dev/null@@ -1,20 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- * http://www.apache.org/licenses/LICENSE-2.0- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */--package org.apache.gravitino.spark.connector.integration.test.authorization;--public class SparkAuthorizationIT33 extends SparkAuthorizationIT {}diff --git a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/glue/SparkAwsGlueCatalogIT33.java b/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/glue/SparkAwsGlueCatalogIT33.javadeleted file mode 100644index 17b8a78ea7..0000000000--- a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/glue/SparkAwsGlueCatalogIT33.java+++ /dev/null@@ -1,37 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.integration.test.glue;--import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;--/**- * Integration test for Spark 3.3 Glue catalog connector against a real AWS Glue endpoint.- *- * <p>This test is <b>skipped by default</b> and only runs when {@code AWS_ACCESS_KEY_ID} is set.- * Required environment variables:- *- * <ul>- * <li>{@code AWS_ACCESS_KEY_ID}- * <li>{@code AWS_SECRET_ACCESS_KEY}- * <li>{@code AWS_DEFAULT_REGION}- * <li>{@code AWS_S3_TEST_BUCKET}- * </ul>- */-@EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY_ID", matches = ".+")-public class SparkAwsGlueCatalogIT33 extends SparkGlueCatalogIT {}diff --git a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT33.java b/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT33.javadeleted file mode 100644index 23773314df..0000000000--- a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT33.java+++ /dev/null@@ -1,41 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.integration.test.hive;--import org.apache.gravitino.spark.connector.hive.GravitinoHiveCatalogSpark33;-import org.junit.jupiter.api.Assertions;-import org.junit.jupiter.api.Test;--public class SparkHiveCatalogIT33 extends SparkHiveCatalogIT {- @Test- void testCatalogClassName() {- String catalogClass =- getSparkSession()- .sessionState()- .conf()- .getConfString("spark.sql.catalog." + getCatalogName());- Assertions.assertEquals(GravitinoHiveCatalogSpark33.class.getName(), catalogClass);- }-- @Override- protected boolean supportsFunction() {- // Spark 3.3 does not support function operations- return false;- }-}diff --git a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogHiveBackendIT33.java b/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogHiveBackendIT33.javadeleted file mode 100644index df88b21199..0000000000--- a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogHiveBackendIT33.java+++ /dev/null@@ -1,74 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.integration.test.iceberg;--import org.apache.gravitino.spark.connector.iceberg.GravitinoIcebergCatalogSpark33;-import org.apache.gravitino.spark.connector.integration.test.util.SparkMetadataColumnInfo;-import org.apache.spark.sql.types.DataTypes;-import org.apache.spark.sql.types.StructField;-import org.junit.jupiter.api.Assertions;-import org.junit.jupiter.api.Test;-import org.junit.jupiter.api.condition.DisabledIf;--/**- * Spark 3.3 integration tests for the Iceberg Hive catalog backend.- *- * <p>Spark 3.3 pins Iceberg to 1.8.x ({@code iceberg4spark33}); Gravitino's lakehouse Iceberg stack- * is 1.11. {@link DisabledIf} skips embedded mode to avoid classpath conflicts. Deploy-mode tests- * run a 1.8.x client against Gravitino with Iceberg 1.11 on the server and cover basic catalog CRUD- * only; they do not validate Iceberg 1.11 REST changes such as {@code file-scan-tasks} scan- * planning or the configurable multi-level namespace separator contract.- */-@DisabledIf("org.apache.gravitino.integration.test.util.ITUtils#isEmbedded")-public class SparkIcebergCatalogHiveBackendIT33 extends SparkIcebergCatalogHiveBackendIT {- @Test- void testCatalogClassName() {- String catalogClass =- getSparkSession()- .sessionState()- .conf()- .getConfString("spark.sql.catalog." + getCatalogName());- Assertions.assertEquals(GravitinoIcebergCatalogSpark33.class.getName(), catalogClass);- }-- @Override- protected boolean supportsFunction() {- // Spark 3.3 does not support function operations- return false;- }-- /**- * Spark 3.3 uses Iceberg 1.8.x; its {@code SparkTable#metadataColumns()} exposes five columns,- * not the seven row-lineage columns added in Iceberg 1.11.- */- @Override- protected SparkMetadataColumnInfo[] getIcebergMetadataColumns() {- return new SparkMetadataColumnInfo[] {- new SparkMetadataColumnInfo("_spec_id", DataTypes.IntegerType, false),- new SparkMetadataColumnInfo(- "_partition",- DataTypes.createStructType(- new StructField[] {DataTypes.createStructField("name", DataTypes.StringType, true)}),- true),- new SparkMetadataColumnInfo("_file", DataTypes.StringType, false),- new SparkMetadataColumnInfo("_pos", DataTypes.LongType, false),- new SparkMetadataColumnInfo("_deleted", DataTypes.BooleanType, false)- };- }-}diff --git a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestBackendIT33.java b/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestBackendIT33.javadeleted file mode 100644index 788b1009f3..0000000000--- a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestBackendIT33.java+++ /dev/null@@ -1,62 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */--package org.apache.gravitino.spark.connector.integration.test.iceberg;--import org.apache.gravitino.spark.connector.integration.test.util.SparkMetadataColumnInfo;-import org.apache.spark.sql.types.DataTypes;-import org.apache.spark.sql.types.StructField;-import org.junit.jupiter.api.condition.DisabledIf;--/**- * Spark 3.3 integration tests for the Iceberg REST catalog backend.- *- * <p>Spark 3.3 pins Iceberg to 1.8.x ({@code iceberg4spark33}); Gravitino's lakehouse Iceberg stack- * is 1.11. {@link DisabledIf} skips embedded mode to avoid classpath conflicts. Deploy-mode tests- * run a 1.8.x client against Gravitino's 1.11 REST server and cover basic catalog CRUD only; they- * do not exercise Iceberg 1.11 REST changes such as {@code file-scan-tasks} scan planning or the- * configurable multi-level namespace separator contract.- */-@DisabledIf("org.apache.gravitino.integration.test.util.ITUtils#isEmbedded")-public class SparkIcebergCatalogRestBackendIT33 extends SparkIcebergCatalogRestBackendIT {- @Override- protected boolean supportsFunction() {- // Spark 3.3 does not support function operations- return false;- }-- /**- * Spark 3.3 uses Iceberg 1.8.x; its {@code SparkTable#metadataColumns()} exposes five columns,- * not the seven row-lineage columns added in Iceberg 1.11.- */- @Override- protected SparkMetadataColumnInfo[] getIcebergMetadataColumns() {- return new SparkMetadataColumnInfo[] {- new SparkMetadataColumnInfo("_spec_id", DataTypes.IntegerType, false),- new SparkMetadataColumnInfo(- "_partition",- DataTypes.createStructType(- new StructField[] {DataTypes.createStructField("name", DataTypes.StringType, true)}),- true),- new SparkMetadataColumnInfo("_file", DataTypes.StringType, false),- new SparkMetadataColumnInfo("_pos", DataTypes.LongType, false),- new SparkMetadataColumnInfo("_deleted", DataTypes.BooleanType, false)- };- }-}diff --git a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcMysqlCatalogIT33.java b/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcMysqlCatalogIT33.javadeleted file mode 100644index c96653ae38..0000000000--- a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcMysqlCatalogIT33.java+++ /dev/null@@ -1,42 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */--package org.apache.gravitino.spark.connector.integration.test.jdbc;--import org.apache.gravitino.spark.connector.jdbc.GravitinoJdbcCatalogSpark33;-import org.junit.jupiter.api.Assertions;-import org.junit.jupiter.api.Test;--public class SparkJdbcMysqlCatalogIT33 extends SparkJdbcMysqlCatalogIT {- @Test- void testCatalogClassName() {- String catalogClass =- getSparkSession()- .sessionState()- .conf()- .getConfString("spark.sql.catalog." + getCatalogName());- Assertions.assertEquals(GravitinoJdbcCatalogSpark33.class.getName(), catalogClass);- }-- @Override- protected boolean supportsFunction() {- // Spark 3.3 does not support function operations- return false;- }-}diff --git a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcPostgreSqlCatalogIT33.java b/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcPostgreSqlCatalogIT33.javadeleted file mode 100644index b2e0c8be30..0000000000--- a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcPostgreSqlCatalogIT33.java+++ /dev/null@@ -1,42 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.integration.test.jdbc;--import org.apache.gravitino.spark.connector.jdbc.postgresql.GravitinoPostgreSqlCatalogSpark33;-import org.junit.jupiter.api.Assertions;-import org.junit.jupiter.api.Test;--public class SparkJdbcPostgreSqlCatalogIT33 extends SparkJdbcPostgreSqlCatalogIT {-- @Test- void testCatalogClassName() {- String catalogClass =- getSparkSession()- .sessionState()- .conf()- .getConfString("spark.sql.catalog." + getCatalogName());- Assertions.assertEquals(GravitinoPostgreSqlCatalogSpark33.class.getName(), catalogClass);- }-- @Override- protected boolean supportsFunction() {- // Spark 3.3 does not support function operations- return false;- }-}diff --git a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/paimon/SparkPaimonCatalogFilesystemBackendIT33.java b/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/paimon/SparkPaimonCatalogFilesystemBackendIT33.javadeleted file mode 100644index a4b825637f..0000000000--- a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/paimon/SparkPaimonCatalogFilesystemBackendIT33.java+++ /dev/null@@ -1,41 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.integration.test.paimon;--import org.apache.gravitino.spark.connector.paimon.GravitinoPaimonCatalogSpark33;-import org.junit.jupiter.api.Assertions;-import org.junit.jupiter.api.Test;--public class SparkPaimonCatalogFilesystemBackendIT33 extends SparkPaimonCatalogFilesystemBackendIT {- @Test- void testCatalogClassName() {- String catalogClass =- getSparkSession()- .sessionState()- .conf()- .getConfString("spark.sql.catalog." + getCatalogName());- Assertions.assertEquals(GravitinoPaimonCatalogSpark33.class.getName(), catalogClass);- }-- @Override- protected boolean supportsFunction() {- // Spark 3.3 does not support function operations- return false;- }-}diff --git a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkSQLRegressionTest33.java b/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkSQLRegressionTest33.javadeleted file mode 100644index efc3122624..0000000000--- a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkSQLRegressionTest33.java+++ /dev/null@@ -1,21 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.integration.test.sql;--public class SparkSQLRegressionTest33 extends SparkSQLRegressionTest {}diff --git a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/version/TestCatalogNameAdaptor.java b/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/version/TestCatalogNameAdaptor.javadeleted file mode 100644index 2d82386d02..0000000000--- a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/version/TestCatalogNameAdaptor.java+++ /dev/null@@ -1,48 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.version;--import org.apache.gravitino.spark.connector.hive.GravitinoHiveCatalogSpark33;-import org.apache.gravitino.spark.connector.iceberg.GravitinoIcebergCatalogSpark33;-import org.apache.gravitino.spark.connector.jdbc.GravitinoJdbcCatalogSpark33;-import org.apache.gravitino.spark.connector.jdbc.postgresql.GravitinoPostgreSqlCatalogSpark33;-import org.junit.jupiter.api.Assertions;-import org.junit.jupiter.api.Test;--public class TestCatalogNameAdaptor {- @Test- void testSpark33() {- String hiveCatalogName = CatalogNameAdaptor.getCatalogName("hive");- Assertions.assertEquals(GravitinoHiveCatalogSpark33.class.getName(), hiveCatalogName);-- String icebergCatalogName = CatalogNameAdaptor.getCatalogName("lakehouse-iceberg");- Assertions.assertEquals(GravitinoIcebergCatalogSpark33.class.getName(), icebergCatalogName);-- String paimonCatalogName = CatalogNameAdaptor.getCatalogName("lakehouse-paimon");- Assertions.assertEquals(- "org.apache.gravitino.spark.connector.paimon.GravitinoPaimonCatalogSpark33",- paimonCatalogName);-- String pgCatalogName = CatalogNameAdaptor.getCatalogName("jdbc-postgresql");- Assertions.assertEquals(GravitinoPostgreSqlCatalogSpark33.class.getName(), pgCatalogName);-- String jdbcCatalogName = CatalogNameAdaptor.getCatalogName("jdbc");- Assertions.assertEquals(GravitinoJdbcCatalogSpark33.class.getName(), jdbcCatalogName);- }-}diff --git a/spark-connector/v3.4/build.gradle.kts b/spark-connector/v3.4/build.gradle.ktsdeleted file mode 100644index 043fbfec67..0000000000--- a/spark-connector/v3.4/build.gradle.kts+++ /dev/null@@ -1,22 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */--tasks.all {- enabled = false-}\ No newline at end of filediff --git a/spark-connector/v3.4/spark-runtime/build.gradle.kts b/spark-connector/v3.4/spark-runtime/build.gradle.ktsdeleted file mode 100644index 4065763a87..0000000000--- a/spark-connector/v3.4/spark-runtime/build.gradle.kts+++ /dev/null@@ -1,70 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar--plugins {- `maven-publish`- id("java")- alias(libs.plugins.shadow)-}--val scalaVersion: String = project.properties["scalaVersion"] as? String ?: extra["defaultScalaVersion"].toString()-val sparkVersion: String = libs.versions.spark34.get()-val sparkMajorVersion: String = sparkVersion.substringBeforeLast(".")-val baseName = "${rootProject.name}-spark-connector-runtime-${sparkMajorVersion}_$scalaVersion"--dependencies {- implementation(project(":clients:client-java-runtime", configuration = "shadow"))- when (sparkMajorVersion) {- "3.4" -> {- val kyuubiVersion: String = libs.versions.kyuubi4spark.get()- implementation(project(":spark-connector:spark-3.4"))- implementation("org.apache.kyuubi:kyuubi-spark-connector-hive_$scalaVersion:$kyuubiVersion")- }- else -> throw IllegalArgumentException("Unsupported Spark version: $sparkMajorVersion")- }-}--tasks.withType<ShadowJar>(ShadowJar::class.java) {- isZip64 = true- configurations = listOf(project.configurations.runtimeClasspath.get())- archiveFileName.set("$baseName-$version.jar")- archiveClassifier.set("")-- exclude("org/slf4j/**")-- // Relocate dependencies to avoid conflicts- relocate("com.google", "org.apache.gravitino.shaded.com.google")- relocate("google", "org.apache.gravitino.shaded.google")- relocate("org.apache.hc", "org.apache.gravitino.shaded.org.apache.hc")- relocate("com.github.benmanes.caffeine", "org.apache.gravitino.shaded.com.github.benmanes.caffeine")-}--publishing {- publications {- withType<MavenPublication>().configureEach {- artifactId = baseName- }- }-}--tasks.jar {- dependsOn(tasks.named("shadowJar"))- archiveClassifier.set("empty")-}diff --git a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/SparkTableChangeConverter34.java b/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/SparkTableChangeConverter34.javadeleted file mode 100644index 2aa8b1a807..0000000000--- a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/SparkTableChangeConverter34.java+++ /dev/null@@ -1,41 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector;--import org.apache.gravitino.rel.expressions.literals.Literals;-import org.apache.spark.sql.connector.catalog.TableChange;--public class SparkTableChangeConverter34 extends SparkTableChangeConverter {- public SparkTableChangeConverter34(SparkTypeConverter sparkTypeConverter) {- super(sparkTypeConverter);- }-- @Override- public org.apache.gravitino.rel.TableChange toGravitinoTableChange(TableChange change) {- if (change instanceof TableChange.UpdateColumnDefaultValue) {- TableChange.UpdateColumnDefaultValue updateColumnDefaultValue =- (TableChange.UpdateColumnDefaultValue) change;- return org.apache.gravitino.rel.TableChange.updateColumnDefaultValue(- updateColumnDefaultValue.fieldNames(),- Literals.stringLiteral(updateColumnDefaultValue.newDefaultValue()));- } else {- return super.toGravitinoTableChange(change);- }- }-}diff --git a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/SparkTypeConverter34.java b/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/SparkTypeConverter34.javadeleted file mode 100644index 62d443713f..0000000000--- a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/SparkTypeConverter34.java+++ /dev/null@@ -1,47 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector;--import org.apache.gravitino.rel.types.Type;-import org.apache.gravitino.rel.types.Types;-import org.apache.spark.sql.types.DataType;-import org.apache.spark.sql.types.DataTypes;-import org.apache.spark.sql.types.TimestampNTZType;--public class SparkTypeConverter34 extends SparkTypeConverter {-- @Override- public Type toGravitinoType(DataType sparkType) {- if (sparkType instanceof TimestampNTZType) {- return Types.TimestampType.withoutTimeZone();- } else {- return super.toGravitinoType(sparkType);- }- }-- @Override- public DataType toSparkType(Type gravitinoType) {- if (gravitinoType instanceof Types.TimestampType- && !((Types.TimestampType) gravitinoType).hasTimeZone()) {- return DataTypes.TimestampNTZType;- } else {- return super.toSparkType(gravitinoType);- }- }-}diff --git a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/glue/GravitinoGlueCatalogSpark34.java b/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/glue/GravitinoGlueCatalogSpark34.javadeleted file mode 100644index 3ca04141be..0000000000--- a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/glue/GravitinoGlueCatalogSpark34.java+++ /dev/null@@ -1,38 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.glue;--import org.apache.gravitino.spark.connector.SparkTableChangeConverter;-import org.apache.gravitino.spark.connector.SparkTableChangeConverter34;-import org.apache.gravitino.spark.connector.SparkTypeConverter;-import org.apache.gravitino.spark.connector.hive.SparkHiveTypeConverter34;--/** Spark 3.4 specific Gravitino Glue catalog implementation. */-public class GravitinoGlueCatalogSpark34 extends GravitinoGlueCatalog {- @Override- protected SparkTypeConverter getSparkTypeConverter() {- return new SparkHiveTypeConverter34();- }-- @Override- protected SparkTableChangeConverter getSparkTableChangeConverter(- SparkTypeConverter sparkTypeConverter) {- return new SparkTableChangeConverter34(sparkTypeConverter);- }-}diff --git a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/hive/GravitinoHiveCatalogSpark34.java b/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/hive/GravitinoHiveCatalogSpark34.javadeleted file mode 100644index 54e9b87f5f..0000000000--- a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/hive/GravitinoHiveCatalogSpark34.java+++ /dev/null@@ -1,36 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.hive;--import org.apache.gravitino.spark.connector.SparkTableChangeConverter;-import org.apache.gravitino.spark.connector.SparkTableChangeConverter34;-import org.apache.gravitino.spark.connector.SparkTypeConverter;--public class GravitinoHiveCatalogSpark34 extends GravitinoHiveCatalog {- @Override- protected SparkTypeConverter getSparkTypeConverter() {- return new SparkHiveTypeConverter34();- }-- @Override- protected SparkTableChangeConverter getSparkTableChangeConverter(- SparkTypeConverter sparkTypeConverter) {- return new SparkTableChangeConverter34(sparkTypeConverter);- }-}diff --git a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/hive/SparkHiveTypeConverter34.java b/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/hive/SparkHiveTypeConverter34.javadeleted file mode 100644index 6141d6ab37..0000000000--- a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/hive/SparkHiveTypeConverter34.java+++ /dev/null@@ -1,73 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */--package org.apache.gravitino.spark.connector.hive;--import org.apache.gravitino.rel.types.Type;-import org.apache.gravitino.rel.types.Types;-import org.apache.gravitino.spark.connector.SparkTypeConverter34;-import org.apache.spark.sql.types.DataType;-import org.apache.spark.sql.types.DataTypes;-import org.apache.spark.sql.types.TimestampNTZType;-import org.apache.spark.sql.types.TimestampType;--public class SparkHiveTypeConverter34 extends SparkTypeConverter34 {- /**- * Converts Spark timestamp types to Hive-compatible Gravitino types- *- * <p>This implementation enforces consistent timestamp handling across Spark versions:- *- * <ol>- * <li>Converts Spark's {@link TimestampType} (with timezone) to {@link- * Types.TimestampType#withoutTimeZone()}- * <li>Explicitly rejects {@link TimestampNTZType} as it's incompatible with Hive's type system- * </ol>- *- * @param sparkType Spark data type to convert, must not be null- * @return Gravitino type with timezone information stripped when necessary- * @throws UnsupportedOperationException When encountering {@link TimestampNTZType}- * @see <a href="https://github.com/apache/gravitino/issues/7046">Issue #7046</a>- * @see SparkTypeConverter34#toGravitinoType(DataType) Base implementation- */- @Override- public Type toGravitinoType(DataType sparkType) {- if (sparkType instanceof TimestampType) {- return Types.TimestampType.withoutTimeZone();- } else if (sparkType instanceof TimestampNTZType) {- throw new UnsupportedOperationException(- "Hive does not support 'timestamp_ntz' (timestamp without time zone), please use 'timestamp' instead.");- } else {- return super.toGravitinoType(sparkType);- }- }-- /**- * Converts Gravitino types to Spark data types.- *- * <p>Note: All timestamp types convert to Spark's TimestampType.- */- @Override- public DataType toSparkType(Type gravitinoType) {- if (gravitinoType instanceof Types.TimestampType) {- return DataTypes.TimestampType;- } else {- return super.toSparkType(gravitinoType);- }- }-}diff --git a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalogSpark34.java b/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalogSpark34.javadeleted file mode 100644index 6b8b80a43d..0000000000--- a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalogSpark34.java+++ /dev/null@@ -1,37 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.iceberg;--import org.apache.gravitino.spark.connector.SparkTableChangeConverter;-import org.apache.gravitino.spark.connector.SparkTableChangeConverter34;-import org.apache.gravitino.spark.connector.SparkTypeConverter;-import org.apache.gravitino.spark.connector.SparkTypeConverter34;--public class GravitinoIcebergCatalogSpark34 extends GravitinoIcebergCatalog {- @Override- protected SparkTypeConverter getSparkTypeConverter() {- return new SparkTypeConverter34();- }-- @Override- protected SparkTableChangeConverter getSparkTableChangeConverter(- SparkTypeConverter sparkTypeConverter) {- return new SparkTableChangeConverter34(sparkTypeConverter);- }-}diff --git a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/GravitinoJdbcCatalogSpark34.java b/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/GravitinoJdbcCatalogSpark34.javadeleted file mode 100644index e9c091c188..0000000000--- a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/GravitinoJdbcCatalogSpark34.java+++ /dev/null@@ -1,38 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */--package org.apache.gravitino.spark.connector.jdbc;--import org.apache.gravitino.spark.connector.SparkTableChangeConverter;-import org.apache.gravitino.spark.connector.SparkTableChangeConverter34;-import org.apache.gravitino.spark.connector.SparkTypeConverter;--public class GravitinoJdbcCatalogSpark34 extends GravitinoJdbcCatalog {-- @Override- protected SparkTypeConverter getSparkTypeConverter() {- return new SparkJdbcTypeConverter34();- }-- @Override- protected SparkTableChangeConverter getSparkTableChangeConverter(- SparkTypeConverter sparkTypeConverter) {- return new SparkTableChangeConverter34(sparkTypeConverter);- }-}diff --git a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/SparkJdbcTypeConverter34.java b/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/SparkJdbcTypeConverter34.javadeleted file mode 100644index ae9659edcd..0000000000--- a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/SparkJdbcTypeConverter34.java+++ /dev/null@@ -1,45 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,- * either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */--package org.apache.gravitino.spark.connector.jdbc;--import org.apache.gravitino.rel.types.Type;-import org.apache.gravitino.rel.types.Types;-import org.apache.gravitino.spark.connector.SparkTypeConverter34;-import org.apache.spark.sql.types.DataType;-import org.apache.spark.sql.types.DataTypes;--public class SparkJdbcTypeConverter34 extends SparkTypeConverter34 {- @Override- public DataType toSparkType(Type gravitinoType) {- // if spark version lower than 3.4.4, using VarCharType will throw an exception: Unsupported- // type varchar.- if (gravitinoType instanceof Types.VarCharType) {- return DataTypes.StringType;- } else if (gravitinoType instanceof Types.TimestampType- && !((Types.TimestampType) gravitinoType).hasTimeZone()) {- // MySQL datetime (no timezone) must map to TimestampType, not TimestampNTZType, for JDBC- // filter pushdown compatibility. The MySQL JDBC dialect only handles TimestampType literals- // correctly; TimestampNTZType produces invalid SQL syntax errors during filter pushdown.- return DataTypes.TimestampType;- } else {- return super.toSparkType(gravitinoType);- }- }-}diff --git a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/paimon/GravitinoPaimonCatalogSpark34.java b/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/paimon/GravitinoPaimonCatalogSpark34.javadeleted file mode 100644index eb3e877936..0000000000--- a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/paimon/GravitinoPaimonCatalogSpark34.java+++ /dev/null@@ -1,37 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.paimon;--import org.apache.gravitino.spark.connector.SparkTableChangeConverter;-import org.apache.gravitino.spark.connector.SparkTableChangeConverter34;-import org.apache.gravitino.spark.connector.SparkTypeConverter;-import org.apache.gravitino.spark.connector.SparkTypeConverter34;--public class GravitinoPaimonCatalogSpark34 extends GravitinoPaimonCatalog {- @Override- protected SparkTypeConverter getSparkTypeConverter() {- return new SparkTypeConverter34();- }-- @Override- protected SparkTableChangeConverter getSparkTableChangeConverter(- SparkTypeConverter sparkTypeConverter) {- return new SparkTableChangeConverter34(sparkTypeConverter);- }-}diff --git a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/TestSparkTableChangeConverter34.java b/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/TestSparkTableChangeConverter34.javadeleted file mode 100644index 67ea6c7bbd..0000000000--- a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/TestSparkTableChangeConverter34.java+++ /dev/null@@ -1,54 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector;--import org.apache.gravitino.rel.expressions.literals.Literals;-import org.apache.spark.sql.connector.catalog.TableChange;-import org.junit.jupiter.api.Assertions;-import org.junit.jupiter.api.Test;--public class TestSparkTableChangeConverter34 {-- private SparkTableChangeConverter sparkTableChangeConverter =- new SparkTableChangeConverter34(new SparkTypeConverter34());-- @Test- void testUpdateColumnDefaultValue() {- String[] fieldNames = new String[] {"col"};- String defaultValue = "col_default_value";- TableChange.UpdateColumnDefaultValue sparkUpdateColumnDefaultValue =- (TableChange.UpdateColumnDefaultValue)- TableChange.updateColumnDefaultValue(fieldNames, defaultValue);-- org.apache.gravitino.rel.TableChange gravitinoChange =- sparkTableChangeConverter.toGravitinoTableChange(sparkUpdateColumnDefaultValue);-- Assertions.assertTrue(- gravitinoChange instanceof org.apache.gravitino.rel.TableChange.UpdateColumnDefaultValue);- org.apache.gravitino.rel.TableChange.UpdateColumnDefaultValue- gravitinoUpdateColumnDefaultValue =- (org.apache.gravitino.rel.TableChange.UpdateColumnDefaultValue) gravitinoChange;-- Assertions.assertArrayEquals(- sparkUpdateColumnDefaultValue.fieldNames(), gravitinoUpdateColumnDefaultValue.fieldName());- Assertions.assertEquals(- Literals.stringLiteral(defaultValue),- gravitinoUpdateColumnDefaultValue.getNewDefaultValue());- }-}diff --git a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT34.java b/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT34.javadeleted file mode 100644index 26b845b436..0000000000--- a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT34.java+++ /dev/null@@ -1,20 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- * http://www.apache.org/licenses/LICENSE-2.0- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */--package org.apache.gravitino.spark.connector.integration.test.authorization;--public class SparkAuthorizationIT34 extends SparkAuthorizationIT {}diff --git a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/glue/SparkAwsGlueCatalogIT34.java b/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/glue/SparkAwsGlueCatalogIT34.javadeleted file mode 100644index c6a18f4827..0000000000--- a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/glue/SparkAwsGlueCatalogIT34.java+++ /dev/null@@ -1,37 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.integration.test.glue;--import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;--/**- * Integration test for Spark 3.4 Glue catalog connector against a real AWS Glue endpoint.- *- * <p>This test is <b>skipped by default</b> and only runs when {@code AWS_ACCESS_KEY_ID} is set.- * Required environment variables:- *- * <ul>- * <li>{@code AWS_ACCESS_KEY_ID}- * <li>{@code AWS_SECRET_ACCESS_KEY}- * <li>{@code AWS_DEFAULT_REGION}- * <li>{@code AWS_S3_TEST_BUCKET}- * </ul>- */-@EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY_ID", matches = ".+")-public class SparkAwsGlueCatalogIT34 extends SparkGlueCatalogIT {}diff --git a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/paimon/SparkPaimonCatalogFilesystemBackendIT34.java b/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/paimon/SparkPaimonCatalogFilesystemBackendIT34.javadeleted file mode 100644index d230707325..0000000000--- a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/paimon/SparkPaimonCatalogFilesystemBackendIT34.java+++ /dev/null@@ -1,36 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.integration.test.paimon;--import org.apache.gravitino.spark.connector.paimon.GravitinoPaimonCatalogSpark34;-import org.junit.jupiter.api.Assertions;-import org.junit.jupiter.api.Test;--public class SparkPaimonCatalogFilesystemBackendIT34 extends SparkPaimonCatalogFilesystemBackendIT {-- @Test- void testCatalogClassName() {- String catalogClass =- getSparkSession()- .sessionState()- .conf()- .getConfString("spark.sql.catalog." + getCatalogName());- Assertions.assertEquals(GravitinoPaimonCatalogSpark34.class.getName(), catalogClass);- }-}diff --git a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkSQLRegressionTest34.java b/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkSQLRegressionTest34.javadeleted file mode 100644index 5e002d3318..0000000000--- a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/sql/SparkSQLRegressionTest34.java+++ /dev/null@@ -1,21 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.integration.test.sql;--public class SparkSQLRegressionTest34 extends SparkSQLRegressionTest {}diff --git a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/version/TestCatalogNameAdaptor.java b/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/version/TestCatalogNameAdaptor.javadeleted file mode 100644index ad50652ffc..0000000000--- a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/version/TestCatalogNameAdaptor.java+++ /dev/null@@ -1,48 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.version;--import org.apache.gravitino.spark.connector.hive.GravitinoHiveCatalogSpark34;-import org.apache.gravitino.spark.connector.iceberg.GravitinoIcebergCatalogSpark34;-import org.apache.gravitino.spark.connector.jdbc.GravitinoJdbcCatalogSpark34;-import org.apache.gravitino.spark.connector.jdbc.postgresql.GravitinoPostgreSqlCatalogSpark34;-import org.junit.jupiter.api.Assertions;-import org.junit.jupiter.api.Test;--public class TestCatalogNameAdaptor {- @Test- void testSpark34() {- String hiveCatalogName = CatalogNameAdaptor.getCatalogName("hive");- Assertions.assertEquals(GravitinoHiveCatalogSpark34.class.getName(), hiveCatalogName);-- String icebergCatalogName = CatalogNameAdaptor.getCatalogName("lakehouse-iceberg");- Assertions.assertEquals(GravitinoIcebergCatalogSpark34.class.getName(), icebergCatalogName);-- String paimonCatalogName = CatalogNameAdaptor.getCatalogName("lakehouse-paimon");- Assertions.assertEquals(- "org.apache.gravitino.spark.connector.paimon.GravitinoPaimonCatalogSpark34",- paimonCatalogName);-- String pgCatalogName = CatalogNameAdaptor.getCatalogName("jdbc-postgresql");- Assertions.assertEquals(GravitinoPostgreSqlCatalogSpark34.class.getName(), pgCatalogName);-- String jdbcCatalogName = CatalogNameAdaptor.getCatalogName("jdbc");- Assertions.assertEquals(GravitinoJdbcCatalogSpark34.class.getName(), jdbcCatalogName);- }-}diff --git a/spark-connector/v3.4/spark/src/test/resources/log4j2.properties b/spark-connector/v3.4/spark/src/test/resources/log4j2.propertiesdeleted file mode 100644index 4f72cf653a..0000000000--- a/spark-connector/v3.4/spark/src/test/resources/log4j2.properties+++ /dev/null@@ -1,47 +0,0 @@-#-# Licensed to the Apache Software Foundation (ASF) under one-# or more contributor license agreements. See the NOTICE file-# distributed with this work for additional information-# regarding copyright ownership. The ASF licenses this file-# to you under the Apache License, Version 2.0 (the-# "License"); you may not use this file except in compliance-# with the License. You may obtain a copy of the License at-#-# http://www.apache.org/licenses/LICENSE-2.0-#-# Unless required by applicable law or agreed to in writing,-# software distributed under the License is distributed on an-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY-# KIND, either express or implied. See the License for the-# specific language governing permissions and limitations-# under the License.-#--# Set to debug or trace if log4j initialization is failing-status = info--# Name of the configuration-name = ConsoleLogConfig--# Console appender configuration-appender.console.type = Console-appender.console.name = consoleLogger-appender.console.layout.type = PatternLayout-appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p [%t] %c{1}:%L - %m%n--# Log files location-property.logPath = ${sys:gravitino.log.path:-integration-test/build/integration-test.log}--# File appender configuration-appender.file.type = File-appender.file.name = fileLogger-appender.file.fileName = ${logPath}-appender.file.layout.type = PatternLayout-appender.file.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p [%t] %c{1}:%L - %m%n--# Root logger level-rootLogger.level = info--# Root logger referring to console and file appenders-rootLogger.appenderRef.stdout.ref = consoleLogger-rootLogger.appenderRef.file.ref = fileLoggerdiff --git a/spark-connector/v3.5/spark/build.gradle.kts b/spark-connector/v3.5/spark/build.gradle.ktsindex d59088d5bf..04075bc391 100644--- a/spark-connector/v3.5/spark/build.gradle.kts+++ b/spark-connector/v3.5/spark/build.gradle.kts@@ -16,7 +16,7 @@* specific language governing permissions and limitations* under the License.*/-evaluationDependsOn(":spark-connector:spark-common")+import com.diffplug.gradle.spotless.SpotlessExtensionplugins {`maven-publish`@@ -29,8 +29,7 @@ repositories {mavenCentral()}-val glueHiveJarsDir: String? =- project(":spark-connector:spark-common").extra["glueHiveJarsDir"] as String?+val glueHiveJarsDir: String? = project(":spark-connector").extra["glueHiveJarsDir"] as String?val scalaVersion: String = project.properties["scalaVersion"] as? String ?: extra["defaultScalaVersion"].toString()val sparkVersion: String = libs.versions.spark35.get()@@ -42,30 +41,97 @@ val scalaJava8CompatVersion: String = libs.versions.scala.java.compat.get()val scalaCollectionCompatVersion: String = libs.versions.scala.collection.compat.get()val artifactName = "${rootProject.name}-spark-${sparkMajorVersion}_$scalaVersion"+// The connector's shared sources are compiled here rather than consumed as a jar, so that every+// supported Spark version builds them against its own API. `spark35` holds the one thing a Spark 4+// build cannot compile: the Paimon package, which has no paimon-spark-4.x artifact at the Paimon+// version this repository pins.+val sparkCommonDir = project(":spark-connector").projectDir.resolve("spark-common")++sourceSets {+ named("main") {+ java {+ setSrcDirs(+ listOf(+ "$sparkCommonDir/src/main/java",+ "$sparkCommonDir/src/main/spark35",+ "src/main/java"+ )+ )+ }+ resources {+ setSrcDirs(listOf("src/main/resources"))+ }+ }+ named("test") {+ java {+ setSrcDirs(+ listOf(+ "$sparkCommonDir/src/test/java",+ "src/test/java"+ )+ )+ }+ resources {+ // Only this module's test resources. spark-common's test resources were never packaged+ // either: the golden-file suites read spark-test.conf, test-sqls and data from the source+ // tree via GRAVITINO_ROOT_DIR, and its log4j2.properties would collide with this one.+ setSrcDirs(listOf("src/test/resources"))+ }+ }+}+if (hasProperty("excludePackagesForSparkConnector")) {@Suppress("UNCHECKED_CAST")val configureFunc = properties["excludePackagesForSparkConnector"] as? (Project) -> UnitconfigureFunc?.invoke(project)}+// The source dirs above reach outside this project, and Spotless rejects cross-project targets.+// The shared tree is formatted by the :spark-connector project that owns it, so scope Spotless here+// to this module's own sources. Same approach as the trino-connector version modules.+plugins.withId("com.diffplug.spotless") {+ configure<SpotlessExtension> {+ java {+ target(project.fileTree("src") { include("**/*.java") })+ }+ }+}+dependencies {- implementation(project(":spark-connector:spark-3.4"))- implementation(project(":spark-connector:spark-common"))+ implementation(project(":catalogs:catalog-common")) {+ exclude("org.apache.logging.log4j")+ }+ implementation(libs.guava)+ implementation(libs.caffeine)+compileOnly("org.apache.kyuubi:kyuubi-spark-connector-hive_$scalaVersion:$kyuubiVersion")compileOnly("org.apache.spark:spark-catalyst_$scalaVersion:$sparkVersion") {exclude("com.fasterxml.jackson")}+ compileOnly("org.apache.spark:spark-core_$scalaVersion:$sparkVersion")+ compileOnly("org.apache.spark:spark-sql_$scalaVersion:$sparkVersion")+ compileOnly("org.scala-lang.modules:scala-java8-compat_$scalaVersion:$scalaJava8CompatVersion")compileOnly(project(":clients:client-java-runtime", configuration = "shadow"))compileOnly("org.apache.iceberg:iceberg-spark-runtime-${sparkMajorVersion}_$scalaVersion:$icebergVersion")+ compileOnly(libs.aws.glue)if (scalaVersion == "2.12") {compileOnly("org.apache.paimon:paimon-spark-$sparkMajorVersion:$paimonVersion") {exclude("org.apache.spark")}}+ annotationProcessor(libs.lombok)+ compileOnly(libs.lombok)++ testAnnotationProcessor(libs.lombok)+ testCompileOnly(libs.lombok)+testImplementation(project(":api")) {exclude("org.apache.logging.log4j")}+ testImplementation(project(":catalogs:catalog-glue")) {+ exclude("org.apache.logging.log4j")+ }testImplementation(project(":catalogs:catalog-jdbc-common")) {exclude("org.apache.logging.log4j")}@@ -96,13 +162,11 @@ dependencies {exclude("org.apache.logging.log4j")exclude("org.slf4j")}- testImplementation(project(":spark-connector:spark-common", "testArtifacts")) {- exclude("com.fasterxml.jackson")- exclude("org.apache.logging.log4j")- exclude("org.slf4j")- }testImplementation(libs.awaitility)+ testImplementation(libs.mockito.core)+ testImplementation(libs.mockito.inline)+ testImplementation(libs.nimbus.jose.jwt)// Iceberg's GlueCatalog references several AWS SDK modules at runtime; must be on test classpathtestImplementation(libs.aws.dynamodb)testImplementation(libs.aws.glue)@@ -193,7 +257,7 @@ tasks.test {exclude("**/integration/test/**")} else {if (glueHiveJarsDir != null) {- dependsOn(":spark-connector:spark-common:downloadGlueHiveJars")+ dependsOn(":spark-connector:downloadGlueHiveJars")jvmArgs("-Dglue.hive-jars-dir=$glueHiveJarsDir")}dependsOn(tasks.jar)diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/authorization/GravitinoAuthorizationSparkSessionExtensions.java b/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/authorization/GravitinoAuthorizationSparkSessionExtensions.javasimilarity index 100%rename from spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/authorization/GravitinoAuthorizationSparkSessionExtensions.javarename to spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/authorization/GravitinoAuthorizationSparkSessionExtensions.javadiff --git a/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/glue/GravitinoGlueCatalogSpark35.java b/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/glue/GravitinoGlueCatalogSpark35.javaindex 0203ef9793..3449655e30 100644--- a/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/glue/GravitinoGlueCatalogSpark35.java+++ b/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/glue/GravitinoGlueCatalogSpark35.java@@ -18,17 +18,5 @@*/package org.apache.gravitino.spark.connector.glue;-import java.util.Set;-import org.apache.spark.sql.catalyst.analysis.NoSuchTableException;-import org.apache.spark.sql.connector.catalog.Identifier;-import org.apache.spark.sql.connector.catalog.Table;-import org.apache.spark.sql.connector.catalog.TableWritePrivilege;-/** Spark 3.5 specific Gravitino Glue catalog implementation. */-public class GravitinoGlueCatalogSpark35 extends GravitinoGlueCatalogSpark34 {- @Override- public Table loadTable(Identifier ident, Set<TableWritePrivilege> writePrivileges)- throws NoSuchTableException {- return loadTableForWriting(ident);- }-}+public class GravitinoGlueCatalogSpark35 extends GravitinoGlueCatalog {}diff --git a/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/hive/GravitinoHiveCatalogSpark35.java b/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/hive/GravitinoHiveCatalogSpark35.javaindex 9331c268f9..ea21c5ca38 100644--- a/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/hive/GravitinoHiveCatalogSpark35.java+++ b/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/hive/GravitinoHiveCatalogSpark35.java@@ -18,16 +18,5 @@*/package org.apache.gravitino.spark.connector.hive;-import java.util.Set;-import org.apache.spark.sql.catalyst.analysis.NoSuchTableException;-import org.apache.spark.sql.connector.catalog.Identifier;-import org.apache.spark.sql.connector.catalog.Table;-import org.apache.spark.sql.connector.catalog.TableWritePrivilege;--public class GravitinoHiveCatalogSpark35 extends GravitinoHiveCatalogSpark34 {- @Override- public Table loadTable(Identifier ident, Set<TableWritePrivilege> writePrivileges)- throws NoSuchTableException {- return loadTableForWriting(ident);- }-}+/** Spark 3.5 specific Gravitino Hive catalog implementation. */+public class GravitinoHiveCatalogSpark35 extends GravitinoHiveCatalog {}diff --git a/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalogSpark35.java b/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalogSpark35.javaindex 53484a9bb5..f84ea19037 100644--- a/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalogSpark35.java+++ b/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalogSpark35.java@@ -18,16 +18,45 @@*/package org.apache.gravitino.spark.connector.iceberg;-import java.util.Set;-import org.apache.spark.sql.catalyst.analysis.NoSuchTableException;+import java.lang.reflect.InvocationTargetException;+import org.apache.iceberg.spark.procedures.SparkProcedures;+import org.apache.spark.sql.catalyst.analysis.NoSuchProcedureException;import org.apache.spark.sql.connector.catalog.Identifier;-import org.apache.spark.sql.connector.catalog.Table;-import org.apache.spark.sql.connector.catalog.TableWritePrivilege;+import org.apache.spark.sql.connector.iceberg.catalog.Procedure;+import org.apache.spark.sql.connector.iceberg.catalog.ProcedureCatalog;-public class GravitinoIcebergCatalogSpark35 extends GravitinoIcebergCatalogSpark34 {+/**+ * Spark 3.5 specific Gravitino Iceberg catalog implementation. {@link ProcedureCatalog} is declared+ * here rather than in the shared base because on Spark 3.x it is a class Iceberg ships, returning+ * Iceberg's {@link Procedure}, while Spark 4 ships its own with a different return type.+ */+public class GravitinoIcebergCatalogSpark35 extends GravitinoIcebergCatalog+ implements ProcedureCatalog {++ /**+ * Procedures validate that the catalog registered with Spark's catalogManager is the same one+ * passed to the {@code ProcedureBuilder} that invokes loadProcedure(). Pass this catalog rather+ * than the internal Spark catalog to satisfy that check.+ */@Override- public Table loadTable(Identifier ident, Set<TableWritePrivilege> writePrivileges)- throws NoSuchTableException {- return loadTableForWriting(ident);+ public Procedure loadProcedure(Identifier identifier) throws NoSuchProcedureException {+ String[] namespace = identifier.namespace();+ String name = identifier.name();++ try {+ if (isSystemNamespace(namespace)) {+ SparkProcedures.ProcedureBuilder builder = SparkProcedures.newBuilder(name);+ if (builder != null) {+ return builder.withTableCatalog(this).build();+ }+ }+ } catch (NoSuchMethodException+ | IllegalAccessException+ | InvocationTargetException+ | ClassNotFoundException e) {+ throw new RuntimeException("Failed to load Iceberg Procedure " + identifier, e);+ }++ throw new NoSuchProcedureException(identifier);}}diff --git a/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/GravitinoJdbcCatalogSpark35.java b/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/GravitinoJdbcCatalogSpark35.javaindex 9448664085..25c646b124 100644--- a/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/GravitinoJdbcCatalogSpark35.java+++ b/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/GravitinoJdbcCatalogSpark35.java@@ -19,31 +19,5 @@package org.apache.gravitino.spark.connector.jdbc;-import java.util.Set;-import org.apache.gravitino.spark.connector.SparkTableChangeConverter;-import org.apache.gravitino.spark.connector.SparkTableChangeConverter34;-import org.apache.gravitino.spark.connector.SparkTypeConverter;-import org.apache.spark.sql.catalyst.analysis.NoSuchTableException;-import org.apache.spark.sql.connector.catalog.Identifier;-import org.apache.spark.sql.connector.catalog.Table;-import org.apache.spark.sql.connector.catalog.TableWritePrivilege;--public class GravitinoJdbcCatalogSpark35 extends GravitinoJdbcCatalog {-- @Override- protected SparkTypeConverter getSparkTypeConverter() {- return new SparkJdbcTypeConverter34();- }-- @Override- protected SparkTableChangeConverter getSparkTableChangeConverter(- SparkTypeConverter sparkTypeConverter) {- return new SparkTableChangeConverter34(sparkTypeConverter);- }-- @Override- public Table loadTable(Identifier ident, Set<TableWritePrivilege> writePrivileges)- throws NoSuchTableException {- return loadTableForWriting(ident);- }-}+/** Spark 3.5 specific Gravitino JDBC catalog implementation. */+public class GravitinoJdbcCatalogSpark35 extends GravitinoJdbcCatalog {}diff --git a/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/paimon/GravitinoPaimonCatalogSpark35.java b/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/paimon/GravitinoPaimonCatalogSpark35.javaindex 2bd5daaa12..5f3cd4ce87 100644--- a/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/paimon/GravitinoPaimonCatalogSpark35.java+++ b/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/paimon/GravitinoPaimonCatalogSpark35.java@@ -18,16 +18,5 @@*/package org.apache.gravitino.spark.connector.paimon;-import java.util.Set;-import org.apache.spark.sql.catalyst.analysis.NoSuchTableException;-import org.apache.spark.sql.connector.catalog.Identifier;-import org.apache.spark.sql.connector.catalog.Table;-import org.apache.spark.sql.connector.catalog.TableWritePrivilege;--public class GravitinoPaimonCatalogSpark35 extends GravitinoPaimonCatalogSpark34 {- @Override- public Table loadTable(Identifier ident, Set<TableWritePrivilege> writePrivileges)- throws NoSuchTableException {- return loadTableForWriting(ident);- }-}+/** Spark 3.5 specific Gravitino Paimon catalog implementation. */+public class GravitinoPaimonCatalogSpark35 extends GravitinoPaimonCatalog {}diff --git a/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/plugin/GravitinoSparkPlugin.java b/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/plugin/GravitinoSparkPlugin.javanew file mode 100644index 0000000000..ec19cc6753--- /dev/null+++ b/spark-connector/v3.5/spark/src/main/java/org/apache/gravitino/spark/connector/plugin/GravitinoSparkPlugin.java@@ -0,0 +1,100 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.spark.connector.plugin;++import com.google.common.annotations.VisibleForTesting;+import org.apache.gravitino.spark.connector.authorization.GravitinoAuthorizationSparkSessionExtensions;+import org.apache.gravitino.spark.connector.catalog.SparkCatalogKind;+import org.apache.gravitino.spark.connector.glue.GravitinoGlueCatalogSpark35;+import org.apache.gravitino.spark.connector.hive.GravitinoHiveCatalogSpark35;+import org.apache.gravitino.spark.connector.iceberg.GravitinoIcebergCatalogSpark35;+import org.apache.gravitino.spark.connector.jdbc.GravitinoJdbcCatalogSpark35;+import org.apache.gravitino.spark.connector.jdbc.postgresql.GravitinoPostgreSqlCatalogSpark35;+import org.apache.spark.api.plugin.DriverPlugin;+import org.apache.spark.api.plugin.ExecutorPlugin;+import org.apache.spark.api.plugin.SparkPlugin;+import org.slf4j.Logger;+import org.slf4j.LoggerFactory;++/**+ * The entrypoint for Apache Gravitino Spark connector on Spark 3.5.+ *+ * <p>Every supported Spark version has a class of this name in this package, which is what users+ * name in {@code spark.plugins}. Each one binds the classes its own Spark version needs, as+ * compile-time class references, so a renamed or missing class fails the build rather than the+ * session, and a jar can only bind classes it actually contains.+ */+public class GravitinoSparkPlugin implements SparkPlugin {++ private static final Logger LOG = LoggerFactory.getLogger(GravitinoSparkPlugin.class);++ /**+ * The Paimon catalog is the one binding that cannot be a class reference: the build takes its+ * Paimon dependency only under Scala 2.12 and excludes the Paimon package otherwise, so the class+ * is absent from the 2.13 jar. Resolved by presence below, and checked against the real class by+ * a test in that package, which the same build exclusion drops on 2.13.+ */+ @VisibleForTesting+ public static final String PAIMON_CATALOG =+ "org.apache.gravitino.spark.connector.paimon.GravitinoPaimonCatalogSpark35";++ @Override+ public DriverPlugin driverPlugin() {+ return new GravitinoDriverPlugin(bindings());+ }++ @Override+ public ExecutorPlugin executorPlugin() {+ return null;+ }++ private static SparkBindings bindings() {+ SparkBindings.Builder builder =+ SparkBindings.builder()+ .authorizationExtension(GravitinoAuthorizationSparkSessionExtensions.class)+ .catalog(SparkCatalogKind.HIVE, GravitinoHiveCatalogSpark35.class)+ .catalog(SparkCatalogKind.LAKEHOUSE_ICEBERG, GravitinoIcebergCatalogSpark35.class)+ .catalog(SparkCatalogKind.GLUE, GravitinoGlueCatalogSpark35.class)+ .catalog(SparkCatalogKind.JDBC, GravitinoJdbcCatalogSpark35.class)+ .catalog(SparkCatalogKind.JDBC_POSTGRESQL, GravitinoPostgreSqlCatalogSpark35.class);+ if (isPresent(PAIMON_CATALOG)) {+ builder.catalog(SparkCatalogKind.LAKEHOUSE_PAIMON, PAIMON_CATALOG);+ }+ return builder.build();+ }++ private static boolean isPresent(String className) {+ try {+ Class.forName(className, false, GravitinoSparkPlugin.class.getClassLoader());+ return true;+ } catch (ClassNotFoundException e) {+ // The Scala 2.13 build compiles the Paimon package out, so its jar does not carry the class.+ LOG.debug("No Paimon catalog in this build: {} is absent.", className, e);+ return false;+ } catch (LinkageError e) {+ // initialize=false still links the class, which resolves its Paimon supertypes. The class is+ // in this jar but the Paimon runtime is not on the classpath, which is the documented default+ // for a deployment that does not use Paimon. It is also what an incompatible Paimon version+ // looks like, so record why rather than only that.+ LOG.debug("No Paimon catalog available: {} does not link.", className, e);+ return false;+ }+ }+}diff --git a/spark-connector/v3.5/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT35.java b/spark-connector/v3.5/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT35.javaindex 01efb02e0e..f8974cac65 100644--- a/spark-connector/v3.5/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT35.java+++ b/spark-connector/v3.5/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT35.java@@ -17,25 +17,5 @@package org.apache.gravitino.spark.connector.integration.test.authorization;-import static org.junit.Assert.assertThrows;--import org.apache.gravitino.exceptions.ForbiddenException;--/**- * Spark 3.5+ specific authorization integration tests. Overrides assertion methods for- * functionality that behaves differently in Spark 3.5+, such as the loadTable method with- * TableWritePrivilege support.- */-public class SparkAuthorizationIT35 extends SparkAuthorizationIT {-- /**- * In Spark 3.5+, INSERT should throw ForbiddenException when user doesn't have MODIFY_TABLE- * privilege because Spark 3.5+ supports {@code loadTable(Identifier, Set<TableWritePrivilege>)}.- */- @Override- protected void assertInsertBehaviorWithoutModifyPrivilege(String tableName) {- assertThrows(- ForbiddenException.class,- () -> getSparkSession().sql(String.format("INSERT INTO %s VALUES (1, 'test')", tableName)));- }-}+/** Spark 3.5 authorization integration tests. */+public class SparkAuthorizationIT35 extends SparkAuthorizationIT {}diff --git a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/TestSparkTypeConverter34.java b/spark-connector/v3.5/spark/src/test/java/org/apache/gravitino/spark/connector/paimon/TestPaimonCatalogBinding.javasimilarity index 54%rename from spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/TestSparkTypeConverter34.javarename to spark-connector/v3.5/spark/src/test/java/org/apache/gravitino/spark/connector/paimon/TestPaimonCatalogBinding.javaindex bab8aa6421..81ac170850 100644--- a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/TestSparkTypeConverter34.java+++ b/spark-connector/v3.5/spark/src/test/java/org/apache/gravitino/spark/connector/paimon/TestPaimonCatalogBinding.java@@ -16,26 +16,26 @@* specific language governing permissions and limitations* under the License.*/-package org.apache.gravitino.spark.connector;-import org.apache.gravitino.rel.types.Types.TimestampType;-import org.apache.spark.sql.types.DataTypes;+package org.apache.gravitino.spark.connector.paimon;++import org.apache.gravitino.spark.connector.plugin.GravitinoSparkPlugin;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.api.Test;-import org.junit.jupiter.api.TestInstance;-import org.junit.jupiter.api.TestInstance.Lifecycle;-@TestInstance(Lifecycle.PER_CLASS)-public class TestSparkTypeConverter34 {- private SparkTypeConverter sparkTypeConverter = new SparkTypeConverter34();+/**+ * Tests that the Paimon catalog class the Spark 3.5 plugin binds is the one this module ships. The+ * plugin binds it by name rather than by class reference, because the Scala 2.13 build compiles the+ * Paimon package out, so nothing else would catch a typo or a rename.+ *+ * <p>This test lives in the {@code paimon} package so the build exclusion that drops that package+ * on Scala 2.13 drops this test with it, where the class it names is absent.+ */+public class TestPaimonCatalogBinding {@Test- void testTimestampNTZ() {- Assertions.assertEquals(- TimestampType.withoutTimeZone(),- sparkTypeConverter.toGravitinoType(DataTypes.TimestampNTZType));+ void testThePaimonCatalogClassNamedByThePluginExists() {Assertions.assertEquals(- DataTypes.TimestampNTZType,- sparkTypeConverter.toSparkType(TimestampType.withoutTimeZone()));+ GravitinoPaimonCatalogSpark35.class.getName(), GravitinoSparkPlugin.PAIMON_CATALOG);}}diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/plugin/GravitinoSparkPlugin.java b/spark-connector/v3.5/spark/src/test/java/org/apache/gravitino/spark/connector/plugin/TestGravitinoSparkPlugin.javasimilarity index 62%rename from spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/plugin/GravitinoSparkPlugin.javarename to spark-connector/v3.5/spark/src/test/java/org/apache/gravitino/spark/connector/plugin/TestGravitinoSparkPlugin.javaindex 17d84363d2..e7577f662b 100644--- a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/plugin/GravitinoSparkPlugin.java+++ b/spark-connector/v3.5/spark/src/test/java/org/apache/gravitino/spark/connector/plugin/TestGravitinoSparkPlugin.java@@ -19,20 +19,18 @@package org.apache.gravitino.spark.connector.plugin;-import org.apache.spark.api.plugin.DriverPlugin;-import org.apache.spark.api.plugin.ExecutorPlugin;-import org.apache.spark.api.plugin.SparkPlugin;+import org.junit.jupiter.api.Assertions;+import org.junit.jupiter.api.Test;-/** The entrypoint for Apache Gravitino Spark connector. */-public class GravitinoSparkPlugin implements SparkPlugin {-- @Override- public DriverPlugin driverPlugin() {- return new GravitinoDriverPlugin();- }+/**+ * Tests that this module's bindings are complete. Constructing the driver plugin runs {@code+ * SparkBindings.build()}, whose Preconditions reject a missing binding, so a catalog this module+ * forgot to bind fails here rather than at session startup.+ */+public class TestGravitinoSparkPlugin {- @Override- public ExecutorPlugin executorPlugin() {- return null;+ @Test+ void testTheBindingsThisModuleDeclaresAreComplete() {+ Assertions.assertNotNull(new GravitinoSparkPlugin().driverPlugin());}}diff --git a/spark-connector/v3.5/spark/src/test/java/org/apache/gravitino/spark/connector/version/TestCatalogNameAdaptor.java b/spark-connector/v3.5/spark/src/test/java/org/apache/gravitino/spark/connector/version/TestCatalogNameAdaptor.javadeleted file mode 100644index 28d9337242..0000000000--- a/spark-connector/v3.5/spark/src/test/java/org/apache/gravitino/spark/connector/version/TestCatalogNameAdaptor.java+++ /dev/null@@ -1,48 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package org.apache.gravitino.spark.connector.version;--import org.apache.gravitino.spark.connector.hive.GravitinoHiveCatalogSpark35;-import org.apache.gravitino.spark.connector.iceberg.GravitinoIcebergCatalogSpark35;-import org.apache.gravitino.spark.connector.jdbc.GravitinoJdbcCatalogSpark35;-import org.apache.gravitino.spark.connector.jdbc.postgresql.GravitinoPostgreSqlCatalogSpark35;-import org.junit.jupiter.api.Assertions;-import org.junit.jupiter.api.Test;--public class TestCatalogNameAdaptor {- @Test- void testSpark35() {- String hiveCatalogName = CatalogNameAdaptor.getCatalogName("hive");- Assertions.assertEquals(GravitinoHiveCatalogSpark35.class.getName(), hiveCatalogName);-- String icebergCatalogName = CatalogNameAdaptor.getCatalogName("lakehouse-iceberg");- Assertions.assertEquals(GravitinoIcebergCatalogSpark35.class.getName(), icebergCatalogName);-- String paimonCatalogName = CatalogNameAdaptor.getCatalogName("lakehouse-paimon");- Assertions.assertEquals(- "org.apache.gravitino.spark.connector.paimon.GravitinoPaimonCatalogSpark35",- paimonCatalogName);-- String pgCatalogName = CatalogNameAdaptor.getCatalogName("jdbc-postgresql");- Assertions.assertEquals(GravitinoPostgreSqlCatalogSpark35.class.getName(), pgCatalogName);-- String jdbcCatalogName = CatalogNameAdaptor.getCatalogName("jdbc");- Assertions.assertEquals(GravitinoJdbcCatalogSpark35.class.getName(), jdbcCatalogName);- }-}diff --git a/spark-connector/v3.3/spark-runtime/build.gradle.kts b/spark-connector/v4.0/spark-runtime/build.gradle.ktssimilarity index 78%rename from spark-connector/v3.3/spark-runtime/build.gradle.ktsrename to spark-connector/v4.0/spark-runtime/build.gradle.ktsindex 5c8b1a1c07..74fa1e8ae1 100644--- a/spark-connector/v3.3/spark-runtime/build.gradle.kts+++ b/spark-connector/v4.0/spark-runtime/build.gradle.kts@@ -24,21 +24,17 @@ plugins {alias(libs.plugins.shadow)}-val scalaVersion: String = project.properties["scalaVersion"] as? String ?: extra["defaultScalaVersion"].toString()-val sparkVersion: String = libs.versions.spark33.get()+// Spark 4 is Scala 2.13 only.+val scalaVersion: String = "2.13"+val sparkVersion: String = libs.versions.spark40.get()val sparkMajorVersion: String = sparkVersion.substringBeforeLast(".")+val kyuubiVersion: String = libs.versions.kyuubi4spark.get()val baseName = "${rootProject.name}-spark-connector-runtime-${sparkMajorVersion}_$scalaVersion"dependencies {implementation(project(":clients:client-java-runtime", configuration = "shadow"))- when (sparkMajorVersion) {- "3.3" -> {- val kyuubiVersion: String = libs.versions.kyuubi4spark.get()- implementation(project(":spark-connector:spark-3.3"))- implementation("org.apache.kyuubi:kyuubi-spark-connector-hive_$scalaVersion:$kyuubiVersion")- }- else -> throw IllegalArgumentException("Unsupported Spark version: $sparkMajorVersion")- }+ implementation(project(":spark-connector:spark-4.0"))+ implementation("org.apache.kyuubi:kyuubi-spark-connector-hive_$scalaVersion:$kyuubiVersion")}tasks.withType<ShadowJar>(ShadowJar::class.java) {diff --git a/spark-connector/v3.4/spark/build.gradle.kts b/spark-connector/v4.0/spark/build.gradle.ktssimilarity index 53%rename from spark-connector/v3.4/spark/build.gradle.ktsrename to spark-connector/v4.0/spark/build.gradle.ktsindex d4da6062fc..47ec80bbf6 100644--- a/spark-connector/v3.4/spark/build.gradle.kts+++ b/spark-connector/v4.0/spark/build.gradle.kts@@ -16,7 +16,7 @@* specific language governing permissions and limitations* under the License.*/-evaluationDependsOn(":spark-connector:spark-common")+import com.diffplug.gradle.spotless.SpotlessExtensionplugins {`maven-publish`@@ -29,39 +29,136 @@ repositories {mavenCentral()}-val scalaVersion: String = project.properties["scalaVersion"] as? String ?: extra["defaultScalaVersion"].toString()-val sparkVersion: String = libs.versions.spark34.get()+// Spark 4 is Scala 2.13 only.+val scalaVersion: String = "2.13"+val sparkVersion: String = libs.versions.spark40.get()val sparkMajorVersion: String = sparkVersion.substringBeforeLast(".")-val icebergVersion: String = libs.versions.iceberg4spark34.get()-val paimonVersion: String = libs.versions.paimon.get()+val icebergVersion: String = libs.versions.iceberg4spark40.get()val kyuubiVersion: String = libs.versions.kyuubi4spark.get()-val scalaJava8CompatVersion: String = libs.versions.scala.java.compat.get()val scalaCollectionCompatVersion: String = libs.versions.scala.collection.compat.get()+val jerseyVersion: String = libs.versions.jersey.get()+val javaxWsRsVersion: String = libs.versions.javax.ws.rs.api.get()+// The HK2 line that Jersey 2.x is built against (javax.inject annotations).+val hk2Version: String = "2.6.1"+// jakarta.validation-api 2.x still ships the javax.validation packages; 3.x renames them.+val jakartaValidationVersion: String = "2.0.2"val artifactName = "${rootProject.name}-spark-${sparkMajorVersion}_$scalaVersion"-if (hasProperty("excludePackagesForSparkConnector")) {- @Suppress("UNCHECKED_CAST")- val configureFunc = properties["excludePackagesForSparkConnector"] as? (Project) -> Unit- configureFunc?.invoke(project)+// The connector's shared sources are compiled here rather than consumed as a jar, so that every+// supported Spark version builds them against its own API. Everything a Spark 4 build needs its own+// copy of lives in this module's own src/main/java, so no flavor directory is composed in.+val sparkCommonDir = project(":spark-connector").projectDir.resolve("spark-common")++sourceSets {+ named("main") {+ java {+ setSrcDirs(+ listOf(+ "$sparkCommonDir/src/main/java",+ "src/main/java"+ )+ )+ }+ resources {+ setSrcDirs(listOf("src/main/resources"))+ }+ }+ named("test") {+ java {+ setSrcDirs(+ listOf(+ "$sparkCommonDir/src/test/java",+ "src/test/java"+ )+ )+ }+ resources {+ setSrcDirs(listOf("src/test/resources"))+ }+ }+}++// Paimon publishes no paimon-spark-4.x artifact at the version this repository pins, so the Paimon+// classes stay out of the Spark 4 builds. They live in spark-common/src/main/spark35 and are not on+// this module's source path; the shared tests that exercise them are excluded here. The two shared+// test utilities that mention Paimon reach it by simple class name and provider string, so they need+// no exclusion.+sourceSets {+ named("test") {+ java {+ exclude("org/apache/gravitino/spark/connector/paimon/**")+ exclude("org/apache/gravitino/spark/connector/integration/test/paimon/**")+ }+ }+}++// The source dirs above reach outside this project, and Spotless rejects cross-project targets.+// The shared tree is formatted by the :spark-connector project that owns it, so scope Spotless here+// to this module's own sources.+plugins.withId("com.diffplug.spotless") {+ configure<SpotlessExtension> {+ java {+ target(project.fileTree("src") { include("**/*.java") })+ }+ }+}++// The ITs run an embedded Gravitino server, which serves REST on Jetty 9 (javax.servlet) with+// Jersey 2 (javax.ws.rs) and HK2 2.x (javax.inject). Spark 4 brings the jakarta flavor of these+// transitively via spark-hive, and Gradle's conflict resolution upgrades the server's copies:+// Jersey 2.41 -> 3.0.x (Jetty 9 then rejects the ServletContainer: "is not a javax.servlet.Servlet"),+// HK2 2.6.1 -> 3.0.x (HK2 3 reads jakarta.inject annotations, so Jersey 2's javax.inject-annotated+// RequestContext is no longer seen as a singleton), and jakarta.validation-api 2.0.2 -> 3.0.x+// (the 2.x jar still holds the javax.validation packages Jersey 2 looks up). Pin the test classpath+// back to the javax flavor. Tests only: the Spark 4 connector runtime jar bundles neither Jersey+// nor the Gravitino server.+configurations.testRuntimeClasspath {+ resolutionStrategy {+ force("javax.ws.rs:javax.ws.rs-api:$javaxWsRsVersion")+ force("org.glassfish.jersey.core:jersey-server:$jerseyVersion")+ force("org.glassfish.jersey.core:jersey-common:$jerseyVersion")+ force("org.glassfish.jersey.core:jersey-client:$jerseyVersion")+ force("org.glassfish.jersey.containers:jersey-container-servlet:$jerseyVersion")+ force("org.glassfish.jersey.containers:jersey-container-servlet-core:$jerseyVersion")+ force("org.glassfish.jersey.containers:jersey-container-jetty-http:$jerseyVersion")+ force("org.glassfish.jersey.inject:jersey-hk2:$jerseyVersion")+ force("org.glassfish.hk2:hk2-api:$hk2Version")+ force("org.glassfish.hk2:hk2-locator:$hk2Version")+ force("org.glassfish.hk2:hk2-utils:$hk2Version")+ force("org.glassfish.hk2.external:aopalliance-repackaged:$hk2Version")+ force("org.glassfish.hk2.external:jakarta.inject:$hk2Version")+ force("jakarta.validation:jakarta.validation-api:$jakartaValidationVersion")+ }}dependencies {- implementation(project(":spark-connector:spark-common"))+ implementation(project(":catalogs:catalog-common")) {+ exclude("org.apache.logging.log4j")+ }+ implementation(libs.guava)+ implementation(libs.caffeine)+compileOnly("org.apache.kyuubi:kyuubi-spark-connector-hive_$scalaVersion:$kyuubiVersion")compileOnly("org.apache.spark:spark-catalyst_$scalaVersion:$sparkVersion") {exclude("com.fasterxml.jackson")}+ compileOnly("org.apache.spark:spark-core_$scalaVersion:$sparkVersion")+ compileOnly("org.apache.spark:spark-sql_$scalaVersion:$sparkVersion")compileOnly(project(":clients:client-java-runtime", configuration = "shadow"))compileOnly("org.apache.iceberg:iceberg-spark-runtime-${sparkMajorVersion}_$scalaVersion:$icebergVersion")- if (scalaVersion == "2.12") {- compileOnly("org.apache.paimon:paimon-spark-$sparkMajorVersion:$paimonVersion") {- exclude("org.apache.spark")- }- }+ compileOnly(libs.aws.glue)++ annotationProcessor(libs.lombok)+ compileOnly(libs.lombok)++ testAnnotationProcessor(libs.lombok)+ testCompileOnly(libs.lombok)testImplementation(project(":api")) {exclude("org.apache.logging.log4j")- exclude("org.slf4j")+ }+ testImplementation(project(":catalogs:catalog-glue")) {+ exclude("org.apache.logging.log4j")}testImplementation(project(":catalogs:catalog-jdbc-common")) {exclude("org.apache.logging.log4j")@@ -93,11 +190,14 @@ dependencies {exclude("org.apache.logging.log4j")exclude("org.slf4j")}- testImplementation(project(":spark-connector:spark-common", "testArtifacts")) {- exclude("com.fasterxml.jackson")- }testImplementation(libs.awaitility)+ testImplementation(libs.mockito.core)+ testImplementation(libs.mockito.inline)+ testImplementation(libs.nimbus.jose.jwt)+ // Spark 3.x pulled javax.ws.rs transitively via spark-hive; Spark 4 no longer does, so the+ // embedded MiniGravitino server started by the ITs needs the JAX-RS API added explicitly.+ testImplementation(libs.javax.ws.rs.api)// Iceberg's GlueCatalog references several AWS SDK modules at runtime; must be on test classpathtestImplementation(libs.aws.dynamodb)testImplementation(libs.aws.glue)@@ -117,7 +217,6 @@ dependencies {exclude("org.eclipse.jetty.aggregate", "jetty-all")exclude("org.eclipse.jetty.orbit", "javax.servlet")}-testImplementation(libs.hive2.metastore) {exclude("co.cask.tephra")exclude("com.github.joshelser")@@ -147,17 +246,12 @@ dependencies {testImplementation(libs.postgresql.driver)testImplementation(libs.testcontainers)- // org.apache.iceberg.rest.RESTSerializers#registerAll(ObjectMapper) has different method signature for iceberg-core and iceberg-spark-runtime package, we must make sure iceberg-core is in front to start up MiniGravitino server.+ // iceberg-core must precede iceberg-spark-runtime: RESTSerializers#registerAll has a different+ // signature in each, and the MiniGravitino server needs the iceberg-core one.testImplementation("org.apache.iceberg:iceberg-core:$icebergVersion")testImplementation("org.apache.iceberg:iceberg-spark-runtime-${sparkMajorVersion}_$scalaVersion:$icebergVersion")testImplementation("org.apache.iceberg:iceberg-hive-metastore:$icebergVersion")- if (scalaVersion == "2.12") {- testImplementation("org.apache.paimon:paimon-spark-$sparkMajorVersion:$paimonVersion") {- exclude("org.apache.spark")- }- }testImplementation("org.apache.kyuubi:kyuubi-spark-connector-hive_$scalaVersion:$kyuubiVersion")- // include spark-sql,spark-catalyst,hive-common,hdfs-clienttestImplementation("org.apache.spark:spark-hive_$scalaVersion:$sparkVersion") {// conflict with Gravitino server jerseyexclude("org.glassfish.jersey.core")@@ -175,9 +269,6 @@ dependencies {testRuntimeOnly(libs.junit.jupiter.engine)}-val glueHiveJarsDir: String? =- project(":spark-connector:spark-common").extra["glueHiveJarsDir"] as String?-tasks.test {val skipITs = project.hasProperty("skipITs")val enableSparkSQLITs = project.hasProperty("enableSparkSQLITs")@@ -185,21 +276,22 @@ tasks.test {exclude("**/integration/test/sql/**")}if (skipITs) {- // Exclude integration testsexclude("**/integration/test/**")} else {- if (glueHiveJarsDir != null) {- dependsOn(":spark-connector:spark-common:downloadGlueHiveJars")- jvmArgs("-Dglue.hive-jars-dir=$glueHiveJarsDir")- }dependsOn(tasks.jar)dependsOn(":catalogs:catalog-lakehouse-iceberg:jar")dependsOn(":catalogs:catalog-hive:jar")dependsOn(":iceberg:iceberg-rest-server:jar")dependsOn(":lance:lance-rest-server:jar")- dependsOn(":catalogs:catalog-lakehouse-paimon:jar")dependsOn(":catalogs:catalog-jdbc-mysql:jar")dependsOn(":catalogs:catalog-jdbc-postgresql:jar")++ // Spark 4's web UI serves its REST API with Jersey 3 (jakarta.servlet) on its shaded Jetty,+ // while the embedded Gravitino server needs Jersey 2 (javax.servlet) on Jetty 9 -- the two+ // cannot coexist on one classpath, and the block above pins Jersey to 2.x for the server. The+ // ITs never look at the UI, so turn it off. SparkConf loads defaults from "spark.*" system+ // properties, so this reaches the session without touching the shared SparkEnvIT.+ systemProperty("spark.ui.enabled", "false")}}diff --git a/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/authorization/GravitinoAuthorizationSparkSessionExtensions.java b/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/authorization/GravitinoAuthorizationSparkSessionExtensions.javanew file mode 100644index 0000000000..c466dd8f23--- /dev/null+++ b/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/authorization/GravitinoAuthorizationSparkSessionExtensions.java@@ -0,0 +1,108 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.spark.connector.authorization;++import org.apache.spark.sql.SparkSessionExtensions;+import org.apache.spark.sql.catalyst.FunctionIdentifier;+import org.apache.spark.sql.catalyst.TableIdentifier;+import org.apache.spark.sql.catalyst.expressions.Expression;+import org.apache.spark.sql.catalyst.parser.ParseException;+import org.apache.spark.sql.catalyst.parser.ParserInterface;+import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan;+import org.apache.spark.sql.types.DataType;+import org.apache.spark.sql.types.StructType;+import scala.Function1;+import scala.collection.immutable.Seq;++/**+ * Registers Gravitino authorization checks with a Spark session.+ *+ * <p>This is the Spark 4 copy. Each version module carries one at this name, because Spark 4 added+ * the abstract {@code parseRoutineParam} method to {@code ParserInterface} and a parser can only+ * implement one version's interface. Everything else here matches the Spark 3.5 copy in {@code+ * v3.5/spark}.+ */+public class GravitinoAuthorizationSparkSessionExtensions+ implements Function1<SparkSessionExtensions, Void> {++ @Override+ public Void apply(SparkSessionExtensions extensions) {+ // Post-hoc resolution runs after every relation is resolved but before checkAnalysis, so all+ // denied tables are reported together rather than failing on the first resolution error.+ extensions.injectPostHocResolutionRule(session -> new RequiredPrivilegesCheck());+ extensions.injectParser((session, parser) -> new AuthorizationParser(parser));+ return null;+ }++ private static class AuthorizationParser implements ParserInterface {+ private final ParserInterface delegate;++ private AuthorizationParser(ParserInterface delegate) {+ this.delegate = delegate;+ }++ @Override+ public LogicalPlan parsePlan(String sqlText) throws ParseException {+ AuthorizationTable.clear();+ return delegate.parsePlan(sqlText);+ }++ @Override+ public Expression parseExpression(String sqlText) throws ParseException {+ return delegate.parseExpression(sqlText);+ }++ @Override+ public TableIdentifier parseTableIdentifier(String sqlText) throws ParseException {+ return delegate.parseTableIdentifier(sqlText);+ }++ @Override+ public FunctionIdentifier parseFunctionIdentifier(String sqlText) throws ParseException {+ return delegate.parseFunctionIdentifier(sqlText);+ }++ @Override+ public Seq<String> parseMultipartIdentifier(String sqlText) throws ParseException {+ return delegate.parseMultipartIdentifier(sqlText).toList();+ }++ @Override+ public LogicalPlan parseQuery(String sqlText) throws ParseException {+ AuthorizationTable.clear();+ return delegate.parseQuery(sqlText);+ }++ @Override+ public StructType parseTableSchema(String sqlText) throws ParseException {+ return delegate.parseTableSchema(sqlText);+ }++ @Override+ public DataType parseDataType(String sqlText) throws ParseException {+ return delegate.parseDataType(sqlText);+ }++ @Override+ public StructType parseRoutineParam(String sqlText) throws ParseException {+ return delegate.parseRoutineParam(sqlText);+ }+ }+}diff --git a/spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/glue/GravitinoGlueCatalogSpark33.java b/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/glue/GravitinoGlueCatalogSpark40.javasimilarity index 87%rename from spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/glue/GravitinoGlueCatalogSpark33.javarename to spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/glue/GravitinoGlueCatalogSpark40.javaindex 4a8075682d..93c4ef872b 100644--- a/spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/glue/GravitinoGlueCatalogSpark33.java+++ b/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/glue/GravitinoGlueCatalogSpark40.java@@ -18,5 +18,5 @@*/package org.apache.gravitino.spark.connector.glue;-/** Spark 3.3 specific Gravitino Glue catalog implementation. */-public class GravitinoGlueCatalogSpark33 extends GravitinoGlueCatalog {}+/** Spark 4.0 specific Gravitino Glue catalog implementation. */+public class GravitinoGlueCatalogSpark40 extends GravitinoGlueCatalog {}diff --git a/spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/hive/GravitinoHiveCatalogSpark33.java b/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/hive/GravitinoHiveCatalogSpark40.javasimilarity index 87%rename from spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/hive/GravitinoHiveCatalogSpark33.javarename to spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/hive/GravitinoHiveCatalogSpark40.javaindex 37d2b7d3f6..c958a73056 100644--- a/spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/hive/GravitinoHiveCatalogSpark33.java+++ b/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/hive/GravitinoHiveCatalogSpark40.java@@ -18,4 +18,5 @@*/package org.apache.gravitino.spark.connector.hive;-public class GravitinoHiveCatalogSpark33 extends GravitinoHiveCatalog {}+/** Spark 4.0 specific Gravitino Hive catalog implementation. */+public class GravitinoHiveCatalogSpark40 extends GravitinoHiveCatalog {}diff --git a/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalogSpark40.java b/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalogSpark40.javanew file mode 100644index 0000000000..b5906e03cf--- /dev/null+++ b/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/iceberg/GravitinoIcebergCatalogSpark40.java@@ -0,0 +1,64 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */+package org.apache.gravitino.spark.connector.iceberg;++import java.lang.reflect.InvocationTargetException;+import org.apache.iceberg.spark.procedures.SparkProcedures;+import org.apache.spark.sql.connector.catalog.Identifier;+import org.apache.spark.sql.connector.catalog.ProcedureCatalog;+import org.apache.spark.sql.connector.catalog.procedures.UnboundProcedure;++/**+ * Spark 4.0 specific Gravitino Iceberg catalog implementation. {@link ProcedureCatalog} is declared+ * here rather than in the shared base because Spark 4 moved the procedure types out of Iceberg's+ * package into its own and changed {@code loadProcedure} to return {@link UnboundProcedure}.+ */+public class GravitinoIcebergCatalogSpark40 extends GravitinoIcebergCatalog+ implements ProcedureCatalog {++ /**+ * Procedures validate that the catalog registered with Spark's catalogManager is the same one+ * passed to the {@code ProcedureBuilder} that invokes loadProcedure(). Pass this catalog rather+ * than the internal Spark catalog to satisfy that check.+ */+ @Override+ public UnboundProcedure loadProcedure(Identifier identifier) {+ String[] namespace = identifier.namespace();+ String name = identifier.name();++ try {+ if (isSystemNamespace(namespace)) {+ SparkProcedures.ProcedureBuilder builder = SparkProcedures.newBuilder(name);+ if (builder != null) {+ return builder.withTableCatalog(this).build();+ }+ }+ } catch (NoSuchMethodException+ | IllegalAccessException+ | InvocationTargetException+ | ClassNotFoundException e) {+ throw new RuntimeException("Failed to load Iceberg Procedure " + identifier, e);+ }++ // Spark 4 ships no NoSuchProcedureException: it wraps whatever loadProcedure throws in+ // FAILED_TO_LOAD_ROUTINE unless the exception is already a SparkThrowable. Iceberg's own+ // BaseCatalog throws a plain RuntimeException here for the same reason, so match it.+ throw new RuntimeException("Procedure does not exist: " + identifier);+ }+}diff --git a/spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/GravitinoJdbcCatalogSpark33.java b/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/GravitinoJdbcCatalogSpark40.javasimilarity index 87%rename from spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/GravitinoJdbcCatalogSpark33.javarename to spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/GravitinoJdbcCatalogSpark40.javaindex d322cd82ca..702a71fff5 100644--- a/spark-connector/v3.3/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/GravitinoJdbcCatalogSpark33.java+++ b/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/GravitinoJdbcCatalogSpark40.java@@ -16,7 +16,7 @@* specific language governing permissions and limitations* under the License.*/-package org.apache.gravitino.spark.connector.jdbc;-public class GravitinoJdbcCatalogSpark33 extends GravitinoJdbcCatalog {}+/** Spark 4.0 specific Gravitino JDBC catalog implementation. */+public class GravitinoJdbcCatalogSpark40 extends GravitinoJdbcCatalog {}diff --git a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/postgresql/GravitinoPostgreSqlCatalogSpark34.java b/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/postgresql/GravitinoPostgreSqlCatalogSpark40.javasimilarity index 90%rename from spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/postgresql/GravitinoPostgreSqlCatalogSpark34.javarename to spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/postgresql/GravitinoPostgreSqlCatalogSpark40.javaindex 61c1c32751..89f1fe4c40 100644--- a/spark-connector/v3.4/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/postgresql/GravitinoPostgreSqlCatalogSpark34.java+++ b/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/jdbc/postgresql/GravitinoPostgreSqlCatalogSpark40.java@@ -22,7 +22,8 @@ import org.apache.gravitino.spark.connector.PropertiesConverter;import org.apache.gravitino.spark.connector.jdbc.GravitinoJdbcCatalog;import org.apache.gravitino.spark.connector.jdbc.JdbcPropertiesConverter;-public class GravitinoPostgreSqlCatalogSpark34 extends GravitinoJdbcCatalog {+/** Spark 4.0 specific Gravitino PostgreSQL catalog implementation. */+public class GravitinoPostgreSqlCatalogSpark40 extends GravitinoJdbcCatalog {@Overrideprotected PropertiesConverter getPropertiesConverter() {return JdbcPropertiesConverter.getNoTablePropertiesInstance();diff --git a/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/plugin/GravitinoSparkPlugin.java b/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/plugin/GravitinoSparkPlugin.javanew file mode 100644index 0000000000..6d6c199f53--- /dev/null+++ b/spark-connector/v4.0/spark/src/main/java/org/apache/gravitino/spark/connector/plugin/GravitinoSparkPlugin.java@@ -0,0 +1,66 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.spark.connector.plugin;++import org.apache.gravitino.spark.connector.authorization.GravitinoAuthorizationSparkSessionExtensions;+import org.apache.gravitino.spark.connector.catalog.SparkCatalogKind;+import org.apache.gravitino.spark.connector.glue.GravitinoGlueCatalogSpark40;+import org.apache.gravitino.spark.connector.hive.GravitinoHiveCatalogSpark40;+import org.apache.gravitino.spark.connector.iceberg.GravitinoIcebergCatalogSpark40;+import org.apache.gravitino.spark.connector.jdbc.GravitinoJdbcCatalogSpark40;+import org.apache.gravitino.spark.connector.jdbc.postgresql.GravitinoPostgreSqlCatalogSpark40;+import org.apache.spark.api.plugin.DriverPlugin;+import org.apache.spark.api.plugin.ExecutorPlugin;+import org.apache.spark.api.plugin.SparkPlugin;++/**+ * The entrypoint for Apache Gravitino Spark connector on Spark 4.0.+ *+ * <p>Every supported Spark version has a class of this name in this package, which is what users+ * name in {@code spark.plugins}. Each one binds the classes its own Spark version needs, as+ * compile-time class references, so a renamed or missing class fails the build rather than the+ * session, and a jar can only bind classes it actually contains.+ *+ * <p>No Paimon catalog is bound: Paimon publishes no {@code paimon-spark-4.x} artifact at the+ * Paimon version this repository pins, so the Spark 4 build has no Paimon catalog to name.+ */+public class GravitinoSparkPlugin implements SparkPlugin {++ @Override+ public DriverPlugin driverPlugin() {+ return new GravitinoDriverPlugin(bindings());+ }++ @Override+ public ExecutorPlugin executorPlugin() {+ return null;+ }++ private static SparkBindings bindings() {+ return SparkBindings.builder()+ .authorizationExtension(GravitinoAuthorizationSparkSessionExtensions.class)+ .catalog(SparkCatalogKind.HIVE, GravitinoHiveCatalogSpark40.class)+ .catalog(SparkCatalogKind.LAKEHOUSE_ICEBERG, GravitinoIcebergCatalogSpark40.class)+ .catalog(SparkCatalogKind.GLUE, GravitinoGlueCatalogSpark40.class)+ .catalog(SparkCatalogKind.JDBC, GravitinoJdbcCatalogSpark40.class)+ .catalog(SparkCatalogKind.JDBC_POSTGRESQL, GravitinoPostgreSqlCatalogSpark40.class)+ .build();+ }+}diff --git a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkJwksAuthorizationIT33.java b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT40.javasimilarity index 88%rename from spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkJwksAuthorizationIT33.javarename to spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT40.javaindex 2ec8cdd566..3256fc0a12 100644--- a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkJwksAuthorizationIT33.java+++ b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkAuthorizationIT40.java@@ -18,4 +18,5 @@*/package org.apache.gravitino.spark.connector.integration.test.authorization;-public class SparkJwksAuthorizationIT33 extends SparkJwksAuthorizationIT {}+/** Spark 4.0 authorization integration tests. */+public class SparkAuthorizationIT40 extends SparkAuthorizationIT {}diff --git a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkJwksAuthorizationIT34.java b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkJwksAuthorizationIT40.javasimilarity index 85%rename from spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkJwksAuthorizationIT34.javarename to spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkJwksAuthorizationIT40.javaindex 5c7563d560..050dc87036 100644--- a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkJwksAuthorizationIT34.java+++ b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/authorization/SparkJwksAuthorizationIT40.java@@ -18,4 +18,5 @@*/package org.apache.gravitino.spark.connector.integration.test.authorization;-public class SparkJwksAuthorizationIT34 extends SparkJwksAuthorizationIT {}+/** Spark 4.0 authorization integration tests against a JWKS-backed Gravitino server. */+public class SparkJwksAuthorizationIT40 extends SparkJwksAuthorizationIT {}diff --git a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT34.java b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT40.javasimilarity index 89%rename from spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT34.javarename to spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT40.javaindex 6e2f43cdea..30f0624ae8 100644--- a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT34.java+++ b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT40.java@@ -18,11 +18,11 @@*/package org.apache.gravitino.spark.connector.integration.test.hive;-import org.apache.gravitino.spark.connector.hive.GravitinoHiveCatalogSpark34;+import org.apache.gravitino.spark.connector.hive.GravitinoHiveCatalogSpark40;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.api.Test;-public class SparkHiveCatalogIT34 extends SparkHiveCatalogIT {+public class SparkHiveCatalogIT40 extends SparkHiveCatalogIT {@Testvoid testCatalogClassName() {String catalogClass =@@ -30,6 +30,6 @@ public class SparkHiveCatalogIT34 extends SparkHiveCatalogIT {.sessionState().conf().getConfString("spark.sql.catalog." + getCatalogName());- Assertions.assertEquals(GravitinoHiveCatalogSpark34.class.getName(), catalogClass);+ Assertions.assertEquals(GravitinoHiveCatalogSpark40.class.getName(), catalogClass);}}diff --git a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestRoutingIT33.java b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/IcebergMetadataColumnsSpark40.javasimilarity index 59%rename from spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestRoutingIT33.javarename to spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/IcebergMetadataColumnsSpark40.javaindex 181cf6a0bc..c3f25ed30c 100644--- a/spark-connector/v3.3/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestRoutingIT33.java+++ b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/IcebergMetadataColumnsSpark40.java@@ -16,39 +16,31 @@* specific language governing permissions and limitations* under the License.*/-package org.apache.gravitino.spark.connector.integration.test.iceberg;import org.apache.gravitino.spark.connector.integration.test.util.SparkMetadataColumnInfo;import org.apache.spark.sql.types.DataTypes;import org.apache.spark.sql.types.StructField;-import org.junit.jupiter.api.condition.DisabledIf;/**- * Spark 3.3 integration tests for Iceberg REST routing.+ * The metadata columns Iceberg reports from its Spark 4.0 module, which differ from its 3.5 one.+ *+ * <p>The row-lineage columns ({@code _row_id}, {@code _last_updated_sequence_number}) only show up+ * for tables that support row lineage, meaning format version 3 and above, while the 3.5 module+ * reports them unconditionally; these ITs create format version 2 tables, Iceberg's default. {@code+ * _spec_id} is also nullable here and non-nullable on 3.5.*- * <p>Spark 3.3 pins Iceberg to 1.8.x ({@code iceberg4spark33}); Gravitino's lakehouse Iceberg stack- * is 1.11. {@link DisabledIf} skips embedded mode to avoid classpath conflicts. Deploy-mode tests- * run a 1.8.x client against Gravitino's 1.11 REST server and cover basic catalog CRUD only; they- * do not exercise Iceberg 1.11 REST changes such as {@code file-scan-tasks} scan planning or the- * configurable multi-level namespace separator contract.+ * <p>Every Iceberg IT on this line needs the same answer, and the two backends inherit from+ * different shared bases, so it lives here rather than being overridden twice.*/-@DisabledIf("org.apache.gravitino.integration.test.util.ITUtils#isEmbedded")-public class SparkIcebergCatalogRestRoutingIT33 extends SparkIcebergCatalogRestRoutingIT {- @Override- protected boolean supportsFunction() {- // Spark 3.3 does not support function operations- return false;- }+final class IcebergMetadataColumnsSpark40 {++ private IcebergMetadataColumnsSpark40() {}- /**- * Spark 3.3 uses Iceberg 1.8.x; its {@code SparkTable#metadataColumns()} exposes five columns,- * not the seven row-lineage columns added in Iceberg 1.11.- */- @Override- protected SparkMetadataColumnInfo[] getIcebergMetadataColumns() {+ /** Returns a fresh array each call: the shared ITs mutate entries of it in place. */+ static SparkMetadataColumnInfo[] newMetadataColumns() {return new SparkMetadataColumnInfo[] {- new SparkMetadataColumnInfo("_spec_id", DataTypes.IntegerType, false),+ new SparkMetadataColumnInfo("_spec_id", DataTypes.IntegerType, true),new SparkMetadataColumnInfo("_partition",DataTypes.createStructType(diff --git a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogHiveBackendIT34.java b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogHiveBackendIT40.javasimilarity index 76%rename from spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogHiveBackendIT34.javarename to spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogHiveBackendIT40.javaindex 8a2b217784..19047aca73 100644--- a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogHiveBackendIT34.java+++ b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogHiveBackendIT40.java@@ -18,11 +18,12 @@*/package org.apache.gravitino.spark.connector.integration.test.iceberg;-import org.apache.gravitino.spark.connector.iceberg.GravitinoIcebergCatalogSpark34;+import org.apache.gravitino.spark.connector.iceberg.GravitinoIcebergCatalogSpark40;+import org.apache.gravitino.spark.connector.integration.test.util.SparkMetadataColumnInfo;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.api.Test;-public class SparkIcebergCatalogHiveBackendIT34 extends SparkIcebergCatalogHiveBackendIT {+public class SparkIcebergCatalogHiveBackendIT40 extends SparkIcebergCatalogHiveBackendIT {@Testvoid testCatalogClassName() {@@ -31,6 +32,11 @@ public class SparkIcebergCatalogHiveBackendIT34 extends SparkIcebergCatalogHiveB.sessionState().conf().getConfString("spark.sql.catalog." + getCatalogName());- Assertions.assertEquals(GravitinoIcebergCatalogSpark34.class.getName(), catalogClass);+ Assertions.assertEquals(GravitinoIcebergCatalogSpark40.class.getName(), catalogClass);+ }++ @Override+ protected SparkMetadataColumnInfo[] getIcebergMetadataColumns() {+ return IcebergMetadataColumnsSpark40.newMetadataColumns();}}diff --git a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestBackendIT34.java b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestBackendIT40.javasimilarity index 65%rename from spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestBackendIT34.javarename to spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestBackendIT40.javaindex ecff644384..75593f09e3 100644--- a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestBackendIT34.java+++ b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestBackendIT40.java@@ -16,10 +16,20 @@* specific language governing permissions and limitations* under the License.*/-package org.apache.gravitino.spark.connector.integration.test.iceberg;+import org.apache.gravitino.spark.connector.integration.test.util.SparkMetadataColumnInfo;import org.junit.jupiter.api.condition.DisabledIf;+/**+ * Runs the shared Iceberg suite against the Iceberg REST backend on Spark 4.0. The base is disabled+ * in embedded mode; repeating the condition here matches what the 3.5 subclass does.+ */@DisabledIf("org.apache.gravitino.integration.test.util.ITUtils#isEmbedded")-public class SparkIcebergCatalogRestBackendIT34 extends SparkIcebergCatalogRestBackendIT {}+public class SparkIcebergCatalogRestBackendIT40 extends SparkIcebergCatalogRestBackendIT {++ @Override+ protected SparkMetadataColumnInfo[] getIcebergMetadataColumns() {+ return IcebergMetadataColumnsSpark40.newMetadataColumns();+ }+}diff --git a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestRoutingIT34.java b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestRoutingIT40.javasimilarity index 64%rename from spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestRoutingIT34.javarename to spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestRoutingIT40.javaindex ae23429b09..9443ad554c 100644--- a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestRoutingIT34.java+++ b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/iceberg/SparkIcebergCatalogRestRoutingIT40.java@@ -16,10 +16,21 @@* specific language governing permissions and limitations* under the License.*/-package org.apache.gravitino.spark.connector.integration.test.iceberg;+import org.apache.gravitino.spark.connector.integration.test.util.SparkMetadataColumnInfo;import org.junit.jupiter.api.condition.DisabledIf;+/**+ * Runs the shared Iceberg suite against a Hive-backed catalog routed through the Iceberg REST+ * server on Spark 4.0. The base is disabled in embedded mode; repeating the condition here matches+ * what the 3.5 subclass does.+ */@DisabledIf("org.apache.gravitino.integration.test.util.ITUtils#isEmbedded")-public class SparkIcebergCatalogRestRoutingIT34 extends SparkIcebergCatalogRestRoutingIT {}+public class SparkIcebergCatalogRestRoutingIT40 extends SparkIcebergCatalogRestRoutingIT {++ @Override+ protected SparkMetadataColumnInfo[] getIcebergMetadataColumns() {+ return IcebergMetadataColumnsSpark40.newMetadataColumns();+ }+}diff --git a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcMysqlCatalogIT34.java b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcMysqlCatalogIT40.javasimilarity index 89%rename from spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcMysqlCatalogIT34.javarename to spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcMysqlCatalogIT40.javaindex 9a4038404d..c7376896b3 100644--- a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcMysqlCatalogIT34.java+++ b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcMysqlCatalogIT40.java@@ -18,11 +18,11 @@*/package org.apache.gravitino.spark.connector.integration.test.jdbc;-import org.apache.gravitino.spark.connector.jdbc.GravitinoJdbcCatalogSpark34;+import org.apache.gravitino.spark.connector.jdbc.GravitinoJdbcCatalogSpark40;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.api.Test;-public class SparkJdbcMysqlCatalogIT34 extends SparkJdbcMysqlCatalogIT {+public class SparkJdbcMysqlCatalogIT40 extends SparkJdbcMysqlCatalogIT {@Testvoid testCatalogClassName() {String catalogClass =@@ -30,6 +30,6 @@ public class SparkJdbcMysqlCatalogIT34 extends SparkJdbcMysqlCatalogIT {.sessionState().conf().getConfString("spark.sql.catalog." + getCatalogName());- Assertions.assertEquals(GravitinoJdbcCatalogSpark34.class.getName(), catalogClass);+ Assertions.assertEquals(GravitinoJdbcCatalogSpark40.class.getName(), catalogClass);}}diff --git a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcPostgreSqlCatalogIT34.java b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcPostgreSqlCatalogIT40.javasimilarity index 88%rename from spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcPostgreSqlCatalogIT34.javarename to spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcPostgreSqlCatalogIT40.javaindex f394ae96a4..34fffcc941 100644--- a/spark-connector/v3.4/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcPostgreSqlCatalogIT34.java+++ b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/integration/test/jdbc/SparkJdbcPostgreSqlCatalogIT40.java@@ -18,12 +18,11 @@*/package org.apache.gravitino.spark.connector.integration.test.jdbc;-import org.apache.gravitino.spark.connector.jdbc.postgresql.GravitinoPostgreSqlCatalogSpark34;+import org.apache.gravitino.spark.connector.jdbc.postgresql.GravitinoPostgreSqlCatalogSpark40;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.api.Test;-public class SparkJdbcPostgreSqlCatalogIT34 extends SparkJdbcPostgreSqlCatalogIT {-+public class SparkJdbcPostgreSqlCatalogIT40 extends SparkJdbcPostgreSqlCatalogIT {@Testvoid testCatalogClassName() {String catalogClass =@@ -31,6 +30,6 @@ public class SparkJdbcPostgreSqlCatalogIT34 extends SparkJdbcPostgreSqlCatalogIT.sessionState().conf().getConfString("spark.sql.catalog." + getCatalogName());- Assertions.assertEquals(GravitinoPostgreSqlCatalogSpark34.class.getName(), catalogClass);+ Assertions.assertEquals(GravitinoPostgreSqlCatalogSpark40.class.getName(), catalogClass);}}diff --git a/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/plugin/TestGravitinoSparkPlugin.java b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/plugin/TestGravitinoSparkPlugin.javanew file mode 100644index 0000000000..e7577f662b--- /dev/null+++ b/spark-connector/v4.0/spark/src/test/java/org/apache/gravitino/spark/connector/plugin/TestGravitinoSparkPlugin.java@@ -0,0 +1,36 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.spark.connector.plugin;++import org.junit.jupiter.api.Assertions;+import org.junit.jupiter.api.Test;++/**+ * Tests that this module's bindings are complete. Constructing the driver plugin runs {@code+ * SparkBindings.build()}, whose Preconditions reject a missing binding, so a catalog this module+ * forgot to bind fails here rather than at session startup.+ */+public class TestGravitinoSparkPlugin {++ @Test+ void testTheBindingsThisModuleDeclaresAreComplete() {+ Assertions.assertNotNull(new GravitinoSparkPlugin().driverPlugin());+ }+}diff --git a/spark-connector/v3.3/spark/src/test/resources/log4j2.properties b/spark-connector/v4.0/spark/src/test/resources/log4j2.propertiessimilarity index 100%rename from spark-connector/v3.3/spark/src/test/resources/log4j2.propertiesrename to spark-connector/v4.0/spark/src/test/resources/log4j2.properties