Skip to content

[SPARK-58087][PYTHON][DOCS] Document accepted input and return types in the PySpark functions API - #57185

Closed
HyukjinKwon wants to merge 7 commits into
apache:masterfrom
HyukjinKwon:split-func-types-python
Closed

[SPARK-58087][PYTHON][DOCS] Document accepted input and return types in the PySpark functions API#57185
HyukjinKwon wants to merge 7 commits into
apache:masterfrom
HyukjinKwon:split-func-types-python

Conversation

@HyukjinKwon

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

This documents, for every built-in function in the PySpark functions API (builtin.py), the
accepted input type of each argument (Parameters) and the return type of each function
(Returns), using the numeric umbrella where numeric subtypes cast in and timestamp for
TIMESTAMP_NTZ in type phrases.

Subtask of SPARK-57999, split out from #57079 for reviewability. This PR covers only
the PySpark builtin.py surface.

Why are the changes needed?

The PySpark functions docstrings previously had no per-argument type information for most
functions. This fills that gap.

Does this PR introduce any user-facing change?

Yes, documentation only. No behavioral or API change.

How was this patch tested?

Python lint (flake8 + black) and the docstring doctests pass. Types were derived from and verified
against the analyzer's behavior and each expression's inputTypes / dataType.

Co-authored-by: Isaac

Comment threadpython/pyspark/sql/functions/builtin.py Outdated
Comment threadpython/pyspark/sql/functions/builtin.py Outdated
Comment threadpython/pyspark/sql/functions/builtin.py Outdated
Comment threadpython/pyspark/sql/functions/builtin.py Outdated
Comment threadpython/pyspark/sql/functions/builtin.py Outdated
@HyukjinKwon

Copy link
Copy Markdown
MemberAuthor

Thank you @dongjoon-hyun for review. Let me try to take a look throughoutly.

@HyukjinKwon
HyukjinKwon marked this pull request as draft July 12, 2026 22:08
@HyukjinKwon
HyukjinKwonforce-pushed the split-func-types-python branch 2 times, most recently from 241f910 to d9b102bCompareJuly 13, 2026 00:01
@HyukjinKwon
HyukjinKwon marked this pull request as ready for review July 13, 2026 06:26
Comment threadpython/pyspark/sql/functions/builtin.py Outdated

@dongjoon-hyundongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For kll_sketch_get_quantile_bigint/_float/_double, kll_sketch_get_rank_*, the return type is sometimes array.

Comment threadpython/pyspark/sql/functions/builtin.py
Comment threadpython/pyspark/sql/functions/builtin.py Outdated

@cloud-fancloud-fan 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.

1 blocking, 0 non-blocking, 0 nits.
The documentation sweep is broadly consistent, but one family of timestamp constructors still has undocumented argument types.

Correctness (1)

  • python/pyspark/sql/functions/builtin.py:26638: Document the remaining timezone/date/time argument types in the timestamp constructor family -- see inline

Verification

Compared the timestamp constructor docstrings with MakeTimestamp.inputTypes and MakeTimestampFromDateTime.inputTypes in Catalyst. These require string timezone, date, and time inputs for the parameters whose type phrases are still absent.

Comment threadpython/pyspark/sql/functions/builtin.py
…in the PySpark functions API
### What changes were proposed in this pull request?
This documents, for every built-in function in the PySpark `functions` API (`builtin.py`), the
accepted input type of each argument (`Parameters`) and the return type of each function
(`Returns`), using the numeric umbrella where numeric subtypes cast in and `timestamp` for
TIMESTAMP_NTZ in type phrases.
Subtask of SPARK-57999, split out from apache#57079 for reviewability. This PR covers only
the PySpark `builtin.py` surface.
### Why are the changes needed?
The PySpark `functions` docstrings previously had no per-argument type information for most
functions. This fills that gap.
### Does this PR introduce _any_ user-facing change?
Yes, documentation only. No behavioral or API change.
### How was this patch tested?
Python lint (flake8 + black) and the docstring doctests pass. Types were derived from and verified
against the analyzer's behavior and each expression's `inputTypes` / `dataType`.
Co-authored-by: Isaac
… to_char constant note, and broaden date extractor input types
Co-authored-by: Isaac
…uctors
Add the accepted-type phrases for the timezone (string), date, and time
arguments across the make_timestamp / try_make_timestamp family, matching
the Catalyst MakeTimestamp and MakeTimestampFromDateTime inputTypes contracts.
Co-authored-by: Isaac
Match the SQL and Scala function reference by noting that the variadic
concat_ws argument accepts a string or an array of strings.
Co-authored-by: Isaac
@HyukjinKwon
HyukjinKwonforce-pushed the split-func-types-python branch from 423fd0b to 1c55308CompareJuly 20, 2026 22:49
Audit surfaced many functions where some arguments (or the return) carried an
accepted-type phrase but sibling value arguments did not. Document the missing
arguments and returns to match the per-argument coverage promised by the PR,
keeping the accepted types consistent with the SQL and Scala function reference.
Co-authored-by: Isaac
Add the accepted-type phrase to the Returns section of stddev and its std
alias, matching the sibling aggregate functions.
Co-authored-by: Isaac
Bring the from_json/to_json/schema_of_json, variant_*, from_csv/to_csv/
schema_of_csv, and from_xml/to_xml/schema_of_xml function families into the
accepted-type documentation convention, documenting both their arguments and
their return values to match the Scala functions API.
Co-authored-by: Isaac
HyukjinKwon added a commit that referenced this pull request Jul 21, 2026
…n the PySpark functions API
### What changes were proposed in this pull request?
This documents, for every built-in function in the PySpark `functions` API (`builtin.py`), the
accepted input type of each argument (`Parameters`) and the return type of each function
(`Returns`), using the numeric umbrella where numeric subtypes cast in and `timestamp` for
TIMESTAMP_NTZ in type phrases.
Subtask of SPARK-57999, split out from #57079 for reviewability. This PR covers only
the PySpark `builtin.py` surface.
### Why are the changes needed?
The PySpark `functions` docstrings previously had no per-argument type information for most
functions. This fills that gap.
### Does this PR introduce _any_ user-facing change?
Yes, documentation only. No behavioral or API change.
### How was this patch tested?
Python lint (flake8 + black) and the docstring doctests pass. Types were derived from and verified
against the analyzer's behavior and each expression's `inputTypes` / `dataType`.
Co-authored-by: Isaac
Closes#57185 from HyukjinKwon/split-func-types-python.
Authored-by: Hyukjin Kwon <gurwls223@apache.org>
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
(cherry picked from commit ddd66fa)
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
@HyukjinKwon

Copy link
Copy Markdown
MemberAuthor

Merge Summary:

Posted by merge_spark_pr.py

Sign up for freeto 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.

4 participants

@HyukjinKwon@cloud-fan@zhengruifeng@dongjoon-hyun