Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spark: remove ROW_POSITION from project schema #11610

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.iceberg.spark.source;

import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.iceberg.FileFormat;
Expand All @@ -32,12 +31,10 @@
import org.apache.iceberg.io.InputFile;
import org.apache.iceberg.orc.ORC;
import org.apache.iceberg.parquet.Parquet;
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.iceberg.relocated.com.google.common.collect.Sets;
import org.apache.iceberg.spark.data.vectorized.VectorizedSparkOrcReaders;
import org.apache.iceberg.spark.data.vectorized.VectorizedSparkParquetReaders;
import org.apache.iceberg.types.TypeUtil;
import org.apache.iceberg.types.Types;
import org.apache.spark.sql.vectorized.ColumnarBatch;

abstract class BaseBatchReader<T extends ScanTask> extends BaseReader<ColumnarBatch, T> {
Expand Down Expand Up @@ -84,21 +81,9 @@ private CloseableIterable<ColumnarBatch> newParquetIterable(
SparkDeleteFilter deleteFilter) {
// get required schema if there are deletes
Schema requiredSchema = deleteFilter != null ? deleteFilter.requiredSchema() : expectedSchema();
boolean hasPositionDelete = deleteFilter != null ? deleteFilter.hasPosDeletes() : false;
Schema projectedSchema = requiredSchema;
if (hasPositionDelete) {
// We need to add MetadataColumns.ROW_POSITION in the schema for
// ReadConf.generateOffsetToStartPos(Schema schema). This is not needed any
// more after #10107 is merged.
List<Types.NestedField> columns = Lists.newArrayList(requiredSchema.columns());
if (!columns.contains(MetadataColumns.ROW_POSITION)) {
columns.add(MetadataColumns.ROW_POSITION);
projectedSchema = new Schema(columns);
}
}

return Parquet.read(inputFile)
.project(projectedSchema)
.project(requiredSchema)
.split(start, length)
.createBatchedReaderFunc(
fileSchema ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.iceberg.spark.source;

import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.iceberg.FileFormat;
Expand All @@ -32,12 +31,10 @@
import org.apache.iceberg.io.InputFile;
import org.apache.iceberg.orc.ORC;
import org.apache.iceberg.parquet.Parquet;
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.iceberg.relocated.com.google.common.collect.Sets;
import org.apache.iceberg.spark.data.vectorized.VectorizedSparkOrcReaders;
import org.apache.iceberg.spark.data.vectorized.VectorizedSparkParquetReaders;
import org.apache.iceberg.types.TypeUtil;
import org.apache.iceberg.types.Types;
import org.apache.spark.sql.vectorized.ColumnarBatch;

abstract class BaseBatchReader<T extends ScanTask> extends BaseReader<ColumnarBatch, T> {
Expand Down Expand Up @@ -84,21 +81,9 @@ private CloseableIterable<ColumnarBatch> newParquetIterable(
SparkDeleteFilter deleteFilter) {
// get required schema if there are deletes
Schema requiredSchema = deleteFilter != null ? deleteFilter.requiredSchema() : expectedSchema();
boolean hasPositionDelete = deleteFilter != null ? deleteFilter.hasPosDeletes() : false;
Schema projectedSchema = requiredSchema;
if (hasPositionDelete) {
// We need to add MetadataColumns.ROW_POSITION in the schema for
// ReadConf.generateOffsetToStartPos(Schema schema). This is not needed any
// more after #10107 is merged.
List<Types.NestedField> columns = Lists.newArrayList(requiredSchema.columns());
if (!columns.contains(MetadataColumns.ROW_POSITION)) {
columns.add(MetadataColumns.ROW_POSITION);
projectedSchema = new Schema(columns);
}
}

return Parquet.read(inputFile)
.project(projectedSchema)
.project(requiredSchema)
.split(start, length)
.createBatchedReaderFunc(
fileSchema ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.iceberg.spark.source;

import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.iceberg.FileFormat;
Expand All @@ -32,12 +31,10 @@
import org.apache.iceberg.io.InputFile;
import org.apache.iceberg.orc.ORC;
import org.apache.iceberg.parquet.Parquet;
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.iceberg.relocated.com.google.common.collect.Sets;
import org.apache.iceberg.spark.data.vectorized.VectorizedSparkOrcReaders;
import org.apache.iceberg.spark.data.vectorized.VectorizedSparkParquetReaders;
import org.apache.iceberg.types.TypeUtil;
import org.apache.iceberg.types.Types;
import org.apache.spark.sql.vectorized.ColumnarBatch;

abstract class BaseBatchReader<T extends ScanTask> extends BaseReader<ColumnarBatch, T> {
Expand Down Expand Up @@ -84,21 +81,9 @@ private CloseableIterable<ColumnarBatch> newParquetIterable(
SparkDeleteFilter deleteFilter) {
// get required schema if there are deletes
Schema requiredSchema = deleteFilter != null ? deleteFilter.requiredSchema() : expectedSchema();
boolean hasPositionDelete = deleteFilter != null ? deleteFilter.hasPosDeletes() : false;
Schema projectedSchema = requiredSchema;
if (hasPositionDelete) {
// We need to add MetadataColumns.ROW_POSITION in the schema for
// ReadConf.generateOffsetToStartPos(Schema schema). This is not needed any
// more after #10107 is merged.
List<Types.NestedField> columns = Lists.newArrayList(requiredSchema.columns());
if (!columns.contains(MetadataColumns.ROW_POSITION)) {
columns.add(MetadataColumns.ROW_POSITION);
projectedSchema = new Schema(columns);
}
}

return Parquet.read(inputFile)
.project(projectedSchema)
.project(requiredSchema)
.split(start, length)
.createBatchedReaderFunc(
fileSchema ->
Expand Down