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

feat(data type): implement PartialOrd for Variant data-type #4959

Merged
merged 5 commits into from
Apr 21, 2022

Conversation

b41sh
Copy link
Member

@b41sh b41sh commented Apr 20, 2022

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

  • introduce VariantValue as a wrapper of serde_json::Value
  • implement PartialOrd for VariantValue
  • rename JsonColumn as VariantColumn
  • rename DataValue::Json as DataValue::Variant

Changelog

  • New Feature
  • Bug Fix

Related Issues

Fixes #4903

@vercel
Copy link

vercel bot commented Apr 20, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
databend ⬜️ Ignored (Inspect) Apr 21, 2022 at 7:26AM (UTC)

@mergify
Copy link
Contributor

mergify bot commented Apr 20, 2022

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@mergify mergify bot added pr-feature this PR introduces a new feature to the codebase pr-bugfix this PR patches a bug in codebase labels Apr 20, 2022
@b41sh b41sh marked this pull request as ready for review April 21, 2022 02:54
@b41sh b41sh requested a review from BohuTANG as a code owner April 21, 2022 02:54
@b41sh b41sh requested a review from sundy-li April 21, 2022 02:54
use serde_json::Value;

#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
pub struct VariantValue(Value);
Copy link
Member

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
Copy link
Member

@sundy-li sundy-li Apr 21, 2022

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.

Copy link
Member Author

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?

Copy link
Member

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 ...
}

Copy link
Member Author

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()) {
Copy link
Member

Choose a reason for hiding this comment

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

Is object.keys() sorted ?

Copy link
Member Author

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.

@sundy-li sundy-li merged commit d7d6e82 into databendlabs:main Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-review pr-bugfix this PR patches a bug in codebase pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Column with type: Variant does not support take (while in processor thread 0)
3 participants