1#include <Columns/Collator.h>
2#include <Parsers/ASTOrderByElement.h>
3
4
5namespace DB
6{
7
8void ASTOrderByElement::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
9{
10 children.front()->formatImpl(settings, state, frame);
11 settings.ostr << (settings.hilite ? hilite_keyword : "")
12 << (direction == -1 ? " DESC" : " ASC")
13 << (settings.hilite ? hilite_none : "");
14
15 if (nulls_direction_was_explicitly_specified)
16 {
17 settings.ostr << (settings.hilite ? hilite_keyword : "")
18 << " NULLS "
19 << (nulls_direction == direction ? "LAST" : "FIRST")
20 << (settings.hilite ? hilite_none : "");
21 }
22
23 if (collation)
24 {
25 settings.ostr << (settings.hilite ? hilite_keyword : "") << " COLLATE " << (settings.hilite ? hilite_none : "");
26 collation->formatImpl(settings, state, frame);
27 }
28
29 if (with_fill)
30 {
31 settings.ostr << (settings.hilite ? hilite_keyword : "") << " WITH FILL" << (settings.hilite ? hilite_none : "");
32 if (fill_from)
33 {
34 settings.ostr << (settings.hilite ? hilite_keyword : "") << " FROM " << (settings.hilite ? hilite_none : "");
35 fill_from->formatImpl(settings, state, frame);
36 }
37 if (fill_to)
38 {
39 settings.ostr << (settings.hilite ? hilite_keyword : "") << " TO " << (settings.hilite ? hilite_none : "");
40 fill_to->formatImpl(settings, state, frame);
41 }
42 if (fill_step)
43 {
44 settings.ostr << (settings.hilite ? hilite_keyword : "") << " STEP " << (settings.hilite ? hilite_none : "");
45 fill_step->formatImpl(settings, state, frame);
46 }
47 }
48}
49
50}
51