AlenkaF commented on code in PR #35395:
URL: https://github.com/apache/arrow/pull/35395#discussion_r1191511961
##########
python/pyarrow/tests/test_scalars.py:
##########
@@ -295,6 +295,35 @@ def test_cast():
pa.scalar('foo').cast('int32')
+def test_cast_timestamp_to_string():
+ # GH-35370
+ pytest.importorskip("pytz")
+ import pytz
+ dt = datetime.datetime(2000, 1, 1, 0, 0, 0, tzinfo=pytz.utc)
+ ts = pa.scalar(dt, type=pa.timestamp("ns", tz="UTC"))
+ assert ts.cast(pa.string()) == pa.scalar('2000-01-01 00:00:00.000000000Z')
+
+
+def test_cast_float_to_int():
+ # GH-35040
+ float_scalar = pa.scalar(1.5, type=pa.float64())
+ unsafe_cast = float_scalar.cast(pa.int64(), safe=False)
+ expected_unsafe_cast = pa.scalar(1, type=pa.int64())
+ assert unsafe_cast == expected_unsafe_cast
+ with pytest.raises(pa.ArrowInvalid):
+ float_scalar.cast(pa.int64(), safe=True)
+
+
+def test_cast_int_to_float():
+ # GH-34901
Review Comment:
Ok, great 👍
--
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]