gh-yzou commented on code in PR #1985:
URL: https://github.com/apache/polaris/pull/1985#discussion_r2178694967


##########
integration-tests/src/main/java/org/apache/polaris/service/it/ext/SparkSessionBuilder.java:
##########
@@ -0,0 +1,293 @@
+/*
+ * 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.polaris.service.it.ext;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.polaris.service.it.env.PolarisApiEndpoints;
+import org.apache.spark.sql.SparkSession;
+
+/**
+ * A fluent builder for configuring SparkSession instances with Polaris 
catalogs.
+ *
+ * <p>Example usage:
+ *
+ * <pre>
+ * SparkSession session = SparkSessionBuilder
+ *     .withTestDefaults()
+ *     .addCatalog("catalog1", CatalogType.ICEBERG, endpoints, token)
+ *     .addCatalog("catalog2", CatalogType.ICEBERG, endpoints, token)
+ *     .createSession();
+ * </pre>
+ */
+public class SparkSessionBuilder {
+
+  public enum CatalogType {
+    ICEBERG("org.apache.iceberg.spark.SparkCatalog"),

Review Comment:
   i think we can simply have catalogImplClass, which is a string, so the test 
can choose whatever SparkCatalog they want to sue



##########
integration-tests/src/main/java/org/apache/polaris/service/it/ext/SparkSessionBuilder.java:
##########
@@ -0,0 +1,293 @@
+/*
+ * 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.polaris.service.it.ext;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.polaris.service.it.env.PolarisApiEndpoints;
+import org.apache.spark.sql.SparkSession;
+
+/**
+ * A fluent builder for configuring SparkSession instances with Polaris 
catalogs.
+ *
+ * <p>Example usage:
+ *
+ * <pre>
+ * SparkSession session = SparkSessionBuilder
+ *     .withTestDefaults()
+ *     .addCatalog("catalog1", CatalogType.ICEBERG, endpoints, token)
+ *     .addCatalog("catalog2", CatalogType.ICEBERG, endpoints, token)
+ *     .createSession();
+ * </pre>
+ */
+public class SparkSessionBuilder {
+
+  public enum CatalogType {
+    ICEBERG("org.apache.iceberg.spark.SparkCatalog"),
+    POLARIS("org.apache.polaris.spark.SparkCatalog");
+
+    private final String implementationClass;
+
+    CatalogType(String implementationClass) {
+      this.implementationClass = implementationClass;
+    }
+
+    public String getImplementationClass() {
+      return implementationClass;
+    }
+  }
+
+  public enum ExtensionType {
+    
ICEBERG_ONLY("org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions"),
+    ICEBERG_AND_DELTA(
+        
"org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions,io.delta.sql.DeltaSparkSessionExtension");
+
+    private final String extensionClasses;
+
+    ExtensionType(String extensionClasses) {
+      this.extensionClasses = extensionClasses;
+    }
+
+    public String getExtensionClasses() {
+      return extensionClasses;
+    }
+  }
+
+  private static class ConfigPair {
+    final String key;
+    final String value;
+
+    ConfigPair(String key, String value) {
+      this.key = key;
+      this.value = value;
+    }
+  }
+
+  /** Configuration for a single catalog. */
+  private static class CatalogConfig {
+    final String catalogName;
+    final CatalogType catalogType;
+    final PolarisApiEndpoints endpoints;
+    final String token;
+    final List<ConfigPair> catalogSpecificConfigs;
+
+    CatalogConfig(
+        String catalogName,
+        CatalogType catalogType,
+        PolarisApiEndpoints endpoints,
+        String token,
+        List<ConfigPair> catalogSpecificConfigs) {
+      this.catalogName = catalogName;
+      this.catalogType = catalogType;
+      this.endpoints = endpoints;
+      this.token = token;
+      this.catalogSpecificConfigs =
+          catalogSpecificConfigs != null ? catalogSpecificConfigs : new 
ArrayList<>();
+    }
+  }
+
+  private final SparkSession.Builder builder;
+  private final List<CatalogConfig> catalogs = new ArrayList<>();
+  private final List<ConfigPair> additionalConfigs = new ArrayList<>();
+
+  private ExtensionType extensionType = ExtensionType.ICEBERG_ONLY;
+  private URI warehouseDir;
+  private boolean includeDeltaCatalogConfig = false;
+
+  private SparkSessionBuilder(SparkSession.Builder builder) {
+    this.builder = builder;
+  }
+
+  /**
+   * Create a SparkSessionBuilder with common test defaults: local master and 
disabled UI.
+   *
+   * @return new builder instance with test defaults
+   */
+  public static SparkSessionBuilder withTestDefaults() {
+    return new 
SparkSessionBuilder(SparkSession.builder()).withLocalMaster().withDisabledUI();
+  }
+
+  public SparkSessionBuilder master(String master) {
+    this.builder.master(master);
+    return this;
+  }
+
+  public SparkSessionBuilder appName(String name) {
+    this.builder.appName(name);
+    return this;
+  }
+
+  public SparkSessionBuilder withLocalMaster(int cores) {
+    return master(String.format("local[%d]", cores));
+  }
+
+  public SparkSessionBuilder withLocalMaster() {
+    return withLocalMaster(1);
+  }
+
+  public SparkSessionBuilder withDisabledUI() {
+    return withConfig("spark.ui.showConsoleProgress", "false")

Review Comment:
   Let's remove withDisabledUI and withLocalMaster, seems not useful for 
testing, which could be quite confusing when people are using it also



##########
integration-tests/src/main/java/org/apache/polaris/service/it/ext/SparkSessionBuilder.java:
##########
@@ -0,0 +1,293 @@
+/*
+ * 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.polaris.service.it.ext;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.polaris.service.it.env.PolarisApiEndpoints;
+import org.apache.spark.sql.SparkSession;
+
+/**
+ * A fluent builder for configuring SparkSession instances with Polaris 
catalogs.
+ *
+ * <p>Example usage:
+ *
+ * <pre>
+ * SparkSession session = SparkSessionBuilder
+ *     .withTestDefaults()
+ *     .addCatalog("catalog1", CatalogType.ICEBERG, endpoints, token)
+ *     .addCatalog("catalog2", CatalogType.ICEBERG, endpoints, token)
+ *     .createSession();
+ * </pre>
+ */
+public class SparkSessionBuilder {
+
+  public enum CatalogType {
+    ICEBERG("org.apache.iceberg.spark.SparkCatalog"),
+    POLARIS("org.apache.polaris.spark.SparkCatalog");
+
+    private final String implementationClass;
+
+    CatalogType(String implementationClass) {
+      this.implementationClass = implementationClass;
+    }
+
+    public String getImplementationClass() {
+      return implementationClass;
+    }
+  }
+
+  public enum ExtensionType {
+    
ICEBERG_ONLY("org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions"),
+    ICEBERG_AND_DELTA(
+        
"org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions,io.delta.sql.DeltaSparkSessionExtension");
+
+    private final String extensionClasses;
+
+    ExtensionType(String extensionClasses) {
+      this.extensionClasses = extensionClasses;
+    }
+
+    public String getExtensionClasses() {
+      return extensionClasses;
+    }
+  }
+
+  private static class ConfigPair {
+    final String key;
+    final String value;
+
+    ConfigPair(String key, String value) {
+      this.key = key;
+      this.value = value;
+    }
+  }
+
+  /** Configuration for a single catalog. */
+  private static class CatalogConfig {
+    final String catalogName;
+    final CatalogType catalogType;
+    final PolarisApiEndpoints endpoints;
+    final String token;
+    final List<ConfigPair> catalogSpecificConfigs;
+
+    CatalogConfig(
+        String catalogName,
+        CatalogType catalogType,
+        PolarisApiEndpoints endpoints,
+        String token,
+        List<ConfigPair> catalogSpecificConfigs) {
+      this.catalogName = catalogName;
+      this.catalogType = catalogType;
+      this.endpoints = endpoints;
+      this.token = token;
+      this.catalogSpecificConfigs =
+          catalogSpecificConfigs != null ? catalogSpecificConfigs : new 
ArrayList<>();
+    }
+  }
+
+  private final SparkSession.Builder builder;
+  private final List<CatalogConfig> catalogs = new ArrayList<>();
+  private final List<ConfigPair> additionalConfigs = new ArrayList<>();
+
+  private ExtensionType extensionType = ExtensionType.ICEBERG_ONLY;
+  private URI warehouseDir;
+  private boolean includeDeltaCatalogConfig = false;
+
+  private SparkSessionBuilder(SparkSession.Builder builder) {
+    this.builder = builder;
+  }
+
+  /**
+   * Create a SparkSessionBuilder with common test defaults: local master and 
disabled UI.
+   *
+   * @return new builder instance with test defaults
+   */
+  public static SparkSessionBuilder withTestDefaults() {
+    return new 
SparkSessionBuilder(SparkSession.builder()).withLocalMaster().withDisabledUI();
+  }
+
+  public SparkSessionBuilder master(String master) {
+    this.builder.master(master);
+    return this;
+  }
+
+  public SparkSessionBuilder appName(String name) {
+    this.builder.appName(name);
+    return this;
+  }
+
+  public SparkSessionBuilder withLocalMaster(int cores) {
+    return master(String.format("local[%d]", cores));
+  }
+
+  public SparkSessionBuilder withLocalMaster() {
+    return withLocalMaster(1);
+  }
+
+  public SparkSessionBuilder withDisabledUI() {
+    return withConfig("spark.ui.showConsoleProgress", "false")
+        .withConfig("spark.ui.enabled", "false");
+  }
+
+  public SparkSessionBuilder withWarehouse(URI warehouseDir) {
+    this.warehouseDir = warehouseDir;
+    return this;
+  }
+
+  public SparkSessionBuilder withExtensions(ExtensionType extensionType) {
+    this.extensionType = extensionType;
+    return this;
+  }
+
+  public SparkSessionBuilder withDeltaCatalogConfig() {
+    this.includeDeltaCatalogConfig = true;
+    return this;
+  }
+
+  public SparkSessionBuilder withS3MockContainer() {
+    return withS3FileSystem("foo", "bar");
+  }
+
+  public SparkSessionBuilder withS3FileSystem(String accessKey, String 
secretKey) {

Review Comment:
   i think we can also take the s3 region as an input to set the following 
configuration
   ```
   .config(String.format("spark.sql.catalog.%s.s3.region", catalogName), 
"us-west-2");
   ```



##########
plugins/spark/v3.5/integration/src/intTest/java/org/apache/polaris/spark/quarkus/it/SparkCatalogIcebergIT.java:
##########
@@ -19,33 +19,19 @@
 package org.apache.polaris.spark.quarkus.it;
 
 import io.quarkus.test.junit.QuarkusIntegrationTest;
+import org.apache.polaris.service.it.ext.SparkSessionBuilder;
 import org.apache.spark.sql.SparkSession;
 
 @QuarkusIntegrationTest
 public class SparkCatalogIcebergIT extends SparkCatalogBaseIT {
   /** Initialize the spark catalog to use the iceberg spark catalog. */
   @Override
-  protected SparkSession.Builder withCatalog(SparkSession.Builder builder, 
String catalogName) {
-    return builder
-        .config(
-            "spark.sql.extensions",
-            
"org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions")
-        .config(
-            String.format("spark.sql.catalog.%s", catalogName),
-            "org.apache.iceberg.spark.SparkCatalog")
-        .config("spark.sql.warehouse.dir", warehouseDir.toString())
-        .config(String.format("spark.sql.catalog.%s.type", catalogName), 
"rest")
-        .config(
-            String.format("spark.sql.catalog.%s.uri", catalogName),
-            endpoints.catalogApiEndpoint().toString())
-        .config(String.format("spark.sql.catalog.%s.warehouse", catalogName), 
catalogName)
-        .config(String.format("spark.sql.catalog.%s.scope", catalogName), 
"PRINCIPAL_ROLE:ALL")
-        .config(
-            String.format("spark.sql.catalog.%s.header.realm", catalogName), 
endpoints.realmId())
-        .config(String.format("spark.sql.catalog.%s.token", catalogName), 
sparkToken)
-        .config(String.format("spark.sql.catalog.%s.s3.access-key-id", 
catalogName), "fakekey")
-        .config(
-            String.format("spark.sql.catalog.%s.s3.secret-access-key", 
catalogName), "fakesecret")
-        .config(String.format("spark.sql.catalog.%s.s3.region", catalogName), 
"us-west-2");
+  protected SparkSession buildSparkSession() {
+    return SparkSessionBuilder.withTestDefaults()
+        .withS3MockContainer()
+        .withExtensions(SparkSessionBuilder.ExtensionType.ICEBERG_ONLY)

Review Comment:
   the realmId set seems missing         
   ```
    String.format("spark.sql.catalog.%s.header.realm", catalogName), 
endpoints.realmId())
   ```



##########
integration-tests/src/main/java/org/apache/polaris/service/it/ext/SparkSessionBuilder.java:
##########
@@ -0,0 +1,293 @@
+/*
+ * 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.polaris.service.it.ext;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.polaris.service.it.env.PolarisApiEndpoints;
+import org.apache.spark.sql.SparkSession;
+
+/**
+ * A fluent builder for configuring SparkSession instances with Polaris 
catalogs.
+ *
+ * <p>Example usage:
+ *
+ * <pre>
+ * SparkSession session = SparkSessionBuilder
+ *     .withTestDefaults()
+ *     .addCatalog("catalog1", CatalogType.ICEBERG, endpoints, token)
+ *     .addCatalog("catalog2", CatalogType.ICEBERG, endpoints, token)
+ *     .createSession();

Review Comment:
   might be also useful to have an example about the actual sparkSession build 
result with in the comment also 
   like 
   ```
   .config(
               String.format("spark.sql.catalog.%s", catalogName),
               "org.apache.iceberg.spark.SparkCatalog")
           .config("spark.sql.warehouse.dir", warehouseDir.toString())
           .config(String.format("spark.sql.catalog.%s.type", catalogName), 
"rest")
           .config(
               String.format("spark.sql.catalog.%s.uri", catalogName),
               endpoints.catalogApiEndpoint().toString())
           .config(String.format("spark.sql.catalog.%s.warehouse", 
catalogName), catalogName)
           .config(String.format("spark.sql.catalog.%s.scope", catalogName), 
"PRINCIPAL_ROLE:ALL")
           .config(
               String.format("spark.sql.catalog.%s.header.realm", catalogName), 
endpoints.realmId())
           .config(String.format("spark.sql.catalog.%s.token", catalogName), 
sparkToken)
           .config(String.format("spark.sql.catalog.%s.s3.access-key-id", 
catalogName), "fakekey")
           .config(
               String.format("spark.sql.catalog.%s.s3.secret-access-key", 
catalogName), "fakesecret")
           .config(String.format("spark.sql.catalog.%s.s3.region", 
catalogName), "us-west-2");
   ```



##########
integration-tests/src/main/java/org/apache/polaris/service/it/ext/SparkSessionBuilder.java:
##########
@@ -0,0 +1,293 @@
+/*
+ * 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.polaris.service.it.ext;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.polaris.service.it.env.PolarisApiEndpoints;
+import org.apache.spark.sql.SparkSession;
+
+/**
+ * A fluent builder for configuring SparkSession instances with Polaris 
catalogs.
+ *
+ * <p>Example usage:
+ *
+ * <pre>
+ * SparkSession session = SparkSessionBuilder
+ *     .withTestDefaults()
+ *     .addCatalog("catalog1", CatalogType.ICEBERG, endpoints, token)
+ *     .addCatalog("catalog2", CatalogType.ICEBERG, endpoints, token)
+ *     .createSession();
+ * </pre>
+ */
+public class SparkSessionBuilder {
+
+  public enum CatalogType {
+    ICEBERG("org.apache.iceberg.spark.SparkCatalog"),
+    POLARIS("org.apache.polaris.spark.SparkCatalog");
+
+    private final String implementationClass;
+
+    CatalogType(String implementationClass) {
+      this.implementationClass = implementationClass;
+    }
+
+    public String getImplementationClass() {
+      return implementationClass;
+    }
+  }
+
+  public enum ExtensionType {
+    
ICEBERG_ONLY("org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions"),

Review Comment:
   similarly, let's just take a list of extension class strings, so later when 
we do hudi test, and possible combination, the test can just pass whatever 
extension string they want



##########
integration-tests/src/main/java/org/apache/polaris/service/it/ext/SparkSessionBuilder.java:
##########
@@ -0,0 +1,293 @@
+/*
+ * 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.polaris.service.it.ext;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.polaris.service.it.env.PolarisApiEndpoints;
+import org.apache.spark.sql.SparkSession;
+
+/**
+ * A fluent builder for configuring SparkSession instances with Polaris 
catalogs.
+ *
+ * <p>Example usage:
+ *
+ * <pre>
+ * SparkSession session = SparkSessionBuilder
+ *     .withTestDefaults()
+ *     .addCatalog("catalog1", CatalogType.ICEBERG, endpoints, token)
+ *     .addCatalog("catalog2", CatalogType.ICEBERG, endpoints, token)
+ *     .createSession();
+ * </pre>
+ */
+public class SparkSessionBuilder {
+
+  public enum CatalogType {
+    ICEBERG("org.apache.iceberg.spark.SparkCatalog"),
+    POLARIS("org.apache.polaris.spark.SparkCatalog");
+
+    private final String implementationClass;
+
+    CatalogType(String implementationClass) {
+      this.implementationClass = implementationClass;
+    }
+
+    public String getImplementationClass() {
+      return implementationClass;
+    }
+  }
+
+  public enum ExtensionType {
+    
ICEBERG_ONLY("org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions"),
+    ICEBERG_AND_DELTA(
+        
"org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions,io.delta.sql.DeltaSparkSessionExtension");
+
+    private final String extensionClasses;
+
+    ExtensionType(String extensionClasses) {
+      this.extensionClasses = extensionClasses;
+    }
+
+    public String getExtensionClasses() {
+      return extensionClasses;
+    }
+  }
+
+  private static class ConfigPair {
+    final String key;
+    final String value;
+
+    ConfigPair(String key, String value) {
+      this.key = key;
+      this.value = value;
+    }
+  }
+
+  /** Configuration for a single catalog. */
+  private static class CatalogConfig {
+    final String catalogName;
+    final CatalogType catalogType;
+    final PolarisApiEndpoints endpoints;
+    final String token;
+    final List<ConfigPair> catalogSpecificConfigs;
+
+    CatalogConfig(
+        String catalogName,
+        CatalogType catalogType,
+        PolarisApiEndpoints endpoints,
+        String token,
+        List<ConfigPair> catalogSpecificConfigs) {
+      this.catalogName = catalogName;
+      this.catalogType = catalogType;
+      this.endpoints = endpoints;
+      this.token = token;
+      this.catalogSpecificConfigs =
+          catalogSpecificConfigs != null ? catalogSpecificConfigs : new 
ArrayList<>();
+    }
+  }
+
+  private final SparkSession.Builder builder;
+  private final List<CatalogConfig> catalogs = new ArrayList<>();
+  private final List<ConfigPair> additionalConfigs = new ArrayList<>();
+
+  private ExtensionType extensionType = ExtensionType.ICEBERG_ONLY;
+  private URI warehouseDir;
+  private boolean includeDeltaCatalogConfig = false;
+
+  private SparkSessionBuilder(SparkSession.Builder builder) {
+    this.builder = builder;
+  }
+
+  /**
+   * Create a SparkSessionBuilder with common test defaults: local master and 
disabled UI.
+   *
+   * @return new builder instance with test defaults
+   */
+  public static SparkSessionBuilder withTestDefaults() {
+    return new 
SparkSessionBuilder(SparkSession.builder()).withLocalMaster().withDisabledUI();
+  }
+
+  public SparkSessionBuilder master(String master) {
+    this.builder.master(master);
+    return this;
+  }
+
+  public SparkSessionBuilder appName(String name) {
+    this.builder.appName(name);
+    return this;
+  }
+
+  public SparkSessionBuilder withLocalMaster(int cores) {
+    return master(String.format("local[%d]", cores));
+  }
+
+  public SparkSessionBuilder withLocalMaster() {
+    return withLocalMaster(1);
+  }
+
+  public SparkSessionBuilder withDisabledUI() {
+    return withConfig("spark.ui.showConsoleProgress", "false")
+        .withConfig("spark.ui.enabled", "false");
+  }
+
+  public SparkSessionBuilder withWarehouse(URI warehouseDir) {
+    this.warehouseDir = warehouseDir;
+    return this;
+  }
+
+  public SparkSessionBuilder withExtensions(ExtensionType extensionType) {
+    this.extensionType = extensionType;
+    return this;
+  }
+
+  public SparkSessionBuilder withDeltaCatalogConfig() {
+    this.includeDeltaCatalogConfig = true;

Review Comment:
   actually, instead of withDeltaCatalogConfig, we can probably take a 
sparkSessionCatalogImplClass in general for setting up of spark_catalog



##########
integration-tests/src/main/java/org/apache/polaris/service/it/ext/SparkSessionBuilder.java:
##########
@@ -0,0 +1,293 @@
+/*
+ * 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.polaris.service.it.ext;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.polaris.service.it.env.PolarisApiEndpoints;
+import org.apache.spark.sql.SparkSession;
+
+/**
+ * A fluent builder for configuring SparkSession instances with Polaris 
catalogs.
+ *
+ * <p>Example usage:
+ *
+ * <pre>
+ * SparkSession session = SparkSessionBuilder
+ *     .withTestDefaults()
+ *     .addCatalog("catalog1", CatalogType.ICEBERG, endpoints, token)
+ *     .addCatalog("catalog2", CatalogType.ICEBERG, endpoints, token)
+ *     .createSession();
+ * </pre>
+ */
+public class SparkSessionBuilder {
+
+  public enum CatalogType {
+    ICEBERG("org.apache.iceberg.spark.SparkCatalog"),
+    POLARIS("org.apache.polaris.spark.SparkCatalog");
+
+    private final String implementationClass;
+
+    CatalogType(String implementationClass) {
+      this.implementationClass = implementationClass;
+    }
+
+    public String getImplementationClass() {
+      return implementationClass;
+    }
+  }
+
+  public enum ExtensionType {
+    
ICEBERG_ONLY("org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions"),
+    ICEBERG_AND_DELTA(
+        
"org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions,io.delta.sql.DeltaSparkSessionExtension");
+
+    private final String extensionClasses;
+
+    ExtensionType(String extensionClasses) {
+      this.extensionClasses = extensionClasses;
+    }
+
+    public String getExtensionClasses() {
+      return extensionClasses;
+    }
+  }
+
+  private static class ConfigPair {
+    final String key;
+    final String value;
+
+    ConfigPair(String key, String value) {
+      this.key = key;
+      this.value = value;
+    }
+  }
+
+  /** Configuration for a single catalog. */
+  private static class CatalogConfig {
+    final String catalogName;
+    final CatalogType catalogType;
+    final PolarisApiEndpoints endpoints;
+    final String token;
+    final List<ConfigPair> catalogSpecificConfigs;
+
+    CatalogConfig(
+        String catalogName,
+        CatalogType catalogType,
+        PolarisApiEndpoints endpoints,
+        String token,
+        List<ConfigPair> catalogSpecificConfigs) {
+      this.catalogName = catalogName;
+      this.catalogType = catalogType;
+      this.endpoints = endpoints;
+      this.token = token;
+      this.catalogSpecificConfigs =
+          catalogSpecificConfigs != null ? catalogSpecificConfigs : new 
ArrayList<>();
+    }
+  }
+
+  private final SparkSession.Builder builder;
+  private final List<CatalogConfig> catalogs = new ArrayList<>();
+  private final List<ConfigPair> additionalConfigs = new ArrayList<>();
+
+  private ExtensionType extensionType = ExtensionType.ICEBERG_ONLY;
+  private URI warehouseDir;
+  private boolean includeDeltaCatalogConfig = false;
+
+  private SparkSessionBuilder(SparkSession.Builder builder) {
+    this.builder = builder;
+  }
+
+  /**
+   * Create a SparkSessionBuilder with common test defaults: local master and 
disabled UI.
+   *
+   * @return new builder instance with test defaults
+   */
+  public static SparkSessionBuilder withTestDefaults() {
+    return new 
SparkSessionBuilder(SparkSession.builder()).withLocalMaster().withDisabledUI();
+  }
+
+  public SparkSessionBuilder master(String master) {
+    this.builder.master(master);
+    return this;
+  }
+
+  public SparkSessionBuilder appName(String name) {
+    this.builder.appName(name);
+    return this;
+  }
+
+  public SparkSessionBuilder withLocalMaster(int cores) {
+    return master(String.format("local[%d]", cores));
+  }
+
+  public SparkSessionBuilder withLocalMaster() {
+    return withLocalMaster(1);
+  }
+
+  public SparkSessionBuilder withDisabledUI() {
+    return withConfig("spark.ui.showConsoleProgress", "false")
+        .withConfig("spark.ui.enabled", "false");
+  }
+
+  public SparkSessionBuilder withWarehouse(URI warehouseDir) {
+    this.warehouseDir = warehouseDir;
+    return this;
+  }
+
+  public SparkSessionBuilder withExtensions(ExtensionType extensionType) {
+    this.extensionType = extensionType;
+    return this;
+  }
+
+  public SparkSessionBuilder withDeltaCatalogConfig() {
+    this.includeDeltaCatalogConfig = true;

Review Comment:
   let's remove the delta config, so we don't have to add hudiConfig or other 
format config later which could make this utility unncessary complicated



##########
integration-tests/src/main/java/org/apache/polaris/service/it/ext/SparkSessionBuilder.java:
##########
@@ -0,0 +1,293 @@
+/*
+ * 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.polaris.service.it.ext;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.polaris.service.it.env.PolarisApiEndpoints;
+import org.apache.spark.sql.SparkSession;
+
+/**
+ * A fluent builder for configuring SparkSession instances with Polaris 
catalogs.
+ *
+ * <p>Example usage:
+ *
+ * <pre>
+ * SparkSession session = SparkSessionBuilder
+ *     .withTestDefaults()
+ *     .addCatalog("catalog1", CatalogType.ICEBERG, endpoints, token)
+ *     .addCatalog("catalog2", CatalogType.ICEBERG, endpoints, token)
+ *     .createSession();
+ * </pre>
+ */
+public class SparkSessionBuilder {
+
+  public enum CatalogType {
+    ICEBERG("org.apache.iceberg.spark.SparkCatalog"),
+    POLARIS("org.apache.polaris.spark.SparkCatalog");
+
+    private final String implementationClass;
+
+    CatalogType(String implementationClass) {
+      this.implementationClass = implementationClass;
+    }
+
+    public String getImplementationClass() {
+      return implementationClass;
+    }
+  }
+
+  public enum ExtensionType {
+    
ICEBERG_ONLY("org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions"),
+    ICEBERG_AND_DELTA(
+        
"org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions,io.delta.sql.DeltaSparkSessionExtension");
+
+    private final String extensionClasses;
+
+    ExtensionType(String extensionClasses) {
+      this.extensionClasses = extensionClasses;
+    }
+
+    public String getExtensionClasses() {
+      return extensionClasses;
+    }
+  }
+
+  private static class ConfigPair {
+    final String key;
+    final String value;
+
+    ConfigPair(String key, String value) {
+      this.key = key;
+      this.value = value;
+    }
+  }
+
+  /** Configuration for a single catalog. */
+  private static class CatalogConfig {
+    final String catalogName;
+    final CatalogType catalogType;
+    final PolarisApiEndpoints endpoints;
+    final String token;
+    final List<ConfigPair> catalogSpecificConfigs;
+
+    CatalogConfig(
+        String catalogName,
+        CatalogType catalogType,
+        PolarisApiEndpoints endpoints,
+        String token,
+        List<ConfigPair> catalogSpecificConfigs) {
+      this.catalogName = catalogName;
+      this.catalogType = catalogType;
+      this.endpoints = endpoints;
+      this.token = token;
+      this.catalogSpecificConfigs =
+          catalogSpecificConfigs != null ? catalogSpecificConfigs : new 
ArrayList<>();
+    }
+  }
+
+  private final SparkSession.Builder builder;
+  private final List<CatalogConfig> catalogs = new ArrayList<>();
+  private final List<ConfigPair> additionalConfigs = new ArrayList<>();
+
+  private ExtensionType extensionType = ExtensionType.ICEBERG_ONLY;
+  private URI warehouseDir;
+  private boolean includeDeltaCatalogConfig = false;
+
+  private SparkSessionBuilder(SparkSession.Builder builder) {
+    this.builder = builder;
+  }
+
+  /**
+   * Create a SparkSessionBuilder with common test defaults: local master and 
disabled UI.
+   *
+   * @return new builder instance with test defaults
+   */
+  public static SparkSessionBuilder withTestDefaults() {
+    return new 
SparkSessionBuilder(SparkSession.builder()).withLocalMaster().withDisabledUI();
+  }
+
+  public SparkSessionBuilder master(String master) {
+    this.builder.master(master);
+    return this;
+  }
+
+  public SparkSessionBuilder appName(String name) {
+    this.builder.appName(name);
+    return this;
+  }
+
+  public SparkSessionBuilder withLocalMaster(int cores) {
+    return master(String.format("local[%d]", cores));
+  }
+
+  public SparkSessionBuilder withLocalMaster() {
+    return withLocalMaster(1);
+  }
+
+  public SparkSessionBuilder withDisabledUI() {
+    return withConfig("spark.ui.showConsoleProgress", "false")
+        .withConfig("spark.ui.enabled", "false");
+  }
+
+  public SparkSessionBuilder withWarehouse(URI warehouseDir) {
+    this.warehouseDir = warehouseDir;
+    return this;
+  }
+
+  public SparkSessionBuilder withExtensions(ExtensionType extensionType) {
+    this.extensionType = extensionType;
+    return this;
+  }
+
+  public SparkSessionBuilder withDeltaCatalogConfig() {
+    this.includeDeltaCatalogConfig = true;
+    return this;
+  }
+
+  public SparkSessionBuilder withS3MockContainer() {
+    return withS3FileSystem("foo", "bar");

Review Comment:
   i don't think we need this, just withS3FileSystem seems good enough to me



##########
integration-tests/src/main/java/org/apache/polaris/service/it/ext/SparkSessionBuilder.java:
##########
@@ -0,0 +1,293 @@
+/*
+ * 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.polaris.service.it.ext;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.polaris.service.it.env.PolarisApiEndpoints;
+import org.apache.spark.sql.SparkSession;
+
+/**
+ * A fluent builder for configuring SparkSession instances with Polaris 
catalogs.
+ *
+ * <p>Example usage:
+ *
+ * <pre>
+ * SparkSession session = SparkSessionBuilder
+ *     .withTestDefaults()
+ *     .addCatalog("catalog1", CatalogType.ICEBERG, endpoints, token)
+ *     .addCatalog("catalog2", CatalogType.ICEBERG, endpoints, token)
+ *     .createSession();
+ * </pre>
+ */
+public class SparkSessionBuilder {
+
+  public enum CatalogType {
+    ICEBERG("org.apache.iceberg.spark.SparkCatalog"),
+    POLARIS("org.apache.polaris.spark.SparkCatalog");
+
+    private final String implementationClass;
+
+    CatalogType(String implementationClass) {
+      this.implementationClass = implementationClass;
+    }
+
+    public String getImplementationClass() {
+      return implementationClass;
+    }
+  }
+
+  public enum ExtensionType {
+    
ICEBERG_ONLY("org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions"),
+    ICEBERG_AND_DELTA(
+        
"org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions,io.delta.sql.DeltaSparkSessionExtension");
+
+    private final String extensionClasses;
+
+    ExtensionType(String extensionClasses) {
+      this.extensionClasses = extensionClasses;
+    }
+
+    public String getExtensionClasses() {
+      return extensionClasses;
+    }
+  }
+
+  private static class ConfigPair {
+    final String key;
+    final String value;
+
+    ConfigPair(String key, String value) {
+      this.key = key;
+      this.value = value;
+    }
+  }
+
+  /** Configuration for a single catalog. */
+  private static class CatalogConfig {
+    final String catalogName;
+    final CatalogType catalogType;
+    final PolarisApiEndpoints endpoints;
+    final String token;
+    final List<ConfigPair> catalogSpecificConfigs;
+
+    CatalogConfig(
+        String catalogName,
+        CatalogType catalogType,
+        PolarisApiEndpoints endpoints,
+        String token,
+        List<ConfigPair> catalogSpecificConfigs) {
+      this.catalogName = catalogName;
+      this.catalogType = catalogType;
+      this.endpoints = endpoints;
+      this.token = token;
+      this.catalogSpecificConfigs =
+          catalogSpecificConfigs != null ? catalogSpecificConfigs : new 
ArrayList<>();
+    }
+  }
+
+  private final SparkSession.Builder builder;
+  private final List<CatalogConfig> catalogs = new ArrayList<>();
+  private final List<ConfigPair> additionalConfigs = new ArrayList<>();
+
+  private ExtensionType extensionType = ExtensionType.ICEBERG_ONLY;
+  private URI warehouseDir;
+  private boolean includeDeltaCatalogConfig = false;
+
+  private SparkSessionBuilder(SparkSession.Builder builder) {
+    this.builder = builder;
+  }
+
+  /**
+   * Create a SparkSessionBuilder with common test defaults: local master and 
disabled UI.
+   *
+   * @return new builder instance with test defaults
+   */
+  public static SparkSessionBuilder withTestDefaults() {
+    return new 
SparkSessionBuilder(SparkSession.builder()).withLocalMaster().withDisabledUI();

Review Comment:
   we are always using testDefaults, right? i don't see a case that we need to 
use none localMaster without disableUI, let's just remove this configurability



##########
integration-tests/src/main/java/org/apache/polaris/service/it/ext/SparkSessionBuilder.java:
##########
@@ -0,0 +1,293 @@
+/*
+ * 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.polaris.service.it.ext;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.polaris.service.it.env.PolarisApiEndpoints;
+import org.apache.spark.sql.SparkSession;
+
+/**
+ * A fluent builder for configuring SparkSession instances with Polaris 
catalogs.
+ *
+ * <p>Example usage:
+ *
+ * <pre>
+ * SparkSession session = SparkSessionBuilder
+ *     .withTestDefaults()
+ *     .addCatalog("catalog1", CatalogType.ICEBERG, endpoints, token)
+ *     .addCatalog("catalog2", CatalogType.ICEBERG, endpoints, token)
+ *     .createSession();
+ * </pre>
+ */
+public class SparkSessionBuilder {
+
+  public enum CatalogType {
+    ICEBERG("org.apache.iceberg.spark.SparkCatalog"),
+    POLARIS("org.apache.polaris.spark.SparkCatalog");
+
+    private final String implementationClass;
+
+    CatalogType(String implementationClass) {
+      this.implementationClass = implementationClass;
+    }
+
+    public String getImplementationClass() {
+      return implementationClass;
+    }
+  }
+
+  public enum ExtensionType {
+    
ICEBERG_ONLY("org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions"),
+    ICEBERG_AND_DELTA(
+        
"org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions,io.delta.sql.DeltaSparkSessionExtension");
+
+    private final String extensionClasses;
+
+    ExtensionType(String extensionClasses) {
+      this.extensionClasses = extensionClasses;
+    }
+
+    public String getExtensionClasses() {
+      return extensionClasses;
+    }
+  }
+
+  private static class ConfigPair {
+    final String key;
+    final String value;
+
+    ConfigPair(String key, String value) {
+      this.key = key;
+      this.value = value;
+    }
+  }
+
+  /** Configuration for a single catalog. */
+  private static class CatalogConfig {
+    final String catalogName;
+    final CatalogType catalogType;
+    final PolarisApiEndpoints endpoints;
+    final String token;
+    final List<ConfigPair> catalogSpecificConfigs;
+
+    CatalogConfig(
+        String catalogName,
+        CatalogType catalogType,
+        PolarisApiEndpoints endpoints,
+        String token,
+        List<ConfigPair> catalogSpecificConfigs) {
+      this.catalogName = catalogName;
+      this.catalogType = catalogType;
+      this.endpoints = endpoints;
+      this.token = token;
+      this.catalogSpecificConfigs =
+          catalogSpecificConfigs != null ? catalogSpecificConfigs : new 
ArrayList<>();
+    }
+  }
+
+  private final SparkSession.Builder builder;
+  private final List<CatalogConfig> catalogs = new ArrayList<>();
+  private final List<ConfigPair> additionalConfigs = new ArrayList<>();
+
+  private ExtensionType extensionType = ExtensionType.ICEBERG_ONLY;
+  private URI warehouseDir;
+  private boolean includeDeltaCatalogConfig = false;
+
+  private SparkSessionBuilder(SparkSession.Builder builder) {
+    this.builder = builder;
+  }
+
+  /**
+   * Create a SparkSessionBuilder with common test defaults: local master and 
disabled UI.
+   *
+   * @return new builder instance with test defaults
+   */
+  public static SparkSessionBuilder withTestDefaults() {
+    return new 
SparkSessionBuilder(SparkSession.builder()).withLocalMaster().withDisabledUI();
+  }
+
+  public SparkSessionBuilder master(String master) {
+    this.builder.master(master);
+    return this;
+  }
+
+  public SparkSessionBuilder appName(String name) {
+    this.builder.appName(name);
+    return this;
+  }
+
+  public SparkSessionBuilder withLocalMaster(int cores) {
+    return master(String.format("local[%d]", cores));
+  }
+
+  public SparkSessionBuilder withLocalMaster() {
+    return withLocalMaster(1);
+  }
+
+  public SparkSessionBuilder withDisabledUI() {
+    return withConfig("spark.ui.showConsoleProgress", "false")
+        .withConfig("spark.ui.enabled", "false");
+  }
+
+  public SparkSessionBuilder withWarehouse(URI warehouseDir) {
+    this.warehouseDir = warehouseDir;
+    return this;
+  }
+
+  public SparkSessionBuilder withExtensions(ExtensionType extensionType) {
+    this.extensionType = extensionType;
+    return this;
+  }
+
+  public SparkSessionBuilder withDeltaCatalogConfig() {
+    this.includeDeltaCatalogConfig = true;
+    return this;
+  }
+
+  public SparkSessionBuilder withS3MockContainer() {
+    return withS3FileSystem("foo", "bar");
+  }
+
+  public SparkSessionBuilder withS3FileSystem(String accessKey, String 
secretKey) {
+    return withConfig("spark.hadoop.fs.s3.impl", 
"org.apache.hadoop.fs.s3a.S3AFileSystem")
+        .withConfig(
+            "spark.hadoop.fs.s3.aws.credentials.provider",
+            "org.apache.hadoop.fs.s3.TemporaryAWSCredentialsProvider")
+        .withConfig("spark.hadoop.fs.s3.access.key", accessKey)
+        .withConfig("spark.hadoop.fs.s3.secret.key", secretKey);
+  }
+
+  public SparkSessionBuilder addCatalog(
+      String catalogName, CatalogType catalogType, PolarisApiEndpoints 
endpoints, String token) {
+    this.catalogs.add(
+        new CatalogConfig(catalogName, catalogType, endpoints, token, new 
ArrayList<>()));
+    return this;
+  }
+
+  public SparkSessionBuilder withConfig(String key, String value) {
+    this.additionalConfigs.add(new ConfigPair(key, value));
+    return this;
+  }
+
+  public SparkSession createSession() {
+    return build().getOrCreate();
+  }
+
+  /**
+   * Build the underlying SparkSession.Builder with all configurations 
applied. Use this if you need
+   * to do additional configuration before creating the session.
+   *
+   * @return configured SparkSession.Builder
+   */
+  public SparkSession.Builder build() {
+    SparkSession.Builder configuredBuilder = builder;
+
+    // Apply core configurations
+    configuredBuilder = applyExtensions(configuredBuilder);
+    configuredBuilder = applyDeltaConfig(configuredBuilder);
+    configuredBuilder = applyWarehouseConfig(configuredBuilder);
+
+    // Apply catalog configurations
+    configuredBuilder = applyCatalogConfigurations(configuredBuilder);
+
+    // Apply additional configurations
+    configuredBuilder = applyAdditionalConfigurations(configuredBuilder);
+
+    return configuredBuilder;
+  }
+
+  private SparkSession.Builder applyExtensions(SparkSession.Builder builder) {
+    return builder.config("spark.sql.extensions", 
extensionType.getExtensionClasses());
+  }
+
+  private SparkSession.Builder applyDeltaConfig(SparkSession.Builder builder) {
+    if (includeDeltaCatalogConfig) {
+      builder =
+          builder.config(
+              "spark.sql.catalog.spark_catalog", 
"org.apache.spark.sql.delta.catalog.DeltaCatalog");
+    }
+    return builder;
+  }
+
+  private SparkSession.Builder applyWarehouseConfig(SparkSession.Builder 
builder) {
+    if (warehouseDir != null) {
+      builder = builder.config("spark.sql.warehouse.dir", 
warehouseDir.toString());
+    }
+    return builder;
+  }
+
+  private SparkSession.Builder applyCatalogConfigurations(SparkSession.Builder 
builder) {
+    for (CatalogConfig catalog : catalogs) {
+      builder = applySingleCatalogConfig(builder, catalog);
+    }
+    return builder;
+  }
+
+  private SparkSession.Builder applySingleCatalogConfig(
+      SparkSession.Builder builder, CatalogConfig catalog) {
+    // Basic catalog configuration
+    builder =
+        builder
+            .config(
+                String.format("spark.sql.catalog.%s", catalog.catalogName),
+                catalog.catalogType.getImplementationClass())
+            .config(String.format("spark.sql.catalog.%s.type", 
catalog.catalogName), "rest")
+            .config(
+                String.format("spark.sql.catalog.%s.warehouse", 
catalog.catalogName),
+                catalog.catalogName)
+            .config(
+                String.format("spark.sql.catalog.%s.scope", 
catalog.catalogName),
+                "PRINCIPAL_ROLE:ALL");
+
+    // Add endpoint configuration
+    if (catalog.endpoints != null) {

Review Comment:
   without endpoint configuration, the test probably won't work, let's just add 
a precondition check that requires endpoints to be not null



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to