| 1 | #pragma once |
| 2 | |
| 3 | #include <Parsers/IAST.h> |
| 4 | |
| 5 | |
| 6 | namespace DB |
| 7 | { |
| 8 | /** Element of expression with ASC or DESC, |
| 9 | * and possibly with COLLATE. |
| 10 | */ |
| 11 | class ASTOrderByElement : public IAST |
| 12 | { |
| 13 | public: |
| 14 | int direction; /// 1 for ASC, -1 for DESC |
| 15 | int nulls_direction; /// Same as direction for NULLS LAST, opposite for NULLS FIRST. |
| 16 | bool nulls_direction_was_explicitly_specified; |
| 17 | |
| 18 | /** Collation for locale-specific string comparison. If empty, then sorting done by bytes. */ |
| 19 | ASTPtr collation; |
| 20 | |
| 21 | bool with_fill; |
| 22 | ASTPtr fill_from; |
| 23 | ASTPtr fill_to; |
| 24 | ASTPtr fill_step; |
| 25 | |
| 26 | ASTOrderByElement( |
| 27 | const int direction_, const int nulls_direction_, const bool nulls_direction_was_explicitly_specified_, |
| 28 | ASTPtr & collation_, const bool with_fill_, ASTPtr & fill_from_, ASTPtr & fill_to_, ASTPtr & fill_step_) |
| 29 | : direction(direction_) |
| 30 | , nulls_direction(nulls_direction_) |
| 31 | , nulls_direction_was_explicitly_specified(nulls_direction_was_explicitly_specified_) |
| 32 | , collation(collation_) |
| 33 | , with_fill(with_fill_) |
| 34 | , fill_from(fill_from_) |
| 35 | , fill_to(fill_to_) |
| 36 | , fill_step(fill_step_) |
| 37 | { |
| 38 | } |
| 39 | |
| 40 | String getID(char) const override { return "OrderByElement" ; } |
| 41 | |
| 42 | ASTPtr clone() const override |
| 43 | { |
| 44 | auto clone = std::make_shared<ASTOrderByElement>(*this); |
| 45 | clone->cloneChildren(); |
| 46 | return clone; |
| 47 | } |
| 48 | |
| 49 | protected: |
| 50 | void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override; |
| 51 | }; |
| 52 | } |
| 53 | |