-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add custom argument generators for Presto decimal functions #9715
Conversation
✅ Deploy Preview for meta-velox canceled.
|
bcae811
to
8249229
Compare
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.
@rui-mo Looks great % small comments.
class ArgGeneratorTest : public testing::Test {}; | ||
|
||
TEST_F(ArgGeneratorTest, plusMinus) { | ||
auto signature = |
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.
Instead of hard-coding function signature here, can we fetch it from the registry?
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.
Added this function to fetch signature from the registry.
std::vector<const exec::FunctionSignature*> getSignatures(
const FunctionSignatureMap& map,
const std::string& functionName,
const std::string& returnType);
#include "velox/expression/fuzzer/ArgGenerator.h" | ||
|
||
namespace facebook::velox::exec::test { | ||
namespace { |
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.
no anonymous namespaces in header files, please
use 'detail' namespace or make this a private static method
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.
Thank you for pointing out this. Made it a private static method.
DECIMAL(38, 20), | ||
DECIMAL(38, 38), | ||
DECIMAL(38, 0)}) { | ||
fuzzer::test::assertReturnType(generator, *signature, returnType); |
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.
nit: it might be easier to read if this is written without a loop
fuzzer::test::assertReturnType(generator, *signature, DECIMAL(10, 2));
fuzzer::test::assertReturnType(generator, *signature, DECIMAL(18, 18));
...
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.
Updated. Thanks.
if (binder.tryBind()) { | ||
actualType = binder.tryResolveReturnType(); | ||
} else { | ||
VELOX_FAIL( |
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.
nit:
VELOX_CHECK(binder.tryBind(), ...)
auto actualType = binder.tryResolveReturnType();
b73776a
to
6eb2e13
Compare
EXPECT_TRUE(argTypes.empty()); | ||
} | ||
|
||
std::vector<const exec::FunctionSignature*> getSignatures( |
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.
There is FunctionBaseTest::getSignatureStrings method. Maybe add another one that returns signatures as is.
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.
Thanks for your suggestion. Added getSignatures in FunctionBaseTest.
static std::unordered_set<const exec::FunctionSignature*> getSignatures(
const std::string& functionName,
const std::string& returnType);
const auto signatures = getSignatures(allSignatures_, "plus", "decimal"); | ||
VELOX_CHECK_EQ(signatures.size(), 1); | ||
const auto& signature = *signatures[0]; |
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.
This code repeats multiple time. Consider adding helper method:
const auto& signature = getOnlySignature("plus");
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.
Updated. Thanks.
4863a71
to
2edc272
Compare
@@ -318,6 +318,11 @@ class FunctionBaseTest : public testing::Test, | |||
return result[0]; | |||
} | |||
|
|||
// Returns a set of signatures for the given function name and return type. | |||
static std::unordered_set<const exec::FunctionSignature*> getSignatures( |
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.
Why do we return a set? An std::vector should work just fine, no?
Let's document 'returnType' parameter. It may not be obvious what the value is.
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.
I was using set to keep similar style with FunctionBaseTest::getSignatureStrings method. Changed to use vector.
Document 'returnType' parameter as below.
The name of expected return type defined in function signature.
Thanks.
aba3f02
to
2de6929
Compare
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.
Thanks.
@mbasmanova Could we merge this PR? Thanks! |
@kgpai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Hi @kgpai, I notice there are some internal failures. If there is anything needs to be fixed, please kindly let me know. Thanks. |
Conbench analyzed the 1 benchmark run on commit There were no benchmark performance regressions. 🎉 The full Conbench report has more details. |
…incubator#9715) Summary: To generate argument types in the decimal fuzzer test correctly, customized argument type generators are required. This PR adds arg generators for the Presto functions plus/minus, multiply, divide, and floor/round. Inspired by facebookincubator#9358. Pull Request resolved: facebookincubator#9715 Reviewed By: Yuhta Differential Revision: D57173196 Pulled By: kgpai fbshipit-source-id: 0bb23aaa55be046b27e4edef2aef9ed4cdf0545e
…incubator#9715) Summary: To generate argument types in the decimal fuzzer test correctly, customized argument type generators are required. This PR adds arg generators for the Presto functions plus/minus, multiply, divide, and floor/round. Inspired by facebookincubator#9358. Pull Request resolved: facebookincubator#9715 Reviewed By: Yuhta Differential Revision: D57173196 Pulled By: kgpai fbshipit-source-id: 0bb23aaa55be046b27e4edef2aef9ed4cdf0545e
To generate argument types in the decimal fuzzer test correctly, customized
argument type generators are required. This PR adds arg generators for the
Presto functions plus/minus, multiply, divide, and floor/round.
Inspired by #9358.