2011-09-04 05:14:52 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/IAST.h>
|
2016-11-20 12:43:20 +00:00
|
|
|
|
2011-09-04 05:14:52 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2017-01-06 13:36:08 +00:00
|
|
|
/** Element of expression with ASC or DESC,
|
|
|
|
* and possibly with COLLATE.
|
2011-09-04 05:14:52 +00:00
|
|
|
*/
|
|
|
|
class ASTOrderByElement : public IAST
|
|
|
|
{
|
|
|
|
public:
|
2018-05-18 18:30:02 +00:00
|
|
|
int direction; /// 1 for ASC, -1 for DESC
|
2017-04-01 07:20:54 +00:00
|
|
|
int nulls_direction; /// Same as direction for NULLS LAST, opposite for NULLS FIRST.
|
|
|
|
bool nulls_direction_was_explicitly_specified;
|
2016-05-28 14:14:18 +00:00
|
|
|
|
2019-04-23 01:48:51 +00:00
|
|
|
/** Collation for locale-specific string comparison. If empty, then sorting done by bytes. */
|
|
|
|
ASTPtr collation;
|
|
|
|
|
2019-04-21 03:36:59 +00:00
|
|
|
bool with_fill;
|
|
|
|
ASTPtr fill_from;
|
|
|
|
ASTPtr fill_to;
|
|
|
|
ASTPtr fill_step;
|
|
|
|
|
2018-12-07 12:34:40 +00:00
|
|
|
String getID(char) const override { return "OrderByElement"; }
|
2018-05-18 18:30:02 +00:00
|
|
|
|
|
|
|
ASTPtr clone() const override
|
|
|
|
{
|
2018-05-17 13:33:28 +00:00
|
|
|
auto clone = std::make_shared<ASTOrderByElement>(*this);
|
|
|
|
clone->cloneChildren();
|
Get rid of useless std::move to get NRVO
http://eel.is/c++draft/class.copy.elision#:constructor,copy,elision
Some quote:
> Speaking of RVO, return std::move(w); prohibits it. It means "use move constructor or fail to compile", whereas return w; means "use RVO, and if you can't, use move constructor, and if you can't, use copy constructor, and if you can't, fail to compile."
There is one exception to this rule:
```cpp
Block FilterBlockInputStream::removeFilterIfNeed(Block && block)
{
if (block && remove_filter)
block.erase(static_cast<size_t>(filter_column));
return std::move(block);
}
```
because references are not eligible for NRVO, which is another rule "always move rvalue references and forward universal references" that takes precedence.
2018-08-27 14:04:22 +00:00
|
|
|
return clone;
|
2018-05-17 13:33:28 +00:00
|
|
|
}
|
2015-08-05 21:38:31 +00:00
|
|
|
|
2020-08-20 02:01:40 +00:00
|
|
|
void updateTreeHashImpl(SipHash & hash_state) const override;
|
|
|
|
|
2015-08-05 21:38:31 +00:00
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
2011-09-04 05:14:52 +00:00
|
|
|
};
|
|
|
|
}
|