raminqaf commented on code in PR #26806:
URL: https://github.com/apache/flink/pull/26806#discussion_r2215188496
##########
docs/data/sql_functions.yml:
##########
@@ -1219,6 +1219,35 @@ valueconstruction:
- table: NUMERIC.rows
description: Creates a NUMERIC interval of rows (commonly used in window
creation).
+valuemodification:
+ - sql: OBJECT_UPDATE(object, key, value [, key, value , ...])
+ table: OBJECT.objectUpdate(key, value [, key, value , ...])
+ description: |
+ Updates existing fields in a structured object by providing key-value
pairs.
Review Comment:
- Arrays should be supported. In the background, the OBJECT_UPDATE uses a
structured type, and [this
test](https://github.com/raminqaf/flink/blob/e24c76cd611671ad893096bb0d74f89cdfa4dbdb/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/StructuredFunctionsITCase.java#L105-L105)
evaluates its functionality.
- There should be no restrictions on the values, we only check if the type
of the updated value matches the one in the structured type.
- For now, we decided to skip any validation on the field name format. The
user is allowed to write `OBJECT_UPDATE(obj, "my.field.name", 14)`. This should
be up to the user to pass valid field names. For the first iteration, this
validation was not necessary.
- If I understand you correctly, you cannot update an ARRAY type with
OBJECT_UPDATE. The `OBJECT_UPDATE` applies to `STRUCTURED_TYPE`.
- Yes, valus can be null
- Yes, validation errors will be thrown if the the field name is null:
- Here is the [validation
check](https://github.com/raminqaf/flink/blob/e24c76cd611671ad893096bb0d74f89cdfa4dbdb/flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ObjectUpdateInputTypeStrategy.java#L136-L136),
where we see if the field is a non-null String literal.
-
[Tests](https://github.com/raminqaf/flink/blob/e24c76cd611671ad893096bb0d74f89cdfa4dbdb/flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/inference/strategies/ObjectUpdateInputTypeStrategyTest.java#L96-L96)
backing this logic.
--
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]