cc5566 commented on code in PR #9779: URL: https://github.com/apache/gravitino/pull/9779#discussion_r2756324375
########## core/src/test/java/org/apache/gravitino/stats/storage/TestJdbcPartitionStatisticStorageIT.java: ########## @@ -0,0 +1,618 @@ +/* + * 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.gravitino.stats.storage; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.apache.gravitino.EntityStore; +import org.apache.gravitino.GravitinoEnv; +import org.apache.gravitino.MetadataObject; +import org.apache.gravitino.MetadataObjects; +import org.apache.gravitino.integration.test.container.ContainerSuite; +import org.apache.gravitino.integration.test.container.MySQLContainer; +import org.apache.gravitino.integration.test.util.TestDatabaseName; +import org.apache.gravitino.meta.TableEntity; +import org.apache.gravitino.stats.PartitionRange; +import org.apache.gravitino.stats.PartitionStatisticsDrop; +import org.apache.gravitino.stats.PartitionStatisticsModification; +import org.apache.gravitino.stats.PartitionStatisticsUpdate; +import org.apache.gravitino.stats.StatisticValue; +import org.apache.gravitino.stats.StatisticValues; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * End-to-end integration tests for {@link JdbcPartitionStatisticStorage} using real MySQL database + * via Testcontainers. + * + * <p>These tests verify the complete flow from API calls through JDBC to a real MySQL instance. + * They cover: + * + * <ul> + * <li>Full CRUD operations (Create, Read, Update, Delete) + * <li>Partition range queries with different bound types + * <li>Transaction integrity and rollback behavior + * <li>Concurrent access from multiple threads + * <li>JSON serialization/deserialization + * <li>Audit information preservation + * <li>Large dataset handling + * </ul> + */ +@Tag("gravitino-docker-test") +public class TestJdbcPartitionStatisticStorageIT { + + private static final Logger LOG = + LoggerFactory.getLogger(TestJdbcPartitionStatisticStorageIT.class); + + private static final ContainerSuite containerSuite = ContainerSuite.getInstance(); + private static final TestDatabaseName TEST_DB_NAME = TestDatabaseName.MYSQL_MYSQL_ABSTRACT_IT; + + private static JdbcPartitionStatisticStorage storage; + private static MySQLContainer mySQLContainer; + private static EntityStore entityStore; + + private static final String METALAKE = "test_metalake"; + private static final MetadataObject TEST_TABLE = + MetadataObjects.of( + Lists.newArrayList("catalog", "schema", "table"), MetadataObject.Type.TABLE); + + @BeforeAll + public static void setup() throws Exception { + LOG.info("Starting MySQL container for partition statistics integration tests"); + + // Start MySQL container + containerSuite.startMySQLContainer(TEST_DB_NAME); Review Comment: Added PostgreSQL and H2 test coverage using JUnit 5 nested tests pattern ########## docs/manage-statistics-in-gravitino.md: ########## @@ -258,7 +320,14 @@ For Lance remote storage, you can refer to the document [here](https://lancedb.g If you have many tables with a small number of partitions, you should set a smaller metadataFileCacheSizeBytes and indexCacheSizeBytes. -### Implementation a custom partition storage +**To use Lance storage, configure:** + +```properties +gravitino.stats.partition.storageFactoryClass=org.apache.gravitino.stats.storage.LancePartitionStatisticStorageFactory Review Comment: Done -- 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]
