Thomas-Hirsch opened a new issue, #15032:
URL: https://github.com/apache/arrow/issues/15032

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   I'm trying to build a tool to confirm that a given parquet file conforms to 
an expected schema with [our metadata 
format](https://github.com/moj-analytical-services/mojap-metadata). There 
appears to be a bug with how pyarrow converts dates, however.
   
   <details>
   <summary>I have a dummy dataset, called test.csv (expand to view)</summary>
   
   |my_int|animal |my_email                 |my_datetime        |my_date   |
   |------|-------|-------------------------|-------------------|----------|
   |16    |NA     |[email protected]       |2013-01-14 15:54:20|1993-09-27|
   |13    |cat    |[email protected]|2006-12-16 01:44:21|1989-04-08|
   |13    |dog    |[email protected]  |1972-06-19 11:22:59|2006-10-01|
   |18    |NA     |[email protected]|2009-07-11 00:45:28|1992-07-24|
   |10    |fish   |[email protected]    |1970-09-11 22:26:13|2011-11-30|
   |13    |cat    |[email protected]    |2018-09-18 16:18:37|1979-01-22|
   |16    |dog    |[email protected]    |2002-08-26 10:25:03|1981-03-27|
   |11    |dog    |[email protected]    |1989-02-26 16:33:37|2012-06-19|
   |19    |chicken|[email protected]  |1974-07-25 04:41:22|2003-11-06|
   |11    |chicken|[email protected]    |1992-04-03 09:47:30|1972-07-06|
   </details>
   
   I have a user-generated schema that resolves to this:
   ```
   my_int: int64
   animal: string
   my_email: string
   my_datetime: timestamp[s]
   my_date: date64[ms]
   ```
   
   However, the last column seems to be read by pyarrow as `date32[day]`, and 
won't cast otherwise:
   ```python
   import pyarrow as pa
   import pyarrow.parquet as pq
   
   table = pa.csv.read_csv("test.csv")
   table.cast(my_custom_schema)
   pq.write_table(table, "test.parquet")
   table_arrow_schema = 
pq.read_schema("tests/data/parquet_validator/table1.parquet")
   table_arrow_schema
   ```
   gives
   ```
   my_int: int64
   animal: string
   my_email: string
   my_datetime: timestamp[ms]
   my_date: date32[day]
   ```
   
   ### Component(s)
   
   Parquet, 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