Repository navigation
Conversation
…unds The Iceberg foreign data wrapper returned no rows, and no error, for a filter that matched rows when an Iceberg decimal column was declared int or bigint. Spark stores a decimal of precision 18 or less as a Parquet INT32 or INT64, and the reader returns the unscaled integer for such a declaration. On main, d = 20000000 on decimal(9,2) declared int returned nothing, and so did decimal(18,2) declared bigint. Cause: the FDW chose min/max pruning by the PostgreSQL type alone and decoded every bound as a little-endian integer. Iceberg writes a decimal bound as the unscaled value in big-endian two's complement, so the range came out wrong and the file was pruned. Bucket pruning had the same fault: it hashed the constant as an 8-byte long, where Iceberg hashes the decimal's bytes. The fix reads the Iceberg field type from the current schema. PgColumnarIcebergColumnFieldIds gives a column no field id unless the field is an int, long or boolean, so no metric qual is compiled for it. PgColumnarIcebergBucketMap maps a bucket field only when an int column sits over an int or long field, or a text column over a string field. A bigint declaration over an INT32 decimal now fails with a filter too (42804), as the full scan always did, because no file is pruned first. Tests: 10 checks in test/iceberg_fdw.sh and their pytest twins in test_iceberg_fdw.py, plus one pytest-only oracle comparison. A new fixture, warehouse_decimal, written by gen_iceberg_decimal.py with pyiceberg 0.12.0, holds decimal(9,2) as INT32, decimal(18,2) as INT64 and a bucket[8] partition on the decimal. Red on PG18 with main d52f6e8: 7 checks failed, for example "FAIL decimal: d = 20000000 on decimal(18,2) read as bigint returns id 2: got [none] want [2]". With the metric fix alone, the bucket check still failed: "got 'none' want '1'". The three controls passed on main. Registries: cluster_tests 5376 -> 5381 by collection. The ledger merged five green iceberg_fdw.sh logs, PG15 to PG19, in one merge, then the PG18 red log with --mutation, --target for each of the 7 failed checks and --reds-are-real. 10 new rows, 3 never observed red, so checks_never_observed_red moves 4894 -> 4897. Fixes #2086 Ledger-census: rows=9670 never=4897 dated=4773 Co-Authored-By: Claude Opus 5.5 <[email protected]>
ubuntu-latest moved from ubuntu-24.04 to ubuntu-26.04 between 2026-11-12 and 2026-11-22. Since then `sudo -E` no longer carries GITHUB_BASE_REF into run_all_versions.sh. The ledger gate then cannot find the PR's base and refuses: "no trustworthy prior ceiling: GITHUB_BASE_REF is unset". Every PR fails suites (PG 17) and suites (PG 18) although every suite passes (#2056, and every PR from #2127 to #2159). The step now names the variable in the env list, so it reaches the gate whatever sudo preserves. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The suites (PG 17) and suites (PG 18) jobs fail on every PR with "ledger integrity failure: no trustworthy prior ceiling: GITHUB_BASE_REF is unset", because ubuntu-latest moved to 26.04 and sudo -E no longer passes the variable. PR #2162 (845c83e) fixes the workflow but is not merged into main yet, so this branch takes it directly. The merge had no conflicts; CHANGELOG.md keeps both entries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
test/fixtures/iceberg/gen_iceberg_decimal.py starts with a #! line but was
committed with mode 100644. harness_selftest part 300 requires every script
that declares an interpreter to be executable, so suites (PG 17) and
suites (PG 18) failed on this PR with:
FAIL every script that declares an interpreter is executable:
got [[1: test/fixtures/iceberg/gen_iceberg_decimal.py]] want [[]]
The file is now 100755, like the other generators in that directory. The
test was right; only the file mode changes.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fix-up pushed: two commits on top of 6f3614d (new head f4180a6)1. Merged
|
| What | Result |
|---|---|
make after make clean |
38 compiles, 0 warnings |
Guard half (test/pytest/README.md) |
894 passed, expected guard_tests 894 |
test/iceberg_fdw.sh |
accounting: 102 passed + 0 failed + 0 unrunnable + 0 skipped = 102 |
test_iceberg_fdw.py (--pg-config set to the PG 18 build) |
72 passed, accounting: 107 pass + 0 fail + 0 unrun = 107 |
census-commits --against origin/main |
1 change test/check_ledger.tsv since d52f6e8c ..., 0 refused |
I also ran test/run_all_versions.sh on PG 18 with GITHUB_BASE_REF=main, so the ledger gate ran the way CI runs it, with --registered built by the script. The gate passed:
ledger census: rows=9670 | never observed red=4897, ever red=4773, new this run=0
census stated 4897, ledger holds 4897: they agree
ledger coverage: registered=312 | covered=293, not covered=19, ceiling=19
ceiling against refs/remotes/origin/main (4 commits behind HEAD): 19 -> 19, which does not rise
census commits: 1 change test/check_ledger.tsv since d52f6e8c (merge base with refs/remotes/origin/main), 0 refused
That run still ended FAIL PG18, for reasons that come from my machine, not from this PR:
audit,phase2tophase6andsmokecould not connect (createdb: error: connection to server on socket ".../fx-iceberg-0/.s.PGSQL.NNNNN" failed). My sandbox'sPGHOSTsetting leaked into these suites.logical_subscriberfailed withFATAL: role "postgres" does not exist, because I ran it as a non-root user.harness_selftestskipped for the same reason.
None of these suites failed in CI on this PR.
Not verified
CI on f4180a6 has not finished yet.
Fixes #2086.
Problem
The
pgcolumnar_icebergforeign data wrapper (FDW) returned no rows, and no error, for a filter that matched rows. This happened when an Icebergdecimalcolumn was declaredintorbigint. Spark stores a decimal of precision 18 or less as a Parquet INT32 or INT64, and the reader returns its unscaled integer for such a declaration.decimal(9,2)declaredint:d = 20000000returned nothing.decimal(18,2)declaredbigint:d = 20000000returned nothing, although the full scan reads the column correctly.decimal(9,2)declaredbigint: the full scan fails with 42804, but a filtered scan returned an empty result.bucket[8]on a decimal declaredint:d = 10000000returned nothing.Cause
Both lines are in the FDW's pruning setup.
int2,int4,int8,bool), andice_fdw_bound_intdecoded every bound as a little-endian integer. Iceberg writes a decimal bound as the unscaled value in big-endian two's complement. So0x00989680(10000000) decoded as a negative number, and the file was pruned.Because the file was pruned before it was opened, the reader's type check never ran. That is why the refused
bigintdeclaration returned nothing instead of 42804.The fix
The FDW now reads the Iceberg field type from the table's current schema before it prunes.
PgColumnarIcebergColumnFieldIdsgives a column no field id unless its Iceberg field isint,longorboolean. No min/max qual is compiled without a field id.PgColumnarIcebergBucketMapmaps a bucket field only for anint2/int4/int8column over an Icebergintorlong, or atext/varcharcolumn over an Icebergstring. Those are the pairsice_fdw_bucket_of_consthashes the way Iceberg does.A decimal column is no longer pruned by metrics or by bucket. It is read, so it returns the right rows, and a refused declaration fails with 42804 with or without a filter. The
longcolumn of the same file still prunes on min/max (a control check pins this).A new fixture,
test/fixtures/iceberg/warehouse_decimal, is written bygen_iceberg_decimal.pywith pyiceberg 0.12.0. It holdsdecimal(9,2)as INT32,decimal(18,2)as INT64, and abucket[8]partition on the decimal. The tables have the unscaled values 10000000 (id 1) and 20000000 (id 2).docs/features.mdnow states which Iceberg types metrics pruning covers.Red, on main's code
PG18, d52f6e8, with only the tests and fixture added.
test/iceberg_fdw.sh:test_iceberg_fdw.py -k decimal:The three passing checks are controls: the premise, the full-scan refusal, and the
longcolumn still pruning.The bucket gate is needed on its own. With the metric fix in place and the bucket gate disabled, the bucket test still failed:
Green
PG18,
test/iceberg_fdw.sh:PG18,
test_iceberg_fdw.py -k decimal -v:The build gives no compiler warnings (
make 2>err; grep warning: erris empty on PG18).Suites run
All on the final source.
Shell suites, PG18 (18.6) and PG17 (17.11), every one exit 0, same counts on both majors:
fdw_plan_privilege8,iceberg_catalog12,iceberg_data_files42,iceberg_deletes73,iceberg_dv26,iceberg_fdw102,iceberg_fdw_estimate4,iceberg_fdw_projection7,iceberg_malformed68,iceberg_name_mapping22,iceberg_name_mapping_memory7,iceberg_objstore19,iceberg_rest16,iceberg_rest_scan128,iceberg_rest_server39,iceberg_rest_vended18,iceberg_scan46,objstore_error_advice30,planner_choice_quality11. All passed, 0 failed.test/iceberg_fdw.shon PG15, PG16 and PG19 (19beta4) as well, for the ledger: 102 passed + 0 failed on each.pytest,
-n 4,test_iceberg_*.py,test_objstore_error_advice.py,test_planner_choice_quality.py,test_fdw_plan_privilege.py:Guard half, as the README shows:
894 passed,accounting: 2440 pass + 0 fail + 0 unrun = 2440.docs_style.sh: 54 passed.Registries:
cluster_tests5376 -> 5381, by collection of the cluster half.compare_to_bash.pyreports 104 literal matches and 0 missing foriceberg_fdw.shagainsttest_iceberg_fdw.py. The ledger has 10 new rows from one merge of five green logs (PG15 to PG19), then the PG18 red log with--reds-are-real, a--mutationand a--targetfor each of the 7 failed checks.checks_never_observed_red4894 -> 4897.census-commitsreports 0 refused.Not verified
columnar_iceberg.c, whose two changed functions the Iceberg FDW alone calls.test_objstore_module.py,test_extension_upgrade.pyandtest_format_downgrade.pywere not run; this change does not touch the code they cover.🤖 Generated with Claude Code