[ 
https://issues.apache.org/jira/browse/ARROW-1440?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16153062#comment-16153062
 ] 

Wes McKinney commented on ARROW-1440:
-------------------------------------

[~xhochy] the result of reading this Parquet file is a malformed table.

I added a check to catch this rather than segfaulting:

{code}
In [3]: df = t.to_pandas()
---------------------------------------------------------------------------
ArrowInvalid                              Traceback (most recent call last)
<ipython-input-3-a8a2faa68d50> in <module>()
----> 1 df = t.to_pandas()

/home/wesm/code/arrow/python/pyarrow/table.pxi in pyarrow.lib.Table.to_pandas 
(/home/wesm/code/arrow/python/build/temp.linux-x86_64-3.5/lib.cxx:36275)()
    846         if nthreads is None:
    847             nthreads = cpu_count()
--> 848         mgr = pdcompat.table_to_blockmanager(options, self, memory_pool,
    849                                              nthreads)
    850         return pd.DataFrame(mgr)

/home/wesm/code/arrow/python/pyarrow/pandas_compat.py in 
table_to_blockmanager(options, table, memory_pool, nthreads)
    306             )
    307 
--> 308     result = lib.table_to_blocks(options, block_table, nthreads, 
memory_pool)
    309 
    310     blocks = []

/home/wesm/code/arrow/python/pyarrow/table.pxi in pyarrow.lib.table_to_blocks 
(/home/wesm/code/arrow/python/build/temp.linux-x86_64-3.5/lib.cxx:34410)()
    616     pool = maybe_unbox_memory_pool(memory_pool)
    617     with nogil:
--> 618         check_status(
    619             libarrow.ConvertTableToPandas(
    620                 options, c_table, nthreads, pool, &result_obj

/home/wesm/code/arrow/python/pyarrow/error.pxi in pyarrow.lib.check_status 
(/home/wesm/code/arrow/python/build/temp.linux-x86_64-3.5/lib.cxx:7719)()
     75         message = frombytes(status.message())
     76         if status.IsInvalid():
---> 77             raise ArrowInvalid(message)
     78         elif status.IsIOError():
     79             raise ArrowIOError(message)

ArrowInvalid: Column 4 named features_indices expected length 69 but got length 
1
{code}

The fourth column is a list but has a single entry with 69 values (the length 
of the table). So something is running foul in parquet-cpp (or in the Parquet 
file itself):

{code}
In [10]: t = 
pq.read_table('/home/wesm/Downloads/part-00000-6570e34b-b42c-4a39-8adf-21d3a97fb87d.snappy.parquet')

In [11]: len(t[4].data.chunk(0)[0])
Out[11]: 69
{code}

> [Python] Segmentation fault after loading parquet file to pandas dataframe
> --------------------------------------------------------------------------
>
>                 Key: ARROW-1440
>                 URL: https://issues.apache.org/jira/browse/ARROW-1440
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: Python
>    Affects Versions: 0.6.0
>         Environment: ubuntu 16.04.2
>            Reporter: Jarno Seppanen
>             Fix For: 0.7.0
>
>         Attachments: 
> part-00000-6570e34b-b42c-4a39-8adf-21d3a97fb87d.snappy.parquet
>
>
> Reading the attached parquet file into pandas dataframe and then using the 
> dataframe segfaults.
> {noformat}
> Python 3.5.3 |Continuum Analytics, Inc.| (default, Mar  6 2017, 11:58:13) 
> [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> 
> >>> import pyarrow
> >>> import pyarrow.parquet as pq
> >>> pyarrow.__version__
> '0.6.0'
> >>> import pandas as pd
> >>> pd.__version__
> '0.19.0'
> >>> df = 
> >>> pq.read_table('part-00000-6570e34b-b42c-4a39-8adf-21d3a97fb87d.snappy.parquet')
> >>>  \
> ...        .to_pandas()
> >>> len(df)
> 69
> >>> df.info()
> <class 'pandas.core.frame.DataFrame'>
> RangeIndex: 69 entries, 0 to 68
> Data columns (total 6 columns):
> label               69 non-null int32
> account_meta        69 non-null object
> features_type       69 non-null int32
> features_size       69 non-null int32
> features_indices    1 non-null object
> features_values     1 non-null object
> dtypes: int32(3), object(3)
> memory usage: 2.5+ KB
> >>> 
> >>> pd.concat([df, df])
> Segmentation fault (core dumped)
> {noformat}
> Actually just print(df) is enough to trigger the segfault



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to