Class SparkSessionBuilder
java.lang.Object
org.apache.polaris.service.it.ext.SparkSessionBuilder
A fluent builder for configuring SparkSession instances with Polaris catalogs.
This builder creates a SparkSession with sensible test defaults and allows easy configuration of multiple Polaris catalogs. The resulting SparkSession will be configured for local execution with S3Mock support for testing.
Example usage:
SparkSession session = SparkSessionBuilder
.buildWithTestDefaults()
.withExtensions("org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions")
.withWarehouse(warehouseUri)
.addCatalog("catalog1", "org.apache.iceberg.spark.SparkCatalog", endpoints, token)
.addCatalog("catalog2", "org.apache.polaris.spark.SparkCatalog", endpoints, token)
.createSession();
The final SparkSession will be configured with:
- Local master execution (local[1])
- Disabled Spark UI for clean test output
- S3A filesystem with mock credentials (foo/bar)
- Multiple Polaris catalogs with REST endpoints
- Iceberg extensions for table format support
- Custom warehouse directory location
Each catalog will be configured as:
spark.sql.catalog.{catalogName} = {catalogType}
spark.sql.catalog.{catalogName}.type = rest
spark.sql.catalog.{catalogName}.uri = {polarisEndpoint}
spark.sql.catalog.{catalogName}.token = {authToken}
spark.sql.catalog.{catalogName}.warehouse = {catalogName}
spark.sql.catalog.{catalogName}.scope = PRINCIPAL_ROLE:ALL
-
Method Summary
Modifier and TypeMethodDescriptionaddCatalog(String catalogName, String catalogImplClass, PolarisApiEndpoints endpoints, String token) static SparkSessionBuilderCreate a SparkSessionBuilder with common test defaultsorg.apache.spark.sql.SparkSessionwithConfig(String key, String value) withExtensions(String extensions) withWarehouse(URI warehouseDir)
-
Method Details
-
buildWithTestDefaults
Create a SparkSessionBuilder with common test defaults- Returns:
- new builder instance with test defaults
-
withWarehouse
-
withExtensions
-
addCatalog
public SparkSessionBuilder addCatalog(String catalogName, String catalogImplClass, PolarisApiEndpoints endpoints, String token) -
withConfig
-
getOrCreate
public org.apache.spark.sql.SparkSession getOrCreate()
-