| 4284 | |
| 4285 | |
| 4286 | def test_expression_call_function(): |
| 4287 | field = pc.field("field") |
| 4288 | |
| 4289 | # no options |
| 4290 | assert str(pc.hour(field)) == "hour(field)" |
| 4291 | |
| 4292 | # default options |
| 4293 | assert str(pc.round(field)) == "round(field)" |
| 4294 | # specified options |
| 4295 | assert str(pc.round(field, ndigits=1)) == \ |
| 4296 | "round(field, {ndigits=1, round_mode=HALF_TO_EVEN})" |
| 4297 | |
| 4298 | # Will convert non-expression arguments if possible |
| 4299 | assert str(pc.add(field, 1)) == "add(field, 1)" |
| 4300 | assert str(pc.add(field, pa.scalar(1))) == "add(field, 1)" |
| 4301 | |
| 4302 | # Invalid pc.scalar input gives original error message |
| 4303 | msg = "only other expressions allowed as arguments" |
| 4304 | with pytest.raises(TypeError, match=msg): |
| 4305 | pc.add(field, object) |
| 4306 | |
| 4307 | |
| 4308 | def test_cast_table_raises(): |