Skip to content

chore: Setup project layout - #1

Merged
Fokko merged 7 commits into
apache:mainfrom
Xuanwo:setup
Jul 21, 2023
Merged

Fokko merged 7 commits into
apache:mainfrom
Xuanwo:setup

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Jul 21, 2023 •

Copy link
Copy Markdown
Member

This PR will setup the basic project layout.

Please use sqaush merge.

Xuanwo added 3 commits July 21, 2023 14:40
Signed-off-by: Xuanwo <[email protected]>
Signed-off-by: Xuanwo <[email protected]>
@Xuanwo

Xuanwo commented Jul 21, 2023

Copy link
Copy Markdown
Member Author

cc @JanKaul, @liurenjie1024 for review.

Xuanwo added 2 commits July 21, 2023 14:50
Signed-off-by: Xuanwo <[email protected]>
Signed-off-by: Xuanwo <[email protected]>

@liurenjie1024 liurenjie1024 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Others LGTM

Comment thread .asf.yaml Resolved

@liurenjie1024 liurenjie1024 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

Comment thread .asf.yaml Resolved
Comment thread .github/dependabot.yml Resolved
Signed-off-by: Xuanwo <[email protected]>
@Fokko
Fokko merged commit bd435b2 into apache:main Jul 21, 2023
@Xuanwo
Xuanwo deleted the setup branch July 21, 2023 08:47
himadripal pushed a commit to himadripal/iceberg-rust that referenced this pull request Apr 17, 2024
fix connection pool issue for sql catalog
hareshkh pushed a commit to hareshkh/iceberg-rust that referenced this pull request Feb 17, 2026
* try publish

* try

* fix

* use make

* try docker up

* machine exec

* shit
@mbutrovich mbutrovich mentioned this pull request Mar 11, 2026
11 of 15 tasks
greedAuguria referenced this pull request in auguria-io/iceberg-rust May 25, 2026
… not REE

