@@ -1446,7 +1446,7 @@ def table_in_out_function(
14461446 worker's registry.
14471447 input: Iterator yielding input RecordBatches. Must yield at least one
14481448 batch. The first batch's schema is used to initialize the IPC
1449- stream. If the iterator is empty, no output is produced .
1449+ stream. Raises ClientError if the iterator is empty.
14501450 arguments: Optional Arguments container with positional and named
14511451 arguments to pass to the function. Defaults to empty Arguments().
14521452 bind_result_callback: Optional callback invoked with the raw bind
@@ -1468,9 +1468,10 @@ def table_in_out_function(
14681468 Final output from finalize() is always yielded last.
14691469
14701470 Raises:
1471- ClientError: If the client is not started, input iterator yields
1472- non-RecordBatch objects, communication with the worker fails,
1473- or the worker returns an unexpected status or exception.
1471+ ClientError: If the client is not started, input iterator is empty,
1472+ input iterator yields non-RecordBatch objects, communication
1473+ with the worker fails, or the worker returns an unexpected
1474+ status or exception.
14741475
14751476 Example:
14761477 >>> with Client("vgi-example-worker") as client:
@@ -1522,6 +1523,13 @@ def table_in_out_function(
15221523 )
15231524 return
15241525
1526+ # Input iterator was empty - table-in-out functions require input
1527+ raise ClientError (
1528+ f"table_in_out_function requires at least one input batch. "
1529+ f"The input iterator for function '{ function_name } ' was empty. "
1530+ f"Use table_function() for functions that generate data without input."
1531+ )
1532+
15251533 def _table_in_out_function_parallel (
15261534 self ,
15271535 * ,
@@ -1912,7 +1920,7 @@ def scalar_function(
19121920 worker's registry.
19131921 input: Iterator yielding input RecordBatches. Must yield at least one
19141922 batch. The first batch's schema is used to initialize the IPC
1915- stream. If the iterator is empty, no output is produced .
1923+ stream. Raises ClientError if the iterator is empty.
19161924 arguments: Optional Arguments container with positional and named
19171925 arguments to pass to the function. Defaults to empty Arguments().
19181926 bind_result_callback: Optional callback invoked with the raw bind
@@ -1932,9 +1940,10 @@ def scalar_function(
19321940 In parallel mode (max_processes > 1), output order is non-deterministic.
19331941
19341942 Raises:
1935- ClientError: If the client is not started, input iterator yields
1936- non-RecordBatch objects, communication with the worker fails,
1937- or the worker returns an unexpected status or exception.
1943+ ClientError: If the client is not started, input iterator is empty,
1944+ input iterator yields non-RecordBatch objects, communication
1945+ with the worker fails, or the worker returns an unexpected
1946+ status or exception.
19381947
19391948 Example:
19401949 >>> with Client("vgi-example-worker") as client:
@@ -1987,6 +1996,13 @@ def scalar_function(
19871996 )
19881997 return
19891998
1999+ # Input iterator was empty - scalar functions require input
2000+ raise ClientError (
2001+ f"scalar_function requires at least one input batch. "
2002+ f"The input iterator for function '{ function_name } ' was empty. "
2003+ f"Use table_function() for functions that generate data without input."
2004+ )
2005+
19902006 def _scalar_function_parallel (
19912007 self ,
19922008 * ,
0 commit comments