Commit 909608a
authored
fix: Fix bug in
## Which issue does this PR close?
N/A
## Rationale for this change
In #20374, `array_has` with a scalar needle was optimized to reconstruct
matches more efficiently. Unfortunately, that code was incorrect for
sliced arrays: `values()` returns the entire value buffer (including
elements outside the visible slice), so we need to skip the
corresponding indexes in the result bitmap.
We could fix this by just skipping indexes, but it seems more robust and
efficient to arrange to not compare the needle against elements outside
the visible range in the first place.
`array_position` has a similar behavior (introduced in #20532): it
didn't have the buggy behavior, but it still did extra work for sliced
arrays by comparing against elements outside the visible range.
Benchmarking the revised code, there is no performance regression for
unsliced arrays.
## What changes are included in this PR?
* Fix `array_has` bug for sliced arrays with scalar needle
* Improve `array_has` and `array_position` to not compare against
elements outside the visible range of a sliced array
* Add unit test for `array_has` bug
* Add unit test to increase confidence in `array_position` behavior for
sliced arrays
## Are these changes tested?
Yes.
## Are there any user-facing changes?
No.array_has scalar path with sliced arrays (#20677)1 parent 10b5f22 commit 909608a
2 files changed
Lines changed: 140 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
355 | | - | |
356 | | - | |
357 | 355 | | |
358 | 356 | | |
359 | 357 | | |
| |||
362 | 360 | | |
363 | 361 | | |
364 | 362 | | |
365 | | - | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
366 | 374 | | |
367 | 375 | | |
368 | 376 | | |
| |||
382 | 390 | | |
383 | 391 | | |
384 | 392 | | |
385 | | - | |
386 | | - | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
387 | 400 | | |
388 | | - | |
389 | 401 | | |
390 | 402 | | |
391 | 403 | | |
| |||
394 | 406 | | |
395 | 407 | | |
396 | 408 | | |
397 | | - | |
| 409 | + | |
398 | 410 | | |
399 | 411 | | |
400 | 412 | | |
401 | 413 | | |
402 | 414 | | |
403 | 415 | | |
404 | | - | |
| 416 | + | |
405 | 417 | | |
406 | 418 | | |
407 | 419 | | |
| |||
1066 | 1078 | | |
1067 | 1079 | | |
1068 | 1080 | | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
1069 | 1127 | | |
1070 | 1128 | | |
1071 | 1129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | 233 | | |
238 | 234 | | |
239 | 235 | | |
240 | 236 | | |
241 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
242 | 250 | | |
243 | 251 | | |
244 | | - | |
| 252 | + | |
245 | 253 | | |
246 | 254 | | |
247 | 255 | | |
248 | 256 | | |
249 | 257 | | |
| 258 | + | |
| 259 | + | |
250 | 260 | | |
251 | | - | |
252 | | - | |
| 261 | + | |
| 262 | + | |
253 | 263 | | |
254 | 264 | | |
255 | 265 | | |
| |||
474 | 484 | | |
475 | 485 | | |
476 | 486 | | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
0 commit comments