dimas-b commented on code in PR #1991: URL: https://github.com/apache/polaris/pull/1991#discussion_r2180532332
########## plugins/spark/v3.5/spark-bundle/build.gradle.kts: ########## @@ -0,0 +1,69 @@ +/* + * 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 { + id("polaris-client") + id("com.gradleup.shadow") +} + +// get version information +val sparkMajorVersion = "3.5" +val scalaVersion = getAndUseScalaVersionForProject() +val icebergVersion = pluginlibs.versions.iceberg.get() +val spark35Version = pluginlibs.versions.spark35.get() + +val scalaLibraryVersion = + if (scalaVersion == "2.12") { + pluginlibs.versions.scala212.get() + } else { + pluginlibs.versions.scala213.get() + } + +dependencies { implementation(project(":polaris-spark-${sparkMajorVersion}_${scalaVersion}")) } + +tasks.named<ShadowJar>("shadowJar") { + archiveClassifier = null + isZip64 = true + + // pack all the dependencies into an uber jar + configurations = listOf(project.configurations.runtimeClasspath.get()) + + // recursively remove all LICENSE and NOTICE file under META-INF, includes + // directories contains 'license' in the name + exclude("META-INF/**/*LICENSE*") + exclude("META-INF/**/*NOTICE*") + // exclude the top level LICENSE, LICENSE-*.txt and NOTICE + exclude("LICENSE*") + exclude("NOTICE*") + + // add polaris customized LICENSE and NOTICE at top level. Note that the + // customized LICENSE and NOTICE file are called CUSTOM-LICENSE and CUSTOM-NOTICE, + // and renamed to LICENSE and NOTICE after include, this is to avoid the file + // being excluded due to the exclude pattern matching used above. + from("${projectDir}/CUSTOM-LICENSE") { rename { "LICENSE" } } Review Comment: If `CUSTOM` is only to avoid falling under the exclude rules above, how about naming it `BUNDLE-LICENSE` instead? I think that name is clearer. ########## plugins/spark/v3.5/spark-bundle/build.gradle.kts: ########## @@ -0,0 +1,69 @@ +/* + * 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 { + id("polaris-client") + id("com.gradleup.shadow") +} + +// get version information +val sparkMajorVersion = "3.5" +val scalaVersion = getAndUseScalaVersionForProject() +val icebergVersion = pluginlibs.versions.iceberg.get() +val spark35Version = pluginlibs.versions.spark35.get() + +val scalaLibraryVersion = + if (scalaVersion == "2.12") { + pluginlibs.versions.scala212.get() + } else { + pluginlibs.versions.scala213.get() + } + +dependencies { implementation(project(":polaris-spark-${sparkMajorVersion}_${scalaVersion}")) } + +tasks.named<ShadowJar>("shadowJar") { + archiveClassifier = null + isZip64 = true + + // pack all the dependencies into an uber jar + configurations = listOf(project.configurations.runtimeClasspath.get()) + + // recursively remove all LICENSE and NOTICE file under META-INF, includes + // directories contains 'license' in the name + exclude("META-INF/**/*LICENSE*") + exclude("META-INF/**/*NOTICE*") + // exclude the top level LICENSE, LICENSE-*.txt and NOTICE + exclude("LICENSE*") + exclude("NOTICE*") + + // add polaris customized LICENSE and NOTICE at top level. Note that the + // customized LICENSE and NOTICE file are called CUSTOM-LICENSE and CUSTOM-NOTICE, + // and renamed to LICENSE and NOTICE after include, this is to avoid the file + // being excluded due to the exclude pattern matching used above. + from("${projectDir}/CUSTOM-LICENSE") { rename { "LICENSE" } } Review Comment: Alternatively (because the simple `LICENSE` file name feel more appropriate to me), how about the following? 1. Copy `${projectDir}/CUSTOM-LICENSE"` to `build/license/BUNDLE-LICENSE` 2. Include `build/license/BUNDLE-LICENSE` with rename inside the shadow task. ########## plugins/spark/README.md: ########## @@ -66,23 +63,31 @@ bin/spark-shell \ --conf spark.sql.sources.useV1SourceList='' ``` -Assume the path to the built Spark client jar is -`/polaris/plugins/spark/v3.5/spark/build/2.12/libs/polaris-spark-3.5_2.12-0.11.0-beta-incubating-SNAPSHOT-bundle.jar` -and the name of the catalog is `polaris`. The cli command will look like following: +The polaris version can be found in versions.txt in the Polaris root project dir. + +# Build and run with Polaris spark bundle JAR +The polaris-spark-bundle project is used to build the Polaris Spark bundle JAR. The resulting JAR will follow this naming format: +polaris-spark-bundle-<spark_version>_<scala_version>-<polaris_version>.jar +For example: +polaris-spark-bundle-3.5_2.12-1.1.0-incubating-SNAPSHOT.jar + +Run `./gradlew assemble` to build the entire Polaris project without running tests. After the build completes, +the bundle JAR can be found under: plugins/spark/v3.5/spark-bundle/build/<scala_version>/libs/. +To start Spark using the bundle JAR, specify it with the `--jars` option as shown below: ```shell bin/spark-shell \ ---jars /polaris/plugins/spark/v3.5/spark/build/2.12/libs/polaris-spark-3.5_2.12-0.11.0-beta-incubating-SNAPSHOT-bundle.jar \ +--jars <path-to-spark-client-jar> \ --packages org.apache.iceberg:iceberg-aws-bundle:1.9.0,io.delta:delta-spark_2.12:3.3.1 \ --conf spark.sql.extensions=org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions,io.delta.sql.DeltaSparkSessionExtension \ --conf spark.sql.catalog.spark_catalog=org.apache.spark.sql.delta.catalog.DeltaCatalog \ ---conf spark.sql.catalog.polaris.warehouse=<catalog-name> \ ---conf spark.sql.catalog.polaris.header.X-Iceberg-Access-Delegation=vended-credentials \ ---conf spark.sql.catalog.polaris=org.apache.polaris.spark.SparkCatalog \ ---conf spark.sql.catalog.polaris.uri=http://localhost:8181/api/catalog \ ---conf spark.sql.catalog.polaris.credential="root:secret" \ ---conf spark.sql.catalog.polaris.scope='PRINCIPAL_ROLE:ALL' \ ---conf spark.sql.catalog.polaris.token-refresh-enabled=true \ +--conf spark.sql.catalog.<catalog-name>.warehouse=<catalog-name> \ Review Comment: nit: why not use `polaris` as the example catalog name? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@polaris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org