Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-02-07 Thread via GitHub


dawidwys merged PR #23411:
URL: https://github.com/apache/flink/pull/23411


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-02-06 Thread via GitHub


dawidwys commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1930284532

   Thanks for the update @Jiabao-Sun The implementation looks good now. I want 
to go through the tests again, but I need a bit more time. I hope this is fine, 
cause anyway we need to wait for a branch cut.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-02-05 Thread via GitHub


dawidwys commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1477969162


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   The downside of the solution is that the array must fit into memory at all 
times. The difference with the `LagAggFunction` is that `LAG` keeps at most `n` 
elements where `n` is controlled by the user.
   
   Still I am reasonably good with the `LinkedList` approach because it anyhow 
needs to fit into memory when we emit it at the end as a single record. Writing 
this down for awareness.



##
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/aggregate/ArrayAggFunction.java:
##
@@ -0,0 +1,194 @@
+/*
+ * 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, 

Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-02-02 Thread via GitHub


snuyanzin commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1924052949

   I think we could wait until Monday or even more since right now a feature 
freeze and need to wait for cutting release branch


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-02-02 Thread via GitHub


dawidwys commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1924010094

   Sorry, it takes such a long time from my side. I had a vacation in the 
meantime. I'll try to check it Monday. Nevertheless if you're comfortable with 
the PR @snuyanzin feel free to merge it without waiting for my review.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-22 Thread via GitHub


Jiabao-Sun commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1903588731

   Hi @dawidwys, please help review it again when you have time.
   Thanks a lot.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-18 Thread via GitHub


Jiabao-Sun commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1898595368

   @flinkbot run azure


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-18 Thread via GitHub


snuyanzin commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1457306043


##
docs/data/sql_functions.yml:
##
@@ -1059,6 +1059,13 @@ aggregate:
   Divides the rows for each window partition into `n` buckets ranging from 
1 to at most `n`.
   If the number of rows in the window partition doesn't divide evenly into 
the number of buckets, then the remainder values are distributed one per 
bucket, starting with the first bucket.
   For example, with 6 rows and 4 buckets, the bucket values would be as 
follows: 1 1 2 2 3 4
+  - sql: ARRAY_AGG([ ALL | DISTINCT ] expression [ RESPECT NULLS | IGNORE 
NULLS ])
+table: FIELD.arrayAgg
+description: |
+  By default or with keyword `ALL` and, return an array that concatenates 
the input rows
+  and returns `NULL` if there are no input rows. Use `DISTINCT` for one 
unique instance of each value.
+  By default null values are respected, use `IGNORE NULLS` to skip null 
values.

Review Comment:
   ```suggestion
 By default `NULL` values are respected, use `IGNORE NULLS` to skip 
`NULL` values.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-18 Thread via GitHub


snuyanzin commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1457306043


##
docs/data/sql_functions.yml:
##
@@ -1059,6 +1059,13 @@ aggregate:
   Divides the rows for each window partition into `n` buckets ranging from 
1 to at most `n`.
   If the number of rows in the window partition doesn't divide evenly into 
the number of buckets, then the remainder values are distributed one per 
bucket, starting with the first bucket.
   For example, with 6 rows and 4 buckets, the bucket values would be as 
follows: 1 1 2 2 3 4
+  - sql: ARRAY_AGG([ ALL | DISTINCT ] expression [ RESPECT NULLS | IGNORE 
NULLS ])
+table: FIELD.arrayAgg
+description: |
+  By default or with keyword `ALL` and, return an array that concatenates 
the input rows
+  and returns `NULL` if there are no input rows. Use `DISTINCT` for one 
unique instance of each value.
+  By default null values are respected, use `IGNORE NULLS` to skip null 
values.

Review Comment:
   ```suggestion
 By default `NULL` values are respected, use `IGNORE NULLS` to skip 
null values.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-17 Thread via GitHub


Jiabao-Sun commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1897966163

   @flinkbot run azure


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-17 Thread via GitHub


Jiabao-Sun commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1897661962

   > Thanks for addressing comments in general it looks ok from my side i guess 
there is one little thing: since it is based on Calcite parser it allows to 
have `ORDER BY` inside... At the same time it is currently not supported on 
Flink level, not sure whether we can redefine this behavior however at least it 
would make sense to mention it in doc that it is not supported
   
   Yes, ORDER BY allows sorting of any field in the input rows, but currently 
it is difficult to obtain the complete input rows for sorting in the function 
implementation. Therefore, the `ORDER BY` clause is not supported yet.
   I have added an explanation in the documentation.
   
   @snuyanzin, please help take a look again when you have time.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-17 Thread via GitHub


snuyanzin commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1897393850

   Thanks for addressing comments 
   in general it looks ok from my side
   i guess there is one little thing: since it is based on Calcite parser it 
allows to have `ORDER BY` inside...
   At the same time it is currently not supported on Flink level, not sure 
whether we can redefine this behavior however at least it would make sense to 
mention it in doc that it is not supported 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-17 Thread via GitHub


Jiabao-Sun commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1455187450


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   Hi @dawidwys, @snuyanzin,
   
   I referenced `LagAggFunction` to use `LinkedList` to hold null values and it 
works. Now `RESPECT NULLS` and `IGNORE NULLS` are supported. 
   
https://github.com/apache/flink/blob/1ffb48f658b699702357921a48e914d13caf/flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/aggregate/LagAggFunction.java#L147-L150
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-17 Thread via GitHub


Jiabao-Sun commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1455190307


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),

Review Comment:
   Full types test is in `ArrayAggFunctionTest`. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-17 Thread via GitHub


Jiabao-Sun commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1455187450


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   Hi @dawidwys, @snuyanzin,
   
   I refers to `LagAggFunction` use `LinkedList` to hold null values and it 
works. Now `RESPECT NULLS` and `IGNORE NULLS` are supported. 
   
https://github.com/apache/flink/blob/1ffb48f658b699702357921a48e914d13caf/flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/aggregate/LagAggFunction.java#L147-L150
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-16 Thread via GitHub


snuyanzin commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1453313913


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),

Review Comment:
   One more thing
   currently it checks only ability to work with `INT` input for `ARRAY_AGG`
   it would be great to have tests for other types
   especially `ROW`, `ARRAY`, `MAP` where expected output should be 
`ARRAY`, `ARRAY`,   ` ARRAY`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-16 Thread via GitHub


snuyanzin commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1453313913


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),

Review Comment:
   One more thing
   currently it checks only ability to work with `INT` input for `ARRAY_AGG`
   it would be great to have tests for other types
   especially `ROW`, `ARRAY`, `MAP` where expected output should be 
`ARRAY`, `ARRAY`. ARRAY`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-16 Thread via GitHub


snuyanzin commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1453313913


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),

Review Comment:
   One more thing
   currently it checks only ability to work with `INT` input for `ARRAY_AGG`
   it would be great to have tests for other types
   epecially `ROW`, `ARRAY`, `MAP` where expected output should be 
`ARRAY`, `ARRAY`. ARRAY`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-16 Thread via GitHub


snuyanzin commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1453283389


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   yes, I was also thinking about storing null indexes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-16 Thread via GitHub


dawidwys commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1453268979


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   I think it's a very good point. It would be nice to be compatible with SQL 
and other vendors. 
   
   One idea is we could keep the null indices and set those while retrieving 
the result. Happy to hear better solutions though.
   
   Another is to wrap all values in a `GenericRowData`, but we'd need to 
iterate over the data to unwrap it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-16 Thread via GitHub


dawidwys commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1453268979


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   I think it's a very good point. It would be nice to be compatible with SQL 
and other vendors. 
   
   One idea is we could keep the null indices and set those while retrieving 
the result. Happy to hear better solutions though.
   
   Another is to wrap all values in a `GenericRowData`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-16 Thread via GitHub


dawidwys commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1453268979


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   I think it's a very good point. It would be nice to be compatible with SQL 
and other vendors. 
   
   One idea is we could keep the null indices and set those while retrieving 
the result. Happy to hear better solutions though.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-16 Thread via GitHub


Jiabao-Sun commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1453252729


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   @snuyanzin 
   `ListView` cannot hold null values, and since it is a generic `List,` it 
cannot be represented by a specific object for null values. Is there any good 
solution for this?
   
   
https://github.com/apache/flink/blob/d92ab390ff0d91459daccfda7d6cb0acf6ca92eb/flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/aggregate/JsonArrayAggFunction.java#L65



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-16 Thread via GitHub


Jiabao-Sun commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1453223169


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   Thanks @snuyanzin, I'm trying to support `RESPECT NULLS | IGNORE NULLS` 
syntax.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-15 Thread via GitHub


snuyanzin commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1452991614


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   It's ok to support it only partially however the main concern here: 
   ~~I would expect more consistent result
   since there is also input `Row.ofKind(INSERT, "D", null),` and expected 
value `Row.of("D", null),`
   So I would expect for ths either containing nulls or both not containing 
null however not mixed~~
   
   UPD: to be more clear:
   after playing with Postgres and BigQuery I noticed that both respect nulls 
by default and for BigQuery to make it ignoring nulls it should be specified 
explicitely. Is there a reason why for Flink it is done differently? Probably 
it's better to have similar behaviour
   
   I don't tell that we need to support `RESPECT NULLS | IGNORE NULLS` syntax, 
however need to make `RESPECT NULLS` default behaviour to be on same page with 
vendors



-- 
This is an automated message from the Apache Git 

Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-15 Thread via GitHub


snuyanzin commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1452991614


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   It's ok to support it only partially however the main concern here: 
   ~~I would expect more consistent result
   since there is also input `Row.ofKind(INSERT, "D", null),` and expected 
value `Row.of("D", null),`
   So I would expect for ths either containing nulls or both not containing 
null however not mixed~~
   
   UPD: to be more clear:
   after playing with Postgres and BigQuery I noticed that both respect nulls 
by default and for BigQuery to make it ignoring nulls it should be specified 
explicitely. Is there a reason why for Flink it is done differently? Probably 
it's better to have similar behaviour



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: 

Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-15 Thread via GitHub


snuyanzin commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1452991614


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   It's ok to support it only partially however the main concern here: 
   ~~I would expect more consistent result
   since there is also input `Row.ofKind(INSERT, "D", null),` and expected 
value `Row.of("D", null),`
   So I would expect for ths either containing nulls or both not containing 
null however not mixed~~
   
   UPD: to be more clear:
   after playing with Postgres and BigQuery I noticed that both respect nulls 
by default and for BigQuery to make it ignoring nulls it should be specified 
explicitely. Is there a reason why for Flink it is done differently?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please 

Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-15 Thread via GitHub


snuyanzin commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1452991614


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   It's ok to support it only partially however the main concern here: I would 
expect more consistent result
   since there is also input `Row.ofKind(INSERT, "D", null),` and expected 
value `Row.of("D", null),`
   So I would expect for ths either containing nulls or both not containing 
null however not mixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-15 Thread via GitHub


Jiabao-Sun commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1893141857

   Thanks @snuyanzin @dawidwys for the review.
   Could you help review it again?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-15 Thread via GitHub


Jiabao-Sun commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1452975551


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   ```sql
   -- calcite
   ARRAY_AGG([ ALL | DISTINCT ] value [ RESPECT NULLS | IGNORE NULLS ] [ ORDER 
BY orderItem [, orderItem ]* ] )
   -- flink
   ARRAY_AGG([ ALL | DISTINCT ] expression)
   ```
   
   This function simplifies some aspects compared to calcite. 
   1. Currently, the Flink parser does not support parsing RESPECT NULLS | 
IGNORE NULLS, but it is still possible to make changes to support it.
   2. AggregateUtil#extractDistinctInformation 848~858 ignores the ignoreNulls 
fields. 
https://github.com/apache/flink/blob/6bdb4f752adb2b43dbadd8ad4fffcb4c00568dd3/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/utils/AggregateUtil.scala#L848-L858
   3. ListView does not support null values. 

Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-15 Thread via GitHub


Jiabao-Sun commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1452891261


##
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/bridging/BridgingSqlAggFunction.java:
##
@@ -63,6 +64,7 @@ public final class BridgingSqlAggFunction extends 
SqlAggFunction {
 private final List paramTypes;
 
 private BridgingSqlAggFunction(
+FlinkContext context,

Review Comment:
   Yes, I'll revert that changes.
   Thanks.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-15 Thread via GitHub


snuyanzin commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1452799002


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   Also similar query for postgres
   ```sql
   with input(a, c) as (
   select 'a', 1
   union all 
   select 'a', 2
   union all 
   select 'c', 3
   union all 
   select 'c', null
   )
   select a, array_agg(distinct c) from input group by a
   ```
   gives
   ```
   a|array_agg|
   -+-+
   a|{1,2}|
   c|{3,NULL} |
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-15 Thread via GitHub


snuyanzin commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1452798689


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),
+Row.of("D", null),
+Row.of("E", new Integer[] {6})))
+.testResult(
+source ->
+"SELECT f0, array_agg(DISTINCT f1) 
FROM "
++ source
++ " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg().distinct()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+

Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-15 Thread via GitHub


snuyanzin commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1452798388


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/ArrayAggFunctionITCase.java:
##
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.table.planner.functions;
+
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.ARRAY;
+import static org.apache.flink.table.api.DataTypes.INT;
+import static org.apache.flink.table.api.DataTypes.ROW;
+import static org.apache.flink.table.api.DataTypes.STRING;
+import static org.apache.flink.table.api.Expressions.$;
+import static org.apache.flink.types.RowKind.DELETE;
+import static org.apache.flink.types.RowKind.INSERT;
+import static org.apache.flink.types.RowKind.UPDATE_AFTER;
+import static org.apache.flink.types.RowKind.UPDATE_BEFORE;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class ArrayAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_AGG)
+.withDescription("ARRAY changelog stream aggregation")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 2),
+Row.ofKind(INSERT, "B", 3),
+Row.ofKind(INSERT, "C", 3),
+Row.ofKind(INSERT, "C", null),
+Row.ofKind(INSERT, "D", null),
+Row.ofKind(INSERT, "E", 4),
+Row.ofKind(INSERT, "E", 5),
+Row.ofKind(DELETE, "E", 5),
+Row.ofKind(UPDATE_BEFORE, "E", 4),
+Row.ofKind(UPDATE_AFTER, "E", 6)))
+.testResult(
+source ->
+"SELECT f0, array_agg(f1) FROM " + 
source + " GROUP BY f0",
+TableApiAggSpec.groupBySelect(
+Collections.singletonList($("f0")),
+$("f0"),
+$("f1").arrayAgg()),
+ROW(STRING(), ARRAY(INT())),
+ROW(STRING(), ARRAY(INT())),
+Arrays.asList(
+Row.of("A", new Integer[] {1, 2}),
+Row.of("B", new Integer[] {2, 2, 3}),
+Row.of("C", new Integer[] {3}),

Review Comment:
   I wonder why here is just 
   ```java
   Row.of("C", new Integer[] {3}),
   ```
   based on input I would expect
   ```java
   Row.of("C", new Integer[] {3, null}),
   ```
   or did I miss anything?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-15 Thread via GitHub


snuyanzin commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1892868178

   thanks a lot for the explanation @dawidwys you're right


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-15 Thread via GitHub


dawidwys commented on code in PR #23411:
URL: https://github.com/apache/flink/pull/23411#discussion_r1452526246


##
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/bridging/BridgingSqlAggFunction.java:
##
@@ -63,6 +64,7 @@ public final class BridgingSqlAggFunction extends 
SqlAggFunction {
 private final List paramTypes;
 
 private BridgingSqlAggFunction(
+FlinkContext context,

Review Comment:
   What is the reason for those changes? Is it only to be able to create the 
`equalityHandler`? If so, let's keep it simple and remove those.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2024-01-15 Thread via GitHub


dawidwys commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1892398690

   https://github.com/apache/flink/pull/23411#pullrequestreview-1770150649
   
   It took me a while to understand that myself, but I think it's actually ok 
to depend on the `Object#equals/hashcode` in `AggregateFunctions` @snuyanzin 
what you said is correct for `ArrayDistinctFunction`, because:
   1. it is a scalar function, so it can be chained with other functions 
without an exchange before it
   2. It gets data from two input(s) (previous operator and e.g. a literal) 
haystack and needle may come from different operators which may produce data in 
different formats e.g. `GenericRowData` and `BinaryRowData`
   
   In `AggregateFunctions` we will always have all records as `BinaryRowData` 
(and alike) and those `equals/hashcode` should work just fine. (It may be a 
different story when we support `STRUCTURED_TYPE#equals/hashcode`, but we will 
need to revisit most of the operators then, because all `MapView(s)` will work 
incorrectly). This is what we do in other aggregate functions already. Take a 
look at e.g. `JsonArrayAggFunction` or `FirstValueWithRetractAggFunction `
   
   I haven't seen the previous version @Jiabao-Sun , but I believe we can 
remove the `equalityHandler` and make the `ArrayAggFunction` look similar to 
`JsonArrayAggFunction`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2023-12-19 Thread via GitHub


Jiabao-Sun commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1862451170

   Hi @snuyanzin, could you help take a look again when you have time?
   Thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2023-12-18 Thread via GitHub


Jiabao-Sun commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1859780440

   @flinkbot run azure


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2023-12-07 Thread via GitHub


snuyanzin commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1845527082

   yes, sorry was not clear enough
   >to compare when merging and retracting lists?
   
   yes


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2023-12-07 Thread via GitHub


Jiabao-Sun commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1845473679

   Do you mean using equalityEvaluator to compare when merging and retracting 
lists?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2023-12-07 Thread via GitHub


Jiabao-Sun commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1845388338

   Thanks @snuyanzin for the review.
   Sorry, I was a little puzzled because I did not use `HashMap` in 
`Arrayaggfunction`.
   Could you help pinpoint exactly where it is?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-21949][table] Support ARRAY_AGG aggregate function [flink]

2023-10-10 Thread via GitHub


Jiabao-Sun commented on PR #23411:
URL: https://github.com/apache/flink/pull/23411#issuecomment-1754523455

   Hi @wuchong, could you help review this when you have time?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org