pixano.datasets.queries.table
TableQueryBuilder(table)
Builder class for querying LanceTables.
It supports the select, where, limit, offset, and order_by clauses: - The select clause can be used to select specific columns from the table. If not provided, all columns are selected. - The where clause can be used to filter the rows of the table. - The limit clause can be used to limit the number of rows returned. - The offset clause can be used to skip the first n rows. - The order_by clause can be used to sort the rows of the table.
The query is built and executed when calling to_pandas(), to_list(), to_pydantic(), or to_polars().
Attributes:
Name | Type | Description |
---|---|---|
table |
LanceTable
|
The LanceTable to query. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table
|
LanceTable
|
The LanceTable to query. |
required |
Source code in pixano/datasets/queries/table.py
limit(limit)
Sets the limit for the query.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit
|
int | None
|
The number of rows to return. |
required |
Returns:
Type | Description |
---|---|
Self
|
The TableQueryBuilder instance. |
Source code in pixano/datasets/queries/table.py
offset(offset)
Sets the offset for the query.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
int | None
|
The number of rows to skip. |
required |
Returns:
Type | Description |
---|---|
Self
|
The TableQueryBuilder instance. |
Source code in pixano/datasets/queries/table.py
order_by(order_by, descending=False)
Sets the order_by clause for the query.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
order_by
|
str | list[str]
|
The column(s) to sort by. |
required |
descending
|
bool | list[bool]
|
Whether to sort in descending order. |
False
|
Returns:
Type | Description |
---|---|
Self
|
The TableQueryBuilder instance. |
Source code in pixano/datasets/queries/table.py
select(columns)
Selects columns to include in the query.
Note
'id' is always included in the select clause.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
columns
|
str | list[str] | dict[str, str]
|
The columns to include in the query. If a list, the columns are selected in the order they are provided. If a dictionary, the keys are the column names and the values are the aliases. |
required |
Source code in pixano/datasets/queries/table.py
to_list()
to_pandas()
Builds the query and returns the result as a pandas DataFrame.
Returns:
Type | Description |
---|---|
DataFrame
|
The result as a pandas DataFrame. |
to_polars()
Builds the query and returns the result as a polars DataFrame.
Returns:
Type | Description |
---|---|
DataFrame
|
The result as a polars DataFrame. |
to_pydantic(model)
Builds the query and returns the result as a list of Pydantic models.
Returns:
Type | Description |
---|---|
list[T]
|
The result as a list of Pydantic models. |
Source code in pixano/datasets/queries/table.py
where(where)
Sets the where clause for the query.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
where
|
str
|
The condition to filter the rows. |
required |
Returns:
Type | Description |
---|---|
Self
|
The TableQueryBuilder instance. |