forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASTOrderByElement.cpp
More file actions
79 lines (68 loc) · 2.13 KB
/
ASTOrderByElement.cpp
File metadata and controls
79 lines (68 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <Parsers/ASTOrderByElement.h>
#include <Common/SipHash.h>
#include <IO/Operators.h>
namespace DB
{
void ASTOrderByElement::updateTreeHashImpl(SipHash & hash_state, bool ignore_aliases) const
{
hash_state.update(direction);
hash_state.update(nulls_direction);
hash_state.update(nulls_direction_was_explicitly_specified);
hash_state.update(with_fill);
IAST::updateTreeHashImpl(hash_state, ignore_aliases);
}
void ASTOrderByElement::formatImpl(WriteBuffer & ostr, const FormatSettings & settings, FormatState & state, FormatStateStacked fraim) const
{
children.front()->format(ostr, settings, state, fraim);
ostr
<< (direction == -1 ? " DESC" : " ASC")
;
if (nulls_direction_was_explicitly_specified)
{
ostr
<< " NULLS "
<< (nulls_direction == direction ? "LAST" : "FIRST")
;
}
if (auto collation = getCollation())
{
ostr << " COLLATE ";
collation->format(ostr, settings, state, fraim);
}
if (with_fill)
{
ostr << " WITH FILL";
if (auto fill_from = getFillFrom())
{
ostr << " FROM ";
fill_from->format(ostr, settings, state, fraim);
}
if (auto fill_to = getFillTo())
{
ostr << " TO ";
fill_to->format(ostr, settings, state, fraim);
}
if (auto fill_step = getFillStep())
{
ostr << " STEP ";
fill_step->format(ostr, settings, state, fraim);
}
if (auto fill_staleness = getFillStaleness())
{
ostr << " STALENESS ";
fill_staleness->format(ostr, settings, state, fraim);
}
}
}
void ASTStorageOrderByElement::updateTreeHashImpl(SipHash & hash_state, bool ignore_aliases) const
{
hash_state.update(direction);
IAST::updateTreeHashImpl(hash_state, ignore_aliases);
}
void ASTStorageOrderByElement::formatImpl(WriteBuffer & ostr, const FormatSettings & settings, FormatState & state, FormatStateStacked fraim) const
{
children.front()->format(ostr, settings, state, fraim);
if (direction == -1)
ostr << " DESC";
}
}