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

[bugfix] fix select columns in odps dataset v1 #18

Merged
Merged
Show file tree
Hide file tree
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
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ repos:
hooks:
- id: codespell
args: ["--skip", "*.json"]
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
args: ["--in-place", "--wrap-descriptions", "79"]
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
Expand Down
18 changes: 6 additions & 12 deletions tzrec/datasets/odps_dataset_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,14 @@ def __init__(
) -> None:
super().__init__(input_path, batch_size, selected_cols, drop_remainder)
self.schema = []
self._ordered_cols = None
reader = common_io.table.TableReader(
self._input_path.split(",")[0],
selected_cols=",".join(self._selected_cols or []),
)
if self._selected_cols:
self._ordered_cols = []
for field in reader.get_schema():
# pyre-ignore [58]
if field["colname"] in self._selected_cols:
self.schema.append(field)
self._ordered_cols.append(field["colname"])
else:
self.schema = reader.get_schema()
self._ordered_cols = []
for field in reader.get_schema():
if not selected_cols or field["colname"] in selected_cols:
self.schema.append(field)
self._ordered_cols.append(field["colname"])
reader.close()

def _iter_one_table(
Expand All @@ -148,7 +142,7 @@ def _iter_one_table(
input_path,
slice_id=worker_id,
slice_count=num_workers,
selected_cols=",".join(self._selected_cols or []),
selected_cols=",".join(self._ordered_cols or []),
)
while True:
try:
Expand Down
Loading