Abyss-lord commented on code in PR #9870:
URL: https://github.com/apache/gravitino/pull/9870#discussion_r2903757708


##########
clients/client-python/gravitino/api/rel/types/json_serdes/_helper/serdes_utils.py:
##########
@@ -309,3 +322,202 @@ def read_external_type(cls, external_data: Dict[str, 
Any]) -> Types.ExternalType
             f"Cannot parse external type from missing catalogString: 
{external_data}",
         )
         return Types.ExternalType.of(external_data[cls.CATALOG_STRING])
+
+    @classmethod
+    def column_default_value_encoder(cls, value: Expression) -> Union[str, 
None]:
+        if value is None or value == Expression.EMPTY_EXPRESSION:
+            return None
+
+        return cls.write_function_arg(value)
+
+    @classmethod
+    def write_function_arg(cls, arg: FunctionArg) -> Any:
+        if arg.arg_type() == FunctionArg.ArgType.LITERAL:
+            return {
+                cls.TYPE: arg.arg_type().value.lower(),
+                cls.DATA_TYPE: cls.write_data_type(arg.data_type()),
+                cls.LITERAL_VALUE: arg.value(),
+            }
+
+        if arg.arg_type() == FunctionArg.ArgType.FIELD:
+            return {
+                cls.TYPE: arg.arg_type().value.lower(),
+                cls.FIELD_NAME: arg.field_name(),
+            }
+
+        if arg.arg_type() == FunctionArg.ArgType.FUNCTION:
+            return {
+                cls.TYPE: arg.arg_type().value.lower(),
+                cls.FUNCTION_NAME: arg.function_name(),
+                cls.FUNCTION_ARGS: [
+                    cls.write_function_arg(child) for child in arg.args()
+                ],
+            }
+
+        if arg.arg_type() == FunctionArg.ArgType.UNPARSED:
+            return {
+                cls.TYPE: arg.arg_type().value.lower(),
+                cls.UNPARSED_EXPRESSION: arg.unparsed_expression(),
+            }
+
+        raise ValueError(f"Unknown function argument type: {arg.arg_type()}")
+
+    @classmethod
+    def column_default_value_decoder(cls, value: dict) -> Expression:

Review Comment:
   fix



##########
clients/client-python/gravitino/api/rel/types/json_serdes/_helper/serdes_utils.py:
##########
@@ -309,3 +322,202 @@ def read_external_type(cls, external_data: Dict[str, 
Any]) -> Types.ExternalType
             f"Cannot parse external type from missing catalogString: 
{external_data}",
         )
         return Types.ExternalType.of(external_data[cls.CATALOG_STRING])
+
+    @classmethod
+    def column_default_value_encoder(cls, value: Expression) -> Union[str, 
None]:

Review Comment:
   fix



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