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

executor: add builtin aggregate function json_arrayagg #19957

Merged
merged 7 commits into from
Aug 4, 2021

Conversation

arthuryangcs
Copy link
Contributor

@arthuryangcs arthuryangcs commented Sep 11, 2020

What problem does this PR solve?

What is changed and how it works?

add an json_arrayagg function

Check List

  • Make sure the replace instruction is changed back to the required instruction and the version is the latest.

Tests

	tk.MustExec(`CREATE TABLE t (
		a int(11),
		b varchar(100),
		c decimal(3,2),
		d json,
		e date,
		f time,
		g datetime DEFAULT '2012-01-01',
		h timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
		i char(36),
		j text(50));`)

	tk.MustExec(`insert into t values(1, 'ab', 5.5, '{"id": 1}', '2020-01-10', '11:12:13', '2020-01-11', '0000-00-00 00:00:00', 'first', 'json_arrayagg_test');`)

	result := tk.MustQuery("select a, json_arrayagg(b) from t group by a order by a;")
	result.Check(testkit.Rows(`1 ["ab"]`))
	result = tk.MustQuery("select b, json_arrayagg(c) from t group by b order by b;")
	result.Check(testkit.Rows(`ab [5.5]`))
	result = tk.MustQuery("select e, json_arrayagg(f) from t group by e order by e;")
	result.Check(testkit.Rows(`2020-01-10 ["11:12:13"]`))
	result = tk.MustQuery("select f, json_arrayagg(g) from t group by f order by f;")
	result.Check(testkit.Rows(`11:12:13 ["2020-01-11 00:00:00"]`))
	result = tk.MustQuery("select g, json_arrayagg(h) from t group by g order by g;")
	result.Check(testkit.Rows(`2020-01-11 00:00:00 ["0000-00-00 00:00:00"]`))
	result = tk.MustQuery("select h, json_arrayagg(i) from t group by h order by h;")
	result.Check(testkit.Rows(`0000-00-00 00:00:00 ["first"]`))
	result = tk.MustQuery("select i, json_arrayagg(j) from t group by i order by i;")
	result.Check(testkit.Rows(`first ["json_arrayagg_test"]`))
	result = tk.MustQuery("select json_arrayagg(23) from t group by a order by a;")
	result.Check(testkit.Rows(`[23]`))
	result = tk.MustQuery("select json_arrayagg(null) from t group by a order by a;")
	result.Check(testkit.Rows(`[null]`))

Code changes

  • Add executor/aggfuncs/func_json_arrayagg.go
  • Add executor/aggfuncs/func_json_arrayagg_test.go
  • Delete all srcChk.AppendDatum(0, &types.Datum{}) and the end of Chunk

Related changes

  • Need to add the definition of json_objectagg in pingcap/parser

Release Note

Add builtin aggregate function `json_arrayagg`

@arthuryangcs arthuryangcs requested review from a team as code owners September 11, 2020 12:20
@arthuryangcs arthuryangcs requested review from wshwsh12 and winoros and removed request for a team September 11, 2020 12:20
@ti-srebot ti-srebot added the contribution This PR is from a community contributor. label Sep 11, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Sep 11, 2020

@kennytm
Copy link
Contributor

kennytm commented Sep 14, 2020

depends on pingcap/parser#1020

@qw4990 qw4990 self-requested a review September 15, 2020 12:49
@arthuryangcs arthuryangcs force-pushed the json_arrayagg branch 7 times, most recently from a18c7eb to e31a18f Compare September 23, 2020 13:13
@arthuryangcs
Copy link
Contributor Author

@qw4990 @wshwsh12 @winoros Please review the code.

@arthuryangcs arthuryangcs force-pushed the json_arrayagg branch 4 times, most recently from 354207a to 2a8189b Compare September 28, 2020 18:37
@arthuryangcs
Copy link
Contributor Author

@qw4990 @wshwsh12 @winoros Please.

@tisonkun
Copy link
Contributor

tisonkun commented Jul 29, 2021

@arthuryangcs Thanks for your contribution!

You can cc @wshwsh12 to ping him. Most of our committer received many email every day so feel free to ping them when they don't repsonse.

/cc @wshwsh12

@ti-chi-bot ti-chi-bot requested a review from wshwsh12 July 29, 2021 08:27
executor/aggfuncs/func_json_arrayagg_test.go Outdated Show resolved Hide resolved
executor/aggfuncs/func_json_arrayagg_test.go Outdated Show resolved Hide resolved
executor/aggfuncs/aggfunc_test.go Outdated Show resolved Hide resolved
@arthuryangcs arthuryangcs force-pushed the json_arrayagg branch 3 times, most recently from b7e4d43 to 75d605a Compare July 30, 2021 03:45
@wshwsh12 wshwsh12 self-requested a review July 30, 2021 04:11
@arthuryangcs
Copy link
Contributor Author

Done.
/cc @wshwsh12

@arthuryangcs
Copy link
Contributor Author

PTAL
/cc @wshwsh12

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 4, 2021
@wshwsh12
Copy link
Contributor

wshwsh12 commented Aug 4, 2021

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: c17cc16

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 4, 2021
@arthuryangcs
Copy link
Contributor Author

/run-all-tests

@ti-chi-bot
Copy link
Member

@arthuryangcs: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@arthuryangcs
Copy link
Contributor Author

/run-all-tests

@zhouqiang-cl
Copy link
Contributor

/rebuild

@ti-chi-bot ti-chi-bot merged commit 853c41e into pingcap:master Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression contribution This PR is from a community contributor. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/execution SIG execution size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet