()
| 3133 | |
| 3134 | @pytest.mark.acero |
| 3135 | def test_table_group_by_pivot_wider(): |
| 3136 | table = pa.table({'group': [1, 2, 3, 1, 2, 3], |
| 3137 | 'key': ['h', 'h', 'h', 'w', 'w', 'w'], |
| 3138 | 'value': [10, 20, 30, 40, 50, 60]}) |
| 3139 | |
| 3140 | with pytest.raises(ValueError, match='accepts 3 arguments but 2 passed'): |
| 3141 | table.group_by("group").aggregate([("key", "pivot_wider")]) |
| 3142 | |
| 3143 | # GH-45739: calling hash_pivot_wider without options shouldn't crash |
| 3144 | # (even though it's not very useful as key_names=[]) |
| 3145 | result = table.group_by("group").aggregate([(("key", "value"), "pivot_wider")]) |
| 3146 | expected = pa.table({'group': [1, 2, 3], |
| 3147 | 'key_value_pivot_wider': [{}, {}, {}]}) |
| 3148 | assert result.equals(expected) |
| 3149 | |
| 3150 | options = pc.PivotWiderOptions(key_names=('h', 'w')) |
| 3151 | result = table.group_by("group").aggregate( |
| 3152 | [(("key", "value"), "pivot_wider", options)]) |
| 3153 | expected = pa.table( |
| 3154 | {'group': [1, 2, 3], |
| 3155 | 'key_value_pivot_wider': [ |
| 3156 | {'h': 10, 'w': 40}, {'h': 20, 'w': 50}, {'h': 30, 'w': 60}]}) |
| 3157 | assert result.equals(expected) |
| 3158 | |
| 3159 | |
| 3160 | def test_table_to_recordbatchreader(): |
nothing calls this directly
no test coverage detected