-
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 SimpleFunctionMetadata toDebugString function #10821
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for meta-velox canceled.
|
Could you help review? Thanks! @kgpai |
Can you help review? Thanks! @Yuhta |
f73086e
to
a011246
Compare
hi @xiaoxmeng @mbasmanova , can you help review this PR? Thanks! |
EXPECT_TRUE(function.has_value()); | ||
EXPECT_EQ( | ||
function.value().helpMessage(functionName), | ||
"FunctionName: decimal_plus_value\nSignature argument types:\nDECIMAL(I1,I5), BIGINT\n" |
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 find the new message hard to read. What problem are you trying to solve?
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.
Before this PR, we don't print the Metadata
physical argument and result types, and other fields like priority_
and defaultNullBehavior_
that user may wish to know.
If we use std::cout to print it, we will get
FunctionName: decimal_plus_value
Signature argument types:
DECIMAL(I1,I5), BIGINT
Physical argument types:
HUGEINT, BIGINT
Physical result types:
HUGEINT
Priority:999997
DefaultNullBehavior:true
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 message might be helpful to developers, but not users.
Can we keep existing message as is, but introduce a separate method for debugging?
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.
Ok, can I name the new method toString
?
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.
Sure, this should work.
a011246
to
fea5906
Compare
Can you help review again? Thanks! @mbasmanova |
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.
@jinchengchenghh Let's update PR description to provide an example of the output.
FunctionName: decimal_plus_value
Signature argument types:
DECIMAL(I1,I5), BIGINT
Physical argument types:
HUGEINT, BIGINT
Physical result types:
HUGEINT
Priority:999997
DefaultNullBehavior:true
Also, let's streamline this a bit.
- Remove function name (it is not part of the signature).
- Add logical result type.
- Put arguments and result type on a single line.
- Add space after Priority: and DefaultNullBehavior:.
Logical signature: (DECIMAL(I1,I5), BIGINT) -> <result type>
Physical signature: (HUGEINT, BIGINT) -> HUGEINT
Priority: 999997
DefaultNullBehavior: true
velox/core/SimpleFunctionMetadata.h
Outdated
@@ -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; |
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.
Let's rename to toDebugString and remove 'name' parameter.
Let's document this method.
velox/core/SimpleFunctionMetadata.h
Outdated
@@ -536,6 +537,44 @@ class SimpleFunctionMetadata : public ISimpleFunctionMetadata { | |||
return s; | |||
} | |||
|
|||
std::string toString(const std::string& name) const final { | |||
std::stringstream sig; |
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.
do not abbreviate: sig -> signature
It is strange that we do not include the result type here. Let's add it.
You seem to be building signatures twice: once using logical types and once again using physical types. If that's the case, then let's name variables to match: logicalSignature and physicalSignature. Let's make sure both signatures include argument types and return type.
velox/core/SimpleFunctionMetadata.h
Outdated
} | ||
|
||
std::stringstream ss; | ||
first = true; |
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. Let's extract a small helper template:
auto logicalSignature = toSignatureString(signature_->argumentTypes(), resultType_);
auto physicalSignature = toSignatureString(argPhysicalTypes_, resultPhysicalType_);
velox/core/SimpleFunctionMetadata.h
Outdated
} | ||
return fmt::format( | ||
"FunctionName: {}\nSignature argument types:\n{}\nPhysical argument types:\n{}" | ||
"\nPhysical result types:\n{}\nPriority:{}\nDefaultNullBehavior:{}", |
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.
Make sure to add empty space after Priority: and nDefaultNullBehavior:
b389930
to
dcffc48
Compare
dcffc48
to
f980aba
Compare
Can you help review again? Thanks! @mbasmanova |
Print all the Metadata fields such a logical and physical argument type and result type.