-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Feature] support Quantile Sketche #54569
Open
chenminghua8
wants to merge
53
commits into
StarRocks:main
Choose a base branch
from
chenminghua8:support_quantile_sketche
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,205
−269
Open
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
d4fa445
support dataSketches include Quantile Sketches、Theta Sketch、Frequency…
chenminghua8 cf082a9
fix format exception.
chenminghua8 2540ae9
fix format exception.
chenminghua8 02dc2b0
fix format exception.
chenminghua8 358b652
fix format exception.
chenminghua8 60f073e
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 01a85d0
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 6aff6a7
fix AggStateCombinatorTest fault
chenminghua8 c573071
fix AggStateCombinatorTest fault
chenminghua8 51e8596
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 accf967
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 e0257e9
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 38b153e
add tests
chenminghua8 19d9389
add tests
chenminghua8 793cc6c
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 8d337aa
Add test cases to improve code coverage
chenminghua8 643e868
Add test cases to improve code coverage
chenminghua8 6e0516b
Add test cases to improve code coverage
chenminghua8 707b4f1
support dataSketches include Quantile Sketches、Theta Sketch、Frequency…
chenminghua8 f8276df
fix format exception.
chenminghua8 7bde2bc
fix format exception.
chenminghua8 573ee8c
fix format exception.
chenminghua8 fab9f3f
fix format exception.
chenminghua8 cd3cba0
fix AggStateCombinatorTest fault
chenminghua8 b00773a
fix AggStateCombinatorTest fault
chenminghua8 aaae8aa
add tests
chenminghua8 2f092b1
add tests
chenminghua8 e4db576
Add test cases to improve code coverage
chenminghua8 cc875af
Add test cases to improve code coverage
chenminghua8 139ac86
Add test cases to improve code coverage
chenminghua8 ebaca8d
Fix aggregate_test test error due to using unused AnyValUtils
chenminghua8 ca4e313
Fix aggregate_test test error due to using unused AnyValUtils
chenminghua8 260d88b
Fix aggregate_test test error due to using unused AnyValUtils
chenminghua8 6d2dcf2
Fix other sketch nullptr and add ds_theta_count_distinct syntax
chenminghua8 499533f
Fix Clang format failling
chenminghua8 bbe0ec7
Fix Clang format failling
chenminghua8 aaa6acc
Fix Clang format failling
chenminghua8 cd04f84
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 026988f
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 6495748
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 78a11af
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 40589e6
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 f95f6d4
Merge branch 'support_dataSketches' of github.com:chenminghua8/starro…
chenminghua8 df3b57b
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 35b7ef4
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 8cc2d01
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 ecac63f
support DataSketches quantile sketche
chenminghua8 8b1b598
support DataSketches quantile sketche
chenminghua8 8d08860
Merge branch 'StarRocks:main' into support_quantile_sketche
chenminghua8 5adb7aa
support DataSketches quantile sketche
chenminghua8 d3f49cf
Merge branch 'StarRocks:main' into support_quantile_sketche
chenminghua8 983ea74
support DataSketches quantile sketche
chenminghua8 ed11a11
support DataSketches quantile sketche
chenminghua8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
support DataSketches quantile sketche
Signed-off-by: chenminghua8 <cmptmn@126.com>
- Loading branch information
commit 5adb7aa0935269db9a8d55552e1b50838313ab19
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
docs/en/sql-reference/sql-functions/aggregate-functions/ds_quantile.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# DS_QUANTILE | ||
|
||
|
||
|
||
Returns the approximation of the pth percentile, where the value of p is between 0 and 1. | ||
|
||
## Syntax | ||
|
||
```Haskell | ||
DS_QUANTILE(expr, DOUBLE p[, DOUBLE compression]) | ||
``` | ||
|
||
## Examples | ||
|
||
```plain text | ||
MySQL > CREATE TABLE t1 ( | ||
id BIGINT NOT NULL, | ||
province VARCHAR(64), | ||
age SMALLINT, | ||
dt VARCHAR(10) NOT NULL | ||
) | ||
DUPLICATE KEY(id) | ||
DISTRIBUTED BY HASH(id) BUCKETS 4 | ||
PROPERTIES ( | ||
"replication_num" = "1" | ||
); | ||
MySQL > insert into t1 select generate_series, generate_series, generate_series % 10, "2024-07-24" from table(generate_series(1, 100)); | ||
MySQL > select ds_quantile(id), ds_quantile(age) from t2 order by 1, 2; | ||
+-------------------------------------------------------------+ | ||
| ds_quantile(id) ds_quantile(age) | | ||
+------------------------------------------------------------ + | ||
| [50] [4] | | ||
+------------------------------------------------------------+ | ||
MySQL > select ds_quantile(id, [0.1, 0.5, 0.9]), ds_quantile(age, [0.1, 0.5, 0.9]) from t2 order by 1, 2; | ||
+-------------------------------------------------------------+ | ||
| ds_quantile(id) ds_quantile(age) | | ||
+------------------------------------------------------------ + | ||
| [10,50,90] [0,4,8] | | ||
+------------------------------------------------------------+ | ||
MySQL > select ds_quantile(id, [0.1, 0.5, 0.9], 10000), ds_quantile(age, [0.1, 0.5, 0.9], 10000) from t2 order by 1, 2; | ||
+-------------------------------------------------------------+ | ||
| ds_quantile(id) ds_quantile(age) | | ||
+------------------------------------------------------------ + | ||
| [10,50,90] [0,4,8] | | ||
+------------------------------------------------------------+ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-- name: test_datasketchs | ||
CREATE TABLE t2 ( | ||
id BIGINT NOT NULL, | ||
province VARCHAR(64), | ||
age SMALLINT, | ||
dt VARCHAR(10) NOT NULL | ||
) | ||
DUPLICATE KEY(id) | ||
DISTRIBUTED BY HASH(id) BUCKETS 4 | ||
PROPERTIES ( | ||
"replication_num" = "1" | ||
); | ||
-- result: | ||
-- !result | ||
insert into t2 select generate_series, generate_series, generate_series % 10, "2024-07-24" from table(generate_series(1, 100)); | ||
-- result: | ||
-- !result | ||
select ds_quantile(id), ds_quantile(age) from t2 order by 1, 2; | ||
-- result: | ||
[50] [4] | ||
-- !result | ||
select ds_quantile(id, [0.1, 0.5, 0.9]), ds_quantile(age, [0.1, 0.5, 0.9]) from t2 order by 1, 2; | ||
-- result: | ||
[10,50,90] [0,4,8] | ||
-- !result | ||
select ds_quantile(id, [0.1, 0.5, 0.9], 10000), ds_quantile(age, [0.1, 0.5, 0.9], 10000) from t2 order by 1, 2; | ||
-- result: | ||
[10,50,90] [0,4,8] | ||
-- !result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- name: test_quantile_sketch | ||
CREATE TABLE t2 ( | ||
id BIGINT NOT NULL, | ||
province VARCHAR(64), | ||
age SMALLINT, | ||
dt VARCHAR(10) NOT NULL | ||
) | ||
DUPLICATE KEY(id) | ||
DISTRIBUTED BY HASH(id) BUCKETS 4 | ||
PROPERTIES ( | ||
"replication_num" = "1" | ||
); | ||
|
||
insert into t2 select generate_series, generate_series, generate_series % 10, "2024-07-24" from table(generate_series(1, 100)); | ||
|
||
select ds_quantile(id), ds_quantile(age) from t2 order by 1, 2; | ||
|
||
select ds_quantile(id, [0.1, 0.5, 0.9]), ds_quantile(age, [0.1, 0.5, 0.9]) from t2 order by 1, 2; | ||
|
||
select ds_quantile(id, [0.1, 0.5, 0.9], 10000), ds_quantile(age, [0.1, 0.5, 0.9], 10000) from t2 order by 1, 2; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The most risky bug in this code is:
Duplicate registration of
DS_HLL_COUNT_DISTINCT
functions, which can lead to errors or unexpected behavior during function lookup.You can modify the code like this:
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.
The function parameters are different and need to be registered multiple times.