raminqaf commented on code in PR #28456:
URL: https://github.com/apache/flink/pull/28456#discussion_r3418412898
##########
docs/data/sql_functions.yml:
##########
@@ -1611,6 +1611,16 @@ aggregate:
`(NUMERIC: INTEGER_NUMERIC, FLOAT, DOUBLE, DECIMAL)`
Returns a `DOUBLE` if percentage is numeric, or an `ARRAY<DOUBLE>` if
percentage is an array. `NULL` if percentage is an empty array.
+ - sql: SINGLE_VALUE(expression)
+ description: |
+ Returns a single value of the expression within a group.
+
+ If the group contains more than one distinct value, an exception is
thrown at runtime.
+
+ E.g., SELECT SINGLE_VALUE(id) FROM T.
Review Comment:
If you don't define a aggregation you will face the exception
```
Caused by: org.apache.flink.table.api.TableRuntimeException:
SingleValueAggFunction received more than one element.
```
Try running this in
[WordCountSQLExample](https://github.com/raminqaf/flink/blob/b16909ae925fcee06ce11e73a7dc5ec24a7fadcf/flink-examples/flink-examples-table/src/main/java/org/apache/flink/table/examples/java/basics/WordCountSQLExample.java#L25-L25).
```suggestion
SELECT SINGLE_VALUE(word) AS single_val
FROM VALUES ('Hello'), ('Ciao'), ('World')
AS WordTable(word)
GROUP BY word
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]