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

GH-15195: [C++][FlightRPC][Python] Add ToString/Equals for Flight types #15196

Merged
merged 2 commits into from
Feb 22, 2023

Conversation

lidavidm
Copy link
Member

@lidavidm lidavidm commented Jan 4, 2023

@github-actions
Copy link

github-actions bot commented Jan 4, 2023

@@ -638,6 +726,11 @@ arrow::Result<std::unique_ptr<Result>> SimpleResultStream::Next() {
return std::make_unique<Result>(std::move(results_[position_++]));
}

std::string BasicAuth::ToString() const {
return arrow::util::StringBuilder("BasicAuth<username = '", username, "', password = '",
password, "'>");
Copy link
Member

Choose a reason for hiding this comment

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

It's dangerous to include the password here, as it could leak unwillingly through logging or other means.

ASSERT_EQ(descr2, descr_test);
}
PbType pb_value;
ASSERT_OK(internal::ToProto(values[i], &pb_value));
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated to this PR: if we'd like to test this on Windows, I wonder if we could have wrapper APIs around ToProto that would return std::any.

@pitrou
Copy link
Member

pitrou commented Jan 17, 2023

@jorisvandenbossche Do you want to take a look at the Python changes?

return "<FlightDescriptor command: {!r}>".format(self.command)
else:
return "<FlightDescriptor type: {!r}>".format(self.descriptor_type)
return frombytes(self.descriptor.ToString())
Copy link
Member

Choose a reason for hiding this comment

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

I don't know how consistent we want to be on this front, but so in another recent PR that improved some reprs for Buffer et al objects (#13921), we did keep the <...> around it.

We could easily do that here as well, but the output of ToString already uses that inside the text repr, so that would give double >>'s ?

Copy link
Member

Choose a reason for hiding this comment

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

We also added "pyarrow." in front of the class names. For those flight specific classes, that might be less needed (in comparison to the generic "Buffer", for which it is useful to know it is a pyarrow Buffer), and would also get lengthier ("pyarrow.flight.Action ..")?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I've been distracted as of late. I can rework the Python parts of this so that we have custom Pythonic __repr__ implementations. I originally did the Python changes here just because I figured I'd reduce the duplication while I was already rooting around here, but it's be better to give a good experience for Python users.

@lidavidm
Copy link
Member Author

  • Made Python repr more consistent (<pyarrow.flight.Action type='foo' body=(0 bytes)>)
  • Made C++ repr more compact and more in line with Python (<Action type='foo' body=(0 bytes)>)

@jorisvandenbossche
Copy link
Member

Thanks, those reprs look good!

Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

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

+1 for the GLib part.

@lidavidm lidavidm merged commit 6a0fb7a into apache:main Feb 22, 2023
@lidavidm lidavidm deleted the gh-15195-flight-refactor branch February 22, 2023 21:55
@ursabot
Copy link

ursabot commented Feb 23, 2023

Benchmark runs are scheduled for baseline = 67fa416 and contender = 6a0fb7a. 6a0fb7a is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Failed ⬇️0.73% ⬆️0.0%] test-mac-arm
[Finished ⬇️1.79% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.32% ⬆️0.0%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] 6a0fb7a0 ec2-t3-xlarge-us-east-2
[Failed] 6a0fb7a0 test-mac-arm
[Finished] 6a0fb7a0 ursa-i9-9960x
[Finished] 6a0fb7a0 ursa-thinkcentre-m75q
[Finished] 67fa416d ec2-t3-xlarge-us-east-2
[Failed] 67fa416d test-mac-arm
[Finished] 67fa416d ursa-i9-9960x
[Finished] 67fa416d ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

fatemehp pushed a commit to fatemehp/arrow that referenced this pull request Feb 24, 2023
…ht types (apache#15196)

* Closes: apache#15195

Authored-by: David Li <li.davidm96@gmail.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[C++][FlightRPC] Flight types should all implement ToString, Equals, etc.
5 participants