-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-17524: [C++] Correction for fields included when reading an ORC table #13962
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
Merged
pitrou
merged 16 commits into
apache:master
from
LouisClt:CorrectionForOrcIncludeIndices
Oct 18, 2022
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3b477d8
Correction for fields included when reading an ORC table
LouisClt 9df5886
Merge branch 'apache:master' into CorrectionForOrcIncludeIndices
LouisClt 34b8c4b
Change tests to reflect new behaviour
LouisClt bb48ed3
Correct ruby tests
LouisClt e7329e6
Update c_glib/test/test-orc-file-reader.rb
LouisClt 82c9473
Fix indentation
LouisClt 313acc9
Add C++ test for selection of fields in ORC import
LouisClt 0c91f8c
Fix indentation and test
LouisClt b2b6c3a
Fix spaces+ indentation
LouisClt 6fb76be
Merge branch 'apache:master' into CorrectionForOrcIncludeIndices
LouisClt 8677539
Add another test with random data and improved field selection
LouisClt fc69b34
Fix
LouisClt 1224609
Merge branch 'apache:master' into CorrectionForOrcIncludeIndices
LouisClt d9c48f6
Fix test
LouisClt 3217212
Fix linter
LouisClt ec3b620
Validate output table
pitrou 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -226,7 +226,8 @@ std::shared_ptr<Table> GenerateRandomTable(const std::shared_ptr<Schema>& schema | |
|
|
||
| void AssertTableWriteReadEqual(const std::shared_ptr<Table>& input_table, | ||
| const std::shared_ptr<Table>& expected_output_table, | ||
| const int64_t max_size = kDefaultSmallMemStreamSize) { | ||
| const int64_t max_size = kDefaultSmallMemStreamSize, | ||
| std::vector<int>* opt_selected_read_indices = nullptr) { | ||
| EXPECT_OK_AND_ASSIGN(auto buffer_output_stream, | ||
| io::BufferOutputStream::Create(max_size)); | ||
| auto write_options = adapters::orc::WriteOptions(); | ||
|
|
@@ -250,7 +251,11 @@ void AssertTableWriteReadEqual(const std::shared_ptr<Table>& input_table, | |
| ASSERT_EQ(reader->GetCompression(), write_options.compression); | ||
| ASSERT_EQ(reader->GetCompressionSize(), write_options.compression_block_size); | ||
| ASSERT_EQ(reader->GetRowIndexStride(), write_options.row_index_stride); | ||
| EXPECT_OK_AND_ASSIGN(auto actual_output_table, reader->Read()); | ||
| EXPECT_OK_AND_ASSIGN(auto actual_output_table, | ||
| opt_selected_read_indices == nullptr | ||
| ? reader->Read() | ||
| : reader->Read(*opt_selected_read_indices)); | ||
| ASSERT_OK(actual_output_table->ValidateFull()); | ||
| AssertTablesEqual(*expected_output_table, *actual_output_table, false, false); | ||
| } | ||
|
|
||
|
|
@@ -451,6 +456,37 @@ TEST_F(TestORCWriterTrivialNoConversion, writeChunkless) { | |
| std::shared_ptr<Table> table = TableFromJSON(table_schema, {}); | ||
| AssertTableWriteReadEqual(table, table, kDefaultSmallMemStreamSize / 16); | ||
| } | ||
| TEST_F(TestORCWriterTrivialNoConversion, writeTrivialChunkAndSelectField) { | ||
| std::shared_ptr<Table> table = TableFromJSON(table_schema, {R"([])"}); | ||
| std::shared_ptr<Schema> schema_selected = | ||
| schema({field("int8", int8()), field("int32", int32())}); | ||
| std::shared_ptr<Table> table_selected = TableFromJSON(schema_selected, {R"([])"}); | ||
| std::vector<int> selected_indices = {1, 3}; | ||
| AssertTableWriteReadEqual(table, table_selected, kDefaultSmallMemStreamSize / 16, | ||
| &selected_indices); | ||
| } | ||
|
Member
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. Thanks for the test but:
|
||
| TEST_F(TestORCWriterTrivialNoConversion, writeFilledChunkAndSelectField) { | ||
| std::vector<int> selected_indices = {1, 7}; | ||
| random::RandomArrayGenerator rand(kRandomSeed); | ||
| std::shared_ptr<Schema> local_schema = schema({ | ||
| field("bool", boolean()), | ||
| field("int32", int32()), | ||
| field("int64", int64()), | ||
| field("float", float32()), | ||
| field("struct", struct_({field("a", utf8()), field("b", int64())})), | ||
| field("double", float64()), | ||
| field("date32", date32()), | ||
| field("ts3", timestamp(TimeUnit::NANO)), | ||
| field("string", utf8()), | ||
| field("binary", binary()), | ||
| }); | ||
| auto batch = rand.BatchOf(local_schema->fields(), 100); | ||
| std::shared_ptr<Table> table = Table::Make(local_schema, batch->columns()); | ||
| EXPECT_OK_AND_ASSIGN(auto table_selected, table->SelectColumns(selected_indices)); | ||
| AssertTableWriteReadEqual(table, table_selected, kDefaultSmallMemStreamSize, | ||
| &selected_indices); | ||
| } | ||
|
|
||
| class TestORCWriterTrivialWithConversion : public ::testing::Test { | ||
| public: | ||
| TestORCWriterTrivialWithConversion() { | ||
|
|
||
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.