kosiew opened a new pull request, #1587:
URL: https://github.com/apache/datafusion-python/pull/1587

   ## Which issue does this PR close?
   
   * Part of #1496
   
   ## Rationale for this change
   
   Temporal functions such as `date_part`, `date_trunc`, and their aliases 
conceptually expect a literal date/time part (for example, `"year"` or 
`"month"`). While the current API also accepts an `Expr`, that usage is 
confusing because it suggests arbitrary expressions are intended inputs.
   
   This change begins the deprecation process by warning when an `Expr` is 
passed for the `part` argument while preserving existing runtime behavior. 
   
   ## What changes are included in this PR?
   
   * Added a shared helper to emit a `DeprecationWarning` when an `Expr` is 
passed to a literal control argument.
   * Updated the implementations of:
   
     * `date_part`
     * `datepart`
     * `extract`
     * `date_trunc`
     * `datetrunc`
   
     to warn when `part` is provided as an `Expr`.
   * Refactored alias functions (`datepart`, `extract`, and `datetrunc`) to 
delegate through internal helper functions so warnings reference the 
user-facing function name correctly and avoid duplicate warning behavior.
   * Updated existing temporal function tests to use the preferred 
string-literal form for `part`.
   * Added targeted tests verifying:
   
     * `Expr` inputs emit `DeprecationWarning` for `date_part`, `datepart`, and 
`extract`.
     * `Expr` inputs emit `DeprecationWarning` for `date_trunc` and `datetrunc`.
     * String literal inputs continue to work without emitting deprecation 
warnings. 
   
   ## Are these changes tested?
   
   Yes.
   
   The PR updates existing temporal function tests and adds the following 
deprecation-focused test coverage:
   
   * `test_date_part_expr_part_warns_deprecated`
   * `test_date_trunc_expr_part_warns_deprecated`
   
   It also verifies that preferred string-literal usage does not emit 
`DeprecationWarning` by running:
   
   * `test_date_part_native_str`
   * `test_date_trunc_native_str`
   
   with deprecation warnings treated as errors. 
   
   ## Are there any user-facing changes?
   
   Yes.
   
   Passing an `Expr` (for example, `literal("year")`) as the `part` argument to 
temporal extraction and truncation functions now emits a `DeprecationWarning` 
advising users to pass a Python literal string instead.
   
   Runtime behavior and query results remain unchanged in this release. 
   
   ## LLM-generated code disclosure
   
   This PR includes code, comments generated with assistance from LLM. All 
LLM-generated content has been manually reviewed and tested.
   


-- 
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