-
Notifications
You must be signed in to change notification settings - Fork 2k
[ENH] Serialize Where clause in Rust #5665
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
Conversation
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
|
Implement Serialization for This pull request finalizes Rust-side serialization for the Key Changes• Added a full implementation of Affected Areas• This summary was automatically generated by @propel-code-bot |
| let values_json = match set_value { | ||
| MetadataSetValue::Bool(v) => serde_json::to_value(v), | ||
| MetadataSetValue::Int(v) => serde_json::to_value(v), | ||
| MetadataSetValue::Float(v) => serde_json::to_value(v), | ||
| MetadataSetValue::Str(v) => serde_json::to_value(v), | ||
| } | ||
| .map_err(serde::ser::Error::custom)?; | ||
| inner_map.insert(op_key.to_string(), values_json); |
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.
[BestPractice]
This match statement can be simplified using serde's derive macros. If you add #[derive(Serialize)] and #[serde(untagged)] to the MetadataSetValue enum definition, you can serialize it directly, making the code more concise and idiomatic.
First, modify the MetadataSetValue enum definition:
#[derive(Clone, Debug, PartialEq, Serialize)]
#[cfg_attr(feature = "testing", derive(proptest_derive::Arbitrary))]
#[serde(untagged)]
pub enum MetadataSetValue {
Bool(Vec<bool>),
Int(Vec<i64>),
Float(Vec<f64>),
Str(Vec<String>),
}Then you can simplify this block:
| let values_json = match set_value { | |
| MetadataSetValue::Bool(v) => serde_json::to_value(v), | |
| MetadataSetValue::Int(v) => serde_json::to_value(v), | |
| MetadataSetValue::Float(v) => serde_json::to_value(v), | |
| MetadataSetValue::Str(v) => serde_json::to_value(v), | |
| } | |
| .map_err(serde::ser::Error::custom)?; | |
| inner_map.insert(op_key.to_string(), values_json); | |
| let values_json = | |
| serde_json::to_value(set_value).map_err(serde::ser::Error::custom)?; |
⚡ Committable suggestion
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
Context for Agents
[**BestPractice**]
This `match` statement can be simplified using serde's derive macros. If you add `#[derive(Serialize)]` and `#[serde(untagged)]` to the `MetadataSetValue` enum definition, you can serialize it directly, making the code more concise and idiomatic.
First, modify the `MetadataSetValue` enum definition:
```rust
#[derive(Clone, Debug, PartialEq, Serialize)]
#[cfg_attr(feature = "testing", derive(proptest_derive::Arbitrary))]
#[serde(untagged)]
pub enum MetadataSetValue {
Bool(Vec<bool>),
Int(Vec<i64>),
Float(Vec<f64>),
Str(Vec<String>),
}
```
Then you can simplify this block:
```suggestion
let values_json =
serde_json::to_value(set_value).map_err(serde::ser::Error::custom)?;
```
⚡ **Committable suggestion**
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
File: rust/types/src/metadata.rs
Line: 936There 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.
could work, but this is fine for now
2775b6e to
6e3aceb
Compare

Description of changes
Summarize the changes made by this PR.
impl Serialize for Where. Previously it's atodo!Filteris serializedTest plan
How are these changes tested?
pytestfor python,yarn testfor js,cargo testfor rustMigration plan
Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?
Observability plan
What is the plan to instrument and monitor this change?
Documentation Changes
Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the _docs section?_