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

Minor(proto): Implement TryFrom<&DFSchema> for protobuf::DfSchema #7505

Merged
merged 1 commit into from
Sep 8, 2023

Conversation

jonahgao
Copy link
Member

@jonahgao jonahgao commented Sep 8, 2023

Which issue does this PR close?

N/A

Rationale for this change

Currently, we have only implemented TryFrom<&DFSchemaRef> for protobuf::DfSchema.
In the example below, when encoding a DFSchema, we have to create an Arc, which can be considered wasteful.

let dfschema = datafusion::common::DFSchema::empty();
let arc_dfschema = Arc::new(dfschema);
let proto_dfschema: datafusion_proto::DfSchema =(&arc_dfschema).try_into().unwrap();

Implementing TryFrom<&DFSchema> for protobuf::DfSchema helps to avoid this issue,
and then the code is simplified as follows.

let dfschema = datafusion::common::DFSchema::empty();
let proto_dfschema: datafusion_proto::DfSchema =(&dfschema).try_into().unwrap();

What changes are included in this PR?

Are these changes tested?

Yes

Are there any user-facing changes?

New API, without breaking changes

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @jonahgao

@alamb alamb merged commit c7a93fc into apache:main Sep 8, 2023
21 checks passed
@jonahgao jonahgao deleted the try_from_dfschema branch September 8, 2023 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants