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 2021/08/11 08:32:09 UTC

[GitHub] [arrow] jorisvandenbossche commented on a change in pull request #10904: ARROW-13541: [C++][Python] Implement ExtensionScalar

jorisvandenbossche commented on a change in pull request #10904:
URL: https://github.com/apache/arrow/pull/10904#discussion_r686606690



##########
File path: python/pyarrow/scalar.pxi
##########
@@ -838,6 +843,67 @@ cdef class UnionScalar(Scalar):
         return sp.type_code
 
 
+cdef class ExtensionScalar(Scalar):
+    """
+    Concrete class for Extension scalars.
+    """
+
+    @property
+    def value(self):
+        """
+        Return storage value as a scalar.
+        """
+        cdef CExtensionScalar* sp = <CExtensionScalar*> self.wrapped.get()
+        return Scalar.wrap(sp.value) if sp.is_valid else None

Review comment:
       This could also be a null scalar of the storage type?

##########
File path: python/pyarrow/scalar.pxi
##########
@@ -838,6 +843,67 @@ cdef class UnionScalar(Scalar):
         return sp.type_code
 
 
+cdef class ExtensionScalar(Scalar):
+    """
+    Concrete class for Extension scalars.
+    """
+
+    @property
+    def value(self):
+        """
+        Return storage value as a scalar.
+        """
+        cdef CExtensionScalar* sp = <CExtensionScalar*> self.wrapped.get()
+        return Scalar.wrap(sp.value) if sp.is_valid else None
+
+    def as_py(self):
+        """
+        Return this scalar as a Python object.
+        """
+        # XXX should there be a hook to wrap the result in a custom class?

Review comment:
       Similarly as we have `__arrow_ext_class__` for using an ExtensionArray subclass for the array object, we could indeed have a way to specify a custom scalar wrapper (but that's also fine to leave as a future enhancement I think)




-- 
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