()
| 437 | |
| 438 | |
| 439 | def test_registration_errors(): |
| 440 | # validate function name |
| 441 | doc = { |
| 442 | "summary": "test udf input", |
| 443 | "description": "parameters are validated" |
| 444 | } |
| 445 | in_types = {"scalar": pa.int64()} |
| 446 | out_type = pa.int64() |
| 447 | |
| 448 | def test_reg_function(context): |
| 449 | return pa.array([10]) |
| 450 | |
| 451 | with pytest.raises(TypeError): |
| 452 | pc.register_scalar_function(test_reg_function, |
| 453 | None, doc, in_types, |
| 454 | out_type) |
| 455 | |
| 456 | # validate function |
| 457 | with pytest.raises(TypeError, match="func must be a callable"): |
| 458 | pc.register_scalar_function(None, "test_none_function", doc, in_types, |
| 459 | out_type) |
| 460 | |
| 461 | # validate output type |
| 462 | expected_expr = "DataType expected, got <class 'NoneType'>" |
| 463 | with pytest.raises(TypeError, match=expected_expr): |
| 464 | pc.register_scalar_function(test_reg_function, |
| 465 | "test_output_function", doc, in_types, |
| 466 | None) |
| 467 | |
| 468 | # validate input type |
| 469 | expected_expr = "in_types must be a dictionary of DataType" |
| 470 | with pytest.raises(TypeError, match=expected_expr): |
| 471 | pc.register_scalar_function(test_reg_function, |
| 472 | "test_input_function", doc, None, |
| 473 | out_type) |
| 474 | |
| 475 | # register an already registered function |
| 476 | # first registration |
| 477 | pc.register_scalar_function(test_reg_function, |
| 478 | "test_reg_function", doc, {}, |
| 479 | out_type) |
| 480 | # second registration |
| 481 | expected_expr = "Already have a function registered with name:" \ |
| 482 | + " test_reg_function" |
| 483 | with pytest.raises(KeyError, match=expected_expr): |
| 484 | pc.register_scalar_function(test_reg_function, |
| 485 | "test_reg_function", doc, {}, |
| 486 | out_type) |
| 487 | |
| 488 | |
| 489 | def test_varargs_function_validation(varargs_func_fixture): |
nothing calls this directly
no outgoing calls
no test coverage detected