This is an automated email from the ASF dual-hosted git repository.
panxiaolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 70ddf64126 [Chore](agg-state) add documentation about agg_state, add
group_concat agg_state test case (#21147)
70ddf64126 is described below
commit 70ddf64126272304c00be8c71bfb453594790c01
Author: Pxl <[email protected]>
AuthorDate: Tue Jun 27 11:28:19 2023 +0800
[Chore](agg-state) add documentation about agg_state, add group_concat
agg_state test case (#21147)
add documentation about agg_state, add group_concat agg_state test case
---
.../serde/data_type_fixedlengthobject_serde.h | 8 +-
.../sql-manual/sql-functions/combinators/merge.md | 50 ++++++++++++
.../sql-manual/sql-functions/combinators/state.md | 50 ++++++++++++
.../sql-manual/sql-functions/combinators/union.md | 50 ++++++++++++
.../sql-reference/Data-Types/AGG_STATE.md | 87 +++++++++++++++++++++
docs/sidebars.json | 12 ++-
.../sql-manual/sql-functions/combinators/merge.md | 50 ++++++++++++
.../sql-manual/sql-functions/combinators/state.md | 50 ++++++++++++
.../sql-manual/sql-functions/combinators/union.md | 50 ++++++++++++
.../sql-reference/Data-Types/AGG_STATE.md | 90 ++++++++++++++++++++++
.../agg_state/test_agg_state_group_concat.out | 22 ++++++
.../datatype_p0/agg_state/test_agg_state.groovy | 7 +-
.../agg_state/test_agg_state_group_concat.groovy | 43 +++++++++++
13 files changed, 563 insertions(+), 6 deletions(-)
diff --git a/be/src/vec/data_types/serde/data_type_fixedlengthobject_serde.h
b/be/src/vec/data_types/serde/data_type_fixedlengthobject_serde.h
index 092d2202b0..b61ed39075 100644
--- a/be/src/vec/data_types/serde/data_type_fixedlengthobject_serde.h
+++ b/be/src/vec/data_types/serde/data_type_fixedlengthobject_serde.h
@@ -38,10 +38,10 @@ class DataTypeFixedLengthObjectSerDe : public DataTypeSerDe
{
public:
Status write_column_to_pb(const IColumn& column, PValues& result, int
start,
int end) const override {
- LOG(FATAL) << "Not support write FixedLengthObject column to pb";
+ return Status::NotSupported("Not support write FixedLengthObject
column to pb");
}
Status read_column_from_pb(IColumn& column, const PValues& arg) const
override {
- LOG(FATAL) << "Not support read from pb to FixedLengthObject";
+ return Status::NotSupported("Not support read from pb to
FixedLengthObject");
};
void write_one_cell_to_jsonb(const IColumn& column, JsonbWriter& result,
Arena* mem_pool,
int32_t col_id, int row_num) const override {
@@ -63,12 +63,12 @@ public:
Status write_column_to_mysql(const IColumn& column, MysqlRowBuffer<true>&
row_buffer,
int row_idx, bool col_const) const override {
- LOG(FATAL) << "Not support write object column to mysql";
+ return Status::NotSupported("Not support write object column to
mysql");
}
Status write_column_to_mysql(const IColumn& column, MysqlRowBuffer<false>&
row_buffer,
int row_idx, bool col_const) const override {
- LOG(FATAL) << "Not support write object column to mysql";
+ return Status::NotSupported("Not support write object column to
mysql");
}
};
} // namespace vectorized
diff --git a/docs/en/docs/sql-manual/sql-functions/combinators/merge.md
b/docs/en/docs/sql-manual/sql-functions/combinators/merge.md
new file mode 100644
index 0000000000..6f9ae643b5
--- /dev/null
+++ b/docs/en/docs/sql-manual/sql-functions/combinators/merge.md
@@ -0,0 +1,50 @@
+---
+{
+ "title": "MERGE",
+ "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.
+-->
+
+## MERGE
+
+<version since="2.0.0">
+</version>
+
+
+### description
+#### Syntax
+
+`AGGREGATE_FUNCTION_MERGE(agg_state)`
+The aggregated intermediate results are aggregated and calculated to obtain
the actual result.
+The type of the result is consistent with `AGGREGATE_FUNCTION`.
+
+### example
+```
+mysql [test]>select avg_merge(avg_state(1)) from d_table;
++-------------------------+
+| avg_merge(avg_state(1)) |
++-------------------------+
+| 1 |
++-------------------------+
+```
+### keywords
+AGG_STATE, MERGE
diff --git a/docs/en/docs/sql-manual/sql-functions/combinators/state.md
b/docs/en/docs/sql-manual/sql-functions/combinators/state.md
new file mode 100644
index 0000000000..6202da018e
--- /dev/null
+++ b/docs/en/docs/sql-manual/sql-functions/combinators/state.md
@@ -0,0 +1,50 @@
+---
+{
+ "title": "STATE",
+ "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.
+-->
+
+## STATE
+
+<version since="2.0.0">
+</version>
+
+
+### description
+#### Syntax
+
+`AGGREGATE_FUNCTION_STATE(arg...)`
+Returns the intermediate result of the aggregation function, which can be used
for subsequent aggregation or to obtain the actual calculation result through
the merge combiner, or can be directly written into the agg_state type table
and saved.
+The type of the result is agg_state, and the function signature in agg_state
is `AGGREGATE_FUNCTION(arg...)`.
+
+### example
+```
+mysql [test]>select avg_merge(t) from (select avg_union(avg_state(1)) as t
from d_table group by k1)p;
++----------------+
+| avg_merge(`t`) |
++----------------+
+| 1 |
++----------------+
+```
+### keywords
+AGG_STATE,STATE
diff --git a/docs/en/docs/sql-manual/sql-functions/combinators/union.md
b/docs/en/docs/sql-manual/sql-functions/combinators/union.md
new file mode 100644
index 0000000000..e3c249ca1a
--- /dev/null
+++ b/docs/en/docs/sql-manual/sql-functions/combinators/union.md
@@ -0,0 +1,50 @@
+---
+{
+ "title": "UNION",
+ "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.
+-->
+
+## UNION
+
+<version since="2.0.0">
+</version>
+
+
+### description
+#### Syntax
+
+`AGGREGATE_FUNCTION_UNION(agg_state)`
+Aggregate multiple aggregation intermediate results into one.
+The type of the result is agg_state, and the function signature is consistent
with the input parameter.
+
+### example
+```
+mysql [test]>select avg_merge(t) from (select avg_union(avg_state(1)) as t
from d_table group by k1)p;
++----------------+
+| avg_merge(`t`) |
++----------------+
+| 1 |
++----------------+
+```
+### keywords
+AGG_STATE, UNION
diff --git a/docs/en/docs/sql-manual/sql-reference/Data-Types/AGG_STATE.md
b/docs/en/docs/sql-manual/sql-reference/Data-Types/AGG_STATE.md
new file mode 100644
index 0000000000..69f6f2bb9c
--- /dev/null
+++ b/docs/en/docs/sql-manual/sql-reference/Data-Types/AGG_STATE.md
@@ -0,0 +1,87 @@
+---
+{
+ "title": "AGG_STATE",
+ "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.
+-->
+
+## AGG_STATE
+### description
+ AGG_STATE cannot be used as a key column, and the signature of the
aggregation function must be declared at the same time when creating the table.
+ User does not need to specify length and default value. The actual
stored data size is related to the function implementation.
+
+ AGG_STATE can only be used with
[state](../../sql-functions/combinators/state.md)
+
/[merge](../../sql-functions/combinators/merge.md)/[union](../..//sql-functions/combinators/union.md)
function combiner usage.
+
+ It should be noted that the signature of the aggregation function is also
part of the type, and agg_state with different signatures cannot be mixed. For
example, if the signature of the table creation statement is `max_by(int,int)`,
then `max_by(bigint,int)` or `group_concat(varchar)` cannot be inserted.
+ The nullable attribute here is also part of the signature. If you can
confirm that you will not enter a null value, you can declare the parameter as
not null, which can obtain a smaller storage size and reduce
serialization/deserialization overhead.
+
+### example
+
+Create table example:
+```sql
+ create table a_table(
+ k1 int null,
+ k2 agg_state max_by(int not null,int),
+ k3 agg_state group_concat(string)
+ )
+ aggregate key (k1)
+ distributed BY hash(k1) buckets 3
+ properties("replication_num" = "1");
+```
+Here k2 and k3 use max_by and group_concat as aggregation types respectively.
+
+Insert data example:
+```sql
+ insert into a_table values(1,max_by_state(3,1),group_concat_state('a'));
+ insert into a_table values(1,max_by_state(2,2),group_concat_state('bb'));
+ insert into a_table values(2,max_by_state(1,3),group_concat_state('ccc'));
+```
+For the agg_state column, the insert statement must use the
[state](../../sql-functions/combinators/state.md) function to generate the
corresponding agg_state data, where the functions and input parameter types
must completely correspond to agg_state.
+
+Select data example:
+```sql
+ mysql [test]>select k1,max_by_merge(k2),group_concat_merge(k3) from
a_table group by k1 order by k1;
+ +------+--------------------+--------------------------+
+ | k1 | max_by_merge(`k2`) | group_concat_merge(`k3`) |
+ +------+--------------------+--------------------------+
+ | 1 | 2 | bb,a |
+ | 2 | 1 | ccc |
+ +------+--------------------+--------------------------+
+```
+If you need to get the actual result, you need to use the corresponding
[merge](../../sql-functions/combinators/merge.md) function.
+
+```sql
+ mysql [test]>select max_by_merge(u2),group_concat_merge(u3) from (
+ select k1,max_by_union(k2) as u2,group_concat_union(k3) u3 from a_table
group by k1 order by k1
+ ) t;
+ +--------------------+--------------------------+
+ | max_by_merge(`u2`) | group_concat_merge(`u3`) |
+ +--------------------+--------------------------+
+ | 1 | ccc,bb,a |
+ +--------------------+--------------------------+
+```
+If you want to aggregate only the agg_state without getting the actual result
during the process, you can use the
[union](../..//sql-functions/combinators/union.md) function.
+
+### keywords
+
+ AGG_STATE
diff --git a/docs/sidebars.json b/docs/sidebars.json
index 87a7f7fe3e..470567839c 100644
--- a/docs/sidebars.json
+++ b/docs/sidebars.json
@@ -495,6 +495,15 @@
"sql-manual/sql-functions/struct-functions/struct_element"
]
},
+ {
+ "type": "category",
+ "label": "Combinators",
+ "items": [
+ "sql-manual/sql-functions/combinators/state",
+ "sql-manual/sql-functions/combinators/merge",
+ "sql-manual/sql-functions/combinators/union"
+ ]
+ },
{
"type": "category",
"label": "Aggregate Functions",
@@ -1029,7 +1038,8 @@
"sql-manual/sql-reference/Data-Types/ARRAY",
"sql-manual/sql-reference/Data-Types/MAP",
"sql-manual/sql-reference/Data-Types/STRUCT",
- "sql-manual/sql-reference/Data-Types/JSON"
+ "sql-manual/sql-reference/Data-Types/JSON",
+ "sql-manual/sql-reference/Data-Types/AGG_STATE"
]
},
{
diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/combinators/merge.md
b/docs/zh-CN/docs/sql-manual/sql-functions/combinators/merge.md
new file mode 100644
index 0000000000..fa263a2e39
--- /dev/null
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/combinators/merge.md
@@ -0,0 +1,50 @@
+---
+{
+ "title": "MERGE",
+ "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.
+-->
+
+## MERGE
+
+<version since="2.0.0">
+</version>
+
+
+### description
+#### Syntax
+
+`AGGREGATE_FUNCTION_MERGE(agg_state)`
+将聚合中间结果进行聚合并计算获得实际结果。
+结果的类型与`AGGREGATE_FUNCTION`一致。
+
+### example
+```
+mysql [test]>select avg_merge(avg_state(1)) from d_table;
++-------------------------+
+| avg_merge(avg_state(1)) |
++-------------------------+
+| 1 |
++-------------------------+
+```
+### keywords
+AGG_STATE, MERGE
diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/combinators/state.md
b/docs/zh-CN/docs/sql-manual/sql-functions/combinators/state.md
new file mode 100644
index 0000000000..8c8ddaa26e
--- /dev/null
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/combinators/state.md
@@ -0,0 +1,50 @@
+---
+{
+ "title": "STATE",
+ "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.
+-->
+
+## STATE
+
+<version since="2.0.0">
+</version>
+
+
+### description
+#### Syntax
+
+`AGGREGATE_FUNCTION_STATE(arg...)`
+返回聚合函数的中间结果,可以用于后续的聚合或者通过merge组合器获得实际计算结果,也可以直接写入agg_state类型的表保存下来。
+结果的类型为agg_state,agg_state中的函数签名为`AGGREGATE_FUNCTION(arg...)`。
+
+### example
+```
+mysql [test]>select avg_merge(t) from (select avg_union(avg_state(1)) as t
from d_table group by k1)p;
++----------------+
+| avg_merge(`t`) |
++----------------+
+| 1 |
++----------------+
+```
+### keywords
+AGG_STATE,STATE
diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/combinators/union.md
b/docs/zh-CN/docs/sql-manual/sql-functions/combinators/union.md
new file mode 100644
index 0000000000..8957e6c2f8
--- /dev/null
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/combinators/union.md
@@ -0,0 +1,50 @@
+---
+{
+ "title": "UNION",
+ "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.
+-->
+
+## UNION
+
+<version since="2.0.0">
+</version>
+
+
+### description
+#### Syntax
+
+`AGGREGATE_FUNCTION_UNION(agg_state)`
+将多个聚合中间结果聚合为一个。
+结果的类型为agg_state,函数签名与入参一致。
+
+### example
+```
+mysql [test]>select avg_merge(t) from (select avg_union(avg_state(1)) as t
from d_table group by k1)p;
++----------------+
+| avg_merge(`t`) |
++----------------+
+| 1 |
++----------------+
+```
+### keywords
+AGG_STATE, UNION
diff --git a/docs/zh-CN/docs/sql-manual/sql-reference/Data-Types/AGG_STATE.md
b/docs/zh-CN/docs/sql-manual/sql-reference/Data-Types/AGG_STATE.md
new file mode 100644
index 0000000000..291f835411
--- /dev/null
+++ b/docs/zh-CN/docs/sql-manual/sql-reference/Data-Types/AGG_STATE.md
@@ -0,0 +1,90 @@
+---
+{
+ "title": "AGG_STATE",
+ "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.
+-->
+
+## AGG_STATE
+### description
+ AGG_STATE不能作为key列使用,建表时需要同时声明聚合函数的签名。
+ 用户不需要指定长度和默认值。实际存储的数据大小与函数实现有关。
+
+ AGG_STATE只能配合[state](../../sql-functions/combinators/state.md)
+
/[merge](../../sql-functions/combinators/merge.md)/[union](../..//sql-functions/combinators/union.md)函数组合器使用。
+
+
需要注意的是,聚合函数的签名也是类型的一部分,不同签名的agg_state无法混合使用。比如如果建表声明的签名为`max_by(int,int)`,那就无法插入`max_by(bigint,int)`或者`group_concat(varchar)`。
+ 此处nullable属性也是签名的一部分,如果能确定不会输入null值,可以将参数声明为not
null,这样可以获得更小的存储大小和减少序列化/反序列化开销。
+
+### example
+
+建表示例如下:
+ ```sql
+ create table a_table(
+ k1 int null,
+ k2 agg_state max_by(int not null,int),
+ k3 agg_state group_concat(string)
+ )
+ aggregate key (k1)
+ distributed BY hash(k1) buckets 3
+ properties("replication_num" = "1");
+ ```
+ 这里的k2和k3分别以max_by和group_concat为聚合类型。
+
+插入数据示例:
+ ```sql
+ insert into a_table values(1,max_by_state(3,1),group_concat_state('a'));
+ insert into a_table values(1,max_by_state(2,2),group_concat_state('bb'));
+ insert into a_table values(2,max_by_state(1,3),group_concat_state('ccc'));
+ ```
+
对于agg_state列,插入语句必须用[state](../../sql-functions/combinators/state.md)函数来生成对应的agg_state数据,这里的函数和入参类型都必须跟agg_state完全对应。
+
+查询数据示例:
+
+ ```sql
+ mysql [test]>select k1,max_by_merge(k2),group_concat_merge(k3) from a_table
group by k1 order by k1;
+ +------+--------------------+--------------------------+
+ | k1 | max_by_merge(`k2`) | group_concat_merge(`k3`) |
+ +------+--------------------+--------------------------+
+ | 1 | 2 | bb,a |
+ | 2 | 1 | ccc |
+ +------+--------------------+--------------------------+
+ ```
+
+ 如果需要获取实际结果,则要用对应的[merge](../../sql-functions/combinators/merge.md)函数。
+
+ ```sql
+ mysql [test]>select max_by_merge(u2),group_concat_merge(u3) from (
+ select k1,max_by_union(k2) as u2,group_concat_union(k3) u3 from a_table
group by k1 order by k1
+ ) t;
+ +--------------------+--------------------------+
+ | max_by_merge(`u2`) | group_concat_merge(`u3`) |
+ +--------------------+--------------------------+
+ | 1 | ccc,bb,a |
+ +--------------------+--------------------------+
+ ```
+
+如果想要在过程中只聚合agg_state而不获取实际结果,可以使用[union](../..//sql-functions/combinators/union.md)函数。
+
+### keywords
+
+ AGG_STATE
diff --git
a/regression-test/data/datatype_p0/agg_state/test_agg_state_group_concat.out
b/regression-test/data/datatype_p0/agg_state/test_agg_state_group_concat.out
new file mode 100644
index 0000000000..34376e46bb
--- /dev/null
+++ b/regression-test/data/datatype_p0/agg_state/test_agg_state_group_concat.out
@@ -0,0 +1,22 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !length1 --
+1 15
+
+-- !group1 --
+1 ccc,bb,a
+
+-- !merge1 --
+ccc,bb,a
+
+-- !length2 --
+1 15
+
+-- !group2 --
+1 ccc,bb,a
+
+-- !merge2 --
+ccc,bb,a
+
+-- !union --
+ccc,bb,a
+
diff --git a/regression-test/suites/datatype_p0/agg_state/test_agg_state.groovy
b/regression-test/suites/datatype_p0/agg_state/test_agg_state.groovy
index 142432083e..4c4797d9d1 100644
--- a/regression-test/suites/datatype_p0/agg_state/test_agg_state.groovy
+++ b/regression-test/suites/datatype_p0/agg_state/test_agg_state.groovy
@@ -53,7 +53,7 @@ suite("test_agg_state") {
sql "insert into a_table select 1,max_by_state(1,3);"
sql "insert into a_table select 1,max_by_state(2,2);"
- sql "insert into a_table select 1,max_by_state(3,1);"
+ sql "insert into a_table values(1,max_by_state(3,1));"
qt_length1 """select k1,length(k2) from a_table order by k1;"""
qt_group1 """select k1,max_by_merge(k2) from a_table group by k1 order by
k1;"""
@@ -67,4 +67,9 @@ suite("test_agg_state") {
qt_union """ select max_by_merge(kstate) from (select k1,max_by_union(k2)
kstate from a_table group by k1 order by k1) t; """
qt_max_by_null """ select
max_by_merge(max_by_state(k1,null)),min_by_merge(min_by_state(null,k3)) from
d_table; """
+
+ test {
+ sql "select avg_state(1) from d_table;"
+ exception "[NOT_IMPLEMENTED_ERROR]"
+ }
}
diff --git
a/regression-test/suites/datatype_p0/agg_state/test_agg_state_group_concat.groovy
b/regression-test/suites/datatype_p0/agg_state/test_agg_state_group_concat.groovy
new file mode 100644
index 0000000000..6926a16aba
--- /dev/null
+++
b/regression-test/suites/datatype_p0/agg_state/test_agg_state_group_concat.groovy
@@ -0,0 +1,43 @@
+// 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.
+
+suite("test_agg_state_group_concat") {
+ sql """ DROP TABLE IF EXISTS a_table; """
+ sql """
+ create table a_table(
+ k1 int null,
+ k2 agg_state group_concat(string)
+ )
+ aggregate key (k1)
+ distributed BY hash(k1) buckets 3
+ properties("replication_num" = "1");
+ """
+
+ sql "insert into a_table select 1,group_concat_state('a');"
+ sql "insert into a_table select 1,group_concat_state('bb');"
+ sql "insert into a_table values(1,group_concat_state('ccc'));"
+
+ qt_length1 """select k1,length(k2) from a_table order by k1;"""
+ qt_group1 """select k1,group_concat_merge(k2) from a_table group by k1
order by k1;"""
+ qt_merge1 """select group_concat_merge(k2) from a_table;"""
+
+ qt_length2 """select k1,length(k2) from a_table order by k1;"""
+ qt_group2 """select k1,group_concat_merge(k2) from a_table group by k1
order by k1;"""
+ qt_merge2 """select group_concat_merge(k2) from a_table;"""
+
+ qt_union """ select group_concat_merge(kstate) from (select
k1,group_concat_union(k2) kstate from a_table group by k1 order by k1) t; """
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]