diff --git a/python/feldera/rest/client.py b/python/feldera/rest/client.py index 50b7d7bc481..dc0dbdd262f 100644 --- a/python/feldera/rest/client.py +++ b/python/feldera/rest/client.py @@ -11,6 +11,10 @@ from feldera.rest._httprequests import HttpRequests +def _prepare_boolean_input(value: bool) -> str: + return "true" if value else "false" + + class Client: """ A client for the Feldera HTTP API @@ -399,8 +403,8 @@ def push_to_pipeline( raise ValueError("update_format must be one of 'insert_delete', 'weighted', 'debezium', 'snowflake', 'raw'") # python sends `True` which isn't accepted by the backend - array = "true" if array else "false" - force = "true" if force else "false" + array = _prepare_boolean_input(array) + force = _prepare_boolean_input(force) params = { "force": force, @@ -430,6 +434,7 @@ def listen_to_pipeline( table_name: str, format: str, mode: str = "watch", + backpressure: bool = True, query: Optional[str] = None, quantiles: Optional[int] = None, array: bool = False, @@ -442,6 +447,10 @@ def listen_to_pipeline( :param table_name: The name of the table to listen to :param format: The format of the data, either "json" or "csv" :param mode: The mode to listen in, either "watch" or "snapshot" + :param backpressure: When the flag is True (the default), this method waits for the consumer to receive each + chunk and blocks the pipeline if the consumer cannot keep up. When this flag is False, the pipeline drops + data chunks if the consumer is not keeping up with its output. This prevents a slow consumer from slowing + down the entire pipeline. :param quantiles: For 'quantiles' queries: the number of quantiles to output. The default value is 100 :param query: Query to execute on the table, either "table", "neighborhood" or "quantiles" :param array: Set True to group updates in this stream into JSON arrays, used in conjunction with the @@ -459,13 +468,14 @@ def listen_to_pipeline( params = { "mode": mode, "format": format, + "backpressure": _prepare_boolean_input(backpressure), } if quantiles: params["quantiles"] = quantiles if format == "json": - params["array"] = "true" if array else "false" + params["array"] = _prepare_boolean_input(array) resp = self.http.post( path=f"/pipelines/{pipeline_name}/egress/{table_name}",