danny0405 commented on code in PR #10226: URL: https://github.com/apache/hudi/pull/10226#discussion_r1412716767
########## hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/ShowColumnStatsOverlapProcedure.scala: ########## @@ -0,0 +1,355 @@ +/* + * 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.spark.sql.hudi.command.procedures + +import org.apache.avro.generic.IndexedRecord +import org.apache.hadoop.fs.{FileStatus, Path} +import org.apache.hudi.avro.model._ +import org.apache.hudi.client.common.HoodieSparkEngineContext +import org.apache.hudi.common.config.HoodieMetadataConfig +import org.apache.hudi.common.data.HoodieData +import org.apache.hudi.common.fs.FSUtils +import org.apache.hudi.common.model.{FileSlice, HoodieRecord} +import org.apache.hudi.common.table.timeline.{HoodieDefaultTimeline, HoodieInstant} +import org.apache.hudi.common.table.view.HoodieTableFileSystemView +import org.apache.hudi.common.table.{HoodieTableMetaClient, TableSchemaResolver} +import org.apache.hudi.common.util.{Option => HOption} +import org.apache.hudi.exception.HoodieException +import org.apache.hudi.metadata.HoodieTableMetadata +import org.apache.hudi.{AvroConversionUtils, ColumnStatsIndexSupport} +import org.apache.spark.internal.Logging +import org.apache.spark.sql.Row +import org.apache.spark.sql.types.{DataTypes, Metadata, StructField, StructType} + +import java.util +import java.util.function.{Function, Supplier} +import scala.collection.JavaConversions.asScalaBuffer +import scala.collection.{JavaConversions, mutable} +import scala.jdk.CollectionConverters.{asScalaBufferConverter, asScalaIteratorConverter, seqAsJavaListConverter} + +/** + * Calculate the degree of overlap between column stats. + * The overlap represents the extent to which the min-max ranges cover each other. + * By referring to the overlap, we can visually demonstrate the degree of data skipping + * for different columns under the current table's data layout. + * The calculation is performed at the partition level (assuming that data skipping is based on partition pruning). + * + * For example, consider three files: a.parquet, b.parquet, and c.parquet. + * Taking an integer-type column 'id' as an example, the range (min-max) for 'a' is 1–5, + * for 'b' is 3–7, and for 'c' is 7–8. This results in their values overlapping on the coordinate axis as follows: + * Value Range: 1 2 3 4 5 6 7 8 + * a.parquet: [-------] + * b.parquet: [--------] + * c.parquet: [-] + * Thus, there will be overlap within the ranges 3–5 and 7. + * If the filter conditions for 'id' during data skipping include these values, + * multiple files will be filtered out. For a simpler case, if it's an equality query, + * 2 files will be filtered within these ranges, and no more than one file will be filtered in other cases (possibly outside of the range). + * + * Additionally, calculating the degree of overlap based solely on the maximum values Review Comment: Each new paragraph should start with `<p>`. -- 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]
