Skip to content

get nested data handler working - #17

Merged
andyorange merged 15 commits into
mainfrom
ab_nested_initial
Nov 17, 2025
Merged

get nested data handler working#17
andyorange merged 15 commits into
mainfrom
ab_nested_initial

Conversation

@andyorange

Copy link
Copy Markdown
Collaborator

No description provided.

@andyorange
andyorange requested a review from tswast September 29, 2025 14:26
@tswast

tswast commented Sep 29, 2025

Copy link
Copy Markdown
Collaborator

TODO: @tswast to investigate unit test errors:

leanframe/core/series.py:130: in to_pandas
    return self._data.to_pyarrow().to_pandas(
           ^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/ibis/expr/types/generic.py:1623: in to_pyarrow
    return super().to_pyarrow(params=params, limit=limit, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.12/site-packages/ibis/expr/types/core.py:605: in to_pyarrow
    return self._find_backend(use_default=True).to_pyarrow(
.venv/lib/python3.12/site-packages/ibis/backends/duckdb/__init__.py:1380: in to_pyarrow
    return expr.__pyarrow_result__(table, data_mapper=DuckDBPyArrowData)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = r0 := DatabaseTable: temp.main.lf_echjebykdb
  a int64
  b int64

Add(a, b): r0.a + r0.b
table = <pyarrow.lib.RecordBatchReader object at 0x7fda5b53fbd0>

    def __pyarrow_result__(
        self,
        table: pa.Table,
        *,
        schema: sch.Schema | None = None,
        data_mapper: type[PyArrowData] | None = None,
    ) -> pa.Array | pa.ChunkedArray:
        if data_mapper is None:
            from ibis.formats.pyarrow import PyArrowData as data_mapper
    
        return data_mapper.convert_column(
>           table[0], self.type() if schema is None else schema.types[0]
            ^^^^^^^^
        )
E       TypeError: 'pyarrow.lib.RecordBatchReader' object is not subscriptable

@andyorange

andyorange commented Sep 30, 2025 via email

Copy link
Copy Markdown
Collaborator Author

@tswast

tswast commented Oct 23, 2025

Copy link
Copy Markdown
Collaborator

It's strange that the test are passing just fine locally.

uv run pytest tests
===================================================== test session starts =====================================================
platform linux -- Python 3.13.5, pytest-8.4.2, pluggy-1.6.0
rootdir: /home/swast/src/github.com/tswast/leanframe
configfile: pytest.ini
collected 56 items                                                                                                            

tests/unit/nested_data/test_dynamic_access.py ..                                                                        [  3%]
tests/unit/nested_data/test_dynamic_nested_handler.py ......                                                            [ 14%]
tests/unit/nested_data/test_nested_column_access.py ..                                                                  [ 17%]
tests/unit/nested_data/test_nested_handler.py ....                                                                      [ 25%]
tests/unit/nested_data/test_pure_leanframe_nested.py ...                                                                [ 30%]
tests/unit/session/test_read_sql_table.py .                                                                             [ 32%]
tests/unit/test_frame.py .......                                                                                        [ 44%]
tests/unit/test_series.py ...............................                                                               [100%]

===================================================== 56 passed in 1.86s ======================================================

Maybe a PyArrow / ibis versioning issue with Python 3.11? Python 3.11 is still supported by the PyData community according to https://numpy.org/neps/nep-0029-deprecation_policy.html#support-table though, so I'm not sure why that'd be.

@tswast

tswast commented Oct 23, 2025

Copy link
Copy Markdown
Collaborator

I upgraded ibis-framework and got a successful run. I'm still not sure what the difference was between my local setup and GitHub Actions before this update.

Comment thread demos/demo_dynamic_nested_handler.py Outdated
Comment thread leanframe/__init__.py Outdated
"""LeanFrame provides a DataFrame API for BigQuery."""

from leanframe.core.session import Session
from leanframe.core.nested_handler import DynamicNestedHandler

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be in the top-level leanframe package? Maybe it's something we can return from Session or DataFrame if needed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check how to integrate it in either class, good point.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I place the DynamicNestedHandler in the same file where DataFrame is defined (frame.py)? Reason: I need DataFrame at several points and having both classes defined in frame (we anyway do not want to differ between frames or nested frames....) I can avoid circular imports... Please let me know asap! Thx

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging the two files makes sense to me

Comment thread leanframe/core/nested_handler.py Outdated
from .frame import DataFrame


# TODO: replace prints by logging, ask TIM about logger usage

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've generally done logger = logging.getLogger(__name__)

https://github.com/googleapis/python-bigquery/blob/6065e14c448cb430189982dd70025fa0575777ca/google/cloud/bigquery/opentelemetry_tracing.py#L19

But, this makes filtering logs a bit more difficult. See:

https://github.com/googleapis/python-bigquery/blob/6065e14c448cb430189982dd70025fa0575777ca/TROUBLESHOOTING.md?plain=1#L23-L25

Maybe we create a central logger object for all of leanframe? I can't see a need for folks to filter logs on a per-module basis.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global logger sounds fine, will you create one?

Comment thread demos/utils/create_data.py Outdated
Comment thread tests/unit/nested_data/test_pure_leanframe_nested.py Outdated
@andyorange
andyorange merged commit 3a94b94 into main Nov 17, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants