-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[ENH]: Rename schema fields #5618
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
|
Schema Field Renaming: Remove Special Characters and Standardize Serialization Across Languages This PR performs a cross-language refactor to rename schema-related fields and constants by removing special characters (such as Key Changes• Renamed Affected Areas• This summary was automatically generated by @propel-code-bot |
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ToSchema, Default)] | ||
pub struct ValueTypes { | ||
#[serde(rename = "#string", skip_serializing_if = "Option::is_none")] | ||
#[serde(rename = "string", skip_serializing_if = "Option::is_none")] // STRING_VALUE_NAME |
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]
Serialization compatibility issue: The serde rename attributes have been changed but there's no backward compatibility for deserialization. Code attempting to deserialize old JSON with #string
, #float_list
, etc. will fail.
#[serde(rename = "string", skip_serializing_if = "Option::is_none")] // Was "#string"
This creates a breaking change where old serialized data cannot be read. Consider using serde aliases to maintain backward compatibility:
#[serde(rename = "string", alias = "#string", skip_serializing_if = "Option::is_none")]
Validation: ✅ This approach is correct and follows serde best practices. The alias
attribute allows deserialization from multiple field names while rename
controls the serialization output. Multiple aliases can be specified by repeating the attribute: #[serde(alias = "old_name1", alias = "old_name2")]
.
Context for Agents
[**BestPractice**]
**Serialization compatibility issue**: The serde rename attributes have been changed but there's no backward compatibility for deserialization. Code attempting to deserialize old JSON with `#string`, `#float_list`, etc. will fail.
```rust
#[serde(rename = "string", skip_serializing_if = "Option::is_none")] // Was "#string"
```
This creates a breaking change where old serialized data cannot be read. Consider using serde aliases to maintain backward compatibility:
```rust
#[serde(rename = "string", alias = "#string", skip_serializing_if = "Option::is_none")]
```
**Validation**: ✅ This approach is correct and follows serde best practices. The `alias` attribute allows deserialization from multiple field names while `rename` controls the serialization output. Multiple aliases can be specified by repeating the attribute: `#[serde(alias = "old_name1", alias = "old_name2")]`.
File: rust/types/src/collection_schema.rs
Line: 137
pub defaults: ValueTypes, | ||
/// Key-specific index overrides | ||
pub key_overrides: HashMap<String, ValueTypes>, | ||
pub keys: HashMap<String, ValueTypes>, |
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.
[CriticalError]
Data migration issue: The keys
field rename from key_overrides
without serde alias will cause deserialization failures for existing data. Any persisted schemas using the old key_overrides
field name will fail to deserialize.
Add backward compatibility:
#[serde(rename = "keys", alias = "key_overrides")]
pub keys: HashMap<String, ValueTypes>,
Validation: ✅ This solution is correct. Serde's alias
attribute is specifically designed for this use case - it allows deserialization from both the old field name (key_overrides
) and the new field name (keys
), while serialization will always use the new name specified in rename
. This ensures backward compatibility during data migration without breaking existing serialized data.
Context for Agents
[**CriticalError**]
**Data migration issue**: The `keys` field rename from `key_overrides` without serde alias will cause deserialization failures for existing data. Any persisted schemas using the old `key_overrides` field name will fail to deserialize.
Add backward compatibility:
```rust
#[serde(rename = "keys", alias = "key_overrides")]
pub keys: HashMap<String, ValueTypes>,
```
**Validation**: ✅ This solution is correct. Serde's `alias` attribute is specifically designed for this use case - it allows deserialization from both the old field name (`key_overrides`) and the new field name (`keys`), while serialization will always use the new name specified in `rename`. This ensures backward compatibility during data migration without breaking existing serialized data.
File: rust/types/src/collection_schema.rs
Line: 98
78946c0
to
48287a9
Compare
pub const DOCUMENT_KEY: &str = "#document"; | ||
pub const EMBEDDING_KEY: &str = "#embedding"; |
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.
q: do we have this somewhere else?
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.
It's hard-coded in some places for search and rank. That's a bigger change to consolidate it under this. Created a note
Description of changes
Summarize the changes made by this PR.
Test plan
How are these changes tested?
pytest
for python,yarn test
for js,cargo test
for rustMigration plan
None
Observability plan
None
Documentation Changes
None