Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move meta calculation in dask_cudf.read_parquet #13327

Merged
merged 7 commits into from
May 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions python/dask_cudf/dask_cudf/io/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,31 @@


class CudfEngine(ArrowDatasetEngine):
@staticmethod
def read_metadata(*args, **kwargs):
meta, stats, parts, index = ArrowDatasetEngine.read_metadata(
*args, **kwargs
@classmethod
def _create_dd_meta(cls, dataset_info, **kwargs):
wence- marked this conversation as resolved.
Show resolved Hide resolved
# Start with pandas-version of meta
meta_pd = super()._create_dd_meta(dataset_info, **kwargs)

# Convert to cudf
meta_cudf = cudf.from_pandas(meta_pd)

# Re-set "object" dtypes to align with pa schema
kwargs = dataset_info.get("kwargs", {})
set_object_dtypes_from_pa_schema(
meta_cudf,
kwargs.get("schema", None),
)
new_meta = cudf.from_pandas(meta)
if parts:
# Re-set "object" dtypes align with pa schema
set_object_dtypes_from_pa_schema(
new_meta,
parts[0].get("common_kwargs", {}).get("schema", None),
)

# If `strings_to_categorical==True`, convert objects to int32
strings_to_cats = kwargs.get("strings_to_categorical", False)
for col in new_meta._data.names:
for col in meta_cudf._data.names:
if (
isinstance(new_meta._data[col], cudf.core.column.StringColumn)
isinstance(meta_cudf._data[col], cudf.core.column.StringColumn)
and strings_to_cats
):
new_meta._data[col] = new_meta._data[col].astype("int32")
return (new_meta, stats, parts, index)
meta_cudf._data[col] = meta_cudf._data[col].astype("int32")

return meta_cudf

@classmethod
def multi_support(cls):
Expand Down