zhengruifeng commented on code in PR #51831:
URL: https://github.com/apache/spark/pull/51831#discussion_r2374799530


##########
python/pyspark/sql/connect/functions/builtin.py:
##########
@@ -4043,9 +4126,64 @@ def try_make_timestamp_ntz(
     mins: "ColumnOrName",
     secs: "ColumnOrName",
 ) -> Column:
-    return _invoke_function_over_columns(
-        "try_make_timestamp_ntz", years, months, days, hours, mins, secs
-    )
+    ...
+
+
+@overload
+def try_make_timestamp_ntz(
+    *,
+    date: "ColumnOrName",
+    time: "ColumnOrName",
+) -> Column:
+    ...
+
+
+def try_make_timestamp_ntz(
+    years: Optional["ColumnOrName"] = None,
+    months: Optional["ColumnOrName"] = None,
+    days: Optional["ColumnOrName"] = None,
+    hours: Optional["ColumnOrName"] = None,
+    mins: Optional["ColumnOrName"] = None,
+    secs: Optional["ColumnOrName"] = None,
+    *,
+    date: Optional["ColumnOrName"] = None,
+    time: Optional["ColumnOrName"] = None,
+) -> Column:
+    # 6 positional/keyword arguments: years, months, days, hours, mins, secs
+    if (
+        all(kw is not None for kw in [years, months, days, hours, mins, secs])
+        and date is None
+        and time is None
+    ):
+        from typing import cast
+
+        return _invoke_function_over_columns(
+            "try_make_timestamp_ntz",
+            cast("ColumnOrName", years),
+            cast("ColumnOrName", months),
+            cast("ColumnOrName", days),
+            cast("ColumnOrName", hours),
+            cast("ColumnOrName", mins),
+            cast("ColumnOrName", secs),
+        )
+
+    # 2 keyword arguments: date, time
+    elif (
+        all(kw is None for kw in [years, months, days, hours, mins, secs])
+        and date is not None
+        and time is not None
+    ):
+        from typing import cast
+
+        return _invoke_function_over_columns(
+            "try_make_timestamp_ntz", cast("ColumnOrName", date), 
cast("ColumnOrName", time)
+        )
+
+    # Invalid argument combinations - return NULL for try_ functions
+    # For try_ functions, invalid inputs should return NULL
+    from pyspark.sql.connect.functions import lit
+
+    return lit(None)

Review Comment:
   I think we should not allow this



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to