wangyinsheng commented on code in PR #13068: URL: https://github.com/apache/hudi/pull/13068#discussion_r2079143622
########## hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/HoodieCommandMetrics.scala: ########## @@ -0,0 +1,97 @@ +/* + * 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 + +import org.apache.hudi.common.model.HoodieCommitMetadata +import org.apache.hudi.common.table.HoodieTableMetaClient +import org.apache.hudi.common.table.timeline.{HoodieInstant, InstantComparison} +import org.apache.hudi.common.util.VisibleForTesting + +import org.apache.spark.SparkContext +import org.apache.spark.sql.execution.metric.{SQLMetric, SQLMetrics} + +import scala.collection.JavaConverters._ + +object HoodieCommandMetrics { + + def updateInsertMetrics(metrics: Map[String, SQLMetric], metaClient: HoodieTableMetaClient, commitInstantTime: String): Unit = { + val timeline = metaClient.getActiveTimeline.reload().getCommitsTimeline() + val commitInstant = timeline.getInstants.asScala + .filter(instant => InstantComparison.EQUALS.test(instant.requestedTime(), commitInstantTime)) + commitInstant.map { commit: HoodieInstant => + val metadata = timeline.readCommitMetadata(commit) Review Comment: > I kind of lost the memories why we can't return the `HoodieCommitMetadata` directly from the `#commit` method, is there any ambiguities? the `#commit`method returns a boolean value to indicate whether the commit successed. Many caller use the boolean value to decide their subsequent logic。In case of empty commit,there is no `HoodieCommitMetadata` produced but return `true` . if return `HoodieCommitMetadata` directly, many caller will require adjustments to their validation logic, and there is a lot of ut need adjustments。 see the first commit https://github.com/apache/hudi/pull/13068/commits/0a242f95c39b25b82ebdafbfac6ea18e72022aa0 -- 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]
