mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
OptimizeDateFilterVisitor: Revise variable names for clarity
This commit is contained in:
parent
773a5bbbaa
commit
1bc4eb1a6c
@ -10,26 +10,25 @@
|
|||||||
namespace DB
|
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();
|
const DateLUTImpl & date_lut = DateLUT::instance();
|
||||||
|
|
||||||
if (converter != "toYear") return {};
|
if (converter != "toYear") return {};
|
||||||
|
|
||||||
UInt64 year = compare_to;
|
String start_date = date_lut.dateToString(date_lut.makeDayNum(year, 1, 1));
|
||||||
String from_date = date_lut.dateToString(date_lut.makeDayNum(year, 1, 1));
|
String end_date = date_lut.dateToString(date_lut.makeDayNum(year, 12, 31));
|
||||||
String to_date = date_lut.dateToString(date_lut.makeDayNum(year, 12, 31));
|
|
||||||
|
|
||||||
if (comparator == "equals")
|
if (comparator == "equals")
|
||||||
{
|
{
|
||||||
return makeASTFunction("and",
|
return makeASTFunction("and",
|
||||||
makeASTFunction("greaterOrEquals",
|
makeASTFunction("greaterOrEquals",
|
||||||
std::make_shared<ASTIdentifier>(column),
|
std::make_shared<ASTIdentifier>(column),
|
||||||
std::make_shared<ASTLiteral>(from_date)
|
std::make_shared<ASTLiteral>(start_date)
|
||||||
),
|
),
|
||||||
makeASTFunction("lessOrEquals",
|
makeASTFunction("lessOrEquals",
|
||||||
std::make_shared<ASTIdentifier>(column),
|
std::make_shared<ASTIdentifier>(column),
|
||||||
std::make_shared<ASTLiteral>(to_date)
|
std::make_shared<ASTLiteral>(end_date)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -38,11 +37,11 @@ ASTPtr generateOptimizedDateFilterAST(const String & comparator, const String &
|
|||||||
return makeASTFunction("or",
|
return makeASTFunction("or",
|
||||||
makeASTFunction("less",
|
makeASTFunction("less",
|
||||||
std::make_shared<ASTIdentifier>(column),
|
std::make_shared<ASTIdentifier>(column),
|
||||||
std::make_shared<ASTLiteral>(from_date)
|
std::make_shared<ASTLiteral>(start_date)
|
||||||
),
|
),
|
||||||
makeASTFunction("greater",
|
makeASTFunction("greater",
|
||||||
std::make_shared<ASTIdentifier>(column),
|
std::make_shared<ASTIdentifier>(column),
|
||||||
std::make_shared<ASTLiteral>(to_date)
|
std::make_shared<ASTLiteral>(end_date)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -50,14 +49,14 @@ ASTPtr generateOptimizedDateFilterAST(const String & comparator, const String &
|
|||||||
{
|
{
|
||||||
return makeASTFunction(comparator,
|
return makeASTFunction(comparator,
|
||||||
std::make_shared<ASTIdentifier>(column),
|
std::make_shared<ASTIdentifier>(column),
|
||||||
std::make_shared<ASTLiteral>(from_date)
|
std::make_shared<ASTLiteral>(start_date)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return makeASTFunction(comparator,
|
return makeASTFunction(comparator,
|
||||||
std::make_shared<ASTIdentifier>(column),
|
std::make_shared<ASTIdentifier>(column),
|
||||||
std::make_shared<ASTLiteral>(to_date)
|
std::make_shared<ASTLiteral>(end_date)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user