Skip to content

Commit fcf9e97

Browse files
authored
GH-49231: [C++] Deprecate Feather reader and writer (#50321)
### Rationale for this change See #49231. Deprecate the Feather reader/writer and point users to the Arrow IPC file API. ### What changes are included in this PR? `ipc::feather::Reader::Open`, `ipc::feather::WriteTable` and the `WriteProperties` struct marked with `ARROW_DEPRECATED`, pointing users to `ipc::RecordBatchFileReader` and `ipc::MakeFileWriter`. Deprecation warnings supressed at the internal call sites: `feather.cc`, `feather_test.cc`, the R binding `r/src/feather.cpp` (R deprecation is in #49276), and the GLib binding (GLib deprecation is in #49673). ### Are these changes tested? `-Werror` build of arrow-feather-test passes locally. ### Are there any user-facing changes? No functional change, compile-time deprecation warning for `feather::Reader::Open`, `feather::WriteTable` or feather::WriteProperties. * GitHub Issue: #49231 Authored-by: Tadeja Kadunc <tadeja.kadunc@gmail.com> Signed-off-by: Antoine Pitrou <antoine@python.org>
1 parent 5044ee2 commit fcf9e97

7 files changed

Lines changed: 50 additions & 3 deletions

File tree

c_glib/arrow-glib/reader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,9 @@ GArrowFeatherFileReader *
781781
garrow_feather_file_reader_new(GArrowSeekableInputStream *file, GError **error)
782782
{
783783
auto arrow_random_access_file = garrow_seekable_input_stream_get_raw(file);
784+
ARROW_SUPPRESS_DEPRECATION_WARNING
784785
auto reader = arrow::ipc::feather::Reader::Open(arrow_random_access_file);
786+
ARROW_UNSUPPRESS_DEPRECATION_WARNING
785787
if (garrow::check(error, reader, "[feather-file-reader][new]")) {
786788
return garrow_feather_file_reader_new_raw(&(*reader));
787789
} else {

c_glib/arrow-glib/table.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,9 @@ garrow_table_validate_full(GArrowTable *table, GError **error)
772772
return garrow::check(error, arrow_table->ValidateFull(), "[table][validate-full]");
773773
}
774774

775+
// The Feather C++ API is deprecated; this GLib binding still wraps it.
776+
ARROW_SUPPRESS_DEPRECATION_WARNING
777+
775778
typedef struct GArrowFeatherWritePropertiesPrivate_
776779
{
777780
arrow::ipc::feather::WriteProperties properties;
@@ -932,6 +935,8 @@ garrow_table_write_as_feather(GArrowTable *table,
932935
return garrow::check(error, status, "[feather-write-file]");
933936
}
934937

938+
ARROW_UNSUPPRESS_DEPRECATION_WARNING
939+
935940
G_END_DECLS
936941

937942
GArrowTable *
@@ -948,9 +953,11 @@ garrow_table_get_raw(GArrowTable *table)
948953
return priv->table;
949954
}
950955

956+
ARROW_SUPPRESS_DEPRECATION_WARNING
951957
arrow::ipc::feather::WriteProperties *
952958
garrow_feather_write_properties_get_raw(GArrowFeatherWriteProperties *properties)
953959
{
954960
auto priv = GARROW_FEATHER_WRITE_PROPERTIES_GET_PRIVATE(properties);
955961
return &(priv->properties);
956962
}
963+
ARROW_UNSUPPRESS_DEPRECATION_WARNING

c_glib/arrow-glib/table.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ GARROW_EXTERN
3232
std::shared_ptr<arrow::Table>
3333
garrow_table_get_raw(GArrowTable *table);
3434

35+
ARROW_SUPPRESS_DEPRECATION_WARNING
3536
GARROW_EXTERN
3637
arrow::ipc::feather::WriteProperties *
3738
garrow_feather_write_properties_get_raw(GArrowFeatherWriteProperties *properties);
39+
ARROW_UNSUPPRESS_DEPRECATION_WARNING

cpp/src/arrow/ipc/feather.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,9 @@ class ReaderV2 : public Reader {
770770

771771
Result<std::shared_ptr<Reader>> Reader::Open(
772772
const std::shared_ptr<io::RandomAccessFile>& source) {
773+
ARROW_SUPPRESS_DEPRECATION_WARNING
773774
return Reader::Open(source, IpcReadOptions::Defaults());
775+
ARROW_UNSUPPRESS_DEPRECATION_WARNING
774776
}
775777

776778
Result<std::shared_ptr<Reader>> Reader::Open(
@@ -803,6 +805,9 @@ Result<std::shared_ptr<Reader>> Reader::Open(
803805
}
804806
}
805807

808+
// GCC warns about the deprecated type in these definitions, Clang doesn't
809+
ARROW_SUPPRESS_DEPRECATION_WARNING
810+
806811
WriteProperties WriteProperties::Defaults() {
807812
WriteProperties result;
808813
#ifdef ARROW_WITH_LZ4
@@ -832,6 +837,8 @@ Status WriteTable(const Table& table, io::OutputStream* dst,
832837
}
833838
}
834839

840+
ARROW_UNSUPPRESS_DEPRECATION_WARNING
841+
835842
} // namespace feather
836843
} // namespace ipc
837844
} // namespace arrow

cpp/src/arrow/ipc/feather.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "arrow/ipc/options.h"
2929
#include "arrow/type_fwd.h"
3030
#include "arrow/util/compression.h"
31+
#include "arrow/util/macros.h"
3132
#include "arrow/util/visibility.h"
3233

3334
namespace arrow {
@@ -54,6 +55,9 @@ static constexpr const int kFeatherV2Version = 3;
5455

5556
/// \class Reader
5657
/// \brief An interface for reading columns from Feather files
58+
///
59+
/// \note Deprecated in 26.0.0. Feather V2 is the Arrow IPC file format;
60+
/// use arrow::ipc::RecordBatchFileReader instead.
5761
class ARROW_EXPORT Reader {
5862
public:
5963
virtual ~Reader() = default;
@@ -62,6 +66,8 @@ class ARROW_EXPORT Reader {
6266
///
6367
/// \param[in] source a RandomAccessFile instance
6468
/// \return the table reader
69+
/// \deprecated Deprecated in 26.0.0. Use arrow::ipc::RecordBatchFileReader instead.
70+
ARROW_DEPRECATED("Deprecated in 26.0.0. Use arrow::ipc::RecordBatchFileReader instead.")
6571
static Result<std::shared_ptr<Reader>> Open(
6672
const std::shared_ptr<io::RandomAccessFile>& source);
6773

@@ -71,6 +77,8 @@ class ARROW_EXPORT Reader {
7177
/// \param[in] source a RandomAccessFile instance
7278
/// \param[in] options IPC Read options
7379
/// \return the table reader
80+
/// \deprecated Deprecated in 26.0.0. Use arrow::ipc::RecordBatchFileReader instead.
81+
ARROW_DEPRECATED("Deprecated in 26.0.0. Use arrow::ipc::RecordBatchFileReader instead.")
7482
static Result<std::shared_ptr<Reader>> Open(
7583
const std::shared_ptr<io::RandomAccessFile>& source, const IpcReadOptions& options);
7684

@@ -107,7 +115,10 @@ class ARROW_EXPORT Reader {
107115
std::shared_ptr<Table>* out) = 0;
108116
};
109117

110-
struct ARROW_EXPORT WriteProperties {
118+
/// \deprecated Deprecated in 26.0.0. Feather V2 is the Arrow IPC file format;
119+
/// use arrow::ipc::MakeFileWriter with arrow::ipc::IpcWriteOptions instead.
120+
struct ARROW_DEPRECATED("Deprecated in 26.0.0. Use arrow::ipc::IpcWriteOptions instead.")
121+
ARROW_EXPORT WriteProperties {
111122
static WriteProperties Defaults();
112123

113124
static WriteProperties DefaultsV1() {
@@ -141,9 +152,15 @@ struct ARROW_EXPORT WriteProperties {
141152
int compression_level = ::arrow::util::kUseDefaultCompressionLevel;
142153
};
143154

155+
// Only suppresses the deprecated WriteProperties in the default argument
156+
ARROW_SUPPRESS_DEPRECATION_WARNING
157+
/// \deprecated Deprecated in 26.0.0. Feather V2 is the Arrow IPC file format;
158+
/// use arrow::ipc::MakeFileWriter instead.
159+
ARROW_DEPRECATED("Deprecated in 26.0.0. Use arrow::ipc::MakeFileWriter instead.")
144160
ARROW_EXPORT
145161
Status WriteTable(const Table& table, io::OutputStream* dst,
146162
const WriteProperties& properties = WriteProperties::Defaults());
163+
ARROW_UNSUPPRESS_DEPRECATION_WARNING
147164

148165
} // namespace feather
149166
} // namespace ipc

cpp/src/arrow/ipc/feather_test.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ using internal::checked_cast;
4444
namespace ipc {
4545
namespace feather {
4646

47+
// These tests intentionally exercise the deprecated Feather API, suppressing
48+
// the deprecation warnings for the whole file.
49+
ARROW_SUPPRESS_DEPRECATION_WARNING
50+
4751
struct TestParam {
4852
TestParam(int arg_version,
4953
Compression::type arg_compression = Compression::UNCOMPRESSED)
@@ -383,6 +387,8 @@ TEST_P(TestFeatherRoundTrip, RoundTrip) {
383387
INSTANTIATE_TEST_SUITE_P(FeatherRoundTripTests, TestFeatherRoundTrip,
384388
::testing::ValuesIn(kBatchCases));
385389

390+
ARROW_UNSUPPRESS_DEPRECATION_WARNING
391+
386392
} // namespace feather
387393
} // namespace ipc
388394
} // namespace arrow

r/src/feather.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ void ipc___WriteFeather__Table(const std::shared_ptr<arrow::io::OutputStream>& s
2929
const std::shared_ptr<arrow::Table>& table, int version,
3030
int chunk_size, arrow::Compression::type compression,
3131
int compression_level) {
32+
ARROW_SUPPRESS_DEPRECATION_WARNING
3233
auto properties = arrow::ipc::feather::WriteProperties::Defaults();
3334
properties.version = version;
3435
properties.chunksize = chunk_size;
@@ -37,6 +38,7 @@ void ipc___WriteFeather__Table(const std::shared_ptr<arrow::io::OutputStream>& s
3738
properties.compression_level = compression_level;
3839
}
3940
StopIfNotOk(arrow::ipc::feather::WriteTable(*table, stream.get(), properties));
41+
ARROW_UNSUPPRESS_DEPRECATION_WARNING
4042
}
4143

4244
// ----------- Reader
@@ -82,8 +84,12 @@ std::shared_ptr<arrow::Table> ipc___feather___Reader__Read(
8284
// [[arrow::export]]
8385
std::shared_ptr<arrow::ipc::feather::Reader> ipc___feather___Reader__Open(
8486
const std::shared_ptr<arrow::io::RandomAccessFile>& stream) {
85-
auto result = RunWithCapturedRIfPossible<std::shared_ptr<arrow::ipc::feather::Reader>>(
86-
[&]() { return arrow::ipc::feather::Reader::Open(stream); });
87+
auto result =
88+
RunWithCapturedRIfPossible<std::shared_ptr<arrow::ipc::feather::Reader>>([&]() {
89+
ARROW_SUPPRESS_DEPRECATION_WARNING
90+
return arrow::ipc::feather::Reader::Open(stream);
91+
ARROW_UNSUPPRESS_DEPRECATION_WARNING
92+
});
8793
return ValueOrStop(result);
8894
}
8995

0 commit comments

Comments
 (0)