#include #include #include 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"; } } }