You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "XiaoHongbo-Hope (via GitHub)" <gi...@apache.org> on 2026/03/30 15:59:08 UTC
[PR] [python] Support REST function API in pypaimon [paimon]
XiaoHongbo-Hope opened a new pull request, #7559:
URL: https://github.com/apache/paimon/pull/7559
### Purpose
### Tests
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Support REST function API in pypaimon [paimon]
Posted by "XiaoHongbo-Hope (via GitHub)" <gi...@apache.org>.
XiaoHongbo-Hope commented on code in PR #7559:
URL: https://github.com/apache/paimon/pull/7559#discussion_r3026966500
##########
paimon-python/pypaimon/api/api_response.py:
##########
@@ -327,3 +328,213 @@ def __init__(self, snapshot: Optional[TableSnapshot] = None):
def get_snapshot(self) -> Optional[TableSnapshot]:
return self.snapshot
+
+
+@dataclass
+class GetFunctionResponse(AuditRESTResponse):
+ """Response for getting a function."""
+ FIELD_UUID = "uuid"
+ FIELD_NAME = "name"
+ FIELD_INPUT_PARAMS = "inputParams"
+ FIELD_RETURN_PARAMS = "returnParams"
+ FIELD_DETERMINISTIC = "deterministic"
+ FIELD_DEFINITIONS = "definitions"
+ FIELD_COMMENT = "comment"
+ FIELD_OPTIONS = "options"
+
+ uuid: Optional[str] = json_field(FIELD_UUID, default=None)
+ name: Optional[str] = json_field(FIELD_NAME, default=None)
+ input_params: Optional[List] = json_field(FIELD_INPUT_PARAMS, default=None)
Review Comment:
> It is a `List[dict]` or `List[DataField]`?
Update it as `List[DataField]`
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Support REST function API in pypaimon [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #7559:
URL: https://github.com/apache/paimon/pull/7559#discussion_r3026147076
##########
paimon-python/pypaimon/function/function_definition.py:
##########
@@ -0,0 +1,125 @@
+# 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 typing import Dict, List
+
+
+class Types:
+ FILE = "file"
+ SQL = "sql"
+ LAMBDA = "lambda"
+
+
+class FunctionFileResource:
+ """Represents a file resource for a function."""
+
+ def __init__(self, resource_type: str, uri: str):
+ self.resource_type = resource_type
+ self.uri = uri
+
+ def to_dict(self) -> Dict:
+ return {
+ "resourceType": self.resource_type,
+ "uri": self.uri,
+ }
+
+ @classmethod
+ def from_dict(cls, data: Dict) -> "FunctionFileResource":
+ return cls(
+ resource_type=data.get("resourceType"),
+ uri=data.get("uri"),
+ )
+
+ def __eq__(self, other):
+ if not isinstance(other, FunctionFileResource):
+ return False
+ return self.resource_type == other.resource_type and self.uri == other.uri
+
+ def __hash__(self):
+ return hash((self.resource_type, self.uri))
+
+
+class FunctionDefinition:
+ """Represents a function definition."""
+
+ def __init__(self, definition_type: str, **kwargs):
+ self._type = definition_type
+ self._data = kwargs
+
+ @staticmethod
+ def file(
+ file_resources: List[FunctionFileResource],
+ language: str,
+ class_name: str,
+ function_name: str,
+ ) -> "FunctionDefinition":
+ defn = FunctionDefinition(Types.FILE)
+ defn._data = {
+ "fileResources": file_resources,
+ "language": language,
+ "className": class_name,
+ "functionName": function_name,
+ }
+ return defn
+
+ @staticmethod
+ def sql(body: str) -> "FunctionDefinition":
+ defn = FunctionDefinition(Types.SQL)
+ defn._data = {"definition": body}
+ return defn
+
+ @staticmethod
+ def lambda_def(definition: str, language: str) -> "FunctionDefinition":
+ defn = FunctionDefinition(Types.LAMBDA)
+ defn._data = {"definition": definition, "language": language}
+ return defn
+
+ def to_dict(self) -> Dict:
+ result = {"type": self._type}
+ for key, value in self._data.items():
+ if key == "fileResources" and isinstance(value, list):
+ result[key] = [r.to_dict() if isinstance(r, FunctionFileResource) else r for r in value]
+ else:
+ result[key] = value
+ return result
+
+ @classmethod
+ def from_dict(cls, data: Dict) -> "FunctionDefinition":
+ if data is None:
+ return None
+ defn_type = data.get("type")
+ defn = cls(defn_type)
+ defn._data = {}
+ for key, value in data.items():
+ if key == "type":
+ continue
+ if key == "fileResources" and isinstance(value, list):
+ defn._data[key] = [
+ FunctionFileResource.from_dict(r) if isinstance(r, dict) else r
+ for r in value
+ ]
+ else:
+ defn._data[key] = value
+ return defn
+
+ def __eq__(self, other):
+ if not isinstance(other, FunctionDefinition):
+ return False
+ return self._type == other._type and self._data == other._data
+
+ def __hash__(self):
+ return hash(self._type)
Review Comment:
Why not add _data?
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Support REST function API in pypaimon [paimon]
Posted by "XiaoHongbo-Hope (via GitHub)" <gi...@apache.org>.
XiaoHongbo-Hope commented on PR #7559:
URL: https://github.com/apache/paimon/pull/7559#issuecomment-4159475279
> Take a look to https://github.com/unitycatalog/unitycatalog/blob/main/ai/core/src/unitycatalog/ai/core/client.py#L875
👌
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Support REST function API in pypaimon [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi closed pull request #7559: [python] Support REST function API in pypaimon
URL: https://github.com/apache/paimon/pull/7559
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Support REST function API in pypaimon [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on PR #7559:
URL: https://github.com/apache/paimon/pull/7559#issuecomment-4159457348
Take a look to https://github.com/unitycatalog/unitycatalog/blob/main/ai/core/src/unitycatalog/ai/core/client.py#L875
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Support REST function API in pypaimon [paimon]
Posted by "XiaoHongbo-Hope (via GitHub)" <gi...@apache.org>.
XiaoHongbo-Hope commented on code in PR #7559:
URL: https://github.com/apache/paimon/pull/7559#discussion_r3026987591
##########
paimon-python/pypaimon/function/function_definition.py:
##########
@@ -0,0 +1,125 @@
+# 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 typing import Dict, List
+
+
+class Types:
+ FILE = "file"
+ SQL = "sql"
+ LAMBDA = "lambda"
+
+
+class FunctionFileResource:
+ """Represents a file resource for a function."""
+
+ def __init__(self, resource_type: str, uri: str):
+ self.resource_type = resource_type
+ self.uri = uri
+
+ def to_dict(self) -> Dict:
+ return {
+ "resourceType": self.resource_type,
+ "uri": self.uri,
+ }
+
+ @classmethod
+ def from_dict(cls, data: Dict) -> "FunctionFileResource":
+ return cls(
+ resource_type=data.get("resourceType"),
+ uri=data.get("uri"),
+ )
+
+ def __eq__(self, other):
+ if not isinstance(other, FunctionFileResource):
+ return False
+ return self.resource_type == other.resource_type and self.uri == other.uri
+
+ def __hash__(self):
+ return hash((self.resource_type, self.uri))
+
+
+class FunctionDefinition:
+ """Represents a function definition."""
+
+ def __init__(self, definition_type: str, **kwargs):
+ self._type = definition_type
+ self._data = kwargs
+
+ @staticmethod
+ def file(
+ file_resources: List[FunctionFileResource],
+ language: str,
+ class_name: str,
+ function_name: str,
+ ) -> "FunctionDefinition":
+ defn = FunctionDefinition(Types.FILE)
+ defn._data = {
+ "fileResources": file_resources,
+ "language": language,
+ "className": class_name,
+ "functionName": function_name,
+ }
+ return defn
+
+ @staticmethod
+ def sql(body: str) -> "FunctionDefinition":
+ defn = FunctionDefinition(Types.SQL)
+ defn._data = {"definition": body}
+ return defn
+
+ @staticmethod
+ def lambda_def(definition: str, language: str) -> "FunctionDefinition":
+ defn = FunctionDefinition(Types.LAMBDA)
+ defn._data = {"definition": definition, "language": language}
+ return defn
+
+ def to_dict(self) -> Dict:
+ result = {"type": self._type}
+ for key, value in self._data.items():
+ if key == "fileResources" and isinstance(value, list):
+ result[key] = [r.to_dict() if isinstance(r, FunctionFileResource) else r for r in value]
+ else:
+ result[key] = value
+ return result
+
+ @classmethod
+ def from_dict(cls, data: Dict) -> "FunctionDefinition":
+ if data is None:
+ return None
+ defn_type = data.get("type")
+ defn = cls(defn_type)
+ defn._data = {}
+ for key, value in data.items():
+ if key == "type":
+ continue
+ if key == "fileResources" and isinstance(value, list):
+ defn._data[key] = [
+ FunctionFileResource.from_dict(r) if isinstance(r, dict) else r
+ for r in value
+ ]
+ else:
+ defn._data[key] = value
+ return defn
+
+ def __eq__(self, other):
+ if not isinstance(other, FunctionDefinition):
+ return False
+ return self._type == other._type and self._data == other._data
+
+ def __hash__(self):
+ return hash(self._type)
Review Comment:
> Why not add _data?
Refactored and followed same structure with java.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Support REST function API in pypaimon [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #7559:
URL: https://github.com/apache/paimon/pull/7559#discussion_r3026144229
##########
paimon-python/pypaimon/api/rest_api.py:
##########
@@ -439,3 +584,7 @@ def __validate_identifier(identifier: Identifier):
raise ValueError("Table name cannot be None")
return database_name.strip(), table_name.strip()
+
+
+class IllegalArgumentError(Exception):
Review Comment:
Should be defined in `catalog_exception.py`.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Support REST function API in pypaimon [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #7559:
URL: https://github.com/apache/paimon/pull/7559#discussion_r3026143198
##########
paimon-python/pypaimon/api/api_response.py:
##########
@@ -327,3 +328,213 @@ def __init__(self, snapshot: Optional[TableSnapshot] = None):
def get_snapshot(self) -> Optional[TableSnapshot]:
return self.snapshot
+
+
+@dataclass
+class GetFunctionResponse(AuditRESTResponse):
+ """Response for getting a function."""
+ FIELD_UUID = "uuid"
+ FIELD_NAME = "name"
+ FIELD_INPUT_PARAMS = "inputParams"
+ FIELD_RETURN_PARAMS = "returnParams"
+ FIELD_DETERMINISTIC = "deterministic"
+ FIELD_DEFINITIONS = "definitions"
+ FIELD_COMMENT = "comment"
+ FIELD_OPTIONS = "options"
+
+ uuid: Optional[str] = json_field(FIELD_UUID, default=None)
+ name: Optional[str] = json_field(FIELD_NAME, default=None)
+ input_params: Optional[List] = json_field(FIELD_INPUT_PARAMS, default=None)
Review Comment:
It is a `List[dict]` or `List[DataField]`?
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Support REST function API in pypaimon [paimon]
Posted by "XiaoHongbo-Hope (via GitHub)" <gi...@apache.org>.
XiaoHongbo-Hope commented on PR #7559:
URL: https://github.com/apache/paimon/pull/7559#issuecomment-4174437824
> Take a look to https://github.com/unitycatalog/unitycatalog/blob/main/ai/core/src/unitycatalog/ai/core/client.py#L875
Do you mean we can support callable function in Pypaimon? We can create a separate PR for it.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Support REST function API in pypaimon [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #7559:
URL: https://github.com/apache/paimon/pull/7559
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Support REST function API in pypaimon [paimon]
Posted by "XiaoHongbo-Hope (via GitHub)" <gi...@apache.org>.
XiaoHongbo-Hope commented on code in PR #7559:
URL: https://github.com/apache/paimon/pull/7559#discussion_r3026969272
##########
paimon-python/pypaimon/api/rest_api.py:
##########
@@ -439,3 +584,7 @@ def __validate_identifier(identifier: Identifier):
raise ValueError("Table name cannot be None")
return database_name.strip(), table_name.strip()
+
+
+class IllegalArgumentError(Exception):
Review Comment:
> Should be defined in `catalog_exception.py`.
Moved
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Support REST function API in pypaimon [paimon]
Posted by "gavin9402 (via GitHub)" <gi...@apache.org>.
gavin9402 commented on PR #7559:
URL: https://github.com/apache/paimon/pull/7559#issuecomment-4174954461
+1
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org