kbendick commented on a change in pull request #3543: URL: https://github.com/apache/iceberg/pull/3543#discussion_r749763314
########## File path: spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkCatalogCacheExpiration.java ########## @@ -0,0 +1,103 @@ +/* + * 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.source; + +import java.util.Map; +import org.apache.iceberg.CatalogProperties; +import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; +import org.apache.iceberg.spark.SparkCatalog; +import org.apache.iceberg.spark.SparkCatalogTestBase; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runners.Parameterized; + +public class TestSparkCatalogCacheExpiration extends SparkCatalogTestBase { + + private static final long defaultExpirationIntervalMs = CatalogProperties.TABLE_CACHE_EXPIRATION_INTERVAL_MS_DEFAULT; + private static final String defaultExpirationInterval = String.valueOf(defaultExpirationIntervalMs); + + private final String catalogConfigPrefix; + private final boolean isCacheEnabled; + private final long cacheExpiratonInterval; + private final boolean isCacheExpirationEnabled; + + @Parameterized.Parameters(name = "catalogName = {0}, implementation = {1}, config = {2}") + public static Object[][] parameters() { + return new Object[][] { + { "testcacheexpirationnotenabled", SparkCatalog.class.getName(), + ImmutableMap.of( + "type", "hive", + "default-namespace", "default", + CatalogProperties.TABLE_CACHE_ENABLED, "false", + CatalogProperties.TABLE_CACHE_EXPIRATION_INTERVAL_MS, "0" + ) }, + { "testhadoop", SparkCatalog.class.getName(), + ImmutableMap.of( + "type", "hadoop", + CatalogProperties.TABLE_CACHE_ENABLED, "true", + CatalogProperties.TABLE_CACHE_EXPIRATION_INTERVAL_MS, defaultExpirationInterval + ) } + }; + } + + public TestSparkCatalogCacheExpiration(String catalogName, + String implementation, + Map<String, String> config) { + super(catalogName, implementation, config); + this.catalogConfigPrefix = "spark.sql.catalog." + catalogName + "."; + this.isCacheEnabled = Boolean.parseBoolean( + config.getOrDefault(CatalogProperties.TABLE_CACHE_ENABLED, "true")); + this.cacheExpiratonInterval = Long.parseLong( + config.getOrDefault(CatalogProperties.TABLE_CACHE_EXPIRATION_INTERVAL_MS, defaultExpirationInterval)); + this.isCacheExpirationEnabled = cacheExpiratonInterval > 0; + } + + // TODO - Looking for a better way to test this. Not 100% sure how to access the Iceberg catalog + // from SparkCatalog. Maybe via the `validationCatalog`? + @Test + public void testCachingSparkCatalogRespectsCacheExpirationEnabled() { + + Assert.assertTrue(true); + + // TODO - Come back to these Review comment: I commented this out so I could temporarily commit work and then come back to it. Will go with the ideas mentioned above. -- 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]
