Skip to content

Conversation

Yicong-Huang
Copy link

@Yicong-Huang Yicong-Huang commented Sep 12, 2025

What changes were proposed in this pull request?

Add support for make_timestamp_ntz(date=..., time=...) overload in PySpark. This implements SPARK-53547 to provide an alternative way to create local date-time values using separate date and time columns.

Why are the changes needed?

We need to align with Scala side API to make it flexible for users to create a timestamp with date and time.

Does this PR introduce any user-facing change?

New PySpark function.

How was this patch tested?

Added unit tests.

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

Tests Generated-by: Cursor

Add support for make_timestamp_ntz(date=..., time=...) overload in PySpark.
This implements SPARK-51162 to provide an alternative way to create local
date-time values using separate date and time columns.
@Yicong-Huang Yicong-Huang changed the title [SPARK-51162] Add make_timestamp_ntz overload with date/time parameters [SPARK-51162] [Python] Add make_timestamp_ntz overload with date/time parameters Sep 12, 2025
@@ -25155,10 +25175,14 @@ def make_timestamp_ntz(
mins : :class:`~pyspark.sql.Column` or column name
The minute-of-hour to represent, from 0 to 59
secs : :class:`~pyspark.sql.Column` or column name
The second-of-minute and its micro-fraction to represent, from 0 to 60.
The second-of-minute and its micro-fraction to represent, from 0 to 60..
Copy link
Member

Choose a reason for hiding this comment

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

nit: is that intentional?

) -> Column:
"""
Create local date-time from years, months, days, hours, mins, secs fields.
Create local date-time from years, months, days, hours, mins, secs fields, or from date and time fields.
If the configuration `spark.sql.ansi.enabled` is false, the function returns NULL
on invalid inputs. Otherwise, it will throw an error instead.

Copy link
Member

Choose a reason for hiding this comment

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

Shall we add a .. versionchanged::?

Copy link
Author

Choose a reason for hiding this comment

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

Sure! Which version should I use? (4.1?)

@xinrong-meng
Copy link
Member

PR titles typically follow [SPARK-xxxxx][PYTHON]..

…ror handling

- Add WRONG_NUM_ARGS error class to error-conditions.json
- Update make_timestamp_ntz in builtin.py to use PySparkValueError with WRONG_NUM_ARGS
- Update make_timestamp_ntz in connect/builtin.py to use PySparkValueError with WRONG_NUM_ARGS
- Update test cases to expect PySparkValueError with proper error class and message parameters
@Yicong-Huang Yicong-Huang changed the title [SPARK-51162] [Python] Add make_timestamp_ntz overload with date/time parameters [SPARK-53547] [Python] Add make_timestamp_ntz overload with date/time parameters Sep 13, 2025
- Change error message from 'either all 6 components or both date and time'
  to '(years, months, days, hours, mins, secs) or (date, time)'
- Update consistently across builtin.py, connect/builtin.py, and test_functions.py
- Provides clearer guidance to users about expected parameter names
@Yicong-Huang
Copy link
Author

PR titles typically follow [SPARK-xxxxx][PYTHON]..

Fixed!

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