Skip to content

pinot_connect.rows🔗


RowMaker🔗

class RowMaker(t.Protocol[RowType])

Protocol for a function that takes a list of values (a row) returned from the query and returns any RowType object


RowFactory🔗

class RowFactory(t.Protocol[RowType])

Protocol for a factory method that returns a RowMaker. The method takes a description (from a cursor) which is often useful for building dictionaries for usage or for passing into other objects as kwargs


tuple_row🔗

def tuple_row(description: list["Column"]) -> RowMaker[tuple]

RowFactory that returns a tuple constructor to convert lis of values to tuple of values

Returns: RowMaker[tuple[t.Any, ...]]


list_row🔗

def list_row(description: list["Column"]) -> RowMaker[list]

RowFactory that is a noop. The data is returned as a list directly from the query, so this avoids any additional data conversion. This is not the default as most dbapis return tuple rows, but can easily be used when wanted.


dict_row🔗

def dict_row(description: list["Column"]) -> RowMaker[dict[str, t.Any]]

RowFactory that uses the description to get the column names and injects it into a row maker that converts a row to a dictionary


dict_row_load_json_fields🔗

def dict_row_load_json_fields(*fields: str) -> RowFactory[dict[str, t.Any]]

pinot's query api always returns json fields as strings, with no indication that a field is actually a json field one way would be to make an additional request to get the metadata of the schema, however the other way that does not involve additional IO is specifying the lists of columns that should be loaded to python dictionaries and using orjson to do that as efficiently as possible. This function takes the field names and for those fields, then calls orjson.loads on each of the corresponding values


kwargs_row🔗

def kwargs_row(obj: t.Callable[..., T] | type[T]) -> RowFactory[T]

RowFactory that uses the description to get the column names and builds a dictionary to be passed as kwargs. the kwargs are then passed into the passed function or type/model


args_row🔗

def args_row(obj: t.Callable[..., T] | type[T]) -> RowFactory[T]

Row factory that unpacks the row into positional arguments to the passed function or type/model