-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Core, Data, Spark: Moving Spark to use the new FormatModel API #15328
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
Changes from 5 commits
320ac20
4633b6f
6ae7eaa
576a7c9
4419dc3
b1c225b
025210f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,8 +23,13 @@ | |
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import org.apache.iceberg.FileFormat; | ||
| import org.apache.iceberg.Files; | ||
| import org.apache.iceberg.PartitionSpec; | ||
| import org.apache.iceberg.Schema; | ||
| import org.apache.iceberg.encryption.EncryptedFiles; | ||
| import org.apache.iceberg.formats.FormatModelRegistry; | ||
| import org.apache.iceberg.io.DataWriter; | ||
| import org.apache.iceberg.io.FileAppender; | ||
| import org.apache.iceberg.parquet.Parquet; | ||
| import org.apache.iceberg.spark.SparkSchemaUtil; | ||
|
|
@@ -121,10 +126,28 @@ public void writeUsingSparkWriter() throws IOException { | |
| .set("spark.sql.parquet.outputTimestampType", "TIMESTAMP_MICROS") | ||
| .set("spark.sql.caseSensitive", "false") | ||
| .set("spark.sql.parquet.fieldId.write.enabled", "false") | ||
| .set("spark.sql.parquet.variant.annotateLogicalType.enabled", "false") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests were failing with Spark 4.1, but probably doesn't worth to create a new PR for this.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm okay with this since it isn't production code. It's unlikely that this is going to cause problems cherry-picking. |
||
| .schema(SCHEMA) | ||
| .build()) { | ||
|
|
||
| writer.addAll(rows); | ||
| } | ||
| } | ||
|
|
||
| @Benchmark | ||
| @Threads(1) | ||
| public void writeUsingRegistryWriter() throws IOException { | ||
|
pvary marked this conversation as resolved.
Outdated
|
||
| try (DataWriter<InternalRow> writer = | ||
| FormatModelRegistry.dataWriteBuilder( | ||
| FileFormat.PARQUET, | ||
| InternalRow.class, | ||
| EncryptedFiles.plainAsEncryptedOutput(Files.localOutput(dataFile))) | ||
| .schema(SCHEMA) | ||
| .engineSchema(SparkSchemaUtil.convert(SCHEMA)) | ||
| .spec(PartitionSpec.unpartitioned()) | ||
| .build()) { | ||
|
|
||
| writer.write(rows); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,8 +23,13 @@ | |
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import org.apache.iceberg.FileFormat; | ||
| import org.apache.iceberg.Files; | ||
| import org.apache.iceberg.PartitionSpec; | ||
| import org.apache.iceberg.Schema; | ||
| import org.apache.iceberg.encryption.EncryptedFiles; | ||
| import org.apache.iceberg.formats.FormatModelRegistry; | ||
| import org.apache.iceberg.io.DataWriter; | ||
| import org.apache.iceberg.io.FileAppender; | ||
| import org.apache.iceberg.parquet.Parquet; | ||
| import org.apache.iceberg.spark.SparkSchemaUtil; | ||
|
|
@@ -121,10 +126,28 @@ public void writeUsingSparkWriter() throws IOException { | |
| .set("spark.sql.parquet.outputTimestampType", "TIMESTAMP_MICROS") | ||
| .set("spark.sql.caseSensitive", "false") | ||
| .set("spark.sql.parquet.fieldId.write.enabled", "false") | ||
| .set("spark.sql.parquet.variant.annotateLogicalType.enabled", "false") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests were failing with Spark 4.1, but probably doesn't worth to create a new PR for this.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we file an issue to track the underlying Spark 4.1 test failure, so we can fix the root cause later?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think both "true" and "false" is ok as well. The issue was that the config was not set. |
||
| .schema(SCHEMA) | ||
| .build()) { | ||
|
|
||
| writer.addAll(rows); | ||
| } | ||
| } | ||
|
|
||
| @Benchmark | ||
| @Threads(1) | ||
| public void writeUsingRegistryWriter() throws IOException { | ||
| try (DataWriter<InternalRow> writer = | ||
| FormatModelRegistry.dataWriteBuilder( | ||
| FileFormat.PARQUET, | ||
| InternalRow.class, | ||
| EncryptedFiles.plainAsEncryptedOutput(Files.localOutput(dataFile))) | ||
| .schema(SCHEMA) | ||
| .engineSchema(SparkSchemaUtil.convert(SCHEMA)) | ||
|
pvary marked this conversation as resolved.
Outdated
|
||
| .spec(PartitionSpec.unpartitioned()) | ||
| .build()) { | ||
|
|
||
| writer.write(rows); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to test the direct method vs the registry method? I would expect this to replace the current
readUsingIcebergReaderUnsafeimplementation since this is the same reader implementation. We should make sure that there is not a regression by running these benchmarks (for which it would be fine to leave this method here) but I don't want to accumulate essentially dead code testing the same thing.