Commit 4e223ff
authored
Add deprecation warnings for Expr passed to confirmed literal-only function arguments (#1605)
* feat: add deprecation warning for Expr passed to literal-only args
- Introduced shared `_warn_if_expr_for_literal_arg` in `functions/__init__.py`
- Added `DeprecationWarning` for the following methods when `Expr` is passed as argument:
- `encode(..., encoding=Expr)`
- `decode(..., encoding=Expr)`
- `digest(..., method=Expr)`
- `arrow_cast(..., data_type=Expr)`
- `arrow_try_cast(..., data_type=Expr)`
- `arrow_metadata(..., key=Expr)`
test: update tests to check for warnings
- Implemented tests in `test_functions.py` to ensure:
- Warning is raised for `Expr` form
- No warning for native literal form
* fix(tests): resolve E501 line length issue in test_functions.py
* feat: consolidate warning helpers and update temporal function calls
- Collapsed warning helpers into a single function `_warn_if_expr_for_literal_arg` in `python/datafusion/functions/__init__.py`.
- Updated callers of temporal functions `_date_part` and `_date_trunc` in `python/datafusion/functions/__init__.py`.
- Modified the digest behavior test in `python/tests/test_functions.py` to use native method strings.
- Updated the encode/decode behavior test to use native "base64" in `python/tests/test_functions.py`.
* docs: update function examples in common-operations user guide
- Replaced `string_literal("Float64")` with `"Float64"` in examples.
- Replaced `str_lit("Int32")` with `"Int32"` in examples.
- Removed unused `string_literal` and `str_lit` imports.1 parent 5b7ad64 commit 4e223ff
3 files changed
Lines changed: 87 additions & 20 deletions
File tree
- docs/source/user-guide/common-operations
- python
- datafusion/functions
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
126 | | - | |
| 125 | + | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| |||
437 | 440 | | |
438 | 441 | | |
439 | 442 | | |
| 443 | + | |
440 | 444 | | |
441 | 445 | | |
442 | 446 | | |
| |||
452 | 456 | | |
453 | 457 | | |
454 | 458 | | |
| 459 | + | |
455 | 460 | | |
456 | 461 | | |
457 | 462 | | |
| |||
742 | 747 | | |
743 | 748 | | |
744 | 749 | | |
| 750 | + | |
745 | 751 | | |
746 | 752 | | |
747 | 753 | | |
| |||
2723 | 2729 | | |
2724 | 2730 | | |
2725 | 2731 | | |
2726 | | - | |
2727 | | - | |
| 2732 | + | |
2728 | 2733 | | |
2729 | 2734 | | |
2730 | 2735 | | |
| |||
2760 | 2765 | | |
2761 | 2766 | | |
2762 | 2767 | | |
2763 | | - | |
2764 | | - | |
| 2768 | + | |
2765 | 2769 | | |
2766 | 2770 | | |
2767 | 2771 | | |
| |||
3096 | 3100 | | |
3097 | 3101 | | |
3098 | 3102 | | |
| 3103 | + | |
3099 | 3104 | | |
3100 | 3105 | | |
3101 | 3106 | | |
| |||
3128 | 3133 | | |
3129 | 3134 | | |
3130 | 3135 | | |
| 3136 | + | |
3131 | 3137 | | |
3132 | 3138 | | |
3133 | 3139 | | |
| |||
3235 | 3241 | | |
3236 | 3242 | | |
3237 | 3243 | | |
| 3244 | + | |
3238 | 3245 | | |
3239 | 3246 | | |
3240 | 3247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1014 | 1014 | | |
1015 | 1015 | | |
1016 | 1016 | | |
1017 | | - | |
| 1017 | + | |
1018 | 1018 | | |
1019 | 1019 | | |
1020 | 1020 | | |
| |||
1602 | 1602 | | |
1603 | 1603 | | |
1604 | 1604 | | |
1605 | | - | |
| 1605 | + | |
1606 | 1606 | | |
1607 | | - | |
1608 | | - | |
1609 | | - | |
1610 | | - | |
| 1607 | + | |
| 1608 | + | |
1611 | 1609 | | |
1612 | 1610 | | |
1613 | 1611 | | |
| |||
2355 | 2353 | | |
2356 | 2354 | | |
2357 | 2355 | | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
| 2376 | + | |
| 2377 | + | |
| 2378 | + | |
| 2379 | + | |
| 2380 | + | |
| 2381 | + | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
2358 | 2418 | | |
2359 | 2419 | | |
2360 | 2420 | | |
| |||
0 commit comments