diff --git a/python/cudf/cudf/_lib/parquet.pyx b/python/cudf/cudf/_lib/parquet.pyx index 6eaf0536d9..68bb4ae1b4 100644 --- a/python/cudf/cudf/_lib/parquet.pyx +++ b/python/cudf/cudf/_lib/parquet.pyx @@ -222,25 +222,28 @@ cpdef read_parquet(filepaths_or_buffers, columns=None, row_groups=None, column_names = [x.decode() for x in c_out_table.metadata.column_names] - # Access the Parquet user_data json to find the index index_col = None - cdef map[string, string] user_data = c_out_table.metadata.user_data - json_str = user_data[b'pandas'].decode('utf-8') - meta = None - if json_str != "": - meta = json.loads(json_str) - if 'index_columns' in meta and len(meta['index_columns']) > 0: - index_col = meta['index_columns'] - if isinstance(index_col[0], dict) and \ - index_col[0]['kind'] == 'range': - is_range_index = True - else: - is_range_index = False - index_col_names = OrderedDict() - for idx_col in index_col: - for c in meta['columns']: - if c['field_name'] == idx_col: - index_col_names[idx_col] = c['name'] + cdef map[string, string] user_data + if use_pandas_metadata: + # Access the Parquet user_data json to find the index + user_data = c_out_table.metadata.user_data + json_str = user_data[b'pandas'].decode('utf-8') + meta = None + if json_str != "": + meta = json.loads(json_str) + if 'index_columns' in meta and len(meta['index_columns']) > 0: + index_col = meta['index_columns'] + if isinstance(index_col[0], dict) and \ + index_col[0]['kind'] == 'range': + is_range_index = True + else: + is_range_index = False + index_col_names = OrderedDict() + for idx_col in index_col: + for c in meta['columns']: + if c['field_name'] == idx_col: + index_col_names[idx_col] = c['name'] + df = cudf.DataFrame._from_table( Table.from_unique_ptr( move(c_out_table.tbl),