mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 09:22:05 +00:00
42 lines
860 B
C++
42 lines
860 B
C++
#include <Core/SortDescription.h>
|
|
#include <Core/Block.h>
|
|
#include <IO/Operators.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
void dumpSortDescription(const SortDescription & description, const Block & header, WriteBuffer & out)
|
|
{
|
|
bool first = true;
|
|
|
|
for (const auto & desc : description)
|
|
{
|
|
if (!first)
|
|
out << ", ";
|
|
first = false;
|
|
|
|
if (!desc.column_name.empty())
|
|
out << desc.column_name;
|
|
else
|
|
{
|
|
if (desc.column_number < header.columns())
|
|
out << header.getByPosition(desc.column_number).name;
|
|
else
|
|
out << "?";
|
|
|
|
out << " (pos " << desc.column_number << ")";
|
|
}
|
|
|
|
if (desc.direction > 0)
|
|
out << " ASC";
|
|
else
|
|
out << " DESC";
|
|
|
|
if (desc.with_fill)
|
|
out << " WITH FILL";
|
|
}
|
|
}
|
|
|
|
}
|
|
|