Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jinchengchenghh committed Sep 14, 2024
1 parent fe9581b commit fea5906
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
22 changes: 22 additions & 0 deletions velox/core/SimpleFunctionMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ class ISimpleFunctionMetadata {
virtual bool physicalSignatureEquals(
const ISimpleFunctionMetadata& other) const = 0;
virtual std::string helpMessage(const std::string& name) const = 0;
virtual std::string toString(const std::string& name) const = 0;
};

template <typename T, typename = int32_t>
Expand Down Expand Up @@ -516,6 +517,27 @@ class SimpleFunctionMetadata : public ISimpleFunctionMetadata {
}

std::string helpMessage(const std::string& name) const final {
// return fmt::format("{}({})", name, signature_->toString());
std::string s{name};
s.append("(");
bool first = true;
for (auto& arg : signature_->argumentTypes()) {
if (!first) {
s.append(", ");
}
first = false;
s.append(boost::algorithm::to_upper_copy(arg.toString()));
}

if (isVariadic()) {
s.append("...");
}

s.append(")");
return s;
}

std::string toString(const std::string& name) const final {
std::stringstream sig;
bool first = true;
for (auto& arg : signature_->argumentTypes()) {
Expand Down
4 changes: 4 additions & 0 deletions velox/expression/SimpleFunctionRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ class SimpleFunctionRegistry {
return functionEntry_.getMetadata().helpMessage(name);
}

std::string toString(const std::string& name) const {
return functionEntry_.getMetadata().toString(name);
}

VectorFunctionMetadata metadata() const {
return VectorFunctionMetadata{
false,
Expand Down
2 changes: 1 addition & 1 deletion velox/expression/tests/SimpleFunctionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ TEST_F(SimpleFunctionTest, helpMessage) {
functionName, {DECIMAL(20, 2), BIGINT()});
EXPECT_TRUE(function.has_value());
EXPECT_EQ(
function.value().helpMessage(functionName),
function.value().toString(functionName),
"FunctionName: decimal_plus_value\nSignature argument types:\nDECIMAL(I1,I5), BIGINT\n"
"Physical argument types:\nHUGEINT, BIGINT\nPhysical result types:\nHUGEINT\n"
"Priority:999997\nDefaultNullBehavior:true");
Expand Down

0 comments on commit fea5906

Please sign in to comment.