gavin9402 commented on code in PR #8179:
URL: https://github.com/apache/paimon/pull/8179#discussion_r3402168262


##########
paimon-api/src/main/java/org/apache/paimon/resource/AbstractResource.java:
##########
@@ -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.
+ */
+
+package org.apache.paimon.resource;
+
+import org.apache.paimon.catalog.Identifier;
+
+import 
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonGetter;
+import 
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonIgnore;
+
+import javax.annotation.Nullable;
+
+import java.util.Objects;
+import java.util.Optional;
+
+/** Abstract base implementation of {@link Resource} with common fields and 
accessors. */
+public abstract class AbstractResource implements Resource {
+
+    private static final long serialVersionUID = 1L;
+
+    private final Identifier identifier;
+    @Nullable private final String comment;
+    private final String uri;

Review Comment:
   The current design delegates URI handling to the file systems integrated 
with the engine. The metastore service is only responsible for permission 
management of the resource entity.
   
   For example, in Daft, we assign the URI to the resources field of the 
PyFileResourceFunction instance.
   ```python
       def _get_function(self, ident: Identifier) -> Function:
           ...
           paimon_daft_func: FunctionDefinition = 
self._inner.get_function(str(ident)).definitions()["daft"]
           ...
   
           # file_resources may be a list attribute or a callable method
           raw_resources = paimon_daft_func.file_resources
           resources = raw_resources() if callable(raw_resources) else 
raw_resources
   
           return PyFileResourceFunction(
               identifier=ident,
               module_name=paimon_daft_func.class_name,
               binding_name=paimon_daft_func.function_name,
               resources=[item.uri for item in resources],
           )
   ```
   
   During execution, the engine resolves it by fetching the resources through 
the corresponding file system, and file permissions are also handled by the 
file system.
   ```python
   async def run_plan(
           self,
           plan: LocalPhysicalPlan,
           exec_cfg: PyDaftExecutionConfig,
           context: dict[str, str] | None,
           added_resources: dict[str, int] | None = None,
           **inputs: (
               Input | list[ray.ObjectRef]
           ),  # PyMicroPartitions are separated from Inputs because they are 
Ray ObjectRefs, which will be resolved by Ray.
       ) -> AsyncGenerator[MicroPartition | FlightPartitions | 
SwordfishTaskMetadata, None]:
           """Run a plan on swordfish and yield partitions."""
           if added_resources:
               file_resource_manager.resolve(added_resources)
   ```
   More straightforwardly, we could also use Paimon FileIO for handling this. 
In fact, the engine’s behavior is similar to this.



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