pub struct PageQuery { /* private fields */ }Expand description
What a PageSource is asked for: its rows, in an order (an ORDER BY).
Implementations§
Source§impl PageQuery
impl PageQuery
Sourcepub fn sorted_by(self, key: SortKey) -> Self
pub fn sorted_by(self, key: SortKey) -> Self
The query with its rows sorted by key too, after the keys it has.
Sourcepub fn sort(&self) -> &[SortKey]
pub fn sort(&self) -> &[SortKey]
The keys rows are sorted by, the first first; none for the source’s own order.
Sourcepub fn order_by_sql<S: AsRef<str>>(&self, keys: &[S]) -> String
pub fn order_by_sql<S: AsRef<str>>(&self, keys: &[S]) -> String
The order as an SQL ORDER BY clause, for a source that pages a query with LIMIT and
OFFSET: the sort keys, then the keys not among them, ascending. Give as keys the
columns that tell rows apart (an id): rows that tie in every sort key then keep one
order from page to page, so none shows twice or goes missing. Names are quoted as
standard SQL quotes them ("time", and "a ""b""" for a column named a "b"), each
once. Empty with no sort keys and no keys, which leaves the order to the engine: one
that reads in parallel may change it from one page to the next.
use densa_arrow::{PageQuery, SortKey};
use densa_grid::SortOrder;
let query = PageQuery::new().sorted_by(SortKey::new("time", SortOrder::Descending));
let order = query.order_by_sql(&["id"]);
assert_eq!(order, r#"ORDER BY "time" DESC, "id""#);
let sql = format!("SELECT * FROM trips {order} LIMIT 256 OFFSET 512");