| 389 | } |
| 390 | |
| 391 | bool isAlreadySorted(const Block & block, const SortDescription & description) |
| 392 | { |
| 393 | if (block.empty()) |
| 394 | return true; |
| 395 | |
| 396 | ColumnsWithSortDescriptions columns_with_sort_desc = getColumnsWithSortDescription(block, description); |
| 397 | bool is_collation_required = false; |
| 398 | |
| 399 | for (auto & column_with_sort_desc : columns_with_sort_desc) |
| 400 | { |
| 401 | if (isCollationRequired(column_with_sort_desc.description)) |
| 402 | { |
| 403 | is_collation_required = true; |
| 404 | break; |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | size_t rows = block.rows(); |
| 409 | |
| 410 | if (is_collation_required) |
| 411 | { |
| 412 | PartialSortingLessWithCollation less(columns_with_sort_desc); |
| 413 | return isAlreadySortedImpl(rows, less); |
| 414 | } |
| 415 | |
| 416 | PartialSortingLess less(columns_with_sort_desc); |
| 417 | return isAlreadySortedImpl(rows, less); |
| 418 | } |
| 419 | |
| 420 | } |
no test coverage detected