mchades commented on code in PR #9943:
URL: https://github.com/apache/gravitino/pull/9943#discussion_r2791319638


##########
clients/client-python/gravitino/api/function/function_impl.py:
##########
@@ -0,0 +1,113 @@
+# 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.
+
+from abc import ABC
+from enum import Enum
+from typing import Dict, Optional
+
+from gravitino.api.function.function_resources import FunctionResources
+
+
+class FunctionImpl(ABC):
+    """Base class of function implementations.
+
+    A function implementation must declare its language and optional external 
resources.
+    Concrete implementations are provided by SQLImpl, JavaImpl, and PythonImpl.
+    """
+
+    class Language(Enum):
+        """Supported implementation languages."""
+
+        SQL = "SQL"
+        """SQL implementation."""
+
+        JAVA = "JAVA"
+        """Java implementation."""
+
+        PYTHON = "PYTHON"
+        """Python implementation."""
+
+    class RuntimeType(Enum):
+        """Supported execution runtimes for function implementations."""
+
+        SPARK = "SPARK"
+        """Spark runtime."""
+
+        TRINO = "TRINO"
+        """Trino runtime."""
+
+        @classmethod
+        def from_string(cls, value: str) -> "FunctionImpl.RuntimeType":
+            """Parse a runtime value from string.
+
+            Args:
+                value: Runtime name.
+
+            Returns:
+                Parsed runtime.
+
+            Raises:
+                ValueError: If the runtime is not supported.
+            """
+            if not value or not value.strip():
+                raise ValueError("Function runtime must be set")
+            return cls[value.strip().upper()]

Review Comment:
   Fixed. Changed to iterate over enum values and raise `ValueError`, 
consistent with `FunctionType.from_string()` and `SortDirection.from_string()` 
patterns in the codebase.



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