Commit 7decfb2
authored
fix(scan): don't treat data columns named pos or file_path as metadata columns (#2865)
## Which issue does this PR close?
- Closes #2837.
## What changes are included in this PR?
A user data column named `pos` or `file_path` can't be scanned:
projecting it fails with `field not found`, and renaming the column
makes it work again. This bites VCF → Iceberg pipelines, where `pos` is
a common column name.
`pos` and `file_path` are the internal columns of a position-delete
file, but they were registered in the same reserved name→field-id map
(`get_metadata_field_id`) that a data-table scan consults through
`is_metadata_column_name`. Scan planning checks that map first and never
falls back to the data schema, so a real `pos` column gets mapped to a
reserved delete-file id and is never looked up in the actual schema.
The Iceberg spec reserves only `_`-prefixed names as metadata columns,
so they can't collide with user columns. This guards
`is_metadata_column_name` with a `starts_with('_')` check, and the two
bare names stop shadowing data columns. `get_metadata_field_id` still
maps them to their reserved ids, which the delete read path needs via
the id→field direction; its doc now says it isn't a membership test. No
public API signature changes.
## Are these changes tested?
Unit tests, no infrastructure needed:
- `metadata_columns`: `is_metadata_column_name` accepts the `_`-prefixed
names and rejects the bare `pos`/`file_path`, while
`get_metadata_field_id` still maps them to reserved ids.
- `scan`: projecting `pos`/`file_path`, both explicitly and via the
default projection, resolves to the real field id; an absent column
still fails with `DataInvalid` / "not found". Both fail before the fix
and pass after.
`cargo test -p iceberg --lib`, `cargo fmt --check`, and `cargo clippy -D
warnings` all pass.
## One open question for reviewers
This is the minimal fix, on the scan side. The bare names still live in
the shared name→id map, so `get_metadata_field_id("pos").is_ok()` stays
true and the two public predicates now disagree
(`is_metadata_column_name("pos")` is false). Removing the two names from
that map would be the deeper fix and looks safe in-repo (the delete read
path uses the untouched id→field direction), but it changes a second
public function's behavior, so I left it out. Happy to fold it in if
you'd rather go deeper.1 parent 4532da8 commit 7decfb2
2 files changed
Lines changed: 234 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
428 | 434 | | |
429 | 435 | | |
430 | 436 | | |
| |||
453 | 459 | | |
454 | 460 | | |
455 | 461 | | |
456 | | - | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
457 | 470 | | |
458 | 471 | | |
459 | 472 | | |
460 | 473 | | |
461 | 474 | | |
462 | | - | |
| 475 | + | |
463 | 476 | | |
464 | 477 | | |
465 | 478 | | |
| |||
468 | 481 | | |
469 | 482 | | |
470 | 483 | | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | 484 | | |
477 | 485 | | |
478 | 486 | | |
479 | 487 | | |
480 | 488 | | |
481 | | - | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
482 | 504 | | |
483 | 505 | | |
484 | 506 | | |
485 | 507 | | |
486 | 508 | | |
487 | | - | |
| 509 | + | |
488 | 510 | | |
489 | | - | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
490 | 521 | | |
491 | 522 | | |
492 | 523 | | |
| |||
569 | 600 | | |
570 | 601 | | |
571 | 602 | | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
572 | 679 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2775 | 2775 | | |
2776 | 2776 | | |
2777 | 2777 | | |
| 2778 | + | |
| 2779 | + | |
| 2780 | + | |
| 2781 | + | |
| 2782 | + | |
| 2783 | + | |
| 2784 | + | |
| 2785 | + | |
| 2786 | + | |
| 2787 | + | |
| 2788 | + | |
| 2789 | + | |
| 2790 | + | |
| 2791 | + | |
| 2792 | + | |
| 2793 | + | |
| 2794 | + | |
| 2795 | + | |
| 2796 | + | |
| 2797 | + | |
| 2798 | + | |
| 2799 | + | |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
| 2818 | + | |
| 2819 | + | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
| 2871 | + | |
| 2872 | + | |
| 2873 | + | |
| 2874 | + | |
| 2875 | + | |
| 2876 | + | |
| 2877 | + | |
| 2878 | + | |
| 2879 | + | |
| 2880 | + | |
| 2881 | + | |
| 2882 | + | |
| 2883 | + | |
| 2884 | + | |
| 2885 | + | |
| 2886 | + | |
| 2887 | + | |
| 2888 | + | |
| 2889 | + | |
| 2890 | + | |
| 2891 | + | |
| 2892 | + | |
| 2893 | + | |
| 2894 | + | |
2778 | 2895 | | |
2779 | 2896 | | |
2780 | 2897 | | |
| |||
0 commit comments