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 2020/06/25 14:31:54 UTC

[GitHub] [arrow] kszucs commented on a change in pull request #7519: ARROW-9017: [C++][Python] Refactor scalar bindings

kszucs commented on a change in pull request #7519:
URL: https://github.com/apache/arrow/pull/7519#discussion_r445603562



##########
File path: python/pyarrow/util.py
##########
@@ -41,6 +41,24 @@ def wrapper(*args, **kwargs):
     return wrapper
 
 
+def _deprecate_class(old_name, new_class, next_version,
+                     instancecheck=True):
+    """
+    Raise warning if a deprecated class is used in an isinstance check.

Review comment:
       > Really nice!
   > 
   > Could we add a `is_valid` attribute to the python scalar as well? Now the only way to check for a null value is to do `.as_py() is None` ?
   Definitely!
   > 
   > Might not be related to the changes in this PR, but reviewing this triggered me to test scalar casting:
   > 
   > ```
   > In [2]: s = pa.scalar(pd.Timestamp("2012-01-01")) 
   >    ...:  
   >    ...: import pyarrow.compute as pc 
   >    ...: pc.cast(s, pa.timestamp('ns'))  
   > ../src/arrow/compute/kernels/scalar_cast_temporal.cc:130:  Check failed: (batch[0].kind()) == (Datum::ARRAY) 
   > ...
   > Aborted (core dumped)
   > ```
   I think the cast kernel doesn't support scalars yet, on the other hand the scalars have custom `CastTo` implementation which we may want to remove in favor of `compute.Cast`?
   
   cc @bkietz 
   
   

##########
File path: python/pyarrow/util.py
##########
@@ -41,6 +41,24 @@ def wrapper(*args, **kwargs):
     return wrapper
 
 
+def _deprecate_class(old_name, new_class, next_version,
+                     instancecheck=True):
+    """
+    Raise warning if a deprecated class is used in an isinstance check.

Review comment:
       > Really nice!
   > 
   > Could we add a `is_valid` attribute to the python scalar as well? Now the only way to check for a null value is to do `.as_py() is None` ?
   
   Definitely!
   
   > 
   > Might not be related to the changes in this PR, but reviewing this triggered me to test scalar casting:
   > 
   > ```
   > In [2]: s = pa.scalar(pd.Timestamp("2012-01-01")) 
   >    ...:  
   >    ...: import pyarrow.compute as pc 
   >    ...: pc.cast(s, pa.timestamp('ns'))  
   > ../src/arrow/compute/kernels/scalar_cast_temporal.cc:130:  Check failed: (batch[0].kind()) == (Datum::ARRAY) 
   > ...
   > Aborted (core dumped)
   > ```
   I think the cast kernel doesn't support scalars yet, on the other hand the scalars have custom `CastTo` implementation which we may want to remove in favor of `compute.Cast`?
   
   cc @bkietz 
   
   




----------------------------------------------------------------
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:
users@infra.apache.org