jorisvandenbossche opened a new issue, #36323:
URL: https://github.com/apache/arrow/issues/36323

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   Currently, the repr of the TimestampScalar (well, of scalars in general) 
essentially uses the repr of the Python object. For TimestampScalar, this thus 
fails if this conversion fails, such as for timestamps that are outside of the 
range of `datetime.datetime` ([1-9999]):
   
   ```
   >>> res = pa.scalar("0000-01-01").cast(pa.timestamp("s"))
   >>>type(res)
   pyarrow.lib.TimestampScalar
   >>> repr(res)
   ...
   File 
~/miniconda3/envs/dev39/lib/python3.9/site-packages/pyarrow/scalar.pxi:117, in 
pyarrow.lib.Scalar.__repr__()
   
   File 
~/miniconda3/envs/dev39/lib/python3.9/site-packages/pyarrow/scalar.pxi:521, in 
pyarrow.lib.TimestampScalar.as_py()
   
   File 
~/miniconda3/envs/dev39/lib/python3.9/site-packages/pyarrow/scalar.pxi:437, in 
pyarrow.lib._datetime_from_int()
   
   OverflowError: date value out of range
   
   >>> pc.strftime(res)
   <pyarrow.StringScalar: '0000-01-01T00:00:00'>
   ```
   
   Our generic Scalar `__repr__` implementation:
   
   
https://github.com/apache/arrow/blob/11b140a734a516e436adaddaeb35d23f30dcce44/python/pyarrow/scalar.pxi#L117-L120
   
   I think for Timestamps we should just convert to a string repr ourselves 
(`strftime`, or our own pretty printer as is used for the Array repr)
   
   ### Component(s)
   
   Python


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