2011-09-04 05:14:52 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/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:
|
2017-01-06 13:36:08 +00:00
|
|
|
int direction; /// 1 for ASC, -1 for DESC
|
2017-03-12 12:56:59 +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
|
|
|
|
2016-11-20 12:43:20 +00:00
|
|
|
/** Collation for locale-specific string comparison. If empty, then sorting done by bytes. */
|
|
|
|
ASTPtr collation;
|
2016-05-28 14:14:18 +00:00
|
|
|
|
2014-12-17 15:26:24 +00:00
|
|
|
ASTOrderByElement() = default;
|
2017-03-12 12:56:59 +00:00
|
|
|
ASTOrderByElement(const StringRange range_,
|
|
|
|
const int direction_, const int nulls_direction_, const bool nulls_direction_was_explicitly_specified_,
|
|
|
|
ASTPtr & collation_)
|
|
|
|
: IAST(range_),
|
|
|
|
direction(direction_), nulls_direction(nulls_direction_),
|
|
|
|
nulls_direction_was_explicitly_specified(nulls_direction_was_explicitly_specified_),
|
|
|
|
collation(collation_) {}
|
2016-05-28 14:14:18 +00:00
|
|
|
|
2014-12-17 15:26:24 +00:00
|
|
|
String getID() const override { return "OrderByElement"; }
|
2011-12-12 06:15:34 +00:00
|
|
|
|
2016-05-28 15:42:22 +00:00
|
|
|
ASTPtr clone() const override { return std::make_shared<ASTOrderByElement>(*this); }
|
2015-08-05 21:38:31 +00:00
|
|
|
|
|
|
|
protected:
|
2016-11-20 12:43:20 +00:00
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
2011-09-04 05:14:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|