ClickHouse/src/Parsers/ASTOrderByElement.cpp

51 lines
1.7 KiB
C++
Raw Normal View History

2017-11-20 06:01:05 +00:00
#include <Columns/Collator.h>
#include <Parsers/ASTOrderByElement.h>
2016-11-20 12:43:20 +00:00
namespace DB
{
void ASTOrderByElement::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
{
children.front()->formatImpl(settings, state, frame);
settings.ostr << (settings.hilite ? hilite_keyword : "")
<< (direction == -1 ? " DESC" : " ASC")
<< (settings.hilite ? hilite_none : "");
2016-11-20 12:43:20 +00:00
if (nulls_direction_was_explicitly_specified)
{
settings.ostr << (settings.hilite ? hilite_keyword : "")
<< " NULLS "
<< (nulls_direction == direction ? "LAST" : "FIRST")
<< (settings.hilite ? hilite_none : "");
}
if (collation)
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << " COLLATE " << (settings.hilite ? hilite_none : "");
collation->formatImpl(settings, state, frame);
}
if (with_fill)
{
2019-11-08 16:54:13 +00:00
settings.ostr << (settings.hilite ? hilite_keyword : "") << " WITH FILL" << (settings.hilite ? hilite_none : "");
if (fill_from)
{
2019-11-08 16:54:13 +00:00
settings.ostr << (settings.hilite ? hilite_keyword : "") << " FROM " << (settings.hilite ? hilite_none : "");
fill_from->formatImpl(settings, state, frame);
}
if (fill_to)
{
2019-11-08 16:54:13 +00:00
settings.ostr << (settings.hilite ? hilite_keyword : "") << " TO " << (settings.hilite ? hilite_none : "");
fill_to->formatImpl(settings, state, frame);
}
if (fill_step)
{
2019-11-08 16:54:13 +00:00
settings.ostr << (settings.hilite ? hilite_keyword : "") << " STEP " << (settings.hilite ? hilite_none : "");
fill_step->formatImpl(settings, state, frame);
}
}
2016-11-20 12:43:20 +00:00
}
}