-
Notifications
You must be signed in to change notification settings - Fork 752
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
feat(data type): implement PartialOrd for Variant data-type #4959
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Thanks for the contribution! Please review the labels and make any necessary changes. |
86c81dd
to
f473a41
Compare
use serde_json::Value; | ||
|
||
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)] | ||
pub struct VariantValue(Value); |
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.
Better to put this struct same level as DataValue.
} | ||
|
||
// VariantValue compares as the following rule: | ||
// Null > Array > Object > String > Number > Boolean |
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.
So we can give each struct a level value.
If the level is not equal, compare the level value.
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.
do you mean add a level filed in struct VariantValue
?
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.
fn level(&self) -> u8 {
match ...
}
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.
ok
(Value::Object(_), Value::Null) => Ordering::Less, | ||
(Value::Object(_), Value::Array(_)) => Ordering::Less, | ||
(Value::Object(o1), Value::Object(o2)) => { | ||
for (k1, k2) in o1.keys().zip(o2.keys()) { |
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.
Is object.keys() sorted ?
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.
yes, keys are iterated in alphabetical order.
I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/
Summary
VariantValue
as a wrapper ofserde_json::Value
PartialOrd
forVariantValue
JsonColumn
asVariantColumn
DataValue::Json
asDataValue::Variant
Changelog
Related Issues
Fixes #4903