ClickHouse/src/Core/SortDescription.cpp

42 lines
860 B
C++
Raw Normal View History

2020-06-24 12:09:01 +00:00
#include <Core/SortDescription.h>
#include <Core/Block.h>
2020-06-27 14:02:24 +00:00
#include <IO/Operators.h>
2020-06-24 12:09:01 +00:00
namespace DB
{
2020-06-27 14:02:24 +00:00
void dumpSortDescription(const SortDescription & description, const Block & header, WriteBuffer & out)
2020-06-24 12:09:01 +00:00
{
2020-06-27 14:02:24 +00:00
bool first = true;
2020-06-24 12:09:01 +00:00
for (const auto & desc : description)
{
2020-06-27 14:02:24 +00:00
if (!first)
out << ", ";
first = false;
2020-06-24 12:09:01 +00:00
if (!desc.column_name.empty())
2020-06-27 14:02:24 +00:00
out << desc.column_name;
2020-06-24 12:09:01 +00:00
else
{
if (desc.column_number < header.columns())
2020-06-27 14:02:24 +00:00
out << header.getByPosition(desc.column_number).name;
2020-06-24 12:09:01 +00:00
else
2020-06-27 14:02:24 +00:00
out << "?";
2020-06-24 12:09:01 +00:00
2020-06-27 14:02:24 +00:00
out << " (pos " << desc.column_number << ")";
2020-06-24 12:09:01 +00:00
}
if (desc.direction > 0)
2020-06-27 14:02:24 +00:00
out << " ASC";
2020-06-24 12:09:01 +00:00
else
2020-06-27 14:02:24 +00:00
out << " DESC";
2020-06-24 12:09:01 +00:00
if (desc.with_fill)
2020-06-27 14:02:24 +00:00
out << " WITH FILL";
2020-06-24 12:09:01 +00:00
}
}
}