Skip to content

fix(compaction): handle omitted compaction_options in compact_files#5225

Open
FANNG1 wants to merge 1 commit into
lance-format:mainfrom
FANNG1:fix-compaction-options-none
Open

fix(compaction): handle omitted compaction_options in compact_files#5225
FANNG1 wants to merge 1 commit into
lance-format:mainfrom
FANNG1:fix-compaction-options-none

Conversation

@FANNG1

@FANNG1 FANNG1 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

compact_files() declares compaction_options: Optional[CompactionOptions] = None, but passes the value straight into Compaction.plan(dataset, compaction_options). Compaction.plan's binding requires a dict, so calling compact_files() without explicitly passing compaction_options always fails with:

TypeError: 'None' is not an instance of 'dict'

Fixes #5224.

Change

  • Substitute an empty CompactionOptions() when the caller omits the argument (CompactionOptions is a TypedDict, so an empty instance means "all defaults").
  • Add test_compaction_without_options, a regression test exercising the default-argument path — existing tests all passed compaction_options explicitly, which is why this never surfaced.

Testing

pytest tests/test_distributed_compaction.py -k "basic_compaction or without_options"
2 passed

compact_files() declares compaction_options as Optional with a None
default, but passed it straight into Compaction.plan(), whose binding
rejects non-dict values — calling compact_files() without explicitly
passing compaction_options always raised
"TypeError: 'None' is not an instance of 'dict'".

Substitute an empty CompactionOptions() (a TypedDict, i.e. an empty
dict meaning all defaults) when the caller omits it, and add a
regression test exercising the default-argument path.

Fixes lance-format#5224
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compact_files() crashes with TypeError when compaction_options is omitted

1 participant