kosiew opened a new pull request, #1605:
URL: https://github.com/apache/datafusion-python/pull/1605
## Which issue does this PR close?
* Part of #1496
## Rationale for this change
As part of the audit of `Expr | literal` function arguments, this change
targets a set of arguments that act as control/configuration parameters rather
than row-varying data expressions. These arguments are intended to be provided
as Python literals (for example, encoding names, digest methods, data type
specifiers, and metadata keys).
To prepare for future API cleanup while preserving compatibility, passing an
`Expr` to these arguments now emits a `DeprecationWarning` but continues to
work.
## What changes are included in this PR?
* Added a reusable helper, `_warn_if_expr_for_literal_arg`, that emits a
deprecation warning when an `Expr` is supplied to a confirmed literal-only
argument.
* Added deprecation warnings for the following function arguments:
* `encode(..., encoding=...)`
* `decode(..., encoding=...)`
* `digest(..., method=...)`
* `arrow_cast(..., data_type=...)`
* `arrow_try_cast(..., data_type=...)`
* `arrow_metadata(..., key=...)`
* Preserved existing behavior by continuing to coerce these values to
expressions after warning.
* Added tests covering both warning and non-warning cases.
## Are these changes tested?
Yes.
Added tests in `python/tests/test_functions.py` that verify:
* Passing `literal(...)` / `Expr` values to the audited literal-only
arguments emits a `DeprecationWarning`.
* Passing native Python literal values does **not** emit a
`DeprecationWarning`.
* Coverage includes:
* `encode`
* `decode`
* `digest`
* `arrow_cast`
* `arrow_try_cast`
* `arrow_metadata`
## Are there any user-facing changes?
Yes.
Users will now receive a `DeprecationWarning` when passing an `Expr` to the
following literal-only arguments:
* `encode(..., encoding=...)`
* `decode(..., encoding=...)`
* `digest(..., method=...)`
* `arrow_cast(..., data_type=...)`
* `arrow_try_cast(..., data_type=...)`
* `arrow_metadata(..., key=...)`
Existing behavior is otherwise unchanged, and Python literal inputs remain
fully supported without warnings.
## LLM-generated code disclosure
This PR includes code, comments generated with assistance from LLM. All
LLM-generated content has been manually reviewed.
--
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]