-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
[native] Add row expression optimizer #22927
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,32 +33,10 @@ std::string toJsonString(const T& value) { | |
} | ||
|
||
std::string mapScalarFunction(const std::string& name) { | ||
static const std::unordered_map<std::string, std::string> kFunctionNames = { | ||
// Operator overrides: com.facebook.presto.common.function.OperatorType | ||
{"presto.default.$operator$add", "presto.default.plus"}, | ||
{"presto.default.$operator$between", "presto.default.between"}, | ||
{"presto.default.$operator$divide", "presto.default.divide"}, | ||
{"presto.default.$operator$equal", "presto.default.eq"}, | ||
{"presto.default.$operator$greater_than", "presto.default.gt"}, | ||
{"presto.default.$operator$greater_than_or_equal", "presto.default.gte"}, | ||
{"presto.default.$operator$is_distinct_from", | ||
"presto.default.distinct_from"}, | ||
{"presto.default.$operator$less_than", "presto.default.lt"}, | ||
{"presto.default.$operator$less_than_or_equal", "presto.default.lte"}, | ||
{"presto.default.$operator$modulus", "presto.default.mod"}, | ||
{"presto.default.$operator$multiply", "presto.default.multiply"}, | ||
{"presto.default.$operator$negation", "presto.default.negate"}, | ||
{"presto.default.$operator$not_equal", "presto.default.neq"}, | ||
{"presto.default.$operator$subtract", "presto.default.minus"}, | ||
{"presto.default.$operator$subscript", "presto.default.subscript"}, | ||
// Special form function overrides. | ||
{"presto.default.in", "in"}, | ||
}; | ||
|
||
std::string lowerCaseName = boost::to_lower_copy(name); | ||
|
||
auto it = kFunctionNames.find(lowerCaseName); | ||
if (it != kFunctionNames.end()) { | ||
auto it = kPrestoOperatorMap.find(lowerCaseName); | ||
if (it != kPrestoOperatorMap.end()) { | ||
return it->second; | ||
} | ||
|
||
|
@@ -102,6 +80,15 @@ std::string getFunctionName(const protocol::SqlFunctionId& functionId) { | |
|
||
} // namespace | ||
|
||
const std::unordered_map<std::string, std::string> veloxToPrestoOperatorMap() { | ||
std::unordered_map<std::string, std::string> veloxToPrestoOperatorMap; | ||
for (const auto& entry : kPrestoOperatorMap) { | ||
veloxToPrestoOperatorMap[entry.second] = entry.first; | ||
} | ||
veloxToPrestoOperatorMap.insert({"cast", "presto.default.$operator$cast"}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't follow why this is separated and added in this function. Please can you elaborate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is needed for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is for specfic test functions, then it might be better to make this change in the test function logic instead of here. Its not particularly server side logic then. |
||
return veloxToPrestoOperatorMap; | ||
} | ||
|
||
velox::variant VeloxExprConverter::getConstantValue( | ||
const velox::TypePtr& type, | ||
const protocol::Block& block) const { | ||
|
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.
Might be better to have a single global function for RowExpressionOptimizer->optimize for registration here (It could construct a RowExpressionOptimizer internally though). Lets avoid constructing the object here.