Skip to content

fix(type-inference): map Any to pa.null() for empty container handling (ENG-389) - #155

Merged
eywalker merged 8 commits into
mainfrom
eywalker/eng-389-type-inference-empty-containers-infer-as-dictany-any-listany
Jun 9, 2026
Merged

fix(type-inference): map Any to pa.null() for empty container handling (ENG-389)#155
eywalker merged 8 commits into
mainfrom
eywalker/eng-389-type-inference-empty-containers-infer-as-dictany-any-listany

Conversation

@kurodo3

@kurodo3 kurodo3 Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • list[Any] and dict[Any, Any] (inferred from empty containers) no longer raise ValueError: Unsupported Python type: typing.Any when passed to python_type_to_arrow_type
  • Added Any: pa.null() to _PYTHON_TO_ARROW_MAP in UniversalTypeConverter (forward path)
  • Added explicit pa.types.is_null → Any check in _convert_arrow_to_python (reverse path), suppressing a spurious fallback warning
  • Removed now-unreachable Any-specific hint from the error branch in _convert_python_to_arrow
  • Added 8 converter/round-trip tests and 2 inference documentation tests
  • Logged resolved entry UC1 in DESIGN_ISSUES.md

Test plan

  • test_any_to_arrow_typepython_type_to_arrow_type(Any) == pa.null()
  • test_list_any_to_arrow_typelist[Any] maps to pa.large_list(pa.null())
  • test_dict_any_any_to_arrow_typedict[Any, Any] maps to expected struct
  • test_null_arrow_to_any_python_typepa.null() maps back to Any
  • test_list_any_round_trip and test_dict_any_any_round_trip — full round trips
  • test_empty_container_inference_to_arrow_no_error — end-to-end, no exception
  • test_pyarrow_empty_list_with_null_type — PyArrow accepts empty lists for null-typed columns
  • test_infer_empty_list_schema and test_infer_empty_dict_schema — inference already correct
  • Full test suite: 3495 passed, 56 skipped, 0 failures

Closes ENG-389

🤖 Generated with Claude Code

kurodo3 Bot and others added 7 commits June 8, 2026 18:45
Empty containers ([] / {}) infer element type as typing.Any, which previously
raised ValueError in python_type_to_arrow_type. Now Any maps to pa.null() (Arrow's
canonical unknown-type), and pa.null() maps back to Any on the reverse path.

Closes ENG-389
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes ENG-389 by making typing.Any (commonly produced by empty-container schema inference like list[Any] / dict[Any, Any]) convertible to/from PyArrow types in UniversalTypeConverter, using pa.null() as the Arrow representation for “unknown element type”.

Changes:

  • Map typing.Anypa.null() in the Python→Arrow type map to prevent Unsupported Python type: typing.Any for inferred empty containers.
  • Map pa.null()typing.Any in the Arrow→Python conversion path to ensure clean round-trips and avoid spurious fallback warnings.
  • Add targeted tests covering conversion, round-trips, and empty-container inference behavior; document the resolved design issue.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/orcapod/semantic_types/universal_converter.py Adds Any ↔ pa.null() handling and removes now-unreachable Any-specific error hint.
tests/test_semantic_types/test_universal_converter.py Adds converter + round-trip tests ensuring Any/empty-container inference no longer raises.
tests/test_semantic_types/test_pydata_utils.py Adds tests documenting that empty containers infer as list[Any] / dict[Any, Any].
DESIGN_ISSUES.md Records ENG-389 (UC1) as resolved with the implemented approach.
superpowers/specs/2026-06-08-eng-389-empty-container-type-inference.md Adds an approved spec describing the problem and chosen solution.
superpowers/plans/2026-06-08-eng-389-empty-container-type-inference.md Adds an implementation plan reflecting the changes and verification steps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kurodo3

kurodo3 Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Review round response

Copilot reviewed all 6 changed files and generated no comments — no actionable issues were raised. No code changes are required for this review round.

The implementation is complete as submitted:

  • Any: pa.null() mapping added to _PYTHON_TO_ARROW_MAP (forward path)
  • pa.types.is_null → Any check added to _convert_arrow_to_python (reverse path)
  • Dead Any-specific error hint removed from _convert_python_to_arrow
  • 10 new tests (8 converter/round-trip + 2 inference documentation), all passing
  • Full suite: 3495 passed, 56 skipped, 0 failures

@eywalker
eywalker merged commit 43fe2c7 into main Jun 9, 2026
12 checks passed
@eywalker
eywalker deleted the eywalker/eng-389-type-inference-empty-containers-infer-as-dictany-any-listany branch June 9, 2026 23:25
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.

2 participants