Skip to content

Commit

Permalink
scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasdavis committed Sep 18, 2023
1 parent fd86f66 commit 9e7b806
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/dask_awkward/layers/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ def mock(self) -> tuple[AwkwardInputLayer, TypeTracerReport]:
)
return new_input_layer, report

def project_columns(self, columns: list[str]) -> AwkwardInputLayer:
def project_columns(
self,
columns: list[str],
*,
necessary_shape_columns: list[str] | None = None,
) -> AwkwardInputLayer:
if hasattr(self.io_func, "project_columns"):
# TODO: make project_columns call sites never pass in an
# empty list.
Expand All @@ -182,6 +187,7 @@ def project_columns(self, columns: list[str]) -> AwkwardInputLayer:
io_func = self.io_func.project_columns(
columns,
original_form=original_form,
necessary_shape_columns=necessary_shape_columns,
)
except TypeError:
io_func = self.io_func.project_columns(columns)
Expand Down
7 changes: 7 additions & 0 deletions src/dask_awkward/lib/io/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def _default_project_columns(
self,
columns: Sequence[str],
original_form: Form | None = None,
necessary_shape_columns: Sequence[str] | None = None,
) -> Self:
if self.schema is not None:
return self
Expand Down Expand Up @@ -126,13 +127,15 @@ def project_columns(
self,
columns: Sequence[str],
original_form: Form | None = None,
necessary_shape_columns: Sequence[str] | None = None,
) -> Self:
if not _use_optimization():
return self

return self._default_project_columns(
columns=columns,
original_form=original_form,
necessary_shape_columns=necessary_shape_columns,
)


Expand Down Expand Up @@ -177,13 +180,15 @@ def project_columns(
self,
columns: Sequence[str],
original_form: Form | None = None,
necessary_shape_columns: Sequence[str] | None = None,
) -> Self:
if not _use_optimization():
return self

return self._default_project_columns(
columns=columns,
original_form=original_form,
necessary_shape_columns=necessary_shape_columns,
)


Expand Down Expand Up @@ -236,13 +241,15 @@ def project_columns(
self,
columns: Sequence[str],
original_form: Form | None = None,
necessary_shape_columns: Sequence[str] | None = None,
) -> Self:
if not _use_optimization():
return self

return self._default_project_columns(
columns=columns,
original_form=original_form,
necessary_shape_columns=necessary_shape_columns,
)


Expand Down
3 changes: 3 additions & 0 deletions src/dask_awkward/lib/io/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def project_columns(
self,
columns: Sequence[str] | None,
orignal_form: Form | None = None,
necessary_shape_columns: Sequence[str] | None = None,
) -> _FromParquetFn:
...

Expand Down Expand Up @@ -130,6 +131,7 @@ def project_columns(
self,
columns: Sequence[str] | None,
original_form: Form | None = None,
necessary_shape_columns: Sequence[str] | None = None,
) -> _FromParquetFileWiseFn:
if not _use_optimization():
return self
Expand Down Expand Up @@ -192,6 +194,7 @@ def project_columns(
self,
columns: Sequence[str] | None,
original_form: Form | None = None,
necessary_shape_columns: Sequence[str] | None = None,
) -> _FromParquetFragmentWiseFn:
if not _use_optimization():
return self
Expand Down
5 changes: 4 additions & 1 deletion src/dask_awkward/lib/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ def optimize_columns(dsk: HighLevelGraph) -> HighLevelGraph:
for name, neccols in layer_to_necessary_columns.items():
meta = layers[name]._meta
neccols = _prune_wildcards(neccols, meta)
layers[name] = layers[name].project_columns(neccols)
layers[name] = layers[name].project_columns(
neccols,
necessary_shape_columns=None,
)

return HighLevelGraph(layers, deps)

Expand Down

0 comments on commit 9e7b806

Please sign in to comment.