Commit 674c18b
committed
[feature](lance) push COUNT(*) down to Lance dataset metadata
COUNT(*)/COUNT(1) with no filter can be answered from the Lance dataset's
logical (post-deletion) row count instead of scanning any fragment.
FE (LanceScanNode): add canPushDownCountStar(), which is stricter than the
LIMIT pushdown gate -- it requires both an empty conjunct list and an empty
Lance Substrait filter, since any predicate would make the dataset-wide row
count larger than the real result. When it holds, emit whole-dataset count
carriers holding the logical row count. Each carrier is pinned to the planned
MVCC version (not latest) so a fallback scan -- an old BE, or a BE that
declines the shortcut -- reads exactly the snapshot the count came from
instead of drifting to latest on a time-travel or concurrent-commit read.
Because BE materializes one synthetic row per counted row, a count at or above
COUNT_WITH_PARALLEL_SPLITS is spread over parallelExecInstanceNum * numBackends
carriers (shares summing back to the exact total) to keep the former fragment
parallelism, mirroring IcebergScanNode; a small count stays on one carrier.
table_level_row_count is now always set explicitly, -1 for ordinary and search
scans, matching the Iceberg convention so BE never mistakes a stale value for
a metadata count.
BE (lance_reader): drop the hardcoded _remaining_table_level_count = -1 that
unconditionally disabled the base-class count path, and short-circuit both
prepare_split() and get_block() when _is_table_level_count_active() so the
counted rows are synthesized without opening a scanner.
Tests: add test_lance_optimize_count asserting EXPLAIN shows the metadata count
with no filter (and that the carrier pins the planned dataset version), and
falls back to a normal scan (with matching results) when a filter is present or
the switch is off. Add the multi_frag.lance fixture (three fragments, one
deleted row each: 30 physical / 27 logical rows) plus its build/self-check in
the preinstalled catalog script, which proves the count reports the logical
total and that a multi-split scan applies every fragment's deletion vector
exactly once.1 parent 970d951 commit 674c18b
21 files changed
Lines changed: 372 additions & 21 deletions
File tree
- be/src/format_v2/table
- docker/thirdparties/docker-compose/iceberg/scripts
- preinstalled_data/lance/multi_frag.lance
- _deletions
- _transactions
- _versions
- data
- fe/fe-core/src/main/java/org/apache/doris/datasource/lance/source
- regression-test
- data/external_table_p0/lance
- suites/external_table_p0/lance
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | 371 | | |
375 | 372 | | |
376 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
377 | 380 | | |
378 | 381 | | |
379 | 382 | | |
| |||
394 | 397 | | |
395 | 398 | | |
396 | 399 | | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
397 | 405 | | |
398 | 406 | | |
399 | 407 | | |
| |||
Lines changed: 77 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
102 | 121 | | |
103 | 122 | | |
104 | 123 | | |
| |||
239 | 258 | | |
240 | 259 | | |
241 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
242 | 279 | | |
243 | 280 | | |
| 281 | + | |
244 | 282 | | |
245 | 283 | | |
246 | 284 | | |
| |||
431 | 469 | | |
432 | 470 | | |
433 | 471 | | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
434 | 510 | | |
435 | 511 | | |
436 | 512 | | |
| |||
478 | 554 | | |
479 | 555 | | |
480 | 556 | | |
| 557 | + | |
481 | 558 | | |
482 | 559 | | |
483 | 560 | | |
| |||
0 commit comments