Skip to content

Allow parquet import to be None - #36202

Merged
damccorm merged 1 commit into
masterfrom
users/damccorm/importIssues
Sep 19, 2025
Merged

Allow parquet import to be None#36202
damccorm merged 1 commit into
masterfrom
users/damccorm/importIssues

Conversation

@damccorm

Copy link
Copy Markdown
Contributor

Installing pyarrow can be painful, especially on macs with M1s (I've run into this), and it isn't necessary for most python development. At the same time, doing anything involving conftest.py causes parquetio.py to be loaded[1], and this currently fails when pyarrow is not installed.

This is because even though pyarrow imports are guarded behind a try/except block, we assume that pa is defined later in the file when we enforce the pa.Table type. This works around that issue by creating a variable that holds pa.Table when it is defined, and None otherwise. Invoking these functions will still fail, but now you can load the file without issues.

[1] The dependency path that errors is:

ImportError while loading conftest '/Users/dannymccormick/beam/sdks/python/conftest.py'.
conftest.py:26: in <module>
    from apache_beam.options import pipeline_options
apache_beam/__init__.py:88: in <module>
    from apache_beam import io
apache_beam/io/__init__.py:28: in <module>
    from apache_beam.io.parquetio import *
apache_beam/io/parquetio.py:174: in <module>
    class _ArrowTableToBeamRows(DoFn):
apache_beam/io/parquetio.py:179: in _ArrowTableToBeamRows
    def process(self, element) -> Iterator[pa.Table]:
E   AttributeError: 'NoneType' object has no attribute 'Table'

Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @damccorm, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a common issue where the apache_beam.io.parquetio module would fail to load if the pyarrow library was not installed, even when Parquet-related functionalities were not being used. By introducing a conditional assignment for pyarrow.Table and using this new variable for type hints, the module can now be imported without errors, significantly improving the developer experience for users who do not require pyarrow.

Highlights

  • Optional PyArrow Dependency: Modified the parquetio.py module to gracefully handle cases where pyarrow is not installed, preventing import errors.
  • Conditional Type Hinting: Introduced a new variable, paTable, to conditionally store pyarrow.Table or None, which is then used for type hints throughout the module.
  • Improved Module Loading: Ensures that apache_beam.io.parquetio can be loaded successfully even without pyarrow installed, resolving AttributeError issues during module import for users who do not require Parquet functionalities.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions

Copy link
Copy Markdown
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@Abacn Abacn 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.

Looks like it is intended to be optional but due to typehint this was not effective

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @liferoad for label python.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@damccorm
damccorm merged commit 580dba8 into master Sep 19, 2025
103 of 105 checks passed
@damccorm
damccorm deleted the users/damccorm/importIssues branch September 19, 2025 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants