pub struct Select {Show 36 fields
pub expressions: Vec<Expression>,
pub from: Option<From>,
pub joins: Vec<Join>,
pub lateral_views: Vec<LateralView>,
pub prewhere: Option<Expression>,
pub where_clause: Option<Where>,
pub group_by: Option<GroupBy>,
pub having: Option<Having>,
pub qualify: Option<Qualify>,
pub order_by: Option<OrderBy>,
pub distribute_by: Option<DistributeBy>,
pub cluster_by: Option<ClusterBy>,
pub sort_by: Option<SortBy>,
pub limit: Option<Limit>,
pub offset: Option<Offset>,
pub limit_by: Option<Vec<Expression>>,
pub fetch: Option<Fetch>,
pub distinct: bool,
pub distinct_on: Option<Vec<Expression>>,
pub top: Option<Top>,
pub with: Option<With>,
pub sample: Option<Sample>,
pub settings: Option<Vec<Expression>>,
pub format: Option<Expression>,
pub windows: Option<Vec<NamedWindow>>,
pub hint: Option<Hint>,
pub connect: Option<Connect>,
pub into: Option<SelectInto>,
pub locks: Vec<Lock>,
pub for_xml: Vec<Expression>,
pub leading_comments: Vec<String>,
pub post_select_comments: Vec<String>,
pub kind: Option<String>,
pub operation_modifiers: Vec<String>,
pub qualify_after_window: bool,
pub option: Option<String>,
}Expand description
Represent a complete SELECT statement.
This is the most feature-rich AST node, covering the full surface area of
SELECT syntax across 30+ SQL dialects. Fields that are Option or empty
Vec are omitted from the generated SQL when absent.
§Key Fields
expressions– the select-list (columns,*, computed expressions).from– the FROM clause.NoneforSELECT 1style queries.joins– zero or more JOIN clauses, each with aJoinKind.where_clause– the WHERE predicate.group_by– GROUP BY, including ROLLUP/CUBE/GROUPING SETS.having– HAVING predicate.order_by– ORDER BY with ASC/DESC and NULLS FIRST/LAST.limit/offset/fetch– result set limiting.with– Common Table Expressions (CTEs).distinct/distinct_on– DISTINCT and PostgreSQL DISTINCT ON.windows– named window definitions (WINDOW w AS …).
Dialect-specific extensions are supported via fields like prewhere
(ClickHouse), qualify (Snowflake/BigQuery/DuckDB), connect (Oracle
CONNECT BY), for_xml (TSQL), and settings (ClickHouse).
Fields§
§expressions: Vec<Expression>The select-list: columns, expressions, aliases, and wildcards.
from: Option<From>The FROM clause, containing one or more table sources.
joins: Vec<Join>JOIN clauses applied after the FROM source.
lateral_views: Vec<LateralView>§prewhere: Option<Expression>ClickHouse PREWHERE clause
where_clause: Option<Where>§group_by: Option<GroupBy>§having: Option<Having>§qualify: Option<Qualify>§order_by: Option<OrderBy>§distribute_by: Option<DistributeBy>§cluster_by: Option<ClusterBy>§sort_by: Option<SortBy>§limit: Option<Limit>§offset: Option<Offset>§limit_by: Option<Vec<Expression>>ClickHouse LIMIT BY clause expressions
fetch: Option<Fetch>§distinct: bool§distinct_on: Option<Vec<Expression>>§top: Option<Top>§with: Option<With>§sample: Option<Sample>§settings: Option<Vec<Expression>>ClickHouse SETTINGS clause (e.g., SETTINGS max_threads = 4)
format: Option<Expression>ClickHouse FORMAT clause (e.g., FORMAT PrettyCompact)
windows: Option<Vec<NamedWindow>>§hint: Option<Hint>§connect: Option<Connect>Oracle CONNECT BY clause for hierarchical queries
into: Option<SelectInto>SELECT … INTO table_name for creating tables
locks: Vec<Lock>FOR UPDATE/SHARE locking clauses
for_xml: Vec<Expression>T-SQL FOR XML clause options (PATH, RAW, AUTO, EXPLICIT, BINARY BASE64, ELEMENTS XSINIL, etc.)
leading_comments: Vec<String>Leading comments before the statement
post_select_comments: Vec<String>Comments that appear after SELECT keyword (before expressions) e.g., SELECT /hint/ col -> post_select_comments: [“/hint/”]
kind: Option<String>BigQuery SELECT AS STRUCT / SELECT AS VALUE kind
operation_modifiers: Vec<String>MySQL operation modifiers (HIGH_PRIORITY, STRAIGHT_JOIN, SQL_CALC_FOUND_ROWS, etc.)
qualify_after_window: boolWhether QUALIFY appears after WINDOW (DuckDB) vs before (Snowflake/BigQuery default)
option: Option<String>TSQL OPTION clause (e.g., OPTION(LABEL = ‘foo’))
Implementations§
Source§impl Select
impl Select
pub fn new() -> Self
Sourcepub fn column(self, expr: Expression) -> Self
pub fn column(self, expr: Expression) -> Self
Add a column to select
Sourcepub fn from(self, table: Expression) -> Self
pub fn from(self, table: Expression) -> Self
Set the FROM clause
Sourcepub fn where_(self, condition: Expression) -> Self
pub fn where_(self, condition: Expression) -> Self
Add a WHERE clause
Sourcepub fn limit(self, n: Expression) -> Self
pub fn limit(self, n: Expression) -> Self
Set LIMIT
Sourcepub fn offset(self, n: Expression) -> Self
pub fn offset(self, n: Expression) -> Self
Set OFFSET