Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions python/feldera/rest/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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}",
Expand Down