| 1467 | } |
| 1468 | |
| 1469 | SortDescription 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 | |
| 1502 | static InterpolateDescriptionPtr getInterpolateDescription( |
| 1503 | const ASTSelectQuery & query, const Block & source_block, const Block & result_block, const Aliases & aliases, ContextPtr context) |
no test coverage detected