southernriver commented on code in PR #6442: URL: https://github.com/apache/hudi/pull/6442#discussion_r1009426003
########## hudi-spark-datasource/hudi-spark3.2plus-common/src/main/scala/org/apache/spark/sql/hudi/source/HoodieBatchScanBuilder.scala: ########## @@ -0,0 +1,77 @@ +/* + * 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.source + +import org.apache.hudi.DataSourceReadOptions.QUERY_TYPE +import org.apache.hudi.exception.HoodieException +import org.apache.hudi.{DataSourceOptionsHelper, DefaultSource, HoodieSparkUtils} +import org.apache.spark.sql.{SQLContext, SparkSession} +import org.apache.spark.sql.catalyst.catalog.HoodieCatalogTable +import org.apache.spark.sql.catalyst.expressions.Expression +import org.apache.spark.sql.connector.read.{Scan, ScanBuilder, SupportsPushDownFilters, SupportsPushDownRequiredColumns, SupportsRuntimeFiltering} +import org.apache.spark.sql.execution.datasources.HadoopFsRelation +import org.apache.spark.sql.sources.Filter +import org.apache.spark.sql.types.StructType + + +class HoodieBatchScanBuilder(spark: SparkSession, + hoodieCatalogTable: HoodieCatalogTable, + options: Map[String, String]) + extends ScanBuilder with SupportsPushDownFilters with SupportsPushDownRequiredColumns { + @transient lazy val hadoopConf = { + // Hadoop Configurations are case sensitive. + spark.sessionState.newHadoopConfWithOptions(options) + } + + private var filterExpressions: Option[Expression] = None + + private var filterArrays: Array[Filter] = Array.empty + + private var expectedSchema: StructType= hoodieCatalogTable.tableSchema + + override def build(): Scan = { + val relation = new DefaultSource().createRelation(new SQLContext(spark), options) + relation match { + case HadoopFsRelation(location, partitionSchema, dataSchema, _, _, options) => Review Comment: It‘s really a huge work to reimplement DataSourceV2 APIs for all hudi tables,My initial idea is to use the lower level V2 read interface to support features like `SupportsPushDownFilters` and `SupportsRuntimeFiltering` etc first. And I will continue to follow up on the implementation of new HudiTableScan. -- 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]
