pitrou commented on a change in pull request #10591:
URL: https://github.com/apache/arrow/pull/10591#discussion_r658129744
##########
File path: python/pyarrow/scalar.pxi
##########
@@ -652,21 +649,42 @@ cdef class StructScalar(Scalar, collections.abc.Mapping):
try:
return Scalar.wrap(GetResultValue(sp.field(ref)))
- except ArrowInvalid:
+ except ArrowInvalid as exc:
if isinstance(key, int):
- raise IndexError(key)
+ raise IndexError(key) from exc
else:
- raise KeyError(key)
+ raise KeyError(key) from exc
def as_py(self):
"""
Return this value as a Python dict.
"""
if self.is_valid:
- return {k: v.as_py() for k, v in self.items()}
+ try:
+ return {k: self[k].as_py() for k in self.keys()}
Review comment:
`return dict(self.items())`?
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]