Skip to content

Commit 984519d

Browse files
authored
GH-45129: [Python][C++] Fix usage of deprecated C++ functionality on pyarrow (#45189)
### Rationale for this change We are using two C++ deprecated APIs: - we are using decimal instead of smallest_decimal - we are using Arrow:Status on GetRecordBatchReader instead of Arrow::Result ### What changes are included in this PR? Update code to use non deprecated functions. ### Are these changes tested? Yes via CI with existing tests. ### Are there any user-facing changes? No * GitHub Issue: #45129 Authored-by: Raúl Cumplido <[email protected]> Signed-off-by: Raúl Cumplido <[email protected]>
1 parent 59c5738 commit 984519d

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

python/pyarrow/_parquet.pxd

+3-5
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,9 @@ cdef extern from "parquet/arrow/reader.h" namespace "parquet::arrow" nogil:
484484
const vector[int]& column_indices,
485485
shared_ptr[CTable]* out)
486486

487-
CStatus GetRecordBatchReader(const vector[int]& row_group_indices,
488-
const vector[int]& column_indices,
489-
unique_ptr[CRecordBatchReader]* out)
490-
CStatus GetRecordBatchReader(const vector[int]& row_group_indices,
491-
unique_ptr[CRecordBatchReader]* out)
487+
CResult[unique_ptr[CRecordBatchReader]] GetRecordBatchReader(const vector[int]& row_group_indices,
488+
const vector[int]& column_indices)
489+
CResult[unique_ptr[CRecordBatchReader]] GetRecordBatchReader(const vector[int]& row_group_indices)
492490

493491
CStatus ReadTable(shared_ptr[CTable]* out)
494492
CStatus ReadTable(const vector[int]& column_indices,

python/pyarrow/_parquet.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1616,16 +1616,16 @@ cdef class ParquetReader(_Weakrefable):
16161616
for index in column_indices:
16171617
c_column_indices.push_back(index)
16181618
with nogil:
1619-
check_status(
1619+
recordbatchreader = GetResultValue(
16201620
self.reader.get().GetRecordBatchReader(
1621-
c_row_groups, c_column_indices, &recordbatchreader
1621+
c_row_groups, c_column_indices
16221622
)
16231623
)
16241624
else:
16251625
with nogil:
1626-
check_status(
1626+
recordbatchreader = GetResultValue(
16271627
self.reader.get().GetRecordBatchReader(
1628-
c_row_groups, &recordbatchreader
1628+
c_row_groups
16291629
)
16301630
)
16311631

python/pyarrow/src/arrow/python/python_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ Status TestDecimal128OverflowFails() {
663663
ASSERT_EQ(38, metadata.precision());
664664
ASSERT_EQ(1, metadata.scale());
665665

666-
auto type = ::arrow::decimal(38, 38);
666+
auto type = ::arrow::smallest_decimal(38, 38);
667667
const auto& decimal_type = checked_cast<const DecimalType&>(*type);
668668
ASSERT_RAISES(Invalid,
669669
internal::DecimalFromPythonDecimal(python_decimal, decimal_type, &value));
@@ -689,7 +689,7 @@ Status TestDecimal256OverflowFails() {
689689
ASSERT_EQ(76, metadata.precision());
690690
ASSERT_EQ(1, metadata.scale());
691691

692-
auto type = ::arrow::decimal(76, 76);
692+
auto type = ::arrow::smallest_decimal(76, 76);
693693
const auto& decimal_type = checked_cast<const DecimalType&>(*type);
694694
ASSERT_RAISES(Invalid,
695695
internal::DecimalFromPythonDecimal(python_decimal, decimal_type, &value));

0 commit comments

Comments
 (0)