Function mz_sql::plan::query::plan_view_select
source ยท fn plan_view_select(
qcx: &QueryContext<'_>,
s: Select<Aug>,
order_by_exprs: Vec<OrderByExpr<Aug>>,
) -> Result<SelectPlan, PlanError>
Expand description
Plans a SELECT query. The SELECT query may contain an intrusive ORDER BY clause.
Normally, the ORDER BY clause occurs after the columns specified in the SELECT list have been projected. In a query like
CREATE TABLE (a int, b int) (SELECT a FROM t) UNION (SELECT a FROM t) ORDER BY a
it is valid to refer to a
, because it is explicitly selected, but it would
not be valid to refer to unselected column b
.
But PostgreSQL extends the standard to permit queries like
SELECT a FROM t ORDER BY b
where expressions in the ORDER BY clause can refer to both input columns and output columns.