pitrou commented on a change in pull request #12348:
URL: https://github.com/apache/arrow/pull/12348#discussion_r800901189
##########
File path: cpp/src/arrow/python/python_to_arrow.cc
##########
@@ -416,8 +416,18 @@ class PyValue {
}
RETURN_NOT_OK(PopulateMonthDayNano<MonthDayNanoField::kNanoseconds>::Field(
obj, &output.nanoseconds, &found_attrs));
-
if (ARROW_PREDICT_FALSE(!found_attrs) && !is_date_offset) {
+ if (PyTuple_Check(obj) && PyTuple_Size(obj) == 3) {
+ RETURN_NOT_OK(internal::CIntFromPython(PyTuple_GET_ITEM(obj, 0),
&output.months,
+ "Months (Index 0) index to
large"));
+ RETURN_NOT_OK(internal::CIntFromPython(PyTuple_GET_ITEM(obj, 1),
&output.days,
+ "Days (Index 1) index to
large"));
+ RETURN_NOT_OK(internal::CIntFromPython(PyTuple_GET_ITEM(obj, 2),
+ &output.nanoseconds,
+ "Nanoseconds (Index 2) index to
large"));
+ return output;
+ }
+
// date_offset can have zero fields.
Review comment:
Move this comment before the enclosing `if`?
##########
File path: cpp/src/arrow/python/python_to_arrow.cc
##########
@@ -416,8 +416,18 @@ class PyValue {
}
RETURN_NOT_OK(PopulateMonthDayNano<MonthDayNanoField::kNanoseconds>::Field(
obj, &output.nanoseconds, &found_attrs));
-
if (ARROW_PREDICT_FALSE(!found_attrs) && !is_date_offset) {
+ if (PyTuple_Check(obj) && PyTuple_Size(obj) == 3) {
+ RETURN_NOT_OK(internal::CIntFromPython(PyTuple_GET_ITEM(obj, 0),
&output.months,
+ "Months (Index 0) index to
large"));
+ RETURN_NOT_OK(internal::CIntFromPython(PyTuple_GET_ITEM(obj, 1),
&output.days,
+ "Days (Index 1) index to
large"));
+ RETURN_NOT_OK(internal::CIntFromPython(PyTuple_GET_ITEM(obj, 2),
+ &output.nanoseconds,
+ "Nanoseconds (Index 2) index to
large"));
Review comment:
Wording suggestion:
```suggestion
RETURN_NOT_OK(internal::CIntFromPython(PyTuple_GET_ITEM(obj, 0),
&output.months,
"Months (tuple item #0) too
large"));
RETURN_NOT_OK(internal::CIntFromPython(PyTuple_GET_ITEM(obj, 1),
&output.days,
"Days (tuple item #1) too
large"));
RETURN_NOT_OK(internal::CIntFromPython(PyTuple_GET_ITEM(obj, 2),
&output.nanoseconds,
"Nanoseconds (tuple item #2)
too large"));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]