From 1bc4eb1a6c26db08b6af33745feb83f92f093e9b Mon Sep 17 00:00:00 2001 From: Zhiguo Zhou Date: Thu, 25 May 2023 13:47:03 +0800 Subject: [PATCH] OptimizeDateFilterVisitor: Revise variable names for clarity --- .../OptimizeDateFilterVisitor.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Interpreters/OptimizeDateFilterVisitor.cpp b/src/Interpreters/OptimizeDateFilterVisitor.cpp index 4c714751f7d..58e1b3335f9 100644 --- a/src/Interpreters/OptimizeDateFilterVisitor.cpp +++ b/src/Interpreters/OptimizeDateFilterVisitor.cpp @@ -10,26 +10,25 @@ namespace DB { -ASTPtr generateOptimizedDateFilterAST(const String & comparator, const String & converter, const String & column, UInt64 compare_to) +ASTPtr generateOptimizedDateFilterAST(const String & comparator, const String & converter, const String & column, UInt64 year) { const DateLUTImpl & date_lut = DateLUT::instance(); if (converter != "toYear") return {}; - UInt64 year = compare_to; - String from_date = date_lut.dateToString(date_lut.makeDayNum(year, 1, 1)); - String to_date = date_lut.dateToString(date_lut.makeDayNum(year, 12, 31)); + String start_date = date_lut.dateToString(date_lut.makeDayNum(year, 1, 1)); + String end_date = date_lut.dateToString(date_lut.makeDayNum(year, 12, 31)); if (comparator == "equals") { return makeASTFunction("and", makeASTFunction("greaterOrEquals", std::make_shared(column), - std::make_shared(from_date) + std::make_shared(start_date) ), makeASTFunction("lessOrEquals", std::make_shared(column), - std::make_shared(to_date) + std::make_shared(end_date) ) ); } @@ -38,11 +37,11 @@ ASTPtr generateOptimizedDateFilterAST(const String & comparator, const String & return makeASTFunction("or", makeASTFunction("less", std::make_shared(column), - std::make_shared(from_date) + std::make_shared(start_date) ), makeASTFunction("greater", std::make_shared(column), - std::make_shared(to_date) + std::make_shared(end_date) ) ); } @@ -50,14 +49,14 @@ ASTPtr generateOptimizedDateFilterAST(const String & comparator, const String & { return makeASTFunction(comparator, std::make_shared(column), - std::make_shared(from_date) + std::make_shared(start_date) ); } else { return makeASTFunction(comparator, std::make_shared(column), - std::make_shared(to_date) + std::make_shared(end_date) ); } }