Commit d07fdb3
Add missing scalar functions (#1470)
* Add missing scalar functions: get_field, union_extract, union_tag, arrow_metadata, version, row
Expose upstream DataFusion scalar functions that were not yet available
in the Python API. Closes #1453.
- get_field: extracts a field from a struct or map by name
- union_extract: extracts a value from a union type by field name
- union_tag: returns the active field name of a union type
- arrow_metadata: returns Arrow field metadata (all or by key)
- version: returns the DataFusion version string
- row: alias for the struct constructor
Note: arrow_try_cast was listed in the issue but does not exist in
DataFusion 53, so it is not included.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add tests for new scalar functions
Tests for get_field, arrow_metadata, version, row, union_tag, and
union_extract.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Accept str for field name and type parameters in scalar functions
Allow arrow_cast, get_field, and union_extract to accept plain str
arguments instead of requiring Expr wrappers. Also improve
arrow_metadata test coverage and fix parameter shadowing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Accept str for key parameter in arrow_metadata for consistency
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add doctest examples and fix docstring style for new scalar functions
Replace Args/Returns sections with doctest Examples blocks for
arrow_metadata, get_field, union_extract, union_tag, and version to
match existing codebase conventions. Simplify row to alias-style
docstring with See Also reference. Document that arrow_cast accepts
both str and Expr for data_type.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Support pyarrow DataType in arrow_cast
Allow arrow_cast to accept a pyarrow DataType in addition to str and
Expr. The DataType is converted to its string representation before
being passed to DataFusion. Adds test coverage for the new input type.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Document bracket syntax shorthand in get_field docstring
Note that expr["field"] is a convenient alternative when the field
name is a static string, and get_field is needed for dynamic
expressions. Add a second doctest example showing the bracket syntax.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix arrow_cast with pyarrow DataType by delegating to Expr.cast
Use the existing Rust-side PyArrowType<DataType> conversion via
Expr.cast() instead of str() which produces pyarrow type names
that DataFusion does not recognize.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Clarify when to use arrow_cast vs Expr.cast in docstring
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 99bc960 commit d07fdb3
File tree
3 files changed
+296
-9
lines changed- crates/core/src
- python
- datafusion
- tests
3 files changed
+296
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
695 | 695 | | |
696 | 696 | | |
697 | 697 | | |
| 698 | + | |
| 699 | + | |
698 | 700 | | |
699 | 701 | | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
700 | 721 | | |
701 | 722 | | |
702 | 723 | | |
| |||
1014 | 1035 | | |
1015 | 1036 | | |
1016 | 1037 | | |
| 1038 | + | |
1017 | 1039 | | |
1018 | 1040 | | |
1019 | 1041 | | |
| |||
1142 | 1164 | | |
1143 | 1165 | | |
1144 | 1166 | | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
1145 | 1171 | | |
1146 | 1172 | | |
1147 | 1173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
| 167 | + | |
166 | 168 | | |
167 | 169 | | |
168 | 170 | | |
| |||
280 | 282 | | |
281 | 283 | | |
282 | 284 | | |
| 285 | + | |
283 | 286 | | |
284 | 287 | | |
285 | 288 | | |
| |||
322 | 325 | | |
323 | 326 | | |
324 | 327 | | |
| 328 | + | |
| 329 | + | |
325 | 330 | | |
326 | 331 | | |
327 | 332 | | |
328 | 333 | | |
329 | 334 | | |
330 | 335 | | |
| 336 | + | |
331 | 337 | | |
332 | 338 | | |
333 | 339 | | |
| |||
2628 | 2634 | | |
2629 | 2635 | | |
2630 | 2636 | | |
2631 | | - | |
| 2637 | + | |
2632 | 2638 | | |
2633 | 2639 | | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
| 2643 | + | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
2634 | 2648 | | |
2635 | 2649 | | |
2636 | 2650 | | |
2637 | | - | |
2638 | 2651 | | |
2639 | | - | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
2640 | 2662 | | |
2641 | 2663 | | |
2642 | 2664 | | |
2643 | 2665 | | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
| 2669 | + | |
2644 | 2670 | | |
2645 | 2671 | | |
2646 | 2672 | | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
| 2697 | + | |
| 2698 | + | |
| 2699 | + | |
| 2700 | + | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
| 2721 | + | |
| 2722 | + | |
| 2723 | + | |
| 2724 | + | |
| 2725 | + | |
| 2726 | + | |
| 2727 | + | |
| 2728 | + | |
| 2729 | + | |
| 2730 | + | |
| 2731 | + | |
| 2732 | + | |
| 2733 | + | |
| 2734 | + | |
| 2735 | + | |
| 2736 | + | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
| 2752 | + | |
| 2753 | + | |
| 2754 | + | |
| 2755 | + | |
| 2756 | + | |
| 2757 | + | |
| 2758 | + | |
| 2759 | + | |
| 2760 | + | |
| 2761 | + | |
| 2762 | + | |
| 2763 | + | |
| 2764 | + | |
| 2765 | + | |
| 2766 | + | |
| 2767 | + | |
| 2768 | + | |
| 2769 | + | |
| 2770 | + | |
| 2771 | + | |
| 2772 | + | |
| 2773 | + | |
| 2774 | + | |
| 2775 | + | |
| 2776 | + | |
| 2777 | + | |
| 2778 | + | |
| 2779 | + | |
| 2780 | + | |
| 2781 | + | |
| 2782 | + | |
| 2783 | + | |
| 2784 | + | |
| 2785 | + | |
| 2786 | + | |
| 2787 | + | |
| 2788 | + | |
| 2789 | + | |
| 2790 | + | |
| 2791 | + | |
| 2792 | + | |
| 2793 | + | |
| 2794 | + | |
| 2795 | + | |
| 2796 | + | |
| 2797 | + | |
| 2798 | + | |
| 2799 | + | |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
2647 | 2815 | | |
2648 | 2816 | | |
2649 | 2817 | | |
| |||
0 commit comments