jackye1995 commented on a change in pull request #3543:
URL: https://github.com/apache/iceberg/pull/3543#discussion_r768176783
##########
File path: core/src/main/java/org/apache/iceberg/CatalogProperties.java
##########
@@ -30,6 +30,21 @@ private CatalogProperties() {
public static final String FILE_IO_IMPL = "io-impl";
public static final String WAREHOUSE_LOCATION = "warehouse";
+ public static final String CACHE_ENABLED = "cache-enabled";
Review comment:
nit: I talked about just removing it, but I am also fine if we just keep
it.
In that case, could you add a javadoc about it?
Also with this change we also need to deprecate
`FlinkCatalogFactory.CACHE_ENABLED`
##########
File path:
spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkCatalogCacheExpiration.java
##########
@@ -0,0 +1,140 @@
+/*
+ * 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.CachingCatalog;
+import org.apache.iceberg.CatalogProperties;
+import org.apache.iceberg.catalog.Catalog;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.spark.SparkCatalog;
+import org.apache.iceberg.spark.SparkSessionCatalog;
+import org.apache.iceberg.spark.SparkTestBaseWithCatalog;
+import org.apache.spark.sql.connector.catalog.TableCatalog;
+import org.assertj.core.api.Assertions;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class TestSparkCatalogCacheExpiration extends SparkTestBaseWithCatalog {
+
+ private static final String sessionCatalogName = "spark_catalog";
+ private static final String sessionCatalogImpl =
SparkSessionCatalog.class.getName();
+ private static final Map<String, String> sessionCatalogConfig =
ImmutableMap.of(
+ "type", "hadoop",
+ "default-namespace", "default",
+ CatalogProperties.CACHE_ENABLED, "true",
+ CatalogProperties.CACHE_EXPIRATION_INTERVAL_MS, "3000"
+ );
+
+ private static String asSqlConfCatalogKeyFor(String catalog, String
configKey) {
+ // configKey is empty when the catalog's class is being defined
+ if (configKey.isEmpty()) {
+ return String.format("spark.sql.catalog.%s", catalog);
+ } else {
+ return String.format("spark.sql.catalog.%s.%s", catalog, configKey);
+ }
+ }
+
+ // Add more catalogs to the spark session, so we only need to start spark
one time for multiple
+ // different catalog configuration tests.
+ @BeforeClass
+ public static void beforeClass() {
+ // Catalog - expiration_disabled: Catalog with caching on and expiration
disabled.
+ ImmutableMap.of(
+ "", "org.apache.iceberg.spark.SparkCatalog",
+ "type", "hive",
+ "cache_enabled", "true",
Review comment:
`cache-enabled`? also can use catalog variable.
Same comment for `cache.expiration-interval-ms`, and also all the config
maps.
##########
File path: core/src/main/java/org/apache/iceberg/CatalogProperties.java
##########
@@ -30,6 +30,21 @@ private CatalogProperties() {
public static final String FILE_IO_IMPL = "io-impl";
public static final String WAREHOUSE_LOCATION = "warehouse";
+ public static final String CACHE_ENABLED = "cache-enabled";
+ public static final boolean CACHE_ENABLED_DEFAULT = true;
+
+ /**
+ * Behavior of specific values of cache.expiration-interval-ms
+ * <ul>
Review comment:
nit: need a newline using `<p>`
##########
File path:
spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkCatalogCacheExpiration.java
##########
@@ -0,0 +1,140 @@
+/*
+ * 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.CachingCatalog;
+import org.apache.iceberg.CatalogProperties;
+import org.apache.iceberg.catalog.Catalog;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.spark.SparkCatalog;
+import org.apache.iceberg.spark.SparkSessionCatalog;
+import org.apache.iceberg.spark.SparkTestBaseWithCatalog;
+import org.apache.spark.sql.connector.catalog.TableCatalog;
+import org.assertj.core.api.Assertions;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class TestSparkCatalogCacheExpiration extends SparkTestBaseWithCatalog {
+
+ private static final String sessionCatalogName = "spark_catalog";
+ private static final String sessionCatalogImpl =
SparkSessionCatalog.class.getName();
+ private static final Map<String, String> sessionCatalogConfig =
ImmutableMap.of(
+ "type", "hadoop",
+ "default-namespace", "default",
+ CatalogProperties.CACHE_ENABLED, "true",
+ CatalogProperties.CACHE_EXPIRATION_INTERVAL_MS, "3000"
+ );
+
+ private static String asSqlConfCatalogKeyFor(String catalog, String
configKey) {
+ // configKey is empty when the catalog's class is being defined
+ if (configKey.isEmpty()) {
+ return String.format("spark.sql.catalog.%s", catalog);
+ } else {
+ return String.format("spark.sql.catalog.%s.%s", catalog, configKey);
+ }
+ }
+
+ // Add more catalogs to the spark session, so we only need to start spark
one time for multiple
+ // different catalog configuration tests.
Review comment:
nit: seems to be 1 space off in indentation
--
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]