Skip to content

Fix streaming dataset features after map/add_column - #8685

Open
dajiaohuang wants to merge 1 commit into
huggingface:mainfrom
dajiaohuang:fix-iterable-dataset-features
Open

dajiaohuang wants to merge 1 commit into
huggingface:mainfrom
dajiaohuang:fix-iterable-dataset-features

Conversation

@dajiaohuang

Copy link
Copy Markdown

Fixes #5752

What changed?

  1. Preserves existing features when map() is called without an explicit features parameter (including identity functions like map(lambda x: x))
  2. Properly removes features for columns specified in remove_columns
  3. Adds a feature parameter to add_column() (consistent with the non-streaming Dataset.add_column API)
  4. Automatically infers the new column's feature type when no explicit feature is provided
  5. Merges new column features with existing features instead of overwriting them

Why?

Previously, calling .map() or .add_column() on an IterableDataset (streaming mode) would set features to None, making it impossible to access dataset features after these operations. This fixes the issue reported in #5752 where modified_dataset.features.keys() would raise an AttributeError.

- Preserve existing features when map() is called without explicit features parameter
- Properly remove features for columns specified in remove_columns
- Add feature parameter to add_column() and infer new column features automatically
- Closes huggingface#5752
@lhoestq

lhoestq commented Sep 30, 2026

Copy link
Copy Markdown
Member

I feel like it can be too expensive to always have to infer features, that's why it wasn't implement in the first place, wdyt ?

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.

Streaming dataset looses .feature method after .add_column

2 participants