You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/10/12 16:08:32 UTC

[GitHub] [arrow] lf-shaw opened a new issue #8446: [python] crashed when filter pyarrow.dataset on category field

lf-shaw opened a new issue #8446:
URL: https://github.com/apache/arrow/issues/8446


   I wanna filter dataset on some (pandas) category field, but python crashed.  Some sample code as follows
   ```python
   import pandas as pd
   
   import pyarrow as pa
   import pyarrow.parquet as pq
   import pyarrow.dataset as ds
   
   # B is category
   df = pd.DataFrame({'A': range(4), 'B': list('bccd')})
   df['B'] = df['B'].astype('category')
   
   # save to parquet file
   table = pa.Table.from_pandas(df)
   pq.write_table(table, 'test.parquet')
   
   # read with dataset
   dataset = ds.dataset('test.parquet')
   
   # it's ok
   dataset.to_table().to_pandas()
   
   # it's ok
   dataset.to_table(filter=ds.field('A') > 2).to_pandas()
   
   # it crashed
   dataset.to_table(filter=ds.field('B') == 'b').to_pandas()
   ```
   the crash message
   
   ```sh
   ValueOrDie called on an error: Type error: Cannot compare scalars of differing type: dictionary<values=string, indices=int32, ordered=0> vs string
   ```
   
   I know in C++ `arrow::DictionaryArray` of course cannot comapre with string. But I wanna know is there any possible to filter on category field in python?
   
   Thanks for your attention, and Thanks for this brilliant lib.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] lf-shaw closed issue #8446: [python] crashed when filter pyarrow.dataset on category field

Posted by GitBox <gi...@apache.org>.
lf-shaw closed issue #8446:
URL: https://github.com/apache/arrow/issues/8446


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] lf-shaw commented on issue #8446: [python] crashed when filter pyarrow.dataset on category field

Posted by GitBox <gi...@apache.org>.
lf-shaw commented on issue #8446:
URL: https://github.com/apache/arrow/issues/8446#issuecomment-707394377


   It's cool! 
   Thanks again.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] jorisvandenbossche commented on issue #8446: [python] crashed when filter pyarrow.dataset on category field

Posted by GitBox <gi...@apache.org>.
jorisvandenbossche commented on issue #8446:
URL: https://github.com/apache/arrow/issues/8446#issuecomment-707232146


   @lf-shaw yes, this is a known bug with the current dataset implementation. But it has been fixed in the meantime (https://issues.apache.org/jira/browse/ARROW-10008), and the above code snippet works on master / will work in pyarrow 2.0 (to be released in a few days)


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org