The RecordBatchTransformer back-fills identity-partition columns missing
from a data file (Iceberg column-projection rule #1, commit 663d7a3) and
materialized those constants as RunEndEncoded "for efficiency". But files
that physically carry the column emit the flat type via PassThrough, so the
per-file output schema diverged: `Utf8` for present files vs
`RunEndEncoded(Utf8)` for back-filled ones.

When a DataFusion compaction scans a mix of both (a table with schema
evolution / partial column presence), it concatenates batches across files
and panics:

    Arrow error: It is not possible to concatenate arrays of different data
    types (Utf8, RunEndEncoded("run_ends": Int32, "values": Utf8))

Observed live on golden `dev_golden_ingest_e1_search_events_cisco_asa`
(plan-46 Task 7): the first real `dryRun=false` compaction failed before
commit (no data harm). The existing REE->flat decodes (ad707b3, 7134847)
only run at the WRITE boundary, downstream of this read/merge concat, so
they never see it.

Fix: an identity-partition constant exists in the table schema, so emit it
in the canonical schema type (e.g. `Utf8`) for both the output schema field
and the `ColumnSource::Add` op. Back-filled and read-through files then share
an identical output schema and concat cleanly. Virtual/metadata constants
(`_file`, never in the schema, always back-filled -> already self-consistent)
keep RunEndEncoded, which is a genuine memory win there.

Tests: new `test_partition_constant_schema_matches_passthrough` asserts a
back-filled file and a read-through file produce identical output schemas
(the precondition `concat_batches` enforces); updated
`test_virtual_partition_column_uses_manifest_value` to assert flat `Utf8`.
All 19 record_batch_transformer tests pass.
greedAuguria referenced this pull request in auguria-io/iceberg-rust May 25, 2026
Data files lacking embedded Iceberg field ids were assigned field ids
positionally (physical column N -> field-id N+1) and projected positionally.
That is only correct when a file's physical column order matches field-id
order. A schema-evolving writer that omits a column mid-schema and appends
later ones violates it: on golden cisco_asa, files omit product_name
(field-id 22) and append auguria_event_timestamp, so physical slot 21 (where
field-id 22 falls positionally) holds auguria_event_timestamp -- epoch-millis
were served as the product_name identity-partition value. Lossless but
silently corrupt partitioning (compaction split one table into ~9,787 bogus
product_name=<epoch-millis> partitions). Plan-46 Task 14.

Fix (crates/iceberg/src/arrow/reader.rs):
- assign_field_ids_by_name: for files without embedded ids and without an
  explicit schema.name-mapping.default, assign ids by NAME from the task
  schema, recursing through struct/list/map. Replaces the positional
  add_fallback_field_ids_to_arrow_schema (removed).
- Projection is now always field-id-based: ids are present either embedded
  (Branch 1) or name-assigned (Branch 2/3), so the position-based projection
  mask is no longer used in the read path.
- with_partition back-fill present-set is derived from the name-mapped arrow
  schema when ids aren't embedded, so omitted identity-partition columns stay
  eligible for manifest back-fill (rule #1) instead of being falsely reported
  present at an appended column's slot.
- New regression test
  test_read_parquet_without_field_ids_omitted_identity_partition_backfills_from_manifest.

Name-based resolution degrades to the same result as positional when order
does match field-id order, so nothing is lost. All 81 arrow:: unit tests pass;
clippy clean. Validated end-to-end on golden cisco_asa (465->1, lossless
1,717,975, product_name=cisco_asa) and cisco_asa_firewall (464->1, lossless
1,710,524, product_name=cisco_asa_firewall).
dannycjones added a commit to dannycjones/iceberg-rust that referenced this pull request Sep 17, 2026
A Parquet column the reader cannot read at the projected type was silently
turned into NULLs by the field-ID projection path, without logging, warning,
or erroring.

`get_arrow_projection_mask_with_field_ids` collapsed three unrelated
conditions into one sentinel -- absence from `column_map`: the Arrow field
carries no `PARQUET:field_id`, the field id is absent from either schema,
and `type_promotion_is_valid` rejects the file/projected type pair. The
NULL-filling that follows, and `RecordBatchTransformer` downstream, then
read that sentinel as exactly one thing: the column is not in the file.

Conflating "the file does not contain this column" -- where NULL is
spec-correct, per column-projection rule apache#4 -- with "the file contains this
column but we cannot read its type" means a query returns NULLs where real
values exist on disk. All four column-projection rules are scoped by their
preamble to "field ids which are not present in a data file"; a present-but-
unreadable column was never in scope for any of them.

Since the `filter_leaves` closure cannot return `Err`, accumulate the type
mismatches and fail once it returns, naming all of them; genuine not-present
cases still return `false`. The comment above the projection loop now states
the resulting invariant.

Identity partition columns
--------------------------

The worst case is an identity-partitioned column, covered by
`test_identity_partition_column_unreadable_in_file_errors`. When the
unreadable column was also an identity partition column, skipping the leaf
made it look absent to `RecordBatchTransformer` -- whose `present_in_file`
test consults the *projected* batch schema, not the file -- so rule apache#1 fired
and the manifest's partition constant was served in place of the column.

That was never correct: rule apache#1 is a rule about absent columns, for
metadata-only Hive migrations where the partition value lives only in the
directory path. It is also not reliably right even as a guess, since the
constant matches the column's values only if the file agrees with its
manifest, and the column we cannot decode is exactly the one we cannot check
that against. The test's file deliberately disagrees with its partition
metadata to pin this down: before this change the scan returned the constant
`20240101` for both rows while the file held `20240102` and `20240103`.
Failing the scan is the correct outcome, so no exemption is carved out for
the partition-column case.

The stale comment claiming partition metadata is authoritative over the
file's own columns is corrected; the code has implemented the opposite since
identity-partition reads were fixed, and the two disagreed.

Error kind
----------

`FeatureUnsupported`, not `DataInvalid`: this fires whenever a pair is
missing from `type_promotion_is_valid`'s allowlist, and that allowlist is
narrower than the spec. Some pairs really are invalid data -- the spec
forbids narrowing, so a `long` column under an `int` schema cannot come from
a valid schema history -- but others are valid files this reader cannot yet
interpret, such as a Parquet `Geometry` column that arrow-rs surfaces as
`Binary`, or the v3 `date` -> `timestamp` promotion the allowlist omits. One
error kind covers both, so prefer the one that does not tell users their
valid files are corrupt.

Position-fallback path: left as a marked follow-up
--------------------------------------------------

`get_arrow_projection_mask_fallback` type-checks nothing, so the same harm
still arrives by a different route on that path: the column is projected,
reaches `ColumnSource::Promote`, and is cast with `safe: true`, which NULLs
unrepresentable values row by row while representable ones pass through.
`test_fallback_projection_silently_nulls_unrepresentable_values` pins the
behaviour rather than leaving it undocumented -- a file `long` [30,
5000000000, -3] read as `int` yields [30, NULL, -3].

Applying `type_promotion_is_valid` here is not the fix, and an earlier
revision of this commit that did so is reverted. That allowlist answers "is
this a legal Iceberg promotion", which presumes an Iceberg-aware writer;
files reaching this path have none, so their physical types diverge by
construction. Measured: pre-screening turns a Hive `string` column (written
as unannotated Parquet `binary`) and a `timestamptz` column (written as
naive `Timestamp(us, None)`) from correct reads into hard scan failures.
`test_fallback_projection_reads_diverging_physical_types` locks both files in
as readable so the mistake is not repeated.

A strict (`safe: false`) `Promote` cast is the promising direction: it
permits every lossless cast and fails only on the values that would become
NULL. Measured across the `iceberg` suite, it changes exactly one test --
the gap-pinning one above -- and nothing else. It is left out of this commit
because it is a second behaviour change on a second path, and because the
same cast is shared with the equality-delete loader, where the blast radius
differs (wrong rows returned rather than missing values).

Follow-ups are marked in code rather than left implicit, on
`get_arrow_projection_mask_fallback` (no type check; positional misalignment
undetectable), `build_field_id_set_and_map` (predicate-only columns bypass
the type check entirely, since `collect_scan_field_ids` derives
`project_field_ids` from selected column names alone), and
`BasicDeleteFileLoader::evolve_schema` (delete keys lost to a cast silently
match no row).

Compatibility
-------------

This is a behaviour change on the field-ID path: reads that silently
NULL-fill today will error. Every case it changes is a case that returns
wrong data today. `type_promotion_is_valid` permits only a short allowlist
(`Int`->`Long`, `Float`->`Double`, widening `Decimal`, `Fixed(16)`->`Uuid`)
with `_ => false` as its fallthrough, so the affected set is not narrow.
Distinct from an unsupported *Arrow* type, which already errors earlier via
`arrow_schema_to_schema`.
dannycjones added a commit to dannycjones/iceberg-rust that referenced this pull request Sep 17, 2026
A Parquet column the reader cannot read at the projected type was silently
turned into NULLs by the field-ID projection path, without logging, warning,
or erroring.

`get_arrow_projection_mask_with_field_ids` collapsed three unrelated
conditions into one sentinel -- absence from `column_map`: the Arrow field
carries no `PARQUET:field_id`, the field id is absent from either schema,
and `type_promotion_is_valid` rejects the file/projected type pair. The
NULL-filling that follows, and `RecordBatchTransformer` downstream, then
read that sentinel as exactly one thing: the column is not in the file.

Conflating "the file does not contain this column" -- where NULL is
spec-correct, per column-projection rule apache#4 -- with "the file contains this
column but we cannot read its type" means a query returns NULLs where real
values exist on disk. All four column-projection rules are scoped by their
preamble to "field ids which are not present in a data file"; a present-but-
unreadable column was never in scope for any of them.

Accumulate the type mismatches and fail once the `filter_leaves` closure has
returned, naming all of them; genuine not-present cases still return `false`.
The comment above the projection loop now states the resulting invariant.

Reporting from inside the closure is possible -- arrow exposes
`try_filter_leaves`, and `filter_leaves` is implemented in terms of it -- but
accumulating is preferred on two counts. `try_filter_leaves` short-circuits on
the first `Err`, so a file with several unreadable columns would name only one,
and naming all of them is the point. Its closure also yields
`Result<bool, ArrowError>`, and `ArrowError` converts to `ErrorKind::Unexpected`
(`error.rs`), so returning `FeatureUnsupported` through it means wrapping in
`ArrowError::ExternalError` and downcasting back out -- more machinery than a
`Vec<String>`, and it degrades quietly to `Unexpected` if the round-trip is got
wrong.

Identity partition columns
--------------------------

The worst case is an identity-partitioned column, covered by
`test_identity_partition_column_unreadable_in_file_errors`. When the
unreadable column was also an identity partition column, skipping the leaf
made it look absent to `RecordBatchTransformer` -- whose `present_in_file`
test consults the *projected* batch schema, not the file -- so rule apache#1 fired
and the manifest's partition constant was served in place of the column.

That was never correct: rule apache#1 is a rule about absent columns, for
metadata-only Hive migrations where the partition value lives only in the
directory path. It is also not reliably right even as a guess, since the
constant matches the column's values only if the file agrees with its
manifest, and the column we cannot decode is exactly the one we cannot check
that against. The test's file deliberately disagrees with its partition
metadata to pin this down: before this change the scan returned the constant
`20240101` for both rows while the file held `20240102` and `20240103`.
Failing the scan is the correct outcome, so no exemption is carved out for
the partition-column case.

The stale comment claiming partition metadata is authoritative over the
file's own columns is corrected; the code has implemented the opposite since
identity-partition reads were fixed, and the two disagreed.

Error kind
----------

`FeatureUnsupported`, not `DataInvalid`: this fires whenever a pair is
missing from `type_promotion_is_valid`'s allowlist, and that allowlist is
narrower than the spec. Some pairs really are invalid data -- the spec
forbids narrowing, so a `long` column under an `int` schema cannot come from
a valid schema history -- but others are valid files this reader cannot yet
interpret, such as a Parquet `Geometry` column that arrow-rs surfaces as
`Binary`, or the v3 `date` -> `timestamp` promotion the allowlist omits. One
error kind covers both, so prefer the one that does not tell users their
valid files are corrupt.

Position-fallback path: left as a marked follow-up
--------------------------------------------------

`get_arrow_projection_mask_fallback` type-checks nothing, so the same harm
still arrives by a different route on that path: the column is projected,
reaches `ColumnSource::Promote`, and is cast with `safe: true`, which NULLs
unrepresentable values row by row while representable ones pass through.
`test_fallback_projection_silently_nulls_unrepresentable_values` pins the
behaviour rather than leaving it undocumented -- a file `long` [30,
5000000000, -3] read as `int` yields [30, NULL, -3].

Applying `type_promotion_is_valid` here is not the fix, and an earlier
revision of this commit that did so is reverted. That allowlist answers "is
this a legal Iceberg promotion", which presumes an Iceberg-aware writer;
files reaching this path have none, so their physical types diverge by
construction. Measured: pre-screening turns a Hive `string` column (written
as unannotated Parquet `binary`) and a `timestamptz` column (written as
naive `Timestamp(us, None)`) from correct reads into hard scan failures.
`test_fallback_projection_reads_diverging_physical_types` locks both files in
as readable so the mistake is not repeated.

A strict (`safe: false`) `Promote` cast is the promising direction: it
permits every lossless cast and fails only on the values that would become
NULL. Measured across the `iceberg` suite, it changes exactly one test --
the gap-pinning one above -- and nothing else. It is left out of this commit
because it is a second behaviour change on a second path, and because the
same cast is shared with the equality-delete loader, where the blast radius
differs (wrong rows returned rather than missing values).

Follow-ups are marked in code rather than left implicit, on
`get_arrow_projection_mask_fallback` (no type check; positional misalignment
undetectable), `build_field_id_set_and_map` (predicate-only columns bypass
the type check entirely, since `collect_scan_field_ids` derives
`project_field_ids` from selected column names alone), and
`BasicDeleteFileLoader::evolve_schema` (delete keys lost to a cast silently
match no row).

Compatibility
-------------

This is a behaviour change on the field-ID path: reads that silently
NULL-fill today will error. Every case it changes is a case that returns
wrong data today. `type_promotion_is_valid` permits only a short allowlist
(`Int`->`Long`, `Float`->`Double`, widening `Decimal`, `Fixed(16)`->`Uuid`)
with `_ => false` as its fallthrough, so the affected set is not narrow.
Distinct from an unsupported *Arrow* type, which already errors earlier via
`arrow_schema_to_schema`.
dannycjones added a commit to dannycjones/iceberg-rust that referenced this pull request Sep 17, 2026
A Parquet column the reader cannot read at the projected type was silently
turned into NULLs by the field-ID projection path, without logging, warning,
or erroring.

`get_arrow_projection_mask_with_field_ids` collapsed three unrelated
conditions into one sentinel -- absence from `column_map`: the Arrow field
carries no `PARQUET:field_id`, the field id is absent from either schema,
and `type_promotion_is_valid` rejects the file/projected type pair. The
NULL-filling that follows, and `RecordBatchTransformer` downstream, then
read that sentinel as exactly one thing: the column is not in the file.

Conflating "the file does not contain this column" -- where NULL is
spec-correct, per column-projection rule apache#4 -- with "the file contains this
column but we cannot read its type" means a query returns NULLs where real
values exist on disk. All four column-projection rules are scoped by their
preamble to "field ids which are not present in a data file"; a present-but-
unreadable column was never in scope for any of them.

Accumulate the type mismatches and fail once the `filter_leaves` closure has
returned, naming all of them; genuine not-present cases still return `false`.
The comment above the projection loop now states the resulting invariant.

Reporting from inside the closure is possible -- arrow exposes
`try_filter_leaves`, and `filter_leaves` is implemented in terms of it -- but
accumulating is preferred on two counts. `try_filter_leaves` short-circuits on
the first `Err`, so a file with several unreadable columns would name only one,
and naming all of them is the point. Its closure also yields
`Result<bool, ArrowError>`, and `ArrowError` converts to `ErrorKind::Unexpected`
(`error.rs`), so returning `FeatureUnsupported` through it means wrapping in
`ArrowError::ExternalError` and downcasting back out -- more machinery than a
`Vec<String>`, and it degrades quietly to `Unexpected` if the round-trip is got
wrong.

Identity partition columns
--------------------------

The worst case is an identity-partitioned column, covered by
`test_identity_partition_column_unreadable_in_file_errors`. When the
unreadable column was also an identity partition column, skipping the leaf
made it look absent to `RecordBatchTransformer` -- whose `present_in_file`
test consults the *projected* batch schema, not the file -- so rule apache#1 fired
and the manifest's partition constant was served in place of the column.

That was never correct: rule apache#1 is a rule about absent columns, for
metadata-only Hive migrations where the partition value lives only in the
directory path. It is also not reliably right even as a guess, since the
constant matches the column's values only if the file agrees with its
manifest, and the column we cannot decode is exactly the one we cannot check
that against. The test's file deliberately disagrees with its partition
metadata to pin this down: before this change the scan returned the constant
`20240101` for both rows while the file held `20240102` and `20240103`.
Failing the scan is the correct outcome, so no exemption is carved out for
the partition-column case.

The stale comment claiming partition metadata is authoritative over the
file's own columns is corrected; the code has implemented the opposite since
identity-partition reads were fixed, and the two disagreed.

Error kind
----------

`FeatureUnsupported`, not `DataInvalid`: this fires whenever a pair is
missing from `type_promotion_is_valid`'s allowlist, and that allowlist is
narrower than the spec. Some pairs really are invalid data -- the spec
forbids narrowing, so a `long` column under an `int` schema cannot come from
a valid schema history -- but others are valid files this reader cannot yet
interpret, such as a Parquet `Geometry` column that arrow-rs surfaces as
`Binary`, or the v3 `date` -> `timestamp` promotion the allowlist omits. One
error kind covers both, so prefer the one that does not tell users their
valid files are corrupt.

Position-fallback path: left as a marked follow-up
--------------------------------------------------

`get_arrow_projection_mask_fallback` type-checks nothing, so the same harm
still arrives by a different route on that path: the column is projected,
reaches `ColumnSource::Promote`, and is cast with `safe: true`, which NULLs
unrepresentable values row by row while representable ones pass through.
`test_fallback_projection_silently_nulls_unrepresentable_values` pins the
behaviour rather than leaving it undocumented -- a file `long` [30,
5000000000, -3] read as `int` yields [30, NULL, -3].

Applying `type_promotion_is_valid` here is not the fix, and an earlier
revision of this commit that did so is reverted. That allowlist answers "is
this a legal Iceberg promotion", which presumes an Iceberg-aware writer;
files reaching this path have none, so their physical types diverge by
construction. Measured: pre-screening turns a Hive `string` column (written
as unannotated Parquet `binary`) and a `timestamptz` column (written as
naive `Timestamp(us, None)`) from correct reads into hard scan failures.
`test_fallback_projection_reads_diverging_physical_types` locks both files in
as readable so the mistake is not repeated.

A strict (`safe: false`) `Promote` cast is the promising direction: it
permits every lossless cast and fails only on the values that would become
NULL. Measured across the `iceberg` suite, it changes exactly one test --
the gap-pinning one above -- and nothing else. It is left out of this commit
because it is a second behaviour change on a second path, and because the
same cast is shared with the equality-delete loader, where the blast radius
differs (wrong rows returned rather than missing values).

Remaining follow-ups are marked in code rather than left implicit, on
`get_arrow_projection_mask_fallback` (no type check; positional misalignment
undetectable), `try_cast_literal` in `predicate_visitor.rs` (see below), and
`BasicDeleteFileLoader::evolve_schema` (delete keys lost to a cast silently
match no row).

Filter columns
--------------

The type check covered projected columns only, and the projected set is not a
superset of the filtered set: `collect_scan_field_ids` derives
`project_field_ids` from the selected column names alone. So
`select(["name"]).filter(v < 100)` checked `name` and nothing else, while the
row filter went on to read `v` from the file regardless. Measured on one file
with `v` physically `long` under an `int` schema: selecting `v` failed with
`FeatureUnsupported`, while filtering on `v` without selecting it returned two
rows, filtered against a value (5_000_000_000) the projected schema says
cannot exist.

`get_arrow_projection_mask` now takes the predicate's field ids alongside the
projected ones. The union drives the pre-projection and the type check; the
returned mask is still built from the projected ids alone, so a filter-only
column is validated without being read into the output batch -- the row filter
reads it through its own mask, as before.
`test_predicate_only_column_is_type_checked` asserts both directions of the
pair so they cannot drift apart again.

Separately, and not fixed here: `try_cast_literal` casts the predicate literal
down to the file column's type with `safe: true`, so an out-of-range literal
becomes NULL and every comparison against it is NULL -- the scan silently
returns zero rows. This is reachable on a spec-legal promotion, so it is not a
consequence of an unreadable type: widen an `int` column to `long`, leave older
files physically `int`, and `v < 5000000000` returns 0 rows instead of all of
them. Measured, and noted on the function with the two candidate fixes. It is
out of scope here because it is a bug in literal handling rather than in
column-presence resolution, and it needs its own tests.

Compatibility
-------------

This is a behaviour change on the field-ID path: reads that silently
NULL-fill today will error, and scans that filter on a column at an unreadable
type will error where they previously returned rows. Every case it changes is a case that returns
wrong data today. `type_promotion_is_valid` permits only a short allowlist
(`Int`->`Long`, `Float`->`Double`, widening `Decimal`, `Fixed(16)`->`Uuid`)
with `_ => false` as its fallthrough, so the affected set is not narrow.
Distinct from an unsupported *Arrow* type, which already errors earlier via
`arrow_schema_to_schema`.
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.

3 participants