Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jinchengchenghh
Copy link
Contributor

@jinchengchenghh jinchengchenghh commented Aug 23, 2024

Print all the Metadata fields such a logical and physical argument type and result type.

Logical signature: (decimal(i1,i5), integer) -> decimal(i2,i5)
Physical signature: (HUGEINT, INTEGER) -> HUGEINT
Priority: 999997
DefaultNullBehavior: true

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 23, 2024
Copy link

netlify bot commented Aug 23, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit f980aba
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/6709ea8aa318cd0008889ba5

@jinchengchenghh
Copy link
Contributor Author

Could you help review? Thanks! @kgpai

@jinchengchenghh
Copy link
Contributor Author

Can you help review? Thanks! @Yuhta

@jinchengchenghh
Copy link
Contributor Author

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"
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

@mbasmanova mbasmanova Sep 13, 2024

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?

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, this should work.

@jinchengchenghh jinchengchenghh changed the title Enhance SimpleFunctionMetadata helpMessage function Add SimpleFunctionMetadata toString function Sep 14, 2024
@jinchengchenghh
Copy link
Contributor Author

Can you help review again? Thanks! @mbasmanova

Copy link
Contributor

@mbasmanova mbasmanova left a 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

@@ -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;
Copy link
Contributor

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.

@@ -536,6 +537,44 @@ class SimpleFunctionMetadata : public ISimpleFunctionMetadata {
return s;
}

std::string toString(const std::string& name) const final {
std::stringstream sig;
Copy link
Contributor

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.

}

std::stringstream ss;
first = true;
Copy link
Contributor

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_);

}
return fmt::format(
"FunctionName: {}\nSignature argument types:\n{}\nPhysical argument types:\n{}"
"\nPhysical result types:\n{}\nPriority:{}\nDefaultNullBehavior:{}",
Copy link
Contributor

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:

@jinchengchenghh jinchengchenghh changed the title Add SimpleFunctionMetadata toString function Add SimpleFunctionMetadata toDebugString function Sep 24, 2024
@jinchengchenghh
Copy link
Contributor Author

Can you help review again? Thanks! @mbasmanova

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants