raminqaf commented on code in PR #29617:
URL: https://github.com/apache/flink/pull/29617#discussion_r4401646365


##########
flink-python/pyflink/table/expression.py:
##########
@@ -2456,6 +2456,40 @@ def try_parse_xml(self, force_array=None) -> 
'Expression':
         else:
             return _binary_op("tryParseXml")(self, force_array)
 
+    def variant_get(self, path, return_type: DataType = None) -> 'Expression':
+        """
+        Returns the value of a VARIANT at a path, cast to return_type. Without 
return_type, the
+        value is returned as a VARIANT. If the VARIANT or the path is None, or 
nothing is at the
+        path, None is returned. A variant null at the path gives None, unless 
return_type is
+        omitted or VARIANT, which keeps it as a variant null. If the value 
cannot be cast to
+        return_type, an error is thrown. To return None instead, use
+        :func:`~Expression.try_variant_get`.

Review Comment:
   Reworded: results are NULL, and the type is `DataTypes.VARIANT()`. 
`json_length` is fixed in a separate hotfix commit.



##########
flink-python/pyflink/table/expression.py:
##########
@@ -2456,6 +2456,40 @@ def try_parse_xml(self, force_array=None) -> 
'Expression':
         else:
             return _binary_op("tryParseXml")(self, force_array)
 
+    def variant_get(self, path, return_type: DataType = None) -> 'Expression':
+        """
+        Returns the value of a VARIANT at a path, cast to return_type. Without 
return_type, the
+        value is returned as a VARIANT. If the VARIANT or the path is None, or 
nothing is at the
+        path, None is returned. A variant null at the path gives None, unless 
return_type is
+        omitted or VARIANT, which keeps it as a variant null. If the value 
cannot be cast to
+        return_type, an error is thrown. To return None instead, use
+        :func:`~Expression.try_variant_get`.
+
+        Array indices in a path such as '$.items[0].qty' start at 0. See the 
SQL function
+        VARIANT_GET for the path syntax. Only the logical type of return_type 
is used.
+
+        Example:
+        ::
+
+            >>> lit('{"a": {"b": 1}}').parse_json().variant_get('$.a.b', 
DataTypes.INT()) # 1
+            >>> lit('{"a": 1}').parse_json().variant_get('$.b', 
DataTypes.INT()) # None

Review Comment:
   Done



-- 
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]

Reply via email to