danny0405 commented on code in PR #20516: URL: https://github.com/apache/hudi/pull/20516#discussion_r4594883513
########## hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/streaming/HoodieStreamingSourceSafety.scala: ########## @@ -0,0 +1,190 @@ +/* + * 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.streaming + +import org.apache.hudi.{DataSourceReadOptions, DefaultSource, SparkAdapterSupport} +import org.apache.hudi.common.model.WriteOperationType +import org.apache.hudi.common.table.HoodieTableMetaClient +import org.apache.hudi.common.table.timeline.{HoodieInstant, HoodieTimeline} +import org.apache.hudi.common.util.CleanerUtils +import org.apache.hudi.exception.HoodieException + +import org.apache.spark.{Partition, TaskContext} +import org.apache.spark.rdd.RDD +import org.apache.spark.sql.{DataFrame, SQLContext} +import org.apache.spark.sql.catalyst.InternalRow +import org.apache.spark.sql.execution.datasources.HadoopFsRelation +import org.apache.spark.sql.types.StructType + +import scala.collection.JavaConverters._ + +/** Conservative reset and history validation for checkpointed latest-state streaming consumers. */ +private[streaming] object HoodieStreamingSourceSafety extends SparkAdapterSupport { + private class RebuildRequired(message: String, cause: Throwable = null) extends HoodieException(message, cause) + + // Spark re-plans the last committed batch on restart and discards it. Delay only safety + // rejections; healthy scans must remain visible to column pruning and predicate pushdown. + def deferRejection(sqlContext: SQLContext, schema: StructType)(batch: => DataFrame): DataFrame = { Review Comment: Fixed in db42b31dbde: deferRejection now takes schema by name (schema: => StructType), matching recover. Healthy batches therefore avoid this extra schema resolution; the schema is evaluated only when constructing a deferred rejection. The Spark 3.5 reactor build and style checks passed, and both streaming suites passed (29 tests, 2 expected version skips). -- 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]
