Skip to content

fix(ENGKNOW-4019): return default dictionary header for nor -asdict on an empty dictionary - #155

Merged
gmagnu merged 1 commit into
mainfrom
ENGKNOW-4019-nor-asdict-empty-gord
Oct 8, 2026
Merged

gmagnu merged 1 commit into
mainfrom
ENGKNOW-4019-nor-asdict-empty-gord

Conversation

@gmagnu

@gmagnu gmagnu commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Problem

A dictionary with no entries is valid, but nor -asdict could not read one:

Dictionary file Before After
0 bytes Input source contains no header default dictionary header, 0 rows
only blank lines header col1, blank rows default dictionary header, 0 rows
0 bytes, with .gord.meta Input source contains no header header from .meta, 0 rows
non-empty, no header col1 col2 … unchanged
empty non-dictionary file (nor x.tsv) Input source contains no header unchanged

Any query that reads an empty dictionary with nor -asdict failed. When it was one step of a merged script, the whole script failed.

Change

  • NorInputSource / NoValidateNorInputSource take an optional defaultHeader. When it is set, empty lines are skipped, and an input with no lines reports that header with no rows. A secondary 8-arg constructor keeps the Java callers unchanged.
  • Nor: for -asdict on a .gord/.nord, the default header is the file header from <dict>.meta if present, otherwise GorDictionaryTableMeta.DEFAULT_TABLE_HEADER / NorDictionaryTableMeta.DEFAULT_TABLE_HEADER.

Testing

  • New tests in UTestNorDictionary: 0-byte .gord, blank-line .gord, empty .gord with .meta, empty .nord, an empty dict used positionally downstream (inset -c #2 … | rename #2 …), a non-empty headerless dict (unchanged), and an empty non-dictionary file (still throws). Before the fix 5 of these failed; now all pass.
  • ./gradlew :gortools:test :gortools:testScala: 2661 tests, 0 failures.

🤖 Generated with Claude Code

…n an empty dictionary

A dictionary with no entries is a valid state, but nor -asdict on a 0-byte
.gord/.nord failed with "Input source contains no header", and a file with
only blank lines gave a one-column header (col1). Any query reading such a
dictionary failed, e.g. gregor_sm_gb_track_dicts for long-read projects
where del/me/sma/rep_varcalls.gord are created empty.

NorInputSource takes an optional default header. For -asdict on a .gord or
.nord, Nor passes the file header from the dictionary's .meta if present,
otherwise the dictionary type's default header. With a default header,
empty lines are skipped and an input with no lines reports the default
header with no rows. Non-dictionary inputs and non-empty dictionaries are
unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

Junit Tests - Summary

4 940 tests  +7   4 769 ✅ +7   18m 33s ⏱️ +11s
  513 suites ±0     171 💤 ±0 
  513 files   ±0       0 ❌ ±0 

Results for commit 35556b8. ± Comparison against base commit fe063a2.

@gmagnu
gmagnu marked this pull request as ready for review October 7, 2026 23:43
@gmagnu
gmagnu merged commit a4b99ad into main Oct 8, 2026
14 checks passed
@gmagnu
gmagnu deleted the ENGKNOW-4019-nor-asdict-empty-gord branch October 8, 2026 10:29
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.

2 participants