@@ -33,32 +33,38 @@ PandasOutputFrame::~PandasOutputFrame() {
33
33
if (frame_.is_null ())
34
34
return ;
35
35
36
- for (auto &column : frame_.columns ()) {
37
- auto dt = column->type ().data_type ();
38
- if (is_dynamic_string_type (dt) && column->is_inflated ()) {
39
- auto column_data = column->data ();
40
- column_data.type ().visit_tag ([&](auto type_desc_tag) {
41
- using TDT = decltype (type_desc_tag);
42
- constexpr auto td = TypeDescriptor (type_desc_tag);
43
- if constexpr (is_object_type (TypeDescriptor (type_desc_tag))) {
44
- if constexpr (is_array_type (td)) {
45
- auto it = column_data.buffer ().iterator (sizeof (PyObject*));
46
- while (!it.finished ()) {
47
- util::check (reinterpret_cast <PyObject*>(it.value ()) != nullptr , " Can't delete null item" );
48
- Py_DECREF (reinterpret_cast <PyObject*>(it.value ()));
49
- it.next ();
50
- }
51
- } else {
52
- while (auto block = column_data.next <TDT>()) {
53
- for (auto item : *block) {
54
- util::check (reinterpret_cast <PyObject *>(item) != nullptr , " Can't delete null item" );
55
- Py_DECREF (reinterpret_cast <PyObject *>(item));
36
+ try {
37
+ for (auto &column : frame_.columns ()) {
38
+ auto dt = column->type ().data_type ();
39
+ if (is_dynamic_string_type (dt) && column->is_inflated ()) {
40
+ auto column_data = column->data ();
41
+ column_data.type ().visit_tag ([&](auto type_desc_tag) {
42
+ using TDT = decltype (type_desc_tag);
43
+ constexpr auto td = TypeDescriptor (type_desc_tag);
44
+ if constexpr (is_object_type (td)) {
45
+ if constexpr (is_array_type (td)) {
46
+ auto it = column_data.buffer ().iterator (sizeof (PyObject*));
47
+ while (!it.finished ()) {
48
+ util::check (reinterpret_cast <PyObject*>(it.value ()) != nullptr , " Can't delete null item" );
49
+ Py_DECREF (reinterpret_cast <PyObject*>(it.value ()));
50
+ it.next ();
51
+ }
52
+ } else if constexpr (!is_arrow_output_only_type (td)) {
53
+ while (auto block = column_data.next <TDT>()) {
54
+ for (auto item : *block) {
55
+ util::check (reinterpret_cast <PyObject *>(item) != nullptr , " Can't delete null item" );
56
+ Py_DECREF (reinterpret_cast <PyObject *>(item));
57
+ }
56
58
}
59
+ } else {
60
+ internal::raise<ErrorCode::E_ASSERTION_FAILURE>(" Unexpected arrow output format seen in PandasOutputFrame" );
57
61
}
58
62
}
59
- }
60
- });
63
+ });
64
+ }
61
65
}
66
+ } catch (const std::exception &e) {
67
+ log::version ().warn (" Exception in PandasOutputFrame destructor: {}" , e.what ());
62
68
}
63
69
}
64
70
0 commit comments