-
Notifications
You must be signed in to change notification settings - Fork 81
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
feat: Added support to write iceberg tables #5989
Open
malhotrashivam
wants to merge
32
commits into
deephaven:main
Choose a base branch
from
malhotrashivam:sm-ice-write
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 19 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
8c81883
Initial commit
malhotrashivam 758c1f3
Added type info map and modified instructions class hierarchy
malhotrashivam 48cb8d8
Minor tweaks to the instructions class hierarchy
malhotrashivam 244bc99
Merged writeTable and appendTable into addPartition
malhotrashivam 09340c2
Split IcebergParquetWriteInstructions into WriteInstr and ParquetWrit…
malhotrashivam 33b60e2
Merge branch 'main' into sm-ice-write
malhotrashivam c70b50e
Resolving more conflicts
malhotrashivam cd278ab
Merge branch 'main' into sm-ice-write
malhotrashivam 689e8a1
Added unit tests and moved Iceberg tests to Junit5
malhotrashivam d7f2c81
Preparing change for code review Part 1
malhotrashivam 131a552
Preparing for review Part 2
malhotrashivam 3021585
Added more unit tests
malhotrashivam 9f82ba0
Review with Larry part 1
malhotrashivam cbae64e
Fix for failing job
malhotrashivam 7de59b0
Review with Larry Part 2
malhotrashivam 83a0b14
Merge branch 'main' into sm-ice-write
malhotrashivam c83ddbd
Review with Devin Part 1
malhotrashivam f0f86cc
Fix for failing jobs
malhotrashivam adb21e9
Review with Devin Part 2
malhotrashivam 744ce60
Review with Devin Part 3
malhotrashivam a8252ce
Review with Devin Part 4
malhotrashivam 38f55f0
Merge branch 'main' into sm-ice-write
malhotrashivam 5a64faf
Minor tweaks
malhotrashivam ba70f1a
More tweaks
malhotrashivam 96db353
Updated some comments
malhotrashivam 6e2c233
Updated javadoc and added new tests
malhotrashivam de6eba0
Merge branch 'main' into sm-ice-write
malhotrashivam 0ebeba2
Review with Ryan Part 1
malhotrashivam 31f46ba
Review with Ryan Part 2
malhotrashivam 946def0
Fix for failing parquet reads
malhotrashivam bd8535c
Added more tests for writeDataFile
malhotrashivam 78bd605
Added tests for on write callback
malhotrashivam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
177 changes: 177 additions & 0 deletions
177
...eberg/s3/src/test/java/io/deephaven/iceberg/util/IcebergParquetWriteInstructionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.iceberg.util; | ||
|
||
import io.deephaven.parquet.table.ParquetInstructions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown; | ||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
||
class IcebergParquetWriteInstructionsTest { | ||
|
||
@Test | ||
void defaults() { | ||
final IcebergParquetWriteInstructions instructions = IcebergParquetWriteInstructions.builder().build(); | ||
assertThat(instructions.tableDefinition().isEmpty()).isTrue(); | ||
assertThat(instructions.dataInstructions().isEmpty()).isTrue(); | ||
assertThat(instructions.dhToIcebergColumnRenames().isEmpty()).isTrue(); | ||
assertThat(instructions.createTableIfNotExist()).isFalse(); | ||
assertThat(instructions.verifySchema()).isEmpty(); | ||
assertThat(instructions.compressionCodecName()).isEqualTo("SNAPPY"); | ||
assertThat(instructions.maximumDictionaryKeys()).isEqualTo(1048576); | ||
assertThat(instructions.maximumDictionarySize()).isEqualTo(1048576); | ||
} | ||
|
||
@Test | ||
void testSetCreateTableIfNotExist() { | ||
assertThat(IcebergParquetWriteInstructions.builder() | ||
.createTableIfNotExist(true) | ||
.build() | ||
.createTableIfNotExist()) | ||
.isTrue(); | ||
} | ||
|
||
@Test | ||
void testSetVerifySchema() { | ||
assertThat(IcebergParquetWriteInstructions.builder() | ||
.verifySchema(true) | ||
.build() | ||
.verifySchema()) | ||
.isEqualTo(Optional.of(true)); | ||
malhotrashivam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
@Test | ||
void testSetCompressionCodecName() { | ||
assertThat(IcebergParquetWriteInstructions.builder() | ||
.compressionCodecName("GZIP") | ||
.build() | ||
.compressionCodecName()) | ||
.isEqualTo("GZIP"); | ||
} | ||
|
||
@Test | ||
void testSetMaximumDictionaryKeys() { | ||
assertThat(IcebergParquetWriteInstructions.builder() | ||
.maximumDictionaryKeys(100) | ||
.build() | ||
.maximumDictionaryKeys()) | ||
.isEqualTo(100); | ||
} | ||
|
||
@Test | ||
void testSetMaximumDictionarySize() { | ||
assertThat(IcebergParquetWriteInstructions.builder() | ||
.maximumDictionarySize(100) | ||
.build() | ||
.maximumDictionarySize()) | ||
.isEqualTo(100); | ||
} | ||
|
||
@Test | ||
void testSetTargetPageSize() { | ||
assertThat(IcebergParquetWriteInstructions.builder() | ||
.targetPageSize(1 << 20) | ||
.build() | ||
.targetPageSize()) | ||
.isEqualTo(1 << 20); | ||
} | ||
|
||
@Test | ||
void testMinMaximumDictionaryKeys() { | ||
|
||
try { | ||
IcebergParquetWriteInstructions.builder() | ||
.maximumDictionaryKeys(-1) | ||
.build(); | ||
failBecauseExceptionWasNotThrown(IllegalArgumentException.class); | ||
} catch (IllegalArgumentException e) { | ||
assertThat(e).hasMessageContaining("maximumDictionaryKeys"); | ||
} | ||
} | ||
|
||
@Test | ||
void testMinMaximumDictionarySize() { | ||
try { | ||
IcebergParquetWriteInstructions.builder() | ||
.maximumDictionarySize(-1) | ||
.build(); | ||
failBecauseExceptionWasNotThrown(IllegalArgumentException.class); | ||
} catch (IllegalArgumentException e) { | ||
assertThat(e).hasMessageContaining("maximumDictionarySize"); | ||
} | ||
} | ||
|
||
@Test | ||
void testMinTargetPageSize() { | ||
try { | ||
IcebergParquetWriteInstructions.builder() | ||
.targetPageSize(1024) | ||
.build(); | ||
failBecauseExceptionWasNotThrown(IllegalArgumentException.class); | ||
} catch (IllegalArgumentException e) { | ||
assertThat(e).hasMessageContaining("targetPageSize"); | ||
} | ||
} | ||
|
||
@Test | ||
void testSetToIcebergColumnRename() { | ||
final IcebergParquetWriteInstructions instructions = IcebergParquetWriteInstructions.builder() | ||
.putDhToIcebergColumnRenames("dh1", "ice1") | ||
.putDhToIcebergColumnRenames("dh2", "ice2") | ||
.build(); | ||
assertThat(instructions.dhToIcebergColumnRenames().size()).isEqualTo(2); | ||
assertThat(instructions.dhToIcebergColumnRenames().get("dh1")).isEqualTo("ice1"); | ||
assertThat(instructions.dhToIcebergColumnRenames().get("dh2")).isEqualTo("ice2"); | ||
|
||
final IcebergParquetWriteInstructions instructions2 = IcebergParquetWriteInstructions.builder() | ||
.putAllDhToIcebergColumnRenames(Map.of( | ||
"dh1", "ice1", | ||
"dh2", "ice2", | ||
"dh3", "ice3")) | ||
.build(); | ||
assertThat(instructions2.dhToIcebergColumnRenames().size()).isEqualTo(3); | ||
assertThat(instructions2.dhToIcebergColumnRenames().get("dh1")).isEqualTo("ice1"); | ||
assertThat(instructions2.dhToIcebergColumnRenames().get("dh2")).isEqualTo("ice2"); | ||
assertThat(instructions2.dhToIcebergColumnRenames().get("dh3")).isEqualTo("ice3"); | ||
} | ||
|
||
@Test | ||
void testToIcebergColumnRenameUniqueness() { | ||
try { | ||
IcebergParquetWriteInstructions.builder() | ||
.putDhToIcebergColumnRenames("dh1", "ice1") | ||
.putDhToIcebergColumnRenames("dh2", "ice1") | ||
.build(); | ||
failBecauseExceptionWasNotThrown(IllegalArgumentException.class); | ||
} catch (final IllegalArgumentException e) { | ||
assertThat(e).hasMessageContaining("Duplicate values in column renames"); | ||
} | ||
} | ||
|
||
@Test | ||
void toParquetInstructionTest() { | ||
final IcebergParquetWriteInstructions writeInstructions = IcebergParquetWriteInstructions.builder() | ||
.compressionCodecName("GZIP") | ||
.maximumDictionaryKeys(100) | ||
.maximumDictionarySize(200) | ||
.targetPageSize(1 << 20) | ||
.build(); | ||
final Map<Integer, String> fieldIdToName = Map.of(2, "field2", 3, "field3"); | ||
final ParquetInstructions parquetInstructions = writeInstructions.toParquetInstructions( | ||
null, fieldIdToName); | ||
|
||
assertThat(parquetInstructions.getCompressionCodecName()).isEqualTo("GZIP"); | ||
assertThat(parquetInstructions.getMaximumDictionaryKeys()).isEqualTo(100); | ||
assertThat(parquetInstructions.getMaximumDictionarySize()).isEqualTo(200); | ||
assertThat(parquetInstructions.getTargetPageSize()).isEqualTo(1 << 20); | ||
assertThat(parquetInstructions.getFieldId("field1")).isEmpty(); | ||
assertThat(parquetInstructions.getFieldId("field2")).hasValue(2); | ||
assertThat(parquetInstructions.getFieldId("field3")).hasValue(3); | ||
assertThat(parquetInstructions.onWriteCompleted()).isEmpty(); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why is it a problem to use
ResolvingFileIO
? You will need to provideHadoopConf
info.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.
So from what I understood,
ResolvingFileIO
would add additional step of resolving which file IO to use.And based on the file name, I thought we are sure here that its in S3. That's why I thought of using S3FileIO. Does that sound reasonable?
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.
I understand your point, we clearly know that this should resolve to
S3FileIO
. In all other scenarios, though, we've trusted the Iceberg API to resolve correctly and I'd be happier to stick with that.I don't feel strongly about this however.
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.
In this context, I'm happy to have specify S3FileIO specified. I think in general though, we are leaning away from providing these "pre-configured" entrypoints for the user, and prefer they go through the generic catalog creation? In which case I would argue that
IcebergToolsS3
we might want to deprecate.