Commit af725c0
committed
ORC-2161: [C++] UnionColumnReader should reject out-of-range union tags
### What changes were proposed in this pull request?
This PR adds validation for C++ union tag values before they are used as child indexes.
The change covers:
- UnionColumnReader::skip
- UnionColumnReader::nextInternal
- UnionColumnPrinter::printRow
If a malformed ORC file contains a union tag that is greater than or equal to the number of union children, the C++ reader/printer now throws ParseError instead of indexing out of bounds.
### Why are the changes needed?
Union tags are decoded from the ORC data stream as byte values, but the valid range depends on the number of union children. Malformed input can contain a tag outside that range. The C++ reader previously trusted the tag value directly when indexing per-child state.
This patch makes malformed union tags fail cleanly.
### How was this patch tested?
Added C++ unit tests for a two-child union with invalid tag value 200, covering:
- next
- next with nulls
- skip
- ColumnPrinter
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex GPT-5.
Closes #2618 from wgtmac/fix_union.
Authored-by: Gang Wu <ustcwg@gmail.com>
Signed-off-by: Gang Wu <ustcwg@gmail.com>
(cherry picked from commit 3563ee5)
Signed-off-by: Gang Wu <ustcwg@gmail.com>1 parent df7c5ea commit af725c0
4 files changed
Lines changed: 114 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
540 | 540 | | |
541 | 541 | | |
542 | 542 | | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
543 | 549 | | |
544 | | - | |
| 550 | + | |
545 | 551 | | |
546 | 552 | | |
547 | | - | |
| 553 | + | |
548 | 554 | | |
549 | 555 | | |
550 | 556 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1130 | 1130 | | |
1131 | 1131 | | |
1132 | 1132 | | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
1133 | 1143 | | |
1134 | 1144 | | |
1135 | 1145 | | |
| |||
1180 | 1190 | | |
1181 | 1191 | | |
1182 | 1192 | | |
1183 | | - | |
| 1193 | + | |
1184 | 1194 | | |
1185 | 1195 | | |
1186 | 1196 | | |
1187 | 1197 | | |
1188 | 1198 | | |
1189 | | - | |
| 1199 | + | |
1190 | 1200 | | |
1191 | | - | |
| 1201 | + | |
1192 | 1202 | | |
1193 | 1203 | | |
1194 | 1204 | | |
| |||
1224 | 1234 | | |
1225 | 1235 | | |
1226 | 1236 | | |
1227 | | - | |
| 1237 | + | |
| 1238 | + | |
1228 | 1239 | | |
1229 | 1240 | | |
1230 | 1241 | | |
1231 | 1242 | | |
1232 | | - | |
| 1243 | + | |
| 1244 | + | |
1233 | 1245 | | |
1234 | 1246 | | |
1235 | 1247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
506 | 506 | | |
507 | 507 | | |
508 | 508 | | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
509 | 528 | | |
510 | 529 | | |
511 | 530 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3717 | 3717 | | |
3718 | 3718 | | |
3719 | 3719 | | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
| 3733 | + | |
| 3734 | + | |
| 3735 | + | |
| 3736 | + | |
| 3737 | + | |
| 3738 | + | |
| 3739 | + | |
| 3740 | + | |
| 3741 | + | |
| 3742 | + | |
| 3743 | + | |
| 3744 | + | |
| 3745 | + | |
| 3746 | + | |
| 3747 | + | |
| 3748 | + | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
| 3753 | + | |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
| 3759 | + | |
| 3760 | + | |
| 3761 | + | |
| 3762 | + | |
| 3763 | + | |
| 3764 | + | |
| 3765 | + | |
| 3766 | + | |
| 3767 | + | |
| 3768 | + | |
| 3769 | + | |
| 3770 | + | |
| 3771 | + | |
| 3772 | + | |
| 3773 | + | |
| 3774 | + | |
| 3775 | + | |
| 3776 | + | |
| 3777 | + | |
| 3778 | + | |
| 3779 | + | |
| 3780 | + | |
| 3781 | + | |
| 3782 | + | |
| 3783 | + | |
| 3784 | + | |
| 3785 | + | |
| 3786 | + | |
| 3787 | + | |
| 3788 | + | |
| 3789 | + | |
3720 | 3790 | | |
3721 | 3791 | | |
3722 | 3792 | | |
| |||
0 commit comments