2017-11-20 06:01:05 +00:00
|
|
|
#include <Columns/Collator.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#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 : "");
|
|
|
|
|
2017-03-12 12:56:59 +00:00
|
|
|
if (nulls_direction_was_explicitly_specified)
|
|
|
|
{
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "")
|
|
|
|
<< " NULLS "
|
2017-03-12 13:27:25 +00:00
|
|
|
<< (nulls_direction == direction ? "LAST" : "FIRST")
|
2017-03-12 12:56:59 +00:00
|
|
|
<< (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);
|
|
|
|
}
|
2019-04-21 03:36:59 +00:00
|
|
|
|
|
|
|
if (with_fill)
|
|
|
|
{
|
2019-11-08 16:54:13 +00:00
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " WITH FILL" << (settings.hilite ? hilite_none : "");
|
2019-04-21 03:36:59 +00:00
|
|
|
if (fill_from)
|
|
|
|
{
|
2019-11-08 16:54:13 +00:00
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " FROM " << (settings.hilite ? hilite_none : "");
|
2019-04-21 03:36:59 +00:00
|
|
|
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 : "");
|
2019-04-21 03:36:59 +00:00
|
|
|
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 : "");
|
2019-04-21 03:36:59 +00:00
|
|
|
fill_step->formatImpl(settings, state, frame);
|
|
|
|
}
|
|
|
|
}
|
2016-11-20 12:43:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|