MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / getSortDescription

Method getSortDescription

src/Interpreters/InterpreterSelectQuery.cpp:1469–1500  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1467}
1468
1469SortDescription InterpreterSelectQuery::getSortDescription(const ASTSelectQuery & query, const ContextPtr & context_)
1470{
1471 SortDescription order_descr;
1472 order_descr.reserve(query.orderBy()->children.size());
1473
1474 for (const auto & elem : query.orderBy()->children)
1475 {
1476 const String & column_name = elem->children.front()->getColumnName();
1477 const auto & order_by_elem = elem->as<ASTOrderByElement &>();
1478
1479 std::shared_ptr<Collator> collator;
1480 if (order_by_elem.getCollation())
1481 collator = std::make_shared<Collator>(order_by_elem.getCollation()->as<ASTLiteral &>().value.safeGet<String>());
1482
1483 std::string alias;
1484 if (auto * identifier = order_by_elem.children[0]->as<ASTIdentifier>())
1485 alias = identifier->name();
1486
1487 if (order_by_elem.with_fill)
1488 {
1489 FillColumnDescription fill_desc = getWithFillDescription(order_by_elem, context_);
1490 order_descr.emplace_back(alias, column_name, order_by_elem.direction, order_by_elem.nulls_direction, collator, true, fill_desc);
1491 }
1492 else
1493 order_descr.emplace_back(alias, column_name, order_by_elem.direction, order_by_elem.nulls_direction, collator);
1494 }
1495
1496 order_descr.compile_sort_description = context_->getSettingsRef()[Setting::compile_sort_description];
1497 order_descr.min_count_to_compile_sort_description = context_->getSettingsRef()[Setting::min_count_to_compile_sort_description];
1498
1499 return order_descr;
1500}
1501
1502static InterpolateDescriptionPtr getInterpolateDescription(
1503 const ASTSelectQuery & query, const Block & source_block, const Block & result_block, const Aliases & aliases, ContextPtr context)

Callers 15

explainStepFunction · 0.80
tryTopKThroughJoinFunction · 0.80
enableMemoryBoundMergingFunction · 0.80
tryOptimizeTopKFunction · 0.80
pushLimitByIntoSortFunction · 0.80
tryUseVectorSearchFunction · 0.80
buildInputOrderInfoFunction · 0.80
wouldReadInOrderBeUsefulFunction · 0.80
optimizeReadInOrderFunction · 0.80

Calls 9

getWithFillDescriptionFunction · 0.85
reserveMethod · 0.45
sizeMethod · 0.45
orderByMethod · 0.45
getColumnNameMethod · 0.45
frontMethod · 0.45
getCollationMethod · 0.45
nameMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected