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

Add cluster key statistics in block meta #5194

Merged
merged 4 commits into from
May 6, 2022

Conversation

zhyass
Copy link
Member

@zhyass zhyass commented May 6, 2022

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

Summary

Add cluster key statistics in block meta.

Changelog

  • New Feature

Related Issues

Fixes #issue

@vercel
Copy link

vercel bot commented May 6, 2022

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

Name Status Preview Updated
databend ✅ Ready (Inspect) Visit Preview May 6, 2022 at 10:37AM (UTC)

@mergify
Copy link
Contributor

mergify bot commented May 6, 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 the pr-feature this PR introduces a new feature to the codebase label May 6, 2022
@BohuTANG BohuTANG requested a review from dantengsky May 6, 2022 06:24
@dantengsky dantengsky requested a review from sundy-li May 6, 2022 07:09
@@ -258,6 +273,62 @@ impl DataValue {
}
}

impl Eq for DataValue {}

impl Ord for DataValue {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if we can define a meaningful total order relation between DataValues.
@sundy-li any comments about this? thanks

Copy link
Member

@dantengsky dantengsky May 6, 2022

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

aggregate_scalar_state is generic comparision impls without matching each DataValue, so it's optimized by performance.

In cluster key, we already have min/max indexes, so we don't need to copy this indexes into a Column and apply eval_aggr.

Copy link
Member

@dantengsky dantengsky May 6, 2022

Choose a reason for hiding this comment

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

aggregate_scalar_state is generic comparision impls without matching each DataValue, so it's optimized by performance...

got it.

Two other concerns:

  1. Although we can define our own total order for DataValue (even for weird things like NaN...)
    but a PartialOrder may be easier to define (or just use rust's derive mechanism)
  2. The min/max logic is also implemented by the aggregate_min/max
    It would be better if these two keep in coherent.

A suggestion:

  • derive PartialOrd for DataValue

  • implements the min/max like the aggregate_scalar_state does
    maybe something like this (hope it is doing the same thing as aggregate min max does:-)

            let min = min_stats
                  .iter()
                  .filter(|x| !x.is_null())
                  .min_by(|x, y| min.partial_cmp(&r).unwrap_or(Ordering::Equal))
                  .unwrap_or(DataValue::Null);
    
             let max = max_stats
                  .iter()
                  .filter(|x| !x.is_null())
                  .max_by(|x, y| max.partial_cmp(&r).unwrap_or(Ordering::Equal))
                  .unwrap_or(DataValue::Null);
    

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @dantengsky . This is a great suggestion. I will try it later

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, hope it helps.
As long as the format kept backward compatible, I think we could merge this first and polish it later.

query/src/storages/fuse/operations/append.rs Outdated Show resolved Hide resolved
@BohuTANG
Copy link
Member

BohuTANG commented May 6, 2022

There is a CI error:

---- servers::http::clickhouse_handler::test_insert_format_ndjson stdout ----
thread 'servers::http::clickhouse_handler::test_insert_format_ndjson' panicked at 'Cannot compare different types with non-numeric type', common/datavalues/src/data_value.rs:314:13

https://github.com/datafuselabs/databend/runs/6318429474?check_suite_focus=true#step:3:2198

@zhyass zhyass mentioned this pull request May 6, 2022
8 tasks
@zhyass zhyass requested a review from dantengsky May 6, 2022 08:45
@dantengsky
Copy link
Member

/LGTM

Copy link
Member

@dantengsky dantengsky left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-review pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants