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 builtin aggregate function VAR_POP #14101

Merged
merged 25 commits into from
Jan 7, 2020
Merged

Conversation

githubFZX
Copy link
Contributor

What problem does this PR solve?

#7623

What is changed and how it works?

Implement builtin aggregate function 'varpop' in tidb and use the algorithm described by Chan, Golub, and LeVeque in "Algorithms for computing the sample variance: analysis and recommendations" to calculate the variance.

Check List

Tests

  • Unit test

mysql> create table numerical_t(
    -> a tinyint,
    -> b smallint,
    -> c mediumint,
    -> d int,
    -> e bigint,
    -> f float,
    -> g double,
    -> h decimal
    -> );
Query OK, 0 rows affected (0.10 sec)

mysql> insert into numerical_t 
    -> values
    -> (1, 2, 3, 4, 5, 6.1, 7.2, 8.3), 
    -> (2, 3, 4, 5, 6, 7.2, 8.3, 9.4),
    -> (1, 3, 4, 5, 6, 7.1, 8.2, 9.3);
Query OK, 3 rows affected, 3 warnings (0.01 sec)

mysql> select a, var_pop(b),var_pop(c),var_pop(d),var_pop(e),var_pop(f),var_pop(g),var_pop(h) from numerical_t group by a;
+------+------------+------------+------------+------------+------------+------------+------------+
| a    | var_pop(b) | var_pop(c) | var_pop(d) | var_pop(e) | var_pop(f) | var_pop(g) | var_pop(h) |
+------+------------+------------+------------+------------+------------+------------+------------+
|    2 |          0 |          0 |          0 |          0 |          0 |          0 |          0 |
|    1 |       0.25 |       0.25 |       0.25 |       0.25 |       0.25 |       0.25 |       0.25 |
+------+------------+------------+------------+------------+------------+------------+------------+
2 rows in set (0.01 sec)


@githubFZX githubFZX requested review from a team as code owners December 18, 2019 02:11
@ghost ghost requested review from qw4990, wshwsh12, eurekaka, lzmhhh123 and a team and removed request for a team December 18, 2019 02:11
@sre-bot sre-bot added the contribution This PR is from a community contributor. label Dec 18, 2019
@ghost ghost removed their request for review December 18, 2019 02:11
@claassistantio
Copy link

claassistantio commented Dec 18, 2019

CLA assistant check
All committers have signed the CLA.

@zz-jason
Copy link
Member

Hi @githubFZX, gofmt check failed:

[2019-12-18T02:11:57.303Z] gofmt (simplify)
[2019-12-18T02:12:03.845Z] executor/aggfuncs/func_varpop.go
[2019-12-18T02:12:03.845Z] make: *** [fmt] Error 1

You can run make check on your local machine to fix this

@eurekaka eurekaka removed their request for review December 18, 2019 02:57
@zz-jason zz-jason changed the title add builtin aggregate function 'varpop' *: add builtin aggregate function VAR_POP Dec 18, 2019
@zz-jason zz-jason added the sig/execution SIG execution label Dec 18, 2019
@githubFZX
Copy link
Contributor Author

githubFZX commented Dec 30, 2019

Why does the above error occur in unit test?I just modify go.mod to update parser. I need help.

Copy link
Contributor

@wshwsh12 wshwsh12 left a comment

Choose a reason for hiding this comment

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

LGTM. But I want to know why update tipb, atomic, zap, tools in go.mod ? Only parser is not enough?

@githubFZX
Copy link
Contributor Author

LGTM. But I want to know why update tipb, atomic, zap, tools in go.mod ? Only parser is not enough?

I used command ”GO111MODULE=on go get -u github.com/pingcap/parser@master“ to update parser. But the others changed together.

@zz-jason
Copy link
Member

LGTM. But I want to know why update tipb, atomic, zap, tools in go.mod ? Only parser is not enough?

I used command ”GO111MODULE=on go get -u github.com/pingcap/parser@master“ to update parser. But the others changed together.

@githubFZX @wshwsh12 you can run make tidy to clean the unnecessary modifications on go.mod and go.sum

@zz-jason zz-jason added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Dec 31, 2019
@githubFZX
Copy link
Contributor Author

LGTM. But I want to know why update tipb, atomic, zap, tools in go.mod ? Only parser is not enough?

I used command ”GO111MODULE=on go get -u github.com/pingcap/parser@master“ to update parser. But the others changed together.

@githubFZX @wshwsh12 you can run make tidy to clean the unnecessary modifications on go.mod and go.sum

Ok, thank you!

@zz-jason
Copy link
Member

zz-jason commented Jan 5, 2020

@githubFZX any update? BTW, this PR is conflicted with the master branch, please use make tidy to clean go.mod/go.sum and resolve the conflicts in your spare time.

@githubFZX
Copy link
Contributor Author

@githubFZX any update? BTW, this PR is conflicted with the master branch, please use make tidy to clean go.mod/go.sum and resolve the conflicts in your spare time.

Ok, i will fix it later.

@wshwsh12
Copy link
Contributor

wshwsh12 commented Jan 7, 2020

@githubFZX It seems that someone has updated parser in other pr. Now we can reset the go.mod and go.sum to master and merge this pr .

@zz-jason
Copy link
Member

zz-jason commented Jan 7, 2020

LGTM

@zz-jason zz-jason added status/can-merge Indicates a PR has been approved by a committer. and removed status/ReqChange labels Jan 7, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Jan 7, 2020

Your auto merge job has been accepted, waiting for 14361

@zz-jason
Copy link
Member

zz-jason commented Jan 7, 2020

/run-all-tests

1 similar comment
@sre-bot
Copy link
Contributor

sre-bot commented Jan 7, 2020

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Jan 7, 2020

@githubFZX merge failed.

@githubFZX
Copy link
Contributor Author

There is no error when I use commands "make test" and "make dev" in my local machine. What should I do to resolve this problem that unit-test can not pass?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution This PR is from a community contributor. sig/execution SIG execution status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants