This is an automated email from the ASF dual-hosted git repository. luzhijing pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push: new e253371e8e [Doc](function) Support agg foreach (#561) e253371e8e is described below commit e253371e8e42d8cea0a40daeafd37b74be290bf0 Author: Mryange <59914473+mrya...@users.noreply.github.com> AuthorDate: Wed Apr 17 11:56:25 2024 +0800 [Doc](function) Support agg foreach (#561) --- .../sql-functions/aggregate-functions/foreach.md | 84 ++++++++++++++++++++++ .../sql-functions/aggregate-functions/foreach.md | 82 +++++++++++++++++++++ .../sql-functions/aggregate-functions/foreach.md | 82 +++++++++++++++++++++ sidebars.json | 1 + .../sql-functions/aggregate-functions/foreach.md | 84 ++++++++++++++++++++++ versioned_sidebars/version-2.1-sidebars.json | 1 + 6 files changed, 334 insertions(+) diff --git a/docs/sql-manual/sql-functions/aggregate-functions/foreach.md b/docs/sql-manual/sql-functions/aggregate-functions/foreach.md new file mode 100644 index 0000000000..5f92bb2c87 --- /dev/null +++ b/docs/sql-manual/sql-functions/aggregate-functions/foreach.md @@ -0,0 +1,84 @@ +--- +{ + "title": "FOREACH", + "language": "en" +} +--- + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +## FOREACH + +<version since="2.1.0"> +</version> + + +### description +#### Syntax + +`AGGREGATE_FUNCTION_FOREACH(arg...)` +Converts an aggregate function for tables into an aggregate function for arrays that aggregates the corresponding array items and returns an array of results. For example, sum_foreach for the arrays [1, 2], [3, 4, 5]and[6, 7]returns the result [10, 13, 5] after adding together the corresponding array items. + + + + +### example +``` +mysql [test]>select a , s from db; ++-----------+---------------+ +| a | s | ++-----------+---------------+ +| [1, 2, 3] | ["ab", "123"] | +| [20] | ["cd"] | +| [100] | ["efg"] | +| NULL | NULL | +| [null, 2] | [null, "c"] | ++-----------+---------------+ + +mysql [test]>select sum_foreach(a) from db; ++----------------+ +| sum_foreach(a) | ++----------------+ +| [121, 4, 3] | ++----------------+ + +mysql [test]>select count_foreach(s) from db; ++------------------+ +| count_foreach(s) | ++------------------+ +| [3, 2] | ++------------------+ + +mysql [test]>select array_agg_foreach(a) from db; ++-----------------------------------+ +| array_agg_foreach(a) | ++-----------------------------------+ +| [[1, 20, 100, null], [2, 2], [3]] | ++-----------------------------------+ + +mysql [test]>select map_agg_foreach(a,a) from db; ++---------------------------------------+ +| map_agg_foreach(a, a) | ++---------------------------------------+ +| [{1:1, 20:20, 100:100}, {2:2}, {3:3}] | ++---------------------------------------+ +``` +### keywords +FOREACH \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/foreach.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/foreach.md new file mode 100644 index 0000000000..0417ccaba0 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/foreach.md @@ -0,0 +1,82 @@ +--- +{ + "title": "FOREACH", + "language": "zh-CN" +} +--- + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +## FOREACH + +<version since="2.1.0"> +</version> + + +### description +#### Syntax + +`AGGREGATE_FUNCTION_FOREACH(arg...)` +将表的聚合函数转换为聚合相应数组项并返回结果数组的数组的聚合函数。 例如, `sum_foreach` 对于数组 [1, 2], [3, 4, 5]和[6, 7]返回结果 [10, 13, 5] 之后将相应的数组项添加在一起。 + + +### example +``` +mysql [test]>select a , s from db; ++-----------+---------------+ +| a | s | ++-----------+---------------+ +| [1, 2, 3] | ["ab", "123"] | +| [20] | ["cd"] | +| [100] | ["efg"] | +| NULL | NULL | +| [null, 2] | [null, "c"] | ++-----------+---------------+ + +mysql [test]>select sum_foreach(a) from db; ++----------------+ +| sum_foreach(a) | ++----------------+ +| [121, 4, 3] | ++----------------+ + +mysql [test]>select count_foreach(s) from db; ++------------------+ +| count_foreach(s) | ++------------------+ +| [3, 2] | ++------------------+ + +mysql [test]>select array_agg_foreach(a) from db; ++-----------------------------------+ +| array_agg_foreach(a) | ++-----------------------------------+ +| [[1, 20, 100, null], [2, 2], [3]] | ++-----------------------------------+ + +mysql [test]>select map_agg_foreach(a,a) from db; ++---------------------------------------+ +| map_agg_foreach(a, a) | ++---------------------------------------+ +| [{1:1, 20:20, 100:100}, {2:2}, {3:3}] | ++---------------------------------------+ +``` +### keywords +FOREACH \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/foreach.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/foreach.md new file mode 100644 index 0000000000..0417ccaba0 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/foreach.md @@ -0,0 +1,82 @@ +--- +{ + "title": "FOREACH", + "language": "zh-CN" +} +--- + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +## FOREACH + +<version since="2.1.0"> +</version> + + +### description +#### Syntax + +`AGGREGATE_FUNCTION_FOREACH(arg...)` +将表的聚合函数转换为聚合相应数组项并返回结果数组的数组的聚合函数。 例如, `sum_foreach` 对于数组 [1, 2], [3, 4, 5]和[6, 7]返回结果 [10, 13, 5] 之后将相应的数组项添加在一起。 + + +### example +``` +mysql [test]>select a , s from db; ++-----------+---------------+ +| a | s | ++-----------+---------------+ +| [1, 2, 3] | ["ab", "123"] | +| [20] | ["cd"] | +| [100] | ["efg"] | +| NULL | NULL | +| [null, 2] | [null, "c"] | ++-----------+---------------+ + +mysql [test]>select sum_foreach(a) from db; ++----------------+ +| sum_foreach(a) | ++----------------+ +| [121, 4, 3] | ++----------------+ + +mysql [test]>select count_foreach(s) from db; ++------------------+ +| count_foreach(s) | ++------------------+ +| [3, 2] | ++------------------+ + +mysql [test]>select array_agg_foreach(a) from db; ++-----------------------------------+ +| array_agg_foreach(a) | ++-----------------------------------+ +| [[1, 20, 100, null], [2, 2], [3]] | ++-----------------------------------+ + +mysql [test]>select map_agg_foreach(a,a) from db; ++---------------------------------------+ +| map_agg_foreach(a, a) | ++---------------------------------------+ +| [{1:1, 20:20, 100:100}, {2:2}, {3:3}] | ++---------------------------------------+ +``` +### keywords +FOREACH \ No newline at end of file diff --git a/sidebars.json b/sidebars.json index b3ae7d9169..6282f3ec50 100644 --- a/sidebars.json +++ b/sidebars.json @@ -640,6 +640,7 @@ "sql-manual/sql-functions/aggregate-functions/grouping-id", "sql-manual/sql-functions/aggregate-functions/any-value", "sql-manual/sql-functions/aggregate-functions/array-agg", + "sql-manual/sql-functions/aggregate-functions/foreach", "sql-manual/sql-functions/aggregate-functions/map-agg", "sql-manual/sql-functions/aggregate-functions/bitmap-agg", "sql-manual/sql-functions/aggregate-functions/collect-set", diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/foreach.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/foreach.md new file mode 100644 index 0000000000..5f92bb2c87 --- /dev/null +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/foreach.md @@ -0,0 +1,84 @@ +--- +{ + "title": "FOREACH", + "language": "en" +} +--- + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +## FOREACH + +<version since="2.1.0"> +</version> + + +### description +#### Syntax + +`AGGREGATE_FUNCTION_FOREACH(arg...)` +Converts an aggregate function for tables into an aggregate function for arrays that aggregates the corresponding array items and returns an array of results. For example, sum_foreach for the arrays [1, 2], [3, 4, 5]and[6, 7]returns the result [10, 13, 5] after adding together the corresponding array items. + + + + +### example +``` +mysql [test]>select a , s from db; ++-----------+---------------+ +| a | s | ++-----------+---------------+ +| [1, 2, 3] | ["ab", "123"] | +| [20] | ["cd"] | +| [100] | ["efg"] | +| NULL | NULL | +| [null, 2] | [null, "c"] | ++-----------+---------------+ + +mysql [test]>select sum_foreach(a) from db; ++----------------+ +| sum_foreach(a) | ++----------------+ +| [121, 4, 3] | ++----------------+ + +mysql [test]>select count_foreach(s) from db; ++------------------+ +| count_foreach(s) | ++------------------+ +| [3, 2] | ++------------------+ + +mysql [test]>select array_agg_foreach(a) from db; ++-----------------------------------+ +| array_agg_foreach(a) | ++-----------------------------------+ +| [[1, 20, 100, null], [2, 2], [3]] | ++-----------------------------------+ + +mysql [test]>select map_agg_foreach(a,a) from db; ++---------------------------------------+ +| map_agg_foreach(a, a) | ++---------------------------------------+ +| [{1:1, 20:20, 100:100}, {2:2}, {3:3}] | ++---------------------------------------+ +``` +### keywords +FOREACH \ No newline at end of file diff --git a/versioned_sidebars/version-2.1-sidebars.json b/versioned_sidebars/version-2.1-sidebars.json index 6f10e6aa3c..64d00cd3f2 100644 --- a/versioned_sidebars/version-2.1-sidebars.json +++ b/versioned_sidebars/version-2.1-sidebars.json @@ -634,6 +634,7 @@ "sql-manual/sql-functions/aggregate-functions/grouping-id", "sql-manual/sql-functions/aggregate-functions/any-value", "sql-manual/sql-functions/aggregate-functions/array-agg", + "sql-manual/sql-functions/aggregate-functions/foreach", "sql-manual/sql-functions/aggregate-functions/map-agg", "sql-manual/sql-functions/aggregate-functions/bitmap-agg", "sql-manual/sql-functions/aggregate-functions/collect-set", --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org