You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/07/05 17:39:36 UTC

[GitHub] [arrow] rok commented on a diff in pull request #13454: ARROW-13612: [Python] Allow specifying a custom type for converting ExtensionScalar to python object

rok commented on code in PR #13454:
URL: https://github.com/apache/arrow/pull/13454#discussion_r914041248


##########
python/pyarrow/types.pxi:
##########
@@ -902,6 +902,18 @@ cdef class ExtensionType(BaseExtensionType):
         """
         return ExtensionArray
 
+    def scalar_as_py(self, scalar):
+        """Convert scalar to a Python type.
+
+        This method can be overridden in subclasses to customize what type
+        scalars are converted to.
+
+        Parameters
+        ----------
+        scalar : pyarrow.ExtensionScalar
+          The scalar to be converted to a Python object.
+        """
+        return scalar.as_py() if scalar is not None else None

Review Comment:
   > This should no longer be able to be None right?
   >
   > Also is the type ExtensionScalar? It seems we pass the underlying value right?
   
   Scalar shouldn't be None, but the return value could I think. Changed, please see if it makes sense.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org