This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new ca7e1ccbe8 [python] Fix schema api bug (#6010)
ca7e1ccbe8 is described below

commit ca7e1ccbe8ece0c3225ce4196b7cbdf128a27a11
Author: HeavenZH <[email protected]>
AuthorDate: Fri Aug 1 17:14:17 2025 +0800

    [python] Fix schema api bug (#6010)
---
 paimon-python/pypaimon/api/api_response.py         | 24 +++++++++++-----------
 .../pypaimon/catalog/rest/rest_catalog.py          |  4 ++--
 paimon-python/pypaimon/schema/table_schema.py      |  3 +--
 paimon-python/pypaimon/tests/rest_server.py        |  8 ++++----
 paimon-python/setup.py                             |  4 ++--
 5 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/paimon-python/pypaimon/api/api_response.py 
b/paimon-python/pypaimon/api/api_response.py
index 9709c4f05c..b50754b3cf 100644
--- a/paimon-python/pypaimon/api/api_response.py
+++ b/paimon-python/pypaimon/api/api_response.py
@@ -22,7 +22,7 @@ from dataclasses import dataclass
 
 from pypaimon.common.rest_json import json_field
 from .typedef import T
-from ..schema.table_schema import TableSchema
+from .. import Schema
 
 
 @dataclass
@@ -151,15 +151,15 @@ class GetTableResponse(AuditRESTResponse):
     FIELD_NAME = "name"
     FIELD_PATH = "path"
     FIELD_IS_EXTERNAL = "isExternal"
-    FIELD_TABLE_SCHEMA_ID = "tableSchemaId"
-    FIELD_TABLE_SCHEMA = "tableSchema"
+    FIELD_SCHEMA_ID = "schemaId"
+    FIELD_SCHEMA = "schema"
 
     id: Optional[str] = json_field(FIELD_ID, default=None)
     name: Optional[str] = json_field(FIELD_NAME, default=None)
     path: Optional[str] = json_field(FIELD_PATH, default=None)
     is_external: Optional[bool] = json_field(FIELD_IS_EXTERNAL, default=None)
-    table_schema_id: Optional[int] = json_field(FIELD_TABLE_SCHEMA_ID, 
default=None)
-    table_schema: Optional[TableSchema] = json_field(FIELD_TABLE_SCHEMA, 
default=None)
+    schema_id: Optional[int] = json_field(FIELD_SCHEMA_ID, default=None)
+    schema: Optional[Schema] = json_field(FIELD_SCHEMA, default=None)
 
     def __init__(
             self,
@@ -167,8 +167,8 @@ class GetTableResponse(AuditRESTResponse):
             name: str,
             path: str,
             is_external: bool,
-            table_schema_id: int,
-            table_schema: TableSchema,
+            schema_id: int,
+            schema: Schema,
             owner: Optional[str] = None,
             created_at: Optional[int] = None,
             created_by: Optional[str] = None,
@@ -180,8 +180,8 @@ class GetTableResponse(AuditRESTResponse):
         self.name = name
         self.path = path
         self.is_external = is_external
-        self.table_schema_id = table_schema_id
-        self.table_schema = table_schema
+        self.schema_id = schema_id
+        self.schema = schema
 
     def get_id(self) -> str:
         return self.id
@@ -196,10 +196,10 @@ class GetTableResponse(AuditRESTResponse):
         return self.is_external
 
     def get_schema_id(self) -> int:
-        return self.table_schema_id
+        return self.schema_id
 
-    def get_schema(self) -> TableSchema:
-        return self.table_schema
+    def get_schema(self) -> Schema:
+        return self.schema
 
 
 @dataclass
diff --git a/paimon-python/pypaimon/catalog/rest/rest_catalog.py 
b/paimon-python/pypaimon/catalog/rest/rest_catalog.py
index 540beb6353..b83796dbb3 100644
--- a/paimon-python/pypaimon/catalog/rest/rest_catalog.py
+++ b/paimon-python/pypaimon/catalog/rest/rest_catalog.py
@@ -25,12 +25,12 @@ from pypaimon.common.core_options import CoreOptions
 from pypaimon.common.identifier import Identifier
 from pypaimon.api.options import Options
 
-
 from pypaimon.catalog.catalog_context import CatalogContext
 from pypaimon.catalog.catalog_utils import CatalogUtils
 from pypaimon.catalog.property_change import PropertyChange
 from pypaimon.catalog.table_metadata import TableMetadata
 from pypaimon.catalog.rest.rest_token_file_io import RESTTokenFileIO
+from pypaimon.schema.table_schema import TableSchema
 from pypaimon.table.file_store_table import FileStoreTable
 
 
@@ -101,7 +101,7 @@ class RESTCatalog(Catalog):
         return self.to_table_metadata(identifier.get_database_name(), response)
 
     def to_table_metadata(self, db: str, response: GetTableResponse) -> 
TableMetadata:
-        schema = response.get_schema()
+        schema = TableSchema.from_schema(response.schema_id, 
response.get_schema())
         options: Dict[str, str] = dict(schema.options)
         options[CoreOptions.PATH] = response.get_path()
         response.put_audit_options_to(options)
diff --git a/paimon-python/pypaimon/schema/table_schema.py 
b/paimon-python/pypaimon/schema/table_schema.py
index 28084b2771..4be037f4dd 100644
--- a/paimon-python/pypaimon/schema/table_schema.py
+++ b/paimon-python/pypaimon/schema/table_schema.py
@@ -22,7 +22,6 @@ from dataclasses import dataclass
 from pathlib import Path
 from typing import List, Dict, Optional
 
-
 from pypaimon import Schema
 from pypaimon.common.rest_json import json_field
 from pypaimon.common.core_options import CoreOptions
@@ -127,7 +126,7 @@ class TableSchema:
         partition_keys: List[str] = schema.partition_keys
         primary_keys: List[str] = schema.primary_keys
         options: Dict[str, str] = schema.options
-        highest_field_id: int = max(field.id for field in fields)
+        highest_field_id: int = -1  # max(field.id for field in fields)
 
         return TableSchema(
             TableSchema.CURRENT_VERSION,
diff --git a/paimon-python/pypaimon/tests/rest_server.py 
b/paimon-python/pypaimon/tests/rest_server.py
index 2070acd626..7bb6430b67 100644
--- a/paimon-python/pypaimon/tests/rest_server.py
+++ b/paimon-python/pypaimon/tests/rest_server.py
@@ -395,7 +395,7 @@ class RESTCatalogServer:
                 raise TableNotExistException(identifier)
             table_metadata = 
self.table_metadata_store[identifier.get_full_name()]
             table_path = 
f'file://{self.data_path}/{self.warehouse}/{identifier.database_name}/{identifier.object_name}'
-            schema = table_metadata.schema
+            schema = table_metadata.schema.to_schema()
             response = self.mock_table(identifier, table_metadata, table_path, 
schema)
             return self._mock_response(response, 200)
         #
@@ -594,14 +594,14 @@ class RESTCatalogServer:
         )
 
     def mock_table(self, identifier: Identifier, table_metadata: 
TableMetadata, path: str,
-                   schema: TableSchema) -> GetTableResponse:
+                   schema: Schema) -> GetTableResponse:
         return GetTableResponse(
             id=str(table_metadata.uuid),
             name=identifier.get_object_name(),
             path=path,
             is_external=table_metadata.is_external,
-            table_schema_id=table_metadata.schema.id,
-            table_schema=schema,
+            schema_id=table_metadata.schema.id,
+            schema=schema,
             owner="owner",
             created_at=1,
             created_by="created",
diff --git a/paimon-python/setup.py b/paimon-python/setup.py
index 8fa06e11bc..d36eeedecb 100644
--- a/paimon-python/setup.py
+++ b/paimon-python/setup.py
@@ -25,8 +25,8 @@ install_requires = [
     'readerwriterlock==1.0.9',
     'fsspec==2024.3.1',
     'cachetools==5.3.3',
-    'ossfs==2023.12.0'
-    'fastavro==1.11.1'
+    'ossfs==2023.12.0',
+    'fastavro==1.11.1',
     'pyarrow==15.0.2'
 ]
 

Reply via email to