Merge pull request #70166 from ClickHouse/backport/24.8/70122

Backport #70122 to 24.8: Fix wrong LOGICAL_ERROR when replacing literals in ranges
This commit is contained in:
robot-ch-test-poll 2024-10-01 19:55:05 +02:00 committed by GitHub
commit 02fd7ea893
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View File

@ -326,9 +326,6 @@ ConstantExpressionTemplate::TemplateStructure::TemplateStructure(LiteralsInfo &
for (size_t i = 0; i < replaced_literals.size(); ++i)
{
const LiteralInfo & info = replaced_literals[i];
if (info.literal->begin.value() < prev_end)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Cannot replace literals");
while (prev_end < info.literal->begin.value())
{
tokens.emplace_back(prev_end->begin, prev_end->size());

View File

@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS 03246_range_literal_replacement_works (id UInt8) Engine=Memory;
INSERT INTO 03246_range_literal_replacement_works VALUES (1 BETWEEN 0 AND 2);
SELECT * FROM 03246_range_literal_replacement_works;
DROP TABLE IF EXISTS 03246_range_literal_replacement_works;