llama90 commented on code in PR #40116:
URL: https://github.com/apache/arrow/pull/40116#discussion_r1506068298


##########
python/pyarrow/tests/pyarrow_cython_example.pyx:
##########
@@ -42,14 +42,21 @@ def cast_scalar(scalar, to_type):
     cdef:
         shared_ptr[CScalar] c_scalar
         shared_ptr[CDataType] c_type
-        CResult[shared_ptr[CScalar]] c_result
+        CCastOptions cast_options
+        CExecContext * ctx = NULL
+        CDatum c_datum
+        CTypeHolder c_type_holder
+        CResult[CDatum] c_cast_result
 
     c_scalar = pyarrow_unwrap_scalar(scalar)
     if c_scalar.get() == NULL:
         raise TypeError("not a scalar")
     c_type = pyarrow_unwrap_data_type(to_type)
     if c_type.get() == NULL:
         raise TypeError("not a type")
-    c_result = c_scalar.get().CastTo(c_type)
-    c_scalar = GetResultValue(c_result)
-    return pyarrow_wrap_scalar(c_scalar)
+
+    c_datum = CDatum(c_scalar)
+    c_type_holder = CTypeHolder(c_type)
+    c_cast_result = Cast(c_datum, c_type_holder, cast_options, ctx)

Review Comment:
   As you mentioned, I tried fixing it. Does it match the intention?



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

Reply via email to