Skip to content

[SPARK-51883][DOCS][PYTHON] Python Data Source user guide for filter pushdown #50684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

wengh
Copy link
Contributor

@wengh wengh commented Apr 23, 2025

What changes were proposed in this pull request?

Update python_data_source.rst to add filter pushdown docs.

Why are the changes needed?

Feature was added but documentation was still missing.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Verified locally

image
image
image
image

Was this patch authored or co-authored using generative AI tooling?

Yes. Initial draft was generated using AI then manually edited.

Generated-by: GitHub Copilot with Claude 3.7 Sonnet

@wengh wengh changed the title [SPARK-51883][DOCS][PYTHON] Python Data Source docs for filter pushdown [SPARK-51883][DOCS][PYTHON] Python Data Source user guide for filter pushdown Apr 23, 2025
Copy link
Contributor

@allisonwang-db allisonwang-db left a comment

Choose a reason for hiding this comment

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

Thanks for adding the docs!


Other methods such as DataSource.schema() and DataSourceStreamReader.latestOffset() can be stateful. Changes to the object state made in these methods are visible to future invocations.

Refer to the documentation of each method for more details.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also link to the documentation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the method documentations don't actually mention whether it can change state :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

most methods can change state so I guess we can just list the exceptions here

Copy link
Contributor Author

@wengh wengh May 2, 2025

Choose a reason for hiding this comment

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

The following methods should not mutate internal state. Changes to the object state made in these methods are not guaranteed to be visible or invisible to future calls.

  • DataSourceReader.partitions()
  • DataSourceReader.read()
  • DataSourceStreamReader.read()
  • SimpleDataSourceStreamReader.readBetweenOffsets()
  • All writer methods

All other methods such as DataSource.schema() and DataSourceStreamReader.latestOffset() can be stateful. Changes to the object state made in these methods are visible to future calls.


from pyspark.sql.datasource import EqualTo, Filter, GreaterThan, LessThan

def pushFilters(self, filters: List[Filter]) -> Iterable[Filter]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a complete example here so that people can copy paste and try it out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to an example source that returns prime numbers sequentially

@wengh wengh force-pushed the pyds-docs-pushdown branch from 264ccfc to 13df8b4 Compare May 1, 2025 01:03
@wengh wengh requested a review from allisonwang-db May 2, 2025 03:59
Copy link
Contributor

@allisonwang-db allisonwang-db left a comment

Choose a reason for hiding this comment

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

@wengh this looks good! Could you also attach a screenshot for the updated user guide to the PR description? Thanks!

@wengh
Copy link
Contributor Author

wengh commented May 8, 2025

@wengh this looks good! Could you also attach a screenshot for the updated user guide to the PR description? Thanks!

done 🤗

@xinrong-meng
Copy link
Member

Would you rebase master changes? The CI test failure should have been fixed

@wengh wengh force-pushed the pyds-docs-pushdown branch from 674db09 to 1e94d4b Compare May 15, 2025 00: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.

3 participants