Copilot commented on code in PR #15232: URL: https://github.com/apache/iceberg/pull/15232#discussion_r2802431139
########## spark/v4.1/spark/src/test/java/org/apache/iceberg/spark/DummyMetricsServlet.java: ########## @@ -0,0 +1,62 @@ +/* + * 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; + +import com.codahale.metrics.MetricRegistry; +import java.util.Properties; +import org.apache.spark.SparkConf; +import org.apache.spark.metrics.sink.MetricsServlet; +import org.sparkproject.jetty.servlet.ServletContextHandler; + +/** + * A dummy implementation of {@link MetricsServlet} that does not start a server or report metrics. + * This is used in tests to avoid conflicts with Spark's jetty dependencies. + */ +public class DummyMetricsServlet extends MetricsServlet { + + /** + * Constructor required by Spark's reflection-based instantiation. + * + * @param properties Metrics properties + * @param registry Metric registry + */ + public DummyMetricsServlet(Properties properties, MetricRegistry registry) { + super(properties, registry); + } + + @Override + public ServletContextHandler[] getHandlers(SparkConf conf) { + return new ServletContextHandler[] {}; + } Review Comment: Potential compatibility issue with Spark's shaded Jetty. The DummyMetricsServlet returns an array of org.sparkproject.jetty.servlet.ServletContextHandler, which is Spark's shaded (relocated) Jetty 11 package. However, this PR upgrades Iceberg's own Jetty dependencies to version 12.1.5. This could cause issues if Spark's MetricsServlet interface expects a specific Jetty version's ServletContextHandler. Verify that Spark 4.0/4.1 can handle this mismatch, or consider whether the dummy servlet needs to return Spark's specific shaded Jetty types. ########## spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/sql/TestAggregatePushDown.java: ########## @@ -26,58 +26,22 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; -import org.apache.iceberg.CatalogUtil; import org.apache.iceberg.ParameterizedTestExtension; import org.apache.iceberg.TableProperties; -import org.apache.iceberg.catalog.Namespace; -import org.apache.iceberg.exceptions.AlreadyExistsException; -import org.apache.iceberg.hive.HiveCatalog; -import org.apache.iceberg.hive.TestHiveMetastore; -import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; import org.apache.iceberg.relocated.com.google.common.collect.Lists; import org.apache.iceberg.spark.CatalogTestBase; import org.apache.iceberg.spark.SparkReadOptions; -import org.apache.iceberg.spark.TestBase; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; -import org.apache.spark.sql.SparkSession; import org.apache.spark.sql.execution.ExplainMode; import org.apache.spark.sql.functions; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; @ExtendWith(ParameterizedTestExtension.class) public class TestAggregatePushDown extends CatalogTestBase { - @BeforeAll - public static void startMetastoreAndSpark() { - TestBase.metastore = new TestHiveMetastore(); - metastore.start(); - TestBase.hiveConf = metastore.hiveConf(); - - TestBase.spark.close(); - - TestBase.spark = - SparkSession.builder() - .master("local[2]") - .config("spark.sql.iceberg.aggregate_pushdown", "true") - .enableHiveSupport() - .getOrCreate(); - - TestBase.catalog = - (HiveCatalog) - CatalogUtil.loadCatalog( - HiveCatalog.class.getName(), "hive", ImmutableMap.of(), hiveConf); - - try { - catalog.createNamespace(Namespace.of("default")); - } catch (AlreadyExistsException ignored) { - // the default namespace already exists. ignore the create error - } - } - @AfterEach public void removeTables() { sql("DROP TABLE IF EXISTS %s", tableName); Review Comment: Missing aggregate_pushdown configuration. The previous implementation included .config("spark.sql.iceberg.aggregate_pushdown", "true") to enable aggregate pushdown for testing. This configuration has been removed, which means tests are now running with whatever the default behavior is. If aggregate pushdown needs to be explicitly enabled for these tests to work correctly, this configuration should be restored, either in the TestBase.baseConfigs() or as a separate configuration in this test class's setup. ########## core/src/test/java/org/apache/iceberg/rest/TestRESTViewCatalogWithAssumedViewSupport.java: ########## @@ -31,10 +31,10 @@ import org.apache.iceberg.inmemory.InMemoryCatalog; import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; import org.apache.iceberg.rest.responses.ConfigResponse; +import org.eclipse.jetty.ee10.servlet.ServletContextHandler; +import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.gzip.GzipHandler; Review Comment: Inconsistent migration of GzipHandler to CompressionHandler. This file still imports and uses the old GzipHandler class from "org.eclipse.jetty.server.handler.gzip.GzipHandler" which may not be available or may have been moved in Jetty 12.1.5. It should be updated to use CompressionHandler like other files in this PR (RESTCatalogServer.java and TestBaseWithRESTServer.java). ```suggestion ``` ########## aws/src/integration/java/org/apache/iceberg/aws/s3/signer/TestS3RestSigner.java: ########## @@ -37,10 +37,10 @@ import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; import org.apache.iceberg.rest.auth.OAuth2Properties; import org.apache.iceberg.util.ThreadPools; +import org.eclipse.jetty.ee10.servlet.ServletContextHandler; +import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.gzip.GzipHandler; Review Comment: Inconsistent migration of GzipHandler to CompressionHandler. This file still imports and uses the old GzipHandler class from "org.eclipse.jetty.server.handler.gzip.GzipHandler" which may not be available or may have been moved in Jetty 12.1.5. It should be updated to use CompressionHandler like other files in this PR (RESTCatalogServer.java and TestBaseWithRESTServer.java). ```suggestion import org.eclipse.jetty.server.CompressionHandler; ``` ########## spark/v3.4/spark/src/test/java/org/apache/iceberg/spark/sql/TestAggregatePushDown.java: ########## @@ -26,58 +26,22 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; -import org.apache.iceberg.CatalogUtil; import org.apache.iceberg.ParameterizedTestExtension; import org.apache.iceberg.TableProperties; -import org.apache.iceberg.catalog.Namespace; -import org.apache.iceberg.exceptions.AlreadyExistsException; -import org.apache.iceberg.hive.HiveCatalog; -import org.apache.iceberg.hive.TestHiveMetastore; -import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; import org.apache.iceberg.relocated.com.google.common.collect.Lists; import org.apache.iceberg.spark.CatalogTestBase; import org.apache.iceberg.spark.SparkReadOptions; -import org.apache.iceberg.spark.TestBase; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; -import org.apache.spark.sql.SparkSession; import org.apache.spark.sql.execution.ExplainMode; import org.apache.spark.sql.functions; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; @ExtendWith(ParameterizedTestExtension.class) public class TestAggregatePushDown extends CatalogTestBase { - @BeforeAll - public static void startMetastoreAndSpark() { - TestBase.metastore = new TestHiveMetastore(); - metastore.start(); - TestBase.hiveConf = metastore.hiveConf(); - - TestBase.spark.close(); - - TestBase.spark = - SparkSession.builder() - .master("local[2]") - .config("spark.sql.iceberg.aggregate_pushdown", "true") - .enableHiveSupport() - .getOrCreate(); - - TestBase.catalog = - (HiveCatalog) - CatalogUtil.loadCatalog( - HiveCatalog.class.getName(), "hive", ImmutableMap.of(), hiveConf); - - try { - catalog.createNamespace(Namespace.of("default")); - } catch (AlreadyExistsException ignored) { - // the default namespace already exists. ignore the create error - } - } - @AfterEach public void removeTables() { sql("DROP TABLE IF EXISTS %s", tableName); Review Comment: Missing aggregate_pushdown configuration. The previous implementation included .config("spark.sql.iceberg.aggregate_pushdown", "true") to enable aggregate pushdown for testing. This configuration has been removed, which means tests are now running with whatever the default behavior is. If aggregate pushdown needs to be explicitly enabled for these tests to work correctly, this configuration should be restored, either in the TestBase.baseConfigs() or as a separate configuration in this test class's setup. ########## core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java: ########## @@ -113,10 +113,10 @@ import org.apache.iceberg.util.Pair; import org.assertj.core.api.InstanceOfAssertFactories; import org.awaitility.Awaitility; +import org.eclipse.jetty.ee10.servlet.ServletContextHandler; +import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.gzip.GzipHandler; Review Comment: Inconsistent migration of GzipHandler to CompressionHandler. While RESTCatalogServer.java and TestBaseWithRESTServer.java were updated to use CompressionHandler, several test files (TestRESTCatalog.java, TestRESTViewCatalog.java, TestRESTViewCatalogWithAssumedViewSupport.java, and TestS3RestSigner.java) still import and use the old GzipHandler class from "org.eclipse.jetty.server.handler.gzip.GzipHandler". This will likely cause compilation or runtime issues with Jetty 12.1.5, as the class may have been moved or removed. All usages should be consistently migrated to use CompressionHandler from the jetty-compression-server module. ```suggestion import org.eclipse.jetty.server.handler.CompressionHandler; ``` ########## spark/v4.0/spark/src/test/java/org/apache/iceberg/spark/DummyMetricsServlet.java: ########## @@ -0,0 +1,62 @@ +/* + * 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; + +import com.codahale.metrics.MetricRegistry; +import java.util.Properties; +import org.apache.spark.SparkConf; +import org.apache.spark.metrics.sink.MetricsServlet; +import org.sparkproject.jetty.servlet.ServletContextHandler; + +/** + * A dummy implementation of {@link MetricsServlet} that does not start a server or report metrics. + * This is used in tests to avoid conflicts with Spark's jetty dependencies. + */ +public class DummyMetricsServlet extends MetricsServlet { + + /** + * Constructor required by Spark's reflection-based instantiation. + * + * @param properties Metrics properties + * @param registry Metric registry + */ + public DummyMetricsServlet(Properties properties, MetricRegistry registry) { + super(properties, registry); + } + + @Override + public ServletContextHandler[] getHandlers(SparkConf conf) { + return new ServletContextHandler[] {}; + } Review Comment: Potential compatibility issue with Spark's shaded Jetty. The DummyMetricsServlet returns an array of org.sparkproject.jetty.servlet.ServletContextHandler, which is Spark's shaded (relocated) Jetty 11 package. However, this PR upgrades Iceberg's own Jetty dependencies to version 12.1.5. This could cause issues if Spark's MetricsServlet interface expects a specific Jetty version's ServletContextHandler. Verify that Spark 4.0 can handle this mismatch, or consider whether the dummy servlet needs to return Spark's specific shaded Jetty types. ########## spark/v3.4/spark/src/test/java/org/apache/iceberg/spark/DummyMetricsServlet.java: ########## @@ -0,0 +1,62 @@ +/* + * 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; + +import com.codahale.metrics.MetricRegistry; +import java.util.Properties; +import org.apache.spark.SparkConf; +import org.apache.spark.metrics.sink.MetricsServlet; +import org.sparkproject.jetty.servlet.ServletContextHandler; + +/** + * A dummy implementation of {@link MetricsServlet} that does not start a server or report metrics. + * This is used in tests to avoid conflicts with Spark's jetty dependencies. + */ +public class DummyMetricsServlet extends MetricsServlet { + + /** + * Constructor required by Spark's reflection-based instantiation. + * + * @param properties Metrics properties + * @param registry Metric registry + */ + public DummyMetricsServlet(Properties properties, MetricRegistry registry) { + super(properties, registry); + } + + @Override + public ServletContextHandler[] getHandlers(SparkConf conf) { + return new ServletContextHandler[] {}; + } Review Comment: Potential compatibility issue with Spark's shaded Jetty. The DummyMetricsServlet returns an array of org.sparkproject.jetty.servlet.ServletContextHandler, which is Spark's shaded (relocated) Jetty 11 package. However, this PR upgrades Iceberg's own Jetty dependencies to version 12.1.5. This could cause issues if Spark's MetricsServlet interface expects a specific Jetty version's ServletContextHandler. Verify that Spark 3.4 can handle this mismatch, or consider whether the dummy servlet needs to return Spark's specific shaded Jetty types. ########## spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/DummyMetricsServlet.java: ########## @@ -0,0 +1,62 @@ +/* + * 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; + +import com.codahale.metrics.MetricRegistry; +import java.util.Properties; +import org.apache.spark.SparkConf; +import org.apache.spark.metrics.sink.MetricsServlet; +import org.sparkproject.jetty.servlet.ServletContextHandler; + +/** + * A dummy implementation of {@link MetricsServlet} that does not start a server or report metrics. + * This is used in tests to avoid conflicts with Spark's jetty dependencies. + */ +public class DummyMetricsServlet extends MetricsServlet { + + /** + * Constructor required by Spark's reflection-based instantiation. + * + * @param properties Metrics properties + * @param registry Metric registry + */ + public DummyMetricsServlet(Properties properties, MetricRegistry registry) { + super(properties, registry); + } + + @Override + public ServletContextHandler[] getHandlers(SparkConf conf) { + return new ServletContextHandler[] {}; + } Review Comment: Potential compatibility issue with Spark's shaded Jetty. The DummyMetricsServlet returns an array of org.sparkproject.jetty.servlet.ServletContextHandler, which is Spark's shaded (relocated) Jetty 11 package. However, this PR upgrades Iceberg's own Jetty dependencies to version 12.1.5. This could cause issues if Spark's MetricsServlet interface expects a specific Jetty version's ServletContextHandler. Verify that Spark 3.5 can handle this mismatch, or consider whether the dummy servlet needs to return Spark's specific shaded Jetty types. ########## spark/v4.0/spark/src/test/java/org/apache/iceberg/spark/sql/TestAggregatePushDown.java: ########## @@ -26,58 +26,22 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; -import org.apache.iceberg.CatalogUtil; import org.apache.iceberg.ParameterizedTestExtension; import org.apache.iceberg.TableProperties; -import org.apache.iceberg.catalog.Namespace; -import org.apache.iceberg.exceptions.AlreadyExistsException; -import org.apache.iceberg.hive.HiveCatalog; -import org.apache.iceberg.hive.TestHiveMetastore; -import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; import org.apache.iceberg.relocated.com.google.common.collect.Lists; import org.apache.iceberg.spark.CatalogTestBase; import org.apache.iceberg.spark.SparkReadOptions; -import org.apache.iceberg.spark.TestBase; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; -import org.apache.spark.sql.SparkSession; import org.apache.spark.sql.execution.ExplainMode; import org.apache.spark.sql.functions; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; @ExtendWith(ParameterizedTestExtension.class) public class TestAggregatePushDown extends CatalogTestBase { - @BeforeAll - public static void startMetastoreAndSpark() { - TestBase.metastore = new TestHiveMetastore(); - metastore.start(); - TestBase.hiveConf = metastore.hiveConf(); - - TestBase.spark.stop(); - - TestBase.spark = - SparkSession.builder() - .master("local[2]") - .config("spark.sql.iceberg.aggregate_pushdown", "true") - .enableHiveSupport() - .getOrCreate(); - - TestBase.catalog = - (HiveCatalog) - CatalogUtil.loadCatalog( - HiveCatalog.class.getName(), "hive", ImmutableMap.of(), hiveConf); - - try { - catalog.createNamespace(Namespace.of("default")); - } catch (AlreadyExistsException ignored) { - // the default namespace already exists. ignore the create error - } - } - @AfterEach public void removeTables() { sql("DROP TABLE IF EXISTS %s", tableName); Review Comment: Missing aggregate_pushdown configuration. The previous implementation included .config("spark.sql.iceberg.aggregate_pushdown", "true") to enable aggregate pushdown for testing. This configuration has been removed, which means tests are now running with whatever the default behavior is. If aggregate pushdown needs to be explicitly enabled for these tests to work correctly, this configuration should be restored, either in the TestBase.baseConfigs() or as a separate configuration in this test class's setup. ########## core/src/test/java/org/apache/iceberg/rest/TestRESTViewCatalog.java: ########## @@ -57,10 +57,10 @@ import org.apache.iceberg.rest.responses.LoadViewResponse; import org.apache.iceberg.view.ViewCatalogTests; import org.apache.iceberg.view.ViewMetadata; +import org.eclipse.jetty.ee10.servlet.ServletContextHandler; +import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.gzip.GzipHandler; Review Comment: Inconsistent migration of GzipHandler to CompressionHandler. This file still imports and uses the old GzipHandler class from "org.eclipse.jetty.server.handler.gzip.GzipHandler" which may not be available or may have been moved in Jetty 12.1.5. It should be updated to use CompressionHandler like other files in this PR (RESTCatalogServer.java and TestBaseWithRESTServer.java). ########## spark/v4.1/spark/src/test/java/org/apache/iceberg/spark/sql/TestAggregatePushDown.java: ########## @@ -26,58 +26,22 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; -import org.apache.iceberg.CatalogUtil; import org.apache.iceberg.ParameterizedTestExtension; import org.apache.iceberg.TableProperties; -import org.apache.iceberg.catalog.Namespace; -import org.apache.iceberg.exceptions.AlreadyExistsException; -import org.apache.iceberg.hive.HiveCatalog; -import org.apache.iceberg.hive.TestHiveMetastore; -import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; import org.apache.iceberg.relocated.com.google.common.collect.Lists; import org.apache.iceberg.spark.CatalogTestBase; import org.apache.iceberg.spark.SparkReadOptions; -import org.apache.iceberg.spark.TestBase; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; -import org.apache.spark.sql.SparkSession; import org.apache.spark.sql.execution.ExplainMode; import org.apache.spark.sql.functions; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; @ExtendWith(ParameterizedTestExtension.class) public class TestAggregatePushDown extends CatalogTestBase { - @BeforeAll - public static void startMetastoreAndSpark() { - TestBase.metastore = new TestHiveMetastore(); - metastore.start(); - TestBase.hiveConf = metastore.hiveConf(); - - TestBase.spark.stop(); - - TestBase.spark = - SparkSession.builder() - .master("local[2]") - .config("spark.sql.iceberg.aggregate_pushdown", "true") - .enableHiveSupport() - .getOrCreate(); - - TestBase.catalog = - (HiveCatalog) - CatalogUtil.loadCatalog( - HiveCatalog.class.getName(), "hive", ImmutableMap.of(), hiveConf); - - try { - catalog.createNamespace(Namespace.of("default")); - } catch (AlreadyExistsException ignored) { - // the default namespace already exists. ignore the create error - } - } - @AfterEach public void removeTables() { sql("DROP TABLE IF EXISTS %s", tableName); Review Comment: Missing aggregate_pushdown configuration. The previous implementation included .config("spark.sql.iceberg.aggregate_pushdown", "true") to enable aggregate pushdown for testing. This configuration has been removed, which means tests are now running with whatever the default behavior is. If aggregate pushdown needs to be explicitly enabled for these tests to work correctly, this configuration should be restored, either in the TestBase.baseConfigs() or as a separate configuration in this test class's setup. -- 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]
