Skip to content

test: arrow_import gets its pytest twin, and its error arms assert SQLSTATE under their own names (#1341) - #1395

Merged
jdatcmd merged 4 commits into
commandprompt:mainfrom
OffgridwithJD:test/1341-arrow-import-twin
Oct 14, 2026
Merged

jdatcmd merged 4 commits into
commandprompt:mainfrom
OffgridwithJD:test/1341-arrow-import-twin

Conversation

@OffgridwithJD

Copy link
Copy Markdown
Collaborator

Part of #1341. arrow_import.sh gets its pytest twin, with every check under the shell's name. Three of its error arms move from "any error" to their SQLSTATE.

The shell: expect_error hid its own reds

expect_error accepted any error. When the call succeeded instead, it recorded the failure under a different name, "<label> (expected error)", so the red never reached the ledger row it belonged to. Under the column-count check removed, main's suite does go red, but as reject column-count mismatch (expected error). The row reject column-count mismatch stays never-red. expect_error is gone, and the three arms compare their SQLSTATE under their own names:

arm SQLSTATE
reject non-columnar target 42809
reject column-count mismatch 42804
importing the same keys twice raises unique_violation 23505

The twin

test_arrow_import.py, with six tests. The four that need a pyarrow-written file decline by name as their first outcome when pyarrow is absent, and fail where PGC_REQUIRE names it. The other two always run (round trip and argument errors; indexes; the FIFO), which is the shell's #1159 lesson. The FIFO arm runs its call on a connection of its own in a thread with a 5 s wall clock, and opens the FIFO afterwards so the backend can return. compare_to_bash: every bash property is covered (72 literal matches, 1 template match).

Evidence

Clean: shell 77/77 and pytest 6 passed (with PGC_REQUIRE=pyarrow) on each of PG15–19.

Mutants (PG17):

mutant main's suite this branch, shell pytest
import_arrow without its columnar-relation check 75/75 green (any error accepted; it fails 42804 instead) reject non-columnar target: got [42804] want [42809] red, by name
import_arrow without its column-count check red, but under … (expected error) reject column-count mismatch: got [] want [42804] (a 16-column file imports into a 1-column table) red, by name
without the dictionary-batch refusal green reject dictionary-encoded file red, by name
without the compressed-body refusal green reject a compressed record-batch body red, by name

Bookkeeping

  • Ledger: no new rows. The two argument arms are dated for the first time: never 1895 → 1893, dated 573, rows 2466. Ceiling 244. The gate is clean against origin/main.
  • cluster_tests 541 → 547 (collection +6 against main). guard_tests is 429/429.
  • TESTS.md gets §106, and the pair is added to COMPLETE.

🤖 Generated with Claude Code

@jdatcmd jdatcmd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at the current head. One blocker, which CI already shows.

Blocking: pytest (harness guards, no database) is red

The import guard refuses two imports in the new twin:

REFUSED  test_arrow_import.py imports pyarrow outside require_module (line 80)
REFUSED  test_arrow_import.py imports pyarrow outside require_module (line 244)

Both are import pyarrow.ipc as ipc, one in _write_stream and one in test_the_refusals_and_every_temporal_carrier. ipc is already reachable from the module require_module returns: pa.ipc.new_stream resolves after a plain import pyarrow (checked on pyarrow 23.0.1). So pa.ipc.new_stream(...) in _write_stream, and pa.ipc at line 244, should clear the guard without a second import.

Merge order

TESTS.md §106 is also claimed by #1385 (test_every_suite_job_installs_the_extensions.py) and #1364 (am_contracts). Whichever merges later renumbers. cluster_tests will need restating the same way, since #1396 moves it to 542.

Not yet reproduced

I haven't run the mutants yet. This container has no Python with both pyarrow and psycopg, so the twin's pyarrow tests decline here. Once the guard is green, I'll reproduce the shell side: the columnar-relation and column-count mutants on main's suite and on this branch. The expect_error finding is a good catch: a red recorded under a different name never dates the row it belongs to.

🤖 Generated with Claude Code

@jdatcmd

jdatcmd commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Shell side reproduced on PG18. Main is df6a02f, so its suite is 77 checks after #1365.

mutant main's suite this branch
none — 77/77
import_arrow without its columnar-relation check (if (false && !PgColumnarIsColumnarRelation(relid))) 77/77 green reject non-columnar target: got [42804] want [42809]
without its column-count check (if (false && (int) nfields != ncols)) red, but as reject column-count mismatch (expected error): got [succeeded] reject column-count mismatch: got [] want [42804]

So the expect_error finding holds as you describe: one mutant main can't see, and one red recorded under a name the ledger doesn't have. Once the import guard is fixed and CI is green, I'll approve. The pytest twin's pyarrow tests decline here, so for those I'm relying on CI's cluster jobs.

🤖 Generated with Claude Code

jdatcmd and others added 4 commits October 14, 2026 19:46
…SQLSTATE, and a failure keeps its name (commandprompt#1341)

expect_error accepted any error, and recorded a failure as "<label> (expected
error)", so a red never reached the name the ledger keeps. The three arms now
compare 42809, 42804 and 23505 under their own names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VjTxfQJj5pnii9wzmPP9Ho
…dule returns (commandprompt#1395 review)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VjTxfQJj5pnii9wzmPP9Ho
@OffgridwithJD

Copy link
Copy Markdown
Collaborator Author

Fixed as you suggested, and restated on main: now fadd320.

Thanks for reproducing the shell side.

🤖 Generated with Claude Code

@jdatcmd jdatcmd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fadd320. Both import pyarrow.ipc are gone (pa.ipc.new_stream and pa.ipc.IpcWriteOptions at lines 80 and 255), which clears the guard's refusal. The shell side reproduced earlier: the columnar-relation mutant is invisible to main's suite and red here by name, and the column-count mutant is recorded under its own name. Approving. I'll merge once CI is green, after checking the approval is on this head.

🤖 Generated with Claude Code

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