ClickHouse/src/Parsers/ASTOrderByElement.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

62 lines
2.1 KiB
C++
Raw Normal View History

2017-11-20 06:01:05 +00:00
#include <Columns/Collator.h>
#include <Parsers/ASTOrderByElement.h>
2020-08-20 02:01:40 +00:00
#include <Common/SipHash.h>
2020-11-09 16:05:40 +00:00
#include <IO/Operators.h>
2016-11-20 12:43:20 +00:00
namespace DB
{
2023-11-10 12:15:23 +00:00
void ASTOrderByElement::updateTreeHashImpl(SipHash & hash_state, bool ignore_aliases) const
2020-08-20 02:01:40 +00:00
{
hash_state.update(direction);
hash_state.update(nulls_direction);
hash_state.update(nulls_direction_was_explicitly_specified);
hash_state.update(with_fill);
2023-11-10 12:15:23 +00:00
IAST::updateTreeHashImpl(hash_state, ignore_aliases);
2020-08-20 02:01:40 +00:00
}
2016-11-20 12:43:20 +00:00
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 : "");
if (nulls_direction_was_explicitly_specified)
{
settings.ostr << (settings.hilite ? hilite_keyword : "")
<< " NULLS "
<< (nulls_direction == direction ? "LAST" : "FIRST")
<< (settings.hilite ? hilite_none : "");
}
2016-11-20 12:43:20 +00:00
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
}
}