Skip to content
Closed
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
4 changes: 3 additions & 1 deletion cpp/src/arrow/adapters/orc/adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,9 @@ class ORCFileWriter::Impl {
}

Status Close() {
writer_->close();
if (writer_) {
writer_->close();
}
return Status::OK();
}

Expand Down
17 changes: 17 additions & 0 deletions cpp/src/arrow/adapters/orc/adapter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,23 @@ TEST(TestAdapterRead, ReadIntAndStringFileMultipleStripes) {

// Trivial

class TestORCWriterTrivialNoWrite : public ::testing::Test {};
TEST_F(TestORCWriterTrivialNoWrite, noWrite) {
EXPECT_OK_AND_ASSIGN(auto buffer_output_stream,
io::BufferOutputStream::Create(kDefaultSmallMemStreamSize / 16));
auto write_options = adapters::orc::WriteOptions();
#ifdef ARROW_WITH_SNAPPY
write_options.compression = Compression::SNAPPY;
#else
write_options.compression = Compression::UNCOMPRESSED;
#endif
write_options.file_version = adapters::orc::FileVersion(0, 11);
write_options.compression_block_size = 32768;
write_options.row_index_stride = 5000;
EXPECT_OK_AND_ASSIGN(auto writer, adapters::orc::ORCFileWriter::Open(
buffer_output_stream.get(), write_options));
ARROW_EXPECT_OK(writer->Close());
}
class TestORCWriterTrivialNoConversion : public ::testing::Test {
public:
TestORCWriterTrivialNoConversion() {
Expand Down
21 changes: 21 additions & 0 deletions python/pyarrow/tests/test_orc.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,3 +613,24 @@ def test_column_selection(tempdir):

with pytest.raises(ValueError):
orc_file.read(columns=[5])


def test_wrong_usage_orc_writer(tempdir):
from pyarrow import orc

path = str(tempdir / 'test.orc')
with orc.ORCWriter(path) as writer:
with pytest.raises(AttributeError):
writer.test()


def test_orc_writer_with_null_arrays(tempdir):
from pyarrow import orc
import pyarrow as pa

path = str(tempdir / 'test.orc')
a = pa.array([1, None, 3, None])
b = pa.array([None, None, None, None])
table = pa.table({"int64": a, "utf8": b})
with pytest.raises(pa.ArrowNotImplementedError):
orc.write_table(table, path)