timsaucer commented on PR #962:
URL: 
https://github.com/apache/datafusion-python/pull/962#issuecomment-2538772977

   So doing a little testing to see if this is necessary:
   
   ```
   from datafusion import SessionContext, col, lit
   import pyarrow as pa
   import datetime
   ctx = SessionContext()
   
   df = ctx.from_pydict({
       "a": pa.array([1], type=pa.int64()),
       "date": pa.array([datetime.datetime.today()], type=pa.timestamp("us")),
   })
   
   df.show()
   print(df.schema())
   
   df = (
       df
       .with_column("b", col("a").cast(pa.int8()))
       .with_column("ms_date", col("date").cast(pa.timestamp("ms")))
   )
   
   df.show()
   print(df.schema())
   ```
   
   Produces:
   
   ```
   DataFrame()
   +---+----------------------------+
   | a | date                       |
   +---+----------------------------+
   | 1 | 2024-12-12T07:28:24.431099 |
   +---+----------------------------+
   a: int64
   date: timestamp[us]
   DataFrame()
   +---+----------------------------+---+-------------------------+
   | a | date                       | b | ms_date                 |
   +---+----------------------------+---+-------------------------+
   | 1 | 2024-12-12T07:28:24.431099 | 1 | 2024-12-12T07:28:24.431 |
   +---+----------------------------+---+-------------------------+
   a: int64
   date: timestamp[us]
   b: int8
   ms_date: timestamp[ms]
   ```
   
   So maybe we can use the existing method?


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to