You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "yihua (via GitHub)" <gi...@apache.org> on 2024/09/04 05:19:07 UTC
Re: [PR] [HUDI-5807] Read partition values from file and create infra to support reading only a subset of columns [hudi]
yihua commented on code in PR #11770:
URL: https://github.com/apache/hudi/pull/11770#discussion_r1743085731
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderBasedParquetFileFormat.scala:
##########
@@ -231,4 +270,32 @@ class HoodieFileGroupReaderBasedParquetFileFormat(tableState: HoodieTableState,
override def close(): Unit = closeableFileGroupRecordIterator.close()
}
}
+
+ private def readBaseFile(file: PartitionedFile, parquetFileReader: SparkParquetReader, requestedSchema: StructType,
+ remainingPartitionSchema: StructType, fixedPartitionIndexes: Set[Int], requiredSchema: StructType,
+ partitionSchema: StructType, outputSchema: StructType, filters: Seq[Filter],
+ storageConf: StorageConfiguration[Configuration]): Iterator[InternalRow] = {
+ if (remainingPartitionSchema.fields.length == partitionSchema.fields.length) {
Review Comment:
Are all of these different branches covered by the tests?
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/vectorized/ColumnarBatchUtils.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.vectorized;
+
+import org.apache.spark.sql.types.StructType;
+
+import java.util.function.UnaryOperator;
+
+public class ColumnarBatchUtils {
+
+ public static UnaryOperator<ColumnarBatch> generateProjection(StructType from, StructType to) {
+ if (from.length() < to.length()) {
+ throw new IllegalStateException(from + " has less columns than " + to);
+ }
+
+ if (from.equals(to)) {
+ return UnaryOperator.identity();
+ }
+
+ int[] projection = new int[to.size()];
+ for (int i = 0; i < to.length(); i++) {
+ projection[i] = from.fieldIndex(to.fields()[i].name());
+ }
+
+ return columnarBatch -> {
+ ColumnVector[] vectors = new ColumnVector[projection.length];
+ for (int i = 0; i < projection.length; i++) {
+ vectors[i] = columnarBatch.column(projection[i]);
+ }
+
+ //TODO: [HUDI-8099] replace this with inplace projection by extending columnar batch
+ ColumnarBatch b = new ColumnarBatch(vectors);
+ b.setNumRows(columnarBatch.numRows());
+ return b;
+ };
Review Comment:
Let's file another JIRA ticket to benchmark the performance overhead.
##########
hudi-spark-datasource/hudi-spark3.3.x/src/main/scala/org/apache/spark/sql/execution/datasources/HoodieSpark33PartitionedFileUtils.scala:
##########
@@ -24,12 +24,15 @@ import org.apache.hudi.storage.StoragePath
import org.apache.hadoop.fs.FileStatus
import org.apache.spark.sql.catalyst.InternalRow
+import java.net.URI
+
/**
* Utils on Spark [[PartitionedFile]] and [[PartitionDirectory]] for Spark 3.3.
*/
object HoodieSpark33PartitionedFileUtils extends HoodieSparkPartitionedFileUtils {
override def getPathFromPartitionedFile(partitionedFile: PartitionedFile): StoragePath = {
- new StoragePath(partitionedFile.filePath)
+ //see SPARK-41970
+ new StoragePath(new URI(partitionedFile.filePath))
Review Comment:
So Spark 3.4 and 3.5 do not have the problem?
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieHadoopFsRelationFactory.scala:
##########
@@ -75,6 +78,19 @@ abstract class HoodieBaseHadoopFsRelationFactory(val sqlContext: SQLContext,
protected lazy val basePath: StoragePath = metaClient.getBasePath
protected lazy val partitionColumns: Array[String] = tableConfig.getPartitionFields.orElse(Array.empty)
+ private lazy val keygenTypeHasVariablePartitionCols = !isNullOrEmpty(tableConfig.getKeyGeneratorClassName) &&
+ (tableConfig.getKeyGeneratorClassName.equals("org.apache.hudi.keygen.TimestampBasedKeyGenerator") ||
Review Comment:
Similar for other hardcoded class path.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org