Repository navigation
#3833: ETL unpacker reads any EBCDIC code page, Decimal not float, never a silent 0.0 - #3894
Merged
Merged
Conversation
…gned zoned, never a silent 0.0 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
…0.0, not a failed run All EBCDIC spaces (X'40') or low-values (X'00') in a zoned or packed field is an unfilled field, common in real extracts: it becomes an empty CSV cell (a NULL downstream) and the run reports how many. Garbage -- a sign mid-field, a letter, a bad nibble -- still stops the run naming record and field. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #3833 (the "ETL unpacker" bullet).
What changed
gitgalaxy/tools/cobol_to_cobol/cobol_etl_unpacker.py:--code-page(defaultcp037), validated byresolve_code_page: callsgitgalaxy.core.ebcdic_codecs.register(), thencodecs.lookup, and rejects a non-EBCDIC codec (e.g.utf-8) by checking that bytes F0-F9 decode to0-9. A bad page exits with code 2. Text fields and zoned digits both decode in that page, so cp273 / cp277 / cp278 / cp297 / cp1047 files now come out as the right letters.unpack_comp3and the newunpack_zonedreturndecimal.Decimal, built exactly from the digits with exponent-decimals. The CSV getsformat(value, "f"), so there is no exponent and the field's scale is kept (12.50for V99,0.10,0.0000001). Negative zero prints as0.00.java_target.zoned_sign_characters(code_page), so there is no second sign table: cp037 uses{A-I/}J-R, cp277 usesæ.../å..., and so on.UnpackError("record N, field NAME: ..."). The CLI prints it, deletes the partial CSV and exits with code 1. No value is ever written as0.0for bad data.docs/wiki/05-09-etl-unpacker.md: describes the code page, Decimal, zoned signs and the strict rule, and drops the "cp037 only" limitation.Tests
tests/cobol_mainframe/test_cobol_etl_unpacker.py. The two existing float assertions intest_unpack_comp3now compare withDecimal(Decimal("1234.56") != 1234.56); nothing was removed. New tests:MÜLLÄÖß) round-trips, and the same bytes read under cp037 do not.ÆØÅæøå) round-trips.S9(5)V99-1234.50 gives-1234.50under cp037, cp277, cp273 and cp297.12.50, and unsigned zoned gives0.10.S9(7)V990.10 gives exactly0.10.record 2, field AMOUNT, and no CSV is left behind.--code-pageexits with code 2.18 of the 21 tests fail on main.
Not done, and why
0.0and is now an error. Spaces are not a valid zoned number, and writing 0.0 for them is exactly the silent data loss this bullet is about. If blank numerics turn out to be common in real extracts, a--lenientmode (empty cell plus a reported count) could follow.len(record_bytes) < record_length: break). That is pre-existing and out of this bullet's scope.with (...)is Python 3.10+ syntax; I left it untouched.SIGN LEADING/SIGN SEPARATEzoned fields are not in the JSON schema, so they are not handled (unchanged).Gates
python tests/tools/pr_gates.py: 7/7 pass (lint, audits, secrets, xray, gauntlet, golden 212s, suite 1035s). No golden masters, baselines or refraction snapshots moved. After mergingorigin/main, ruff format,ruff_audit --ciandmypy_audit --ciare clean.🤖 Generated with Claude Code