| 1117 | |
| 1118 | |
| 1119 | static UInt64 getLimitForSorting(const ASTSelectQuery & query, ContextPtr context) |
| 1120 | { |
| 1121 | /// Partial sort can be done if there is LIMIT but no DISTINCT or LIMIT BY, neither ARRAY JOIN. |
| 1122 | if (!query.distinct && !query.limitBy() && !query.limit_with_ties && !query.arrayJoinExpressionList() && query.limitLength()) |
| 1123 | { |
| 1124 | auto [limit_length, limit_offset] = getLimitLengthAndOffset(query, context); |
| 1125 | if (limit_length > std::numeric_limits<UInt64>::max() - limit_offset) |
| 1126 | return 0; |
| 1127 | |
| 1128 | return limit_length + limit_offset; |
| 1129 | } |
| 1130 | return 0; |
| 1131 | } |
| 1132 | |
| 1133 | |
| 1134 | static bool hasWithTotalsInAnySubqueryInFromClause(const ASTSelectQuery & query) |
no test coverage detected