You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "kunwp1 (via GitHub)" <gi...@apache.org> on 2025/12/01 18:26:39 UTC

[PR] Python Support for BigObject [texera]

kunwp1 opened a new pull request, #4100:
URL: https://github.com/apache/texera/pull/4100

   <!--
   Thanks for sending a pull request (PR)! Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: 
        [Contributing to Texera](https://github.com/apache/texera/blob/main/CONTRIBUTING.md)
     2. Ensure you have added or run the appropriate tests for your PR
     3. If the PR is work in progress, mark it a draft on GitHub.
     4. Please write your PR title to summarize what this PR proposes, we 
       are following Conventional Commits style for PR titles as well.
     5. Be sure to keep the PR description updated to reflect all changes.
   -->
   
   ### What changes were proposed in this PR?
   <!--
   Please clarify what changes you are proposing. The purpose of this section 
   is to outline the changes. Here are some tips for you:
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
     3. If it is a refactoring, clarify what has been changed.
     3. It would be helpful to include a before-and-after comparison using 
        screenshots or GIFs.
     4. Please consider writing useful notes for better and faster reviews.
   -->
   This PR introduces Python support for the `big_object` attribute type, enabling Python UDF operators to process data larger than 2 GB. Data is offloaded to MinIO (S3), and the tuple retains only a pointer (URI). This mirrors the existing Java BigObject implementation, ensuring cross-language compatibility. (See #4067 for system diagram)
   
   ## Key Features
   
   ### 1. MinIO/S3 Integration
   - Utilizes the shared `texera-big-objects` bucket.
   - Implements lazy initialization of S3 clients and automatic bucket creation.
   
   ### 2. Streaming I/O
   - **`BigObjectOutputStream`:** Writes data to S3 using multipart uploads (64KB chunks) to prevent blocking the main execution.
   - **`BigObjectInputStream`:** Lazily downloads data only when the read operation begins. Implements standard Python `io.IOBase`.
   
   ### 3. Tuple & Iceberg Compatibility
   - `BigObject` instances are automatically serialized to URI strings for Iceberg storage and Arrow tables.
   - Uses a magic suffix (`__texera_big_obj_ptr`) to distinguish pointers from standard strings.
   
   ### 4. Serialization
   - Pointers are stored as strings with metadata (texera_type: BIG_OBJECT). Auto-conversion ensures UDFs always see BigObject instances, not raw strings.
   
   ## User API Usage
   
   ### 1. Creating & Writing (Output)
   Use `BigObjectOutputStream` to stream large data into a new object.
   
   ```python
   from pytexera import BigObject, BigObjectOutputStream
   
   # Create a new handle
   big_object = BigObject()
   
   # Stream data to S3
   with BigObjectOutputStream(big_object) as out:
       out.write(my_large_data_bytes)
       # Supports bytearray, bytes, etc.
   ```
   
   ### 2. Reading (Input)
   Use `BigObjectInputStream` to read data back. It supports all standard Python stream methods.
   
   ```python
   from pytexera import BigObjectInputStream
   
   with BigObjectInputStream(big_object) as stream:
       # Option A: Read everything
       all_data = stream.read()
   
       # Option B: Chunked reading
       chunk = stream.read(1024)
   
       # Option C: Iteration
       for line in stream:
           process(line)
   ```
   
   ## Dependencies
   - `boto3`: Required for S3 interactions.
   - `StorageConfig`: Uses existing configuration for endpoints/credentials.
   
   ### Any related issues, documentation, discussions?
   <!--
   Please use this section to link other resources if not mentioned already.
     1. If this PR fixes an issue, please include `Fixes #1234`, `Resolves #1234`
        or `Closes #1234`. If it is only related, simply mention the issue number.
     2. If there is design documentation, please add the link.
     3. If there is a discussion in the mailing list, please add the link.
   -->
   
   
   ### How was this PR tested?
   <!--
   If tests were added, say they were added here. Or simply mention that if the PR 
   is tested with existing test cases.  Make sure to include/update test cases that
   check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how
   you tested step by step, ideally copy and paste-able, so that other reviewers can
   test and check, and descendants can verify in the future. If tests were not added, 
   please describe why they were not added and/or why it was difficult to add. 
   -->
   
   
   ### Was this PR authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this PR, 
   please include the phrase: 'Generated-by: ' followed by the name of the tool 
   and its version. If no, write 'No'. 
   Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for Large Binary [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2615953618


##########
amber/src/main/python/pytexera/storage/large_binary_manager.py:
##########
@@ -0,0 +1,86 @@
+# 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.
+
+"""
+Internal largebinary manager for S3 operations.
+
+Users should not interact with this module directly. Use largebinary() constructor
+and LargeBinaryInputStream/LargeBinaryOutputStream instead.
+"""
+
+import logging
+import time
+import uuid
+from core.storage.storage_config import StorageConfig
+
+logger = logging.getLogger(__name__)
+
+
+class LargeBinaryManager:

Review Comment:
   you could consider remove the class. and make all methods module level functions. 



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for BigObject [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on PR #4100:
URL: https://github.com/apache/texera/pull/4100#issuecomment-3624481420

   blocked by #4111


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for Large Binary [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2615932024


##########
amber/src/main/python/pytexera/storage/large_binary_manager.py:
##########
@@ -0,0 +1,86 @@
+# 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.
+
+"""
+Internal largebinary manager for S3 operations.
+
+Users should not interact with this module directly. Use largebinary() constructor
+and LargeBinaryInputStream/LargeBinaryOutputStream instead.
+"""
+
+import logging
+import time
+import uuid
+from core.storage.storage_config import StorageConfig
+
+logger = logging.getLogger(__name__)
+
+
+class LargeBinaryManager:

Review Comment:
   This is more like a static utility class so I'll add a `__new__` guard to prevent instantiation



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for BigObject [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on PR #4100:
URL: https://github.com/apache/texera/pull/4100#issuecomment-3598506167

   @chenlica I described it in the Key Features section.


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for BigObject [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on PR #4100:
URL: https://github.com/apache/texera/pull/4100#issuecomment-3605021751

   I’ve started renaming BigObject to LargeBinary, but the change isn’t complete yet. Since PR #4067 was already merged with the BigObject naming, I plan to submit a follow-up PR that fully renames all remaining BigObject references to LargeBinary across 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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for Large Binary [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2615951998


##########
amber/src/main/python/core/models/schema/large_binary.py:
##########
@@ -0,0 +1,98 @@
+# 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.
+
+"""
+largebinary represents a reference to a large object stored externally (e.g., S3).
+This is a schema type class used throughout the system for handling
+BIG_OBJECT attribute types.
+"""
+
+from typing import Optional
+from urllib.parse import urlparse
+
+
+class largebinary:

Review Comment:
   ok that's true. usually in Python we use LargeBinary for class names and lower case are for primitive types such as list, str, int, etc. In my previous comment I did not realize it is for class name. I think we are fine with `largebinary` for now.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for BigObject [texera]

Posted by "chenlica (via GitHub)" <gi...@apache.org>.
chenlica commented on PR #4100:
URL: https://github.com/apache/texera/pull/4100#issuecomment-3598491774

   @kunwp1 Please include a brief description of the main changes in the PR.


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for Large Binary [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2617798248


##########
amber/src/main/python/core/models/schema/arrow_schema_utils.py:
##########
@@ -0,0 +1,106 @@
+# 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.
+
+"""
+Utilities for converting between Arrow schemas and Amber schemas,
+handling LARGE_BINARY metadata preservation.
+"""
+
+import pyarrow as pa
+from typing import Mapping
+
+from core.models.schema.attribute_type import (
+    AttributeType,
+    FROM_ARROW_MAPPING,
+    TO_ARROW_MAPPING,
+)
+
+# Metadata key used to mark LARGE_BINARY fields in Arrow schemas
+TEXERA_TYPE_METADATA_KEY = b"texera_type"
+LARGE_BINARY_METADATA_VALUE = b"LARGE_BINARY"
+
+
+def detect_attribute_type_from_arrow_field(field: pa.Field) -> AttributeType:
+    """
+    Detects the AttributeType from an Arrow field, checking metadata for LARGE_BINARY.
+
+    :param field: PyArrow field that may contain metadata
+    :return: The detected AttributeType
+    """
+    # Check metadata for LARGE_BINARY type
+    # (can be stored by either Scala ArrowUtils or Python)
+    is_large_binary = (
+        field.metadata
+        and field.metadata.get(TEXERA_TYPE_METADATA_KEY) == LARGE_BINARY_METADATA_VALUE
+    )
+
+    if is_large_binary:
+        return AttributeType.LARGE_BINARY
+    else:
+        return FROM_ARROW_MAPPING[field.type.id]
+
+
+def create_arrow_field_with_metadata(
+    attr_name: str, attr_type: AttributeType
+) -> pa.Field:
+    """
+    Creates a PyArrow field with appropriate metadata for the given AttributeType.
+
+    :param attr_name: Name of the attribute
+    :param attr_type: The AttributeType
+    :return: PyArrow field with metadata if needed
+    """
+    metadata = (
+        {TEXERA_TYPE_METADATA_KEY: LARGE_BINARY_METADATA_VALUE}
+        if attr_type == AttributeType.LARGE_BINARY
+        else None
+    )
+
+    return pa.field(attr_name, TO_ARROW_MAPPING[attr_type], metadata=metadata)

Review Comment:
   sounds good!



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for Large Binary [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2615921137


##########
amber/src/main/python/core/models/schema/attribute_type.py:
##########
@@ -83,6 +87,7 @@ class AttributeType(Enum):
     AttributeType.BOOL: bool,
     AttributeType.BINARY: bytes,
     AttributeType.TIMESTAMP: datetime.datetime,
+    AttributeType.LARGE_BINARY: largebinary,

Review Comment:
   I think in line 65, I am already mapping `LARGE_BINARY` attribute to arrow string. The line you are referring to is mapping `LARGE_BINARY` attribute convert it back to Python object in the UDF.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for BigObject [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2583553127


##########
amber/src/main/python/core/architecture/packaging/output_manager.py:
##########
@@ -259,10 +259,21 @@ def emit_state(
         )
 
     def tuple_to_frame(self, tuples: typing.List[Tuple]) -> DataFrame:
+        from core.models.schema.big_object import BigObject
+
         return DataFrame(
             frame=Table.from_pydict(
                 {
-                    name: [t[name] for t in tuples]
+                    name: [
+                        (
+                            # Convert BigObject objects to URI strings
+                            # for Arrow serialization
+                            t[name].uri
+                            if isinstance(t[name], BigObject)
+                            else t[name]
+                        )

Review Comment:
   I updated the code based on your comment. Can you take a look?



##########
amber/src/main/python/core/models/schema/attribute_type.py:
##########
@@ -92,4 +97,5 @@ class AttributeType(Enum):
     bool: AttributeType.BOOL,
     bytes: AttributeType.BINARY,
     datetime.datetime: AttributeType.TIMESTAMP,
+    BigObject: AttributeType.BIG_OBJECT,

Review Comment:
   Updated.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for Large Binary [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2615952997


##########
amber/src/main/python/core/models/schema/attribute_type.py:
##########
@@ -83,6 +87,7 @@ class AttributeType(Enum):
     AttributeType.BOOL: bool,
     AttributeType.BINARY: bytes,
     AttributeType.TIMESTAMP: datetime.datetime,
+    AttributeType.LARGE_BINARY: largebinary,

Review Comment:
   oh ok then that's correct now. thanks!



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for Large Binary [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2594449572


##########
amber/src/main/python/core/models/schema/large_binary.py:
##########
@@ -0,0 +1,98 @@
+# 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.
+
+"""
+largebinary represents a reference to a large object stored externally (e.g., S3).
+This is a schema type class used throughout the system for handling
+BIG_OBJECT attribute types.
+"""
+
+from typing import Optional
+from urllib.parse import urlparse
+
+
+class largebinary:

Review Comment:
   Let's use `LargeBinary` for class name.



##########
amber/src/main/python/pytexera/storage/large_binary_manager.py:
##########
@@ -0,0 +1,86 @@
+# 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.
+
+"""
+Internal largebinary manager for S3 operations.
+
+Users should not interact with this module directly. Use largebinary() constructor
+and LargeBinaryInputStream/LargeBinaryOutputStream instead.
+"""
+
+import logging
+import time
+import uuid
+from core.storage.storage_config import StorageConfig
+
+logger = logging.getLogger(__name__)
+
+
+class LargeBinaryManager:

Review Comment:
   is this a singleton? if so please follow singleton pattern by adding `__new__(cls)` guard to ensure there is only one copy of the class instance.



##########
amber/src/main/python/core/models/schema/large_binary.py:
##########


Review Comment:
   can you move this to `core/models/type/`? I think that's a better location. 



##########
amber/src/main/python/core/models/schema/arrow_schema_utils.py:
##########
@@ -0,0 +1,106 @@
+# 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.
+
+"""
+Utilities for converting between Arrow schemas and Amber schemas,
+handling LARGE_BINARY metadata preservation.
+"""
+
+import pyarrow as pa
+from typing import Mapping
+
+from core.models.schema.attribute_type import (
+    AttributeType,
+    FROM_ARROW_MAPPING,
+    TO_ARROW_MAPPING,
+)
+
+# Metadata key used to mark LARGE_BINARY fields in Arrow schemas
+TEXERA_TYPE_METADATA_KEY = b"texera_type"
+LARGE_BINARY_METADATA_VALUE = b"LARGE_BINARY"
+
+
+def detect_attribute_type_from_arrow_field(field: pa.Field) -> AttributeType:
+    """
+    Detects the AttributeType from an Arrow field, checking metadata for LARGE_BINARY.
+
+    :param field: PyArrow field that may contain metadata
+    :return: The detected AttributeType
+    """
+    # Check metadata for LARGE_BINARY type
+    # (can be stored by either Scala ArrowUtils or Python)
+    is_large_binary = (
+        field.metadata
+        and field.metadata.get(TEXERA_TYPE_METADATA_KEY) == LARGE_BINARY_METADATA_VALUE
+    )
+
+    if is_large_binary:
+        return AttributeType.LARGE_BINARY
+    else:
+        return FROM_ARROW_MAPPING[field.type.id]
+
+
+def create_arrow_field_with_metadata(
+    attr_name: str, attr_type: AttributeType
+) -> pa.Field:
+    """
+    Creates a PyArrow field with appropriate metadata for the given AttributeType.
+
+    :param attr_name: Name of the attribute
+    :param attr_type: The AttributeType
+    :return: PyArrow field with metadata if needed
+    """
+    metadata = (
+        {TEXERA_TYPE_METADATA_KEY: LARGE_BINARY_METADATA_VALUE}
+        if attr_type == AttributeType.LARGE_BINARY
+        else None
+    )
+
+    return pa.field(attr_name, TO_ARROW_MAPPING[attr_type], metadata=metadata)

Review Comment:
   you see this method only involves `AttributeType` but not `Schema`. so it's better to be moved elsewhere. I recall we have a type utils. can you check and move those methods there?



##########
amber/src/main/python/pytexera/storage/large_binary_input_stream.py:
##########
@@ -0,0 +1,121 @@
+# 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.
+
+"""
+LargeBinaryInputStream for reading largebinary data from S3.
+
+Usage:
+    with LargeBinaryInputStream(large_binary) as stream:
+        content = stream.read()
+"""
+
+from typing import BinaryIO, Optional
+from functools import wraps
+from io import IOBase
+from core.models.schema.large_binary import largebinary
+
+
+def _require_open(func):
+    """Decorator to ensure stream is open before reading operations."""
+
+    @wraps(func)
+    def wrapper(self, *args, **kwargs):
+        if self._closed:
+            raise ValueError("I/O operation on closed stream")
+        if self._underlying is None:
+            self._lazy_init()
+        return func(self, *args, **kwargs)
+
+    return wrapper
+
+
+class LargeBinaryInputStream(IOBase):
+    """
+    InputStream for reading largebinary data from S3.
+
+    Lazily downloads from S3 on first read. Supports context manager and iteration.
+    """
+
+    def __init__(self, large_binary: largebinary):
+        """Initialize stream for reading the given largebinary."""
+        super().__init__()
+        if large_binary is None:
+            raise ValueError("largebinary cannot be None")
+        self._large_binary = large_binary
+        self._underlying: Optional[BinaryIO] = None
+        self._closed = False
+
+    def _lazy_init(self):
+        """Download from S3 on first read operation."""
+        from pytexera.storage.large_binary_manager import LargeBinaryManager
+
+        s3 = LargeBinaryManager._get_s3_client()
+        response = s3.get_object(
+            Bucket=self._large_binary.get_bucket_name(),
+            Key=self._large_binary.get_object_key(),
+        )
+        self._underlying = response["Body"]
+
+    @_require_open
+    def read(self, n: int = -1) -> bytes:
+        """Read and return up to n bytes (-1 reads all)."""
+        return self._underlying.read(n)
+
+    @_require_open
+    def readline(self, size: int = -1) -> bytes:
+        """Read and return one line from the stream."""
+        return self._underlying.readline(size)
+
+    @_require_open
+    def readlines(self, hint: int = -1) -> list[bytes]:
+        """Read and return a list of lines from the stream."""
+        return self._underlying.readlines(hint)
+
+    def readable(self) -> bool:
+        """Return True if the stream can be read from."""
+        return not self._closed
+
+    def seekable(self) -> bool:
+        """Return False - this stream does not support seeking."""
+        return False
+
+    @property
+    def closed(self) -> bool:
+        """Return True if the stream is closed."""
+        return self._closed
+
+    def close(self) -> None:
+        """Close the stream and release resources."""
+        if not self._closed:
+            self._closed = True
+            if self._underlying is not None:
+                self._underlying.close()
+
+    def __enter__(self):
+        return self
+
+    def __exit__(self, exc_type, exc_val, exc_tb):
+        self.close()

Review Comment:
   great that we are using a context manager. 



##########
amber/src/main/python/core/models/schema/attribute_type.py:
##########
@@ -83,6 +87,7 @@ class AttributeType(Enum):
     AttributeType.BOOL: bool,
     AttributeType.BINARY: bytes,
     AttributeType.TIMESTAMP: datetime.datetime,
+    AttributeType.LARGE_BINARY: largebinary,

Review Comment:
   i think we should map it to arrow string type. if map to `largebinary` type, then arrow will do optimizations, but our actual data is only the pointer, which means the optimization maybe a backfire.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for Large Binary [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2615909479


##########
amber/src/main/python/core/models/schema/large_binary.py:
##########
@@ -0,0 +1,98 @@
+# 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.
+
+"""
+largebinary represents a reference to a large object stored externally (e.g., S3).
+This is a schema type class used throughout the system for handling
+BIG_OBJECT attribute types.
+"""
+
+from typing import Optional
+from urllib.parse import urlparse
+
+
+class largebinary:

Review Comment:
   > please consider change name. also use lowercase only to align with other types.
   
   I think this conflicts with your previous comment. Which one should I follow?



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for Large Binary [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 merged PR #4100:
URL: https://github.com/apache/texera/pull/4100


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for BigObject [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2579628132


##########
amber/src/main/python/core/models/schema/big_object.py:
##########
@@ -0,0 +1,98 @@
+# 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.
+
+"""
+BigObject represents a reference to a large object stored externally (e.g., S3).
+This is a schema type class used throughout the system for handling
+BIG_OBJECT attribute types.
+"""
+
+from typing import Optional
+from urllib.parse import urlparse
+
+
+class BigObject:

Review Comment:
   Sounds good. In the future, we are planning to extend the binary type and let the system decide whether to offload it to S3 or not, so I think changing the name to `LargeBinary` aligns with this plan.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for BigObject [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2578711117


##########
amber/src/main/python/core/architecture/packaging/output_manager.py:
##########
@@ -259,10 +259,21 @@ def emit_state(
         )
 
     def tuple_to_frame(self, tuples: typing.List[Tuple]) -> DataFrame:
+        from core.models.schema.big_object import BigObject
+
         return DataFrame(
             frame=Table.from_pydict(
                 {
-                    name: [t[name] for t in tuples]
+                    name: [
+                        (
+                            # Convert BigObject objects to URI strings
+                            # for Arrow serialization
+                            t[name].uri
+                            if isinstance(t[name], BigObject)
+                            else t[name]
+                        )

Review Comment:
   Very intrusive. it should be handled In tuple, not `tuple_to_frame`. 



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for BigObject [texera]

Posted by "chenlica (via GitHub)" <gi...@apache.org>.
chenlica commented on PR #4100:
URL: https://github.com/apache/texera/pull/4100#issuecomment-3599680703

   @Yicong-Huang suggested `LargeBinary` instead of `BigObject`.  I support this renaming.  @kunwp1 Can you see what other systems are using so that we can make a decision?


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for Large Binary [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2615954706


##########
amber/src/main/python/pytexera/storage/large_binary_manager.py:
##########
@@ -0,0 +1,86 @@
+# 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.
+
+"""
+Internal largebinary manager for S3 operations.
+
+Users should not interact with this module directly. Use largebinary() constructor
+and LargeBinaryInputStream/LargeBinaryOutputStream instead.
+"""
+
+import logging
+import time
+import uuid
+from core.storage.storage_config import StorageConfig
+
+logger = logging.getLogger(__name__)

Review Comment:
   sorry just saw this one. please use loguru instead. that's our official logger. 



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for Large Binary [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2615921137


##########
amber/src/main/python/core/models/schema/attribute_type.py:
##########
@@ -83,6 +87,7 @@ class AttributeType(Enum):
     AttributeType.BOOL: bool,
     AttributeType.BINARY: bytes,
     AttributeType.TIMESTAMP: datetime.datetime,
+    AttributeType.LARGE_BINARY: largebinary,

Review Comment:
   I think in line 65, I am already mapping `LARGE_BINARY` attribute to arrow string. The line you are referring to is mapping `LARGE_BINARY` attribute convert it back to Python object in the UDF. Do you also want the Python UDF to read a string?



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for Large Binary [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2616022205


##########
amber/src/main/python/core/models/schema/arrow_schema_utils.py:
##########
@@ -0,0 +1,106 @@
+# 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.
+
+"""
+Utilities for converting between Arrow schemas and Amber schemas,
+handling LARGE_BINARY metadata preservation.
+"""
+
+import pyarrow as pa
+from typing import Mapping
+
+from core.models.schema.attribute_type import (
+    AttributeType,
+    FROM_ARROW_MAPPING,
+    TO_ARROW_MAPPING,
+)
+
+# Metadata key used to mark LARGE_BINARY fields in Arrow schemas
+TEXERA_TYPE_METADATA_KEY = b"texera_type"
+LARGE_BINARY_METADATA_VALUE = b"LARGE_BINARY"
+
+
+def detect_attribute_type_from_arrow_field(field: pa.Field) -> AttributeType:
+    """
+    Detects the AttributeType from an Arrow field, checking metadata for LARGE_BINARY.
+
+    :param field: PyArrow field that may contain metadata
+    :return: The detected AttributeType
+    """
+    # Check metadata for LARGE_BINARY type
+    # (can be stored by either Scala ArrowUtils or Python)
+    is_large_binary = (
+        field.metadata
+        and field.metadata.get(TEXERA_TYPE_METADATA_KEY) == LARGE_BINARY_METADATA_VALUE
+    )
+
+    if is_large_binary:
+        return AttributeType.LARGE_BINARY
+    else:
+        return FROM_ARROW_MAPPING[field.type.id]
+
+
+def create_arrow_field_with_metadata(
+    attr_name: str, attr_type: AttributeType
+) -> pa.Field:
+    """
+    Creates a PyArrow field with appropriate metadata for the given AttributeType.
+
+    :param attr_name: Name of the attribute
+    :param attr_type: The AttributeType
+    :return: PyArrow field with metadata if needed
+    """
+    metadata = (
+        {TEXERA_TYPE_METADATA_KEY: LARGE_BINARY_METADATA_VALUE}
+        if attr_type == AttributeType.LARGE_BINARY
+        else None
+    )
+
+    return pa.field(attr_name, TO_ARROW_MAPPING[attr_type], metadata=metadata)

Review Comment:
   We have a scala version of `AttributeTypeUtils` but we don't have a python version. I created a new `attribute_type_utils.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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for Large Binary [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on PR #4100:
URL: https://github.com/apache/texera/pull/4100#issuecomment-3655174923

   Per discussion with @chenlica, we decided to merge this PR with a single reviewer approval since it blocks a specific use case we want to support. We're comfortable to merge it, and we'll follow up with another PR to add R UDF support. That PR will also validate the changes introduced here. Any issues we find will be addressed in a separate follow-up PR.


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for Large Binary [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on PR #4100:
URL: https://github.com/apache/texera/pull/4100#issuecomment-3633995851

   @Yicong-Huang @bobbai00 #4111 has been merged and I updated this PR to use the new name `LargeBinary`. It’s ready for you to continue the review. Thanks!


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for BigObject [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2578680660


##########
amber/src/main/python/core/models/schema/schema.py:
##########
@@ -81,26 +81,47 @@ def _from_raw_schema(self, raw_schema: Mapping[str, str]) -> None:
     def _from_arrow_schema(self, arrow_schema: pa.Schema) -> None:
         """
         Resets the Schema by converting a pyarrow.Schema.
+        Checks field metadata to detect BIG_OBJECT types.
         :param arrow_schema: a pyarrow.Schema.
         :return:
         """
         self._name_type_mapping = OrderedDict()
         for attr_name in arrow_schema.names:
-            arrow_type = arrow_schema.field(attr_name).type  # type: ignore
-            attr_type = FROM_ARROW_MAPPING[arrow_type.id]
+            field = arrow_schema.field(attr_name)
+
+            # Check metadata for BIG_OBJECT type
+            # (can be stored by either Scala ArrowUtils or Python)
+            is_big_object = (
+                field.metadata and field.metadata.get(b"texera_type") == b"BIG_OBJECT"
+            )
+
+            attr_type = (
+                AttributeType.BIG_OBJECT
+                if is_big_object
+                else FROM_ARROW_MAPPING[field.type.id]
+            )
+
             self.add(attr_name, attr_type)
 
     def as_arrow_schema(self) -> pa.Schema:
         """
         Creates a new pyarrow.Schema according to the current Schema.
+        Includes metadata for BIG_OBJECT types to preserve type information.
         :return: pyarrow.Schema
         """
-        return pa.schema(
-            [
-                pa.field(attr_name, TO_ARROW_MAPPING[attr_type])
-                for attr_name, attr_type in self._name_type_mapping.items()
-            ]
-        )
+        fields = [
+            pa.field(
+                attr_name,
+                TO_ARROW_MAPPING[attr_type],
+                metadata=(
+                    {b"texera_type": b"BIG_OBJECT"}
+                    if attr_type == AttributeType.BIG_OBJECT
+                    else None
+                ),
+            )
+            for attr_name, attr_type in self._name_type_mapping.items()
+        ]
+        return pa.schema(fields)

Review Comment:
   Can you use existing arrow type `large_binary`, instead of creating our own new type? 
   https://arrow.apache.org/docs/python/generated/pyarrow.large_binary.html



##########
amber/src/main/python/core/models/schema/schema.py:
##########
@@ -81,26 +81,47 @@ def _from_raw_schema(self, raw_schema: Mapping[str, str]) -> None:
     def _from_arrow_schema(self, arrow_schema: pa.Schema) -> None:
         """
         Resets the Schema by converting a pyarrow.Schema.
+        Checks field metadata to detect BIG_OBJECT types.
         :param arrow_schema: a pyarrow.Schema.
         :return:
         """
         self._name_type_mapping = OrderedDict()
         for attr_name in arrow_schema.names:
-            arrow_type = arrow_schema.field(attr_name).type  # type: ignore
-            attr_type = FROM_ARROW_MAPPING[arrow_type.id]
+            field = arrow_schema.field(attr_name)
+
+            # Check metadata for BIG_OBJECT type
+            # (can be stored by either Scala ArrowUtils or Python)
+            is_big_object = (
+                field.metadata and field.metadata.get(b"texera_type") == b"BIG_OBJECT"
+            )
+
+            attr_type = (
+                AttributeType.BIG_OBJECT
+                if is_big_object
+                else FROM_ARROW_MAPPING[field.type.id]
+            )
+

Review Comment:
   The implementation is too intrusive to `schema.py`. Please move it out so schema does not care if a field should be handled specially. 



##########
amber/src/main/python/core/models/schema/big_object.py:
##########
@@ -0,0 +1,98 @@
+# 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.
+
+"""
+BigObject represents a reference to a large object stored externally (e.g., S3).
+This is a schema type class used throughout the system for handling
+BIG_OBJECT attribute types.
+"""
+
+from typing import Optional
+from urllib.parse import urlparse
+
+
+class BigObject:

Review Comment:
   I don't like this name in codebase. `BigObject` is more like a temporary project name. Please consider to use `LargeBinary` as a type to align with other systems. 



##########
amber/src/main/python/core/models/schema/attribute_type.py:
##########
@@ -92,4 +97,5 @@ class AttributeType(Enum):
     bool: AttributeType.BOOL,
     bytes: AttributeType.BINARY,
     datetime.datetime: AttributeType.TIMESTAMP,
+    BigObject: AttributeType.BIG_OBJECT,

Review Comment:
   please consider change name. also use lowercase only to align with other types.



##########
amber/src/main/python/core/architecture/packaging/output_manager.py:
##########
@@ -259,10 +259,21 @@ def emit_state(
         )
 
     def tuple_to_frame(self, tuples: typing.List[Tuple]) -> DataFrame:
+        from core.models.schema.big_object import BigObject
+
         return DataFrame(
             frame=Table.from_pydict(
                 {
-                    name: [t[name] for t in tuples]
+                    name: [
+                        (
+                            # Convert BigObject objects to URI strings
+                            # for Arrow serialization
+                            t[name].uri
+                            if isinstance(t[name], BigObject)
+                            else t[name]
+                        )

Review Comment:
   Very intrusive. it should be handled in schema, not `tuple_to_frame`. 



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for BigObject [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2579621464


##########
amber/src/main/python/core/models/schema/schema.py:
##########
@@ -81,26 +81,47 @@ def _from_raw_schema(self, raw_schema: Mapping[str, str]) -> None:
     def _from_arrow_schema(self, arrow_schema: pa.Schema) -> None:
         """
         Resets the Schema by converting a pyarrow.Schema.
+        Checks field metadata to detect BIG_OBJECT types.
         :param arrow_schema: a pyarrow.Schema.
         :return:
         """
         self._name_type_mapping = OrderedDict()
         for attr_name in arrow_schema.names:
-            arrow_type = arrow_schema.field(attr_name).type  # type: ignore
-            attr_type = FROM_ARROW_MAPPING[arrow_type.id]
+            field = arrow_schema.field(attr_name)
+
+            # Check metadata for BIG_OBJECT type
+            # (can be stored by either Scala ArrowUtils or Python)
+            is_big_object = (
+                field.metadata and field.metadata.get(b"texera_type") == b"BIG_OBJECT"
+            )
+
+            attr_type = (
+                AttributeType.BIG_OBJECT
+                if is_big_object
+                else FROM_ARROW_MAPPING[field.type.id]
+            )
+
             self.add(attr_name, attr_type)
 
     def as_arrow_schema(self) -> pa.Schema:
         """
         Creates a new pyarrow.Schema according to the current Schema.
+        Includes metadata for BIG_OBJECT types to preserve type information.
         :return: pyarrow.Schema
         """
-        return pa.schema(
-            [
-                pa.field(attr_name, TO_ARROW_MAPPING[attr_type])
-                for attr_name, attr_type in self._name_type_mapping.items()
-            ]
-        )
+        fields = [
+            pa.field(
+                attr_name,
+                TO_ARROW_MAPPING[attr_type],
+                metadata=(
+                    {b"texera_type": b"BIG_OBJECT"}
+                    if attr_type == AttributeType.BIG_OBJECT
+                    else None
+                ),
+            )
+            for attr_name, attr_type in self._name_type_mapping.items()
+        ]
+        return pa.schema(fields)

Review Comment:
   a second thought on this. if we are only using this field to  store a pointer/metadata, then underlying data type may  be not idea to be `large_binary`, since that is designed for data > 2GB. So I take back this suggestion.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Python Support for BigObject [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on code in PR #4100:
URL: https://github.com/apache/texera/pull/4100#discussion_r2583553928


##########
amber/src/main/python/core/models/schema/big_object.py:
##########
@@ -0,0 +1,98 @@
+# 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.
+
+"""
+BigObject represents a reference to a large object stored externally (e.g., S3).
+This is a schema type class used throughout the system for handling
+BIG_OBJECT attribute types.
+"""
+
+from typing import Optional
+from urllib.parse import urlparse
+
+
+class BigObject:

Review Comment:
   Updated. I will create a separate PR to rename `BigObject` to `LargeBinary` in the Java side.



##########
amber/src/main/python/core/models/schema/schema.py:
##########
@@ -81,26 +81,47 @@ def _from_raw_schema(self, raw_schema: Mapping[str, str]) -> None:
     def _from_arrow_schema(self, arrow_schema: pa.Schema) -> None:
         """
         Resets the Schema by converting a pyarrow.Schema.
+        Checks field metadata to detect BIG_OBJECT types.
         :param arrow_schema: a pyarrow.Schema.
         :return:
         """
         self._name_type_mapping = OrderedDict()
         for attr_name in arrow_schema.names:
-            arrow_type = arrow_schema.field(attr_name).type  # type: ignore
-            attr_type = FROM_ARROW_MAPPING[arrow_type.id]
+            field = arrow_schema.field(attr_name)
+
+            # Check metadata for BIG_OBJECT type
+            # (can be stored by either Scala ArrowUtils or Python)
+            is_big_object = (
+                field.metadata and field.metadata.get(b"texera_type") == b"BIG_OBJECT"
+            )
+
+            attr_type = (
+                AttributeType.BIG_OBJECT
+                if is_big_object
+                else FROM_ARROW_MAPPING[field.type.id]
+            )
+

Review Comment:
   Updated.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org