Skip to content

Preserve DataFrame divisions when reading from parquet using pyarrow - #3387

Merged
jcrist merged 29 commits into
dask:masterfrom
jonmmease:enh_3383
Apr 17, 2018
Merged

jcrist merged 29 commits into
dask:masterfrom
jonmmease:enh_3383

Conversation

@jonmmease

@jonmmease jonmmease commented Apr 8, 2018 •

Copy link
Copy Markdown
Contributor

Implementation of #3383.

I updated a bunch of tests in test_parquet.py to check the read_parquet dask DataFrame against the expected dask DataFrame, rather than the expected pandas DataFrame. I only check_divisions when the reader is fastparquet or pyarrow >= '0.9.0'. This has the added benefit of checking the read_parquet divisions logic for the fastparquet path, which I don't think was really verified previously.

I added a bit of logic to _read_pyarrow to use pyarrow's column metadata stats to compute the min/max of each row group and the use these pairs to build the divisions. It's rough, but it works in many cases.

I ran into a handful of tangentially related issues during a couple of hours of working through the failing tests. I'm not sure if I'll be able to see this through the the finish, but I wanted to at least share my progress.

@jcrist Is this division calculation logic the kind of approach you had in mind in #3383?
@mrocklin Does this division calculation logic give you pause performance-wise?

  • Tests added / passed
  • Passes flake8 dask
  • Changelog

Jon M. Mease added 2 commits April 7, 2018 20:18
@jonmmease

Copy link
Copy Markdown
Contributor Author

A couple of notes on the "tangentially related issues" I mentioned above.

  • test_read_glob: In order to get this to pass for pyarrow reader I added the non_empty_pieces logic in _read_pyarrow (See here). This was needed because the _common_metadata file shows up in the dataset.pieces list, but this shouldn't be a valid partition for the DataFrame.
  • test_empty: The change above results in a failure for the pyarrow-pyarrow cases. This is because my logic added above results in no non-empty pieces, which now sends us down the no-partitions path here. I think this is appropriate, but there seems to be an issue with the dtypes = _get_pyarrow_dtypes(schema, categories) logic above. When the empty DataFrame is both written and read using pyarrow the dtype for the a column/index is incorrectly determined to be float64 rather than object (which is the correct dtype). Interestingly, this isn't a problem when the file is written using fastparquet, so perhaps there is an error in the pyarrow writing logic for empty DataFrames.
  • test_columns_index_with_multi_index: This fails because the min/max statistics in the column metadata seems to be less than full precision. E.g. when the underlying DataFrame has a min of -0.67432957233535817 the min statistic is -0.67433

There are also failures in test_read_parquet_custom_columns and test_timestamp_index, test_partition_on, test_columns_name, and a few others I haven't looked into.

@mrocklin

mrocklin commented Apr 8, 2018

Copy link
Copy Markdown
Member

Does this division calculation logic give you pause performance-wise?

It's not the logic of calculating the divisions, it's the possibility that we would need to read data from many files on a remote store, and that this might take up a significant amount of time. If PyArrow isn't writing a metadata file then my understanding is that we'll have to read a bit of data from each of the parquet files in the dataset, which in practice gets into the thousands (or so I believe). What is the cost for each remote access in this case? I would not be surprised to learn that it was in the hundreds of milliseconds, which means that the read_parquet call might take a few minutes just to read metadata. So some questions I would have here:

  1. Is the hundreds of milliseconds estimate accurate? Lower? Higher?
  2. Is it possible for PyArrow to write the metadata file, or are there reasons against this?
  3. Can we bail out early if we find that the min/max values aren't well formed for dask divisions
  4. Should we make this optional, defaulting to off?

For the arrow and divisions logic we might also ping @xhochy here in case he has time.

@jcrist

jcrist commented Apr 8, 2018

Copy link
Copy Markdown
Member

I won't have time to fully review this until tomorrow, but I just want to respond to:

It's not the logic of calculating the divisions, it's the possibility that we would need to read data from many files on a remote store, and that this might take up a significant amount of time.

Currently when reading parquet with pyarrow, the schema is grabbed from every file. This could be turned off by passing validate_schema=False to ParquetDataset, but there are (or at least were) some issues with constructing that way (bug in arrow that I never filed :( ). This hasn't shown to be a bottleneck for at least my workflows, but may be for a large number of files (we're in the ~500 file range).

The statistics information is also available at known byte offsets in the files, and so may also be efficiently read in for filesystems that support efficient random access (hdfs, local, not sure about others). A single metadata file would certainly be more efficient (https://issues.apache.org/jira/browse/ARROW-1983) but I'm not sure if pulling the stats from every file would be bad enough to warrant an api change. Benchmarking needed.

@martindurant

Copy link
Copy Markdown
Member

Does anyone know the rationale for not writing metadata files? Is it a problem of a blocking finalizer task following parallel writing? For example, spark used to, but no longer does by default.

@jonmmease

Copy link
Copy Markdown
Contributor Author

Another observation:

test_read_parquet_custom_columns fails because pyarrow returns the pieces property of the ParquetDataset is sorted lexicographically by filename, not by part number.

Here's an example from inside test_read_parquet_custom_columns.
Notice the ordering of the parts (0, 1, 10, 11, 12, ..., 18, 19, 2, 3, 4, ..., 8, 9)

dataset.pieces
Out[3]: 
[ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.0.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.1.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.10.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.11.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.12.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.13.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.14.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.15.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.16.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.17.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.18.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.19.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.2.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.3.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.4.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.5.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.6.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.7.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.8.parquet', row_group=None, partition_keys=[]),
 ParquetDatasetPiece('/private/.../test_read_parquet_custom_colum1/part.9.parquet', row_group=None, partition_keys=[])]

This seems unintuitive to me. Is this the expected behavior? If so, determining divisions accuratley will involve sorting the partitions by their min value and then checking to make sure the max values don't overlap with the next min.

But, even apart from the divisions issue, the fact that pyarrow doesn't return pieces ordered by part number suggests that the order of the partitions in the resulting dask dataframe won't necessarily match the order in which they were written.

@jonmmease

Copy link
Copy Markdown
Contributor Author

After poking around at the parquet datasets created by fastparquet, it looks like fastparquet creates the _metadata file in the output directory and that this file contains the order of the pieces/parts.

I also tried using the fastparquet engine to read a dataset created by the pyarrow engine but this errors out because it looks like fastparquet won't treat a directory as a parquet dataset unless it has a _metadata file in it.

Jon M. Mease added 2 commits April 8, 2018 19:36
But getting tests to pass required multiplying int64 time by 1000 and I'm not sure why.
@xhochy

xhochy commented Apr 9, 2018

Copy link
Copy Markdown
Contributor

Does anyone know the rationale for not writing metadata files? Is it a problem of a blocking finalizer task following parallel writing? For example, spark used to, but no longer does by default.

If your Parquet dataset is not the result from a single job but will get appended on e.g. a daily basis updating the _metadata file must be done by a central instance. This is often possible but not simple.

But the actual lack of writing _metadata in pyarrow is due to nobody having implemented it yet. An implementation would be welcome and probably a reasonable performance boost in many cases. Accessing every file in a dataset is really expensive when you have a large dataset. I think we already do this in the PyArrow class ParquetDataset and it would be probably one of the first things I would remove once I do some performance tuning on that path.

Comment thread dask/dataframe/io/parquet.py Outdated

# Handle converting divisions to timestamps
if divisions[0] is not None and meta.index.dtype.kind == 'M':
# Why is this factor of 1000 needed???

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be also a factor of 1M or 1 depending on the precision of the time. Pandas uses nanoseconds by default whereas we use the Parquet preferred default of microsecond precision in Parquet. But as Parquet supports many precisions and Pandas only a single one, you will have to look at the actual Parquet schema to infer the scaling factor, the meta object will not have sufficient information to determine it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the help on this one!

@jonmmease

Copy link
Copy Markdown
Contributor Author

@xhochy Thanks for your feedback. If you can spare another moment, do you any perspective/guidance on the following remaining issues?

  • min/max statistics in the column metadata seems to be less than full precision. E.g. when the underlying DataFrame has a min of -0.67432957233535817 the min statistic is -0.67433
  • Pieces property of the ParquetDataset is sorted lexicographically by filename, not by part number. In this PR a resorted the pieces using a 'natural' sort so that the parts are ordered by part number. Is this a reasonable thing to do in general?

…andas

Refactor division logic into a new method and base it entirely on the
pyarrow schema (not the pandas metadata)
@jonmmease

jonmmease commented Apr 9, 2018 •

Copy link
Copy Markdown
Contributor Author

Test failure notes:
test_columns_name fails with a SIGSEGV on the third line of

pf = piece.get_metadata(pq.ParquetFile)
rg = pf.row_group(0)
col_meta = rg.column(divisions_col_index)  # SIGSEGV here

At this point divisions_col_index is 0 and the row group looks like this.

rg
Out[2]: 
<pyarrow._parquet.RowGroupMetaData object at 0x1158c45a0>
  num_columns: 2
  num_rows: 2
  total_byte_size: 88

And the schema looks like this.

pa_schema
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:52:12) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
PyDev console: using IPython 6.1.0
Out[1]: 
idx: string
A: int64
metadata
--------
{b'pandas': b'{"columns": [{"metadata": null, "name": "idx", "numpy_type": "ob'
            b'ject", "pandas_type": "empty"}, {"metadata": null, "name": "A", '
            b'"numpy_type": "int64", "pandas_type": "int64"}], "index_columns"'
            b': ["idx"], "pandas_version": "0.23.0.dev0+208.g35812ea"}'}

And, interestingly, calling rg.column(1) (rather than 0) returns fine.

Update:
This only occurs in the case where the file is written with fastparquet and read by pyarrow. If the file is both written and read by pyarrow there is not issue. I updated the test to skip this mixed case, but we can revisit if we need to

Jon M. Mease added 2 commits April 9, 2018 09:27
…ith 'pyarrow'

This was causing a SIGSEGV error and the comments already state that fastparquet doesn't write column_names
# Handle encoding of bytes string
if index_field.type == pa.string():
# Is this always true? Is the string encoding specified in the parquet metadata somewhere?
encoding = 'utf-8'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All parquet strings are UTF8, there is no option to set any other encoding.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I'll remove the question and update the comment

@jonmmease

Copy link
Copy Markdown
Contributor Author

I made a few more changes and now there are only 2 failing tests cases, summarized below.

  1. test_columns_index_with_multi fails due to the apparent truncation of the min field in the RowGroupStatistics object. See here:

https://github.com/jmmease/dask/blob/efab4d3648bec7a4e46e3ff48dd1de50c9218e70/dask/dataframe/io/parquet.py#L684-L687

  1. test_empty: When an empty DataFrame with a string datatype column is both written and read by pyarrow, the datatype of the column on read is null which is converted to numpy.float64 by the field.type.to_pandas_dtype() method.

I think this is as far as I can take this without some help from the pyarrow side. Anyone available/willing to take a look?
@mrocklin @jcrist @xhochy

@xhochy

xhochy commented Apr 10, 2018

Copy link
Copy Markdown
Contributor

test_columns_index_with_multi fails due to the apparent truncation of the min field in the RowGroupStatistics object.

I guess not only is min truncated but max is probably then also truncated?

test_empty: When an empty DataFrame with a string datatype column is both written and read by pyarrow, the datatype of the column on read is null which is converted to numpy.float64 by the field.type.to_pandas_dtype() method.

This is the expected behaviour as an empty string column in Pandas is simply an empty column of type object. Sadly object does not tell us much about the type of the column at all. We return numpy.float64 in this case as it's the most efficient type to store nulls in Pandas.

@xhochy

xhochy commented Apr 10, 2018

Copy link
Copy Markdown
Contributor

The code looks good. I'm worried a bit that it might be costly due to a lot of I/O.

@jcrist

jcrist commented Apr 10, 2018

Copy link
Copy Markdown
Member

This is the expected behaviour as an empty string column in Pandas is simply an empty column of type object. Sadly object does not tell us much about the type of the column at all. We return numpy.float64 in this case as it's the most efficient type to store nulls in Pandas.

This seems unintuitive at best to me. An empty object column in pandas is treated differently in many operations than an empty float64 column (str accessor is available, excluded from numeric operations, etc..). Having an empty file read in as a different dtype than was written could lead to errors in processing code downstream. Would arrow be willing to change this behavior?

I'm worried a bit that it might be costly due to a lot of I/O.

Upon further thought, I am too. I think we should provide a kwarg to turn this behavior on/off. Proposed semantics:

    """
    ...
    infer_divisions : bool or None (default).
        By default divisions are inferred only if a global `_metadata` file
        is found for the dataset. Set to ``True`` to force divisions to be
        inferred in all cases. Note that without a `_metadata` file, this
        requires reading metadata from each file in the dataset, which may be
        expensive. Set to ``False`` to never infer divisions.
    """

@xhochy

xhochy commented Apr 10, 2018

Copy link
Copy Markdown
Contributor

This is the expected behaviour as an empty string column in Pandas is simply an empty column of type object. Sadly object does not tell us much about the type of the column at all. We return numpy.float64 in this case as it's the most efficient type to store nulls in Pandas.

This seems unintuitive at best to me. An empty object column in pandas is treated differently in many operations than an empty float64 column (str accessor is available, excluded from numeric operations, etc..). Having an empty file read in as a different dtype than was written could lead to errors in processing code downstream. Would arrow be willing to change this behavior?

We should probably use another method than field.type.to_pandas_dtype() in this case. The column saved in Parquet should be saved with NA as type which sadly does not provide enough information.

We also store the original dtype in the Pandas metadata that is used for the actual DataFrame reconstruction later on. If we would also pick up the metadata when it was written, we should be able to correctly reconstruct the dtype.

@jcrist

jcrist commented Apr 10, 2018

Copy link
Copy Markdown
Member

@jonmmease

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @xhochy , I'll switch to looking directly at the pandas metadata. If I recall correctly this did have the object datatype

test_columns_index_with_multi fails due to the apparent truncation of the min field in the RowGroupStatistics object.

I guess not only is min truncated but max is probably then also truncated?

That's correct, max is truncated as well.

@jcrist The option you describes sounds reasonable. So setting this to False would disable the division calculation logic for fastparquet as well?

I'll take a stab at updating the pyarrow dtype logic to look at the pandas metadata, and adding the infer_divisions kwarg.

Assuming this doesn't uncover any other fundamental issues, I think the last remaining blocker is the min/max truncation.

If we knew how this truncation works, we might be able to add a little padding to each division to account for it. But I fear this could also produce unexpected results in cases where the truncation isn't neccessary. Thoughts?

@jcrist

jcrist commented Apr 10, 2018

Copy link
Copy Markdown
Member

The option you describes sounds reasonable. So setting this to False would disable the division calculation logic for fastparquet as well?

Correct. That part should be fairly easy to add. Adding the infer_divisions=True logic for fastparquet might prove trickier. If so, I'd accept a NotImplementedError for now.

@jonmmease

Copy link
Copy Markdown
Contributor Author

If I recall correctly, it looked like fastparquet requires a _metadata file in order to treat a directory of parquet files as a dataset. Please correct me if I'm wrong @martindurant

So raising a NotImplementedError does make sense in this case.

@jonmmease

jonmmease commented Apr 12, 2018 •

Copy link
Copy Markdown
Contributor Author

Ok, I think this might be just about good to go (and CI tests as passing). @jcrist @xhochy @mrocklin

Summary of updates

  1. I now use the numpy_dtype from the pandas metadata if available and fallback to the pyarrow schema to_pandas_dtype otherwise.

  2. I added an infer_divisions kwarg to read_parquet. I altered the semantics and description slightly from @jcrist 's suggestion.

infer_divisions : bool or None (default).
        By default, divisions are inferred if the read `engine` supports
        doing so efficiently and the `index` of the underlying dataset is
        sorted across the individual parquet files. Set to ``True`` to
        force divisions to be inferred in all cases. Note that this may
        require reading metadata from each file in the dataset, which may
        be expensive. Set to ``False`` to never infer divisions.

With this change,

  • infer_divisions of None (default) should match the legacy behavior for both read engines (infer for fastparquet when possible and never infer for pyarrow)
  • infer_divisions of False means that neither engine will infer divisions
  • infer_divisions of True means that both engines will attempt to infer divisions and will raise an exception if this is not possible (if the index can't be identified, if the column is not sorted across parts, or if the engine version doesn't support it). This will continue to be inexpensive for fastparquet, and it will be potentially expensive for pyarrow.
  1. I added/updated tests for infer_divisions so that they should work for pyarrow 0.8 and 0.9.0.

  2. I updated the changelog

Note: We're no longer hitting the min/max truncation error in the tests because the divisions are not being inferred by default. So I don't think that's a blocker any more, but someone may want to investigate this further on the pyarrow side.

@jonmmease

Copy link
Copy Markdown
Contributor Author

friendly ping @mrocklin @jcrist

@mrocklin mrocklin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general this seems fine to me. It seems safe given that it's off by default and that it escapes early if divisions are not sorted.

I can't say much about the accuracy of actual parquet code. It would be good if someone else is able to look things over as well.

Comment thread dask/dataframe/io/parquet.py Outdated
def to_sort_tuple(piece):
return [int(s) if s.isdigit() else s for s in re.split('(\d+)', piece.path)]

return sorted(pieces, key=to_sort_tuple)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will maybe be useful elsewhere? I suggest that we make this non-parquet specific and throw it in dask/utils.py. Perhaps it should consume a sequence of filenames?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the core of this to dask.utils as nat_sort_key

Comment thread dask/dataframe/io/parquet.py Outdated
if divisions_col_index is None:
rg_paths = [rg.column(i).path_in_schema for i in range(rg.num_columns)]
try:
divisions_col_index = rg_paths.index(divisions_name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be the same for all of the pa_pieces?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. This assumption might be violated if someone passed in a list of paths to parquet datasets where some of the datasets are partitioned and others aren't. Since I'm not confident, I switched back to computing this for each piece.

else:
# Divisions not valid
min_maxs = None
break

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the early break here. Thanks!

Jon M. Mease added 4 commits April 16, 2018 12:58
This ensures that we're testing natural sorting
  - Move nat_sort_key into dask.utils
  - Natural sort paths resulting from globstring patterns before passing lists of paths to the engines
  - Only natural sort pyarrow parquet pieces if a single input path resulted in multiple pieces
# Conflicts:
#	docs/source/changelog.rst
@jonmmease

Copy link
Copy Markdown
Contributor Author

Thanks for the comments @mrocklin, I pushed some updates in response

I also made some updates to the parquet test suite to make sure that we hit the situation more frequently where we have more than 10 parquet pieces (in which case the natural sorting distinction is important).

Let me know if there's anything else you'd like to see here @mrocklin @jcrist

@jcrist jcrist left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good to me. I didn't read too much into how you're getting the divisions, but the tests look good and if they pass that's fine. I left a couple stylistic, linting comments.

Comment thread dask/dataframe/io/parquet.py Outdated
pf = fastparquet.ParquetFile(paths[0], open_with=fs.open, sep=fs.sep)

# Validate infer_divisions
if not pf.fn.endswith('/_metadata') and infer_divisions is True:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is specific to unix-like filesystems. Perhaps os.path.split(pf.fn).endswith('_metadata').

Comment thread dask/dataframe/io/tests/test_parquet.py Outdated
def test_to_parquet_lazy(tmpdir, get):
def test_to_parquet_lazy(tmpdir, get, engine):
check_fastparquet()
check_pyarrow()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for check_fastparquet/check_pyarrow here with the addition of the engine fixture, as that handles this automatically.

Comment thread dask/dataframe/io/parquet.py Outdated
factor = 1
else:
raise ValueError("Unsupported time unit '{unit}'"
.format(unit=unit))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer a lookup table here. Perhaps:

try:
    factor = {'s': 1e9, 'ms': 1e6, 'us': 1e3, 'ns': 1}.get(unit)
except KeyError:
    raise ValueError("Unsupported time unit '{unit}'".format(unit=unit))

return val * int(factor)

Comment thread dask/dataframe/io/parquet.py Outdated
import pyarrow as pa
import pyarrow.parquet as pq

if infer_divisions is True and pa.__version__ < distutils.version.LooseVersion('0.9.0'):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer LooseVersion imported at top-level. Shorter lines, and it's used elsewhere.

Comment thread dask/dataframe/io/tests/test_parquet.py Outdated
try:
import pyarrow.parquet as pq
except ImportError:
check_pa_divs = False

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be wrong, but I believe this line is unnecessary.

Comment thread dask/dataframe/io/tests/test_parquet.py Outdated
check_pa_divs = False


def check_divs(engine):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this doesn't actually check divs, would prefer a better name. Perhaps should_check_divs.

Comment thread dask/utils.py Outdated
hasattr(x, 'dtype'))


def nat_sort_key(s):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer natural_sort_key instead of nat_sort_key, as I read nat as NaT (not a time). It's also not clear to me what natural means in this case, but I struggle to think of a better name.

@jonmmease jonmmease changed the title WIP: Preserve DataFrame divisions when reading from parquet using pyarrow Preserve DataFrame divisions when reading from parquet using pyarrow Apr 16, 2018
@jonmmease

Copy link
Copy Markdown
Contributor Author

Thanks for the comments and for helping me make this better @jcrist I believe I've incorporated all of your suggestions.

@jcrist

jcrist commented Apr 17, 2018

Copy link
Copy Markdown
Member

Looks like you have failures on python 2.

@jonmmease

Copy link
Copy Markdown
Contributor Author

Thanks, @jcrist, I think I found the culprit.

@jonmmease

Copy link
Copy Markdown
Contributor Author

All green now @mrocklin @jcrist

@jcrist

jcrist commented Apr 17, 2018

Copy link
Copy Markdown
Member

Looks good to me. Thanks @jmmease! Merging.

@jonmmease

Copy link
Copy Markdown
Contributor Author

Great! Thanks for all your help on this @jcrist @mrocklin @xhochy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants