RussellSpitzer commented on code in PR #6886: URL: https://github.com/apache/iceberg/pull/6886#discussion_r1176953144
########## spark/v3.4/spark/src/test/java/org/apache/iceberg/spark/sql/TestSparkWarehouseLocation.java: ########## @@ -0,0 +1,94 @@ +/* + * 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.iceberg.spark.sql; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Map; +import org.apache.iceberg.Table; +import org.apache.iceberg.catalog.TableIdentifier; +import org.apache.iceberg.spark.Spark3Util; +import org.apache.iceberg.spark.SparkCatalogConfig; +import org.apache.iceberg.spark.SparkCatalogTestBase; +import org.apache.spark.sql.SparkSession; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class TestSparkWarehouseLocation extends SparkCatalogTestBase { + + private String warehouseLocation; + private final String testNameSpace; + private final String testTableName; + private final TableIdentifier testTableIdentifier; + + public TestSparkWarehouseLocation( + String catalogName, String implementation, Map<String, String> config) { + super(catalogName, implementation, config); + testNameSpace = (catalogName.equals("spark_catalog") ? "" : catalogName + ".") + "default1"; + testTableName = testNameSpace + ".table"; + testTableIdentifier = TableIdentifier.of("default1", "table"); + } + + @Before + public void createTestWarehouseLocation() throws Exception { + this.warehouseLocation = "file:" + temp.newFolder(catalogName).getPath(); + } + + @After + public void dropTestTable() { + sql("DROP TABLE IF EXISTS %s", testTableName); + sql("DROP NAMESPACE IF EXISTS %s", testNameSpace); + spark.sessionState().catalogManager().reset(); + SparkSession.clearDefaultSession(); Review Comment: This doesn't actually change any settings. It just changes what is returned by SparkSession but since all the usages in the tests are based on "spark" which is a set val. So what I was suggesting if you wanted to clear things out what you would do is something like tempSession = spark.newSession() ```java /** * Start a new session with isolated SQL configurations, temporary tables, registered * functions are isolated, but sharing the underlying `SparkContext` and cached data. * * @note Other than the `SparkContext`, all shared state is initialized lazily. * This method will force the initialization of the shared state to ensure that parent * and child sessions are set up with the same shared state. If the underlying catalog * implementation is Hive, this will initialize the metastore, which may take some time. * * @since 2.0.0 */ ``` // Change Config of tempSession // You can reset catalogManager here too if you like Basically every time you do this it makes a new sessionState object which means you get a brand new runtimeConfig as well as a brand new catalog manager. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
