-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add arbitrary const expressions in limit processing #4246
add arbitrary const expressions in limit processing #4246
Conversation
Здравствуйте, я вроде как написал код по задаче "Произвольные константные выражения в LIMIT", но не могу его протестировать :/
Помогите, пожалуйста =) |
} | ||
} | ||
|
||
|
||
void InterpreterSelectQuery::getLimitUIntValue(const ASTPtr& ptr, size_t& result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not return by value?
if (!isNumber(eval_result.second)) { | ||
throw Exception("Illegal limit expression", ErrorCodes::INVALID_LIMIT_EXPRESSION); | ||
} | ||
result = applyVisitor(FieldVisitorConvertToNumber<UInt64>(), eval_result.first); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overflow may happen. Expressions like LIMIT -1
must be explicitly disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The simplest way is to check field type explicitly and process different cases for UInt64, Int64, Float64.
For Float64 we should also check that the limit is a whole number.
@@ -0,0 +1,7 @@ | |||
SELECT * FROM numbers(10) LIMIT 0.33 / 0.165 - 0.33 + 0.67; | |||
SELECT * FROM numbers(10) LIMIT LENGTH('NNN') + COS(0), TO_DATE('0000-00-02'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Date and DateTime should not work. Only numbers. We should check the data type.
SELECT * FROM numbers(10) LIMIT a + 5 - a; | ||
SELECT * FROM numbers(10) LIMIT a + b; | ||
SELECT * FROM numbers(10) LIMIT "Hello"; | ||
SELECT * FROM numbers(10) LIMIT ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cases of LIMIT BY and TOP should be also covered.
Судя по выводу, всё Ок.
Это не обязательно. Достаточно передать путь к клиенту в аргументах при запуске
Последний тест "with server" запускает все функциональные тесты, которые также можно запустить с помощью
|
Dear ClickHouse Team, |
It doesn't work at all:
|
Merged. |
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
For changelog. Remove if this is non-significant change.
Category (leave one):
Short description (up to few sentences):
Support for arbitrary constant expressions in
LIMIT
clause.