piyushgarg5021 commented on issue #15157:
URL: https://github.com/apache/datafusion/issues/15157#issuecomment-2715489360
Proposed Solution:
There are two possible solutions:
1. Implement Serialize and Deserialize for datafusion_proto_common::Schema:
Add #[derive(Serialize, Deserialize)] to the datafusion_proto_common::Schema
type if it is a local type.
If datafusion_proto_common::Schema is from another crate, check if the crate
provides a serde feature flag and enable it.
2. Remove or Fix the json Feature:
If the json feature is not intended to work, it should be removed from the
crate.
Alternatively, fix the feature by ensuring all required types implement
Serialize and Deserialize.
**Implementation Plan:**
Check if datafusion_proto_common::Schema is Local:
If it is a local type, derive Serialize and Deserialize:
rust
#[derive(Serialize, Deserialize)]
pub struct Schema {
// fields
}
If it is from another crate, check if the crate provides a serde feature
flag and enable it in Cargo.toml.
Update Cargo.toml:
Ensure the serde dependency is included and properly configured:
toml
[dependencies]
serde = { version = "1.0", features = ["derive"] }
Add Tests:
Add tests to verify that the json feature works as expected:
rust
#[cfg(feature = "json")]
#[test]
fn test_json_serialization() {
use serde_json;
let schema = Schema::new();
let json = serde_json::to_string(&schema).unwrap();
let deserialized_schema: Schema = serde_json::from_str(&json).unwrap();
assert_eq!(schema, deserialized_schema);
}
Remove the json Feature (if necessary):
If the feature is not intended to work, remove it from Cargo.toml and update
the documentation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]