Skip to content
Merged
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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
import io.trino.spi.Page;
import io.trino.spi.TrinoException;
import io.trino.spi.type.Type;
import org.apache.hadoop.fs.Path;
import org.apache.iceberg.Metrics;
import org.apache.iceberg.Schema;
import org.apache.iceberg.avro.Avro;
import org.apache.iceberg.data.Record;
import org.apache.iceberg.data.avro.DataWriter;
import org.apache.iceberg.io.FileAppender;
import org.apache.iceberg.io.FileIO;
import org.apache.iceberg.io.OutputFile;
import org.openjdk.jol.info.ClassLayout;

import java.io.IOException;
Expand Down Expand Up @@ -53,8 +52,7 @@ public class IcebergAvroFileWriter
private final Callable<Void> rollbackAction;

public IcebergAvroFileWriter(
FileIO fileIo,
Path path,
OutputFile file,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requireNotNull file

Callable<Void> rollbackAction,
Schema icebergSchema,
List<Type> types,
Expand All @@ -65,15 +63,15 @@ public IcebergAvroFileWriter(
this.types = ImmutableList.copyOf(requireNonNull(types, "types is null"));

try {
avroWriter = Avro.write(fileIo.newOutputFile(path.toString()))
avroWriter = Avro.write(file)
.schema(icebergSchema)
.createWriterFunc(DataWriter::create)
.named(AVRO_TABLE_NAME)
.set(AVRO_COMPRESSION, toIcebergAvroCompressionName(hiveCompressionCodec))
.build();
}
catch (IOException e) {
throw new TrinoException(ICEBERG_WRITER_OPEN_ERROR, "Error creating Avro file: " + path, e);
throw new TrinoException(ICEBERG_WRITER_OPEN_ERROR, "Error creating Avro file: " + file.location(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.apache.iceberg.data.Record;
import org.apache.iceberg.data.avro.DataReader;
import org.apache.iceberg.io.CloseableIterator;
import org.apache.iceberg.io.FileIO;
import org.apache.iceberg.io.InputFile;
import org.apache.iceberg.mapping.NameMapping;
import org.apache.iceberg.types.Types;

Expand Down Expand Up @@ -61,8 +61,7 @@ public class IcebergAvroPageSource
private long readTimeNanos;

public IcebergAvroPageSource(
FileIO fileIo,
String path,
InputFile file,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requireNotNull file

long start,
long length,
Schema fileSchema,
Expand All @@ -72,9 +71,6 @@ public IcebergAvroPageSource(
List<Boolean> rowIndexLocations,
AggregatedMemoryContext memoryUsage)
{
requireNonNull(fileIo, "fileIo is null");
requireNonNull(path, "path is null");
requireNonNull(fileSchema, "fileSchema is null");
this.columnNames = ImmutableList.copyOf(requireNonNull(columnNames, "columnNames is null"));
this.columnTypes = ImmutableList.copyOf(requireNonNull(columnTypes, "columnTypes is null"));
this.rowIndexLocations = ImmutableList.copyOf(requireNonNull(rowIndexLocations, "rowIndexLocations is null"));
Expand All @@ -85,7 +81,7 @@ public IcebergAvroPageSource(

// The column orders in the generated schema might be different from the original order
Schema readSchema = fileSchema.select(columnNames);
Avro.ReadBuilder builder = Avro.read(fileIo.newInputFile(path))
Avro.ReadBuilder builder = Avro.read(file)
.project(readSchema)
.createReaderFunc(DataReader::create)
.split(start, length);
Expand Down
Loading