AlenkaF commented on code in PR #55811:
URL: https://github.com/apache/arrow/pull/55811#discussion_r4739265139
##########
python/pyarrow/scalar.pxi:
##########
@@ -904,6 +904,80 @@ cdef class DurationScalar(Scalar):
return datetime.timedelta(microseconds=sp.value // 1000)
+cdef class MonthIntervalScalar(Scalar):
+ """
+ Concrete class for month interval scalars.
+ """
+
+ def __repr__(self):
+ return '<pyarrow.{}: {}>'.format(
+ self.__class__.__name__, frombytes(self.wrapped.get().ToString())
+ )
+
+ def __str__(self):
+ return frombytes(self.wrapped.get().ToString())
+
+ def as_py(self, *, maps_as_pydicts=None):
+ """
+ Return this value as a Python integer.
+
+ Parameters
+ ----------
+ maps_as_pydicts : str, optional, default `None`
+ Valid values are `None`, 'lossy', or 'strict'.
+ This parameter is ignored for non-nested Scalars.
+
+ Returns
+ -------
+ int
+ """
+ cdef:
+ CMonthIntervalScalar* scalar
+ scalar = <CMonthIntervalScalar*>self.wrapped.get()
+
+ if not scalar.is_valid:
+ return None
+
+ return scalar.value
+
+
+cdef class DayTimeIntervalScalar(Scalar):
+ """
+ Concrete class for day-time interval scalars.
+ """
+
+ def __repr__(self):
+ return '<pyarrow.{}: {}>'.format(
+ self.__class__.__name__, frombytes(self.wrapped.get().ToString())
+ )
+
+ def __str__(self):
+ return frombytes(self.wrapped.get().ToString())
+
+ def as_py(self, *, maps_as_pydicts=None):
+ """
+ Return this value as a tuple of Python integers.
+
+ Parameters
+ ----------
+ maps_as_pydicts : str, optional, default `None`
+ Valid values are `None`, 'lossy', or 'strict'.
+ This parameter is ignored for non-nested Scalars.
+
+ Returns
+ -------
+ tuple
+ """
+ cdef:
+ CDayTimeIntervalScalar* scalar
+ scalar = <CDayTimeIntervalScalar*>self.wrapped.get()
+
+ if not scalar.is_valid:
+ return None
+
+ return (scalar.value.days, scalar.value.milliseconds)
Review Comment:
Done:
https://github.com/apache/arrow/pull/55811/commits/888cd4ce48007116439329e9a685f3756ef640fa
The inference/creating an array from Python will be done in a follow-up.
##########
python/pyarrow/scalar.pxi:
##########
@@ -904,6 +904,80 @@ cdef class DurationScalar(Scalar):
return datetime.timedelta(microseconds=sp.value // 1000)
+cdef class MonthIntervalScalar(Scalar):
+ """
+ Concrete class for month interval scalars.
+ """
+
+ def __repr__(self):
+ return '<pyarrow.{}: {}>'.format(
+ self.__class__.__name__, frombytes(self.wrapped.get().ToString())
+ )
+
+ def __str__(self):
+ return frombytes(self.wrapped.get().ToString())
+
+ def as_py(self, *, maps_as_pydicts=None):
+ """
+ Return this value as a Python integer.
+
+ Parameters
+ ----------
+ maps_as_pydicts : str, optional, default `None`
+ Valid values are `None`, 'lossy', or 'strict'.
+ This parameter is ignored for non-nested Scalars.
+
+ Returns
+ -------
+ int
+ """
+ cdef:
+ CMonthIntervalScalar* scalar
+ scalar = <CMonthIntervalScalar*>self.wrapped.get()
+
+ if not scalar.is_valid:
+ return None
+
+ return scalar.value
Review Comment:
Done:
https://github.com/apache/arrow/pull/55811/commits/888cd4ce48007116439329e9a685f3756ef640fa
--
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]