Polyglot SQL API Documentation - v0.8.1
    Preparing search index...

    Type Alias Select

    Represent a complete SELECT statement.

    This is the most feature-rich AST node, covering the full surface area of SELECT syntax across more than 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. None for SELECT 1 style queries.
    • joins -- zero or more JOIN clauses, each with a [JoinKind].
    • 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).

    type Select = {
        cluster_by: ClusterBy | null;
        connect: Connect | null;
        distinct: boolean;
        distinct_on: Expression[] | null;
        distribute_by: DistributeBy | null;
        exclude?: Expression[] | null;
        expressions: Expression[];
        fetch: Fetch | null;
        for_json?: Expression[];
        for_xml?: Expression[];
        format?: Expression | null;
        from: From | null;
        group_by: GroupBy | null;
        having: Having | null;
        hint: Hint | null;
        into: SelectInto | null;
        joins: Join[];
        kind?: string | null;
        lateral_views: LateralView[];
        leading_comments: string[];
        limit: Limit | null;
        limit_by?: Expression[] | null;
        locks: Lock[];
        offset: Offset | null;
        operation_modifiers?: string[];
        option?: string | null;
        order_by: OrderBy | null;
        post_select_comments?: string[];
        prewhere?: Expression | null;
        qualify: Qualify | null;
        qualify_after_window?: boolean;
        sample: Sample | null;
        settings?: Expression[] | null;
        sort_by: SortBy | null;
        top: Top | null;
        where_clause: Where | null;
        windows: NamedWindow[] | null;
        with: With | null;
    }
    Index

    Properties

    cluster_by: ClusterBy | null
    connect: Connect | null

    Oracle CONNECT BY clause for hierarchical queries

    distinct: boolean
    distinct_on: Expression[] | null
    distribute_by: DistributeBy | null
    exclude?: Expression[] | null

    Redshift-style EXCLUDE clause at the end of the projection list e.g., SELECT *, 4 AS col4 EXCLUDE (col2, col3) FROM ...

    expressions: Expression[]

    The select-list: columns, expressions, aliases, and wildcards.

    fetch: Fetch | null
    for_json?: Expression[]

    T-SQL FOR JSON clause options (PATH, AUTO, ROOT, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER)

    for_xml?: Expression[]

    T-SQL FOR XML clause options (PATH, RAW, AUTO, EXPLICIT, BINARY BASE64, ELEMENTS XSINIL, etc.)

    format?: Expression | null

    ClickHouse FORMAT clause (e.g., FORMAT PrettyCompact)

    from: From | null

    The FROM clause, containing one or more table sources.

    group_by: GroupBy | null
    having: Having | null
    hint: Hint | null
    into: SelectInto | null

    SELECT ... INTO table_name for creating tables

    joins: Join[]

    JOIN clauses applied after the FROM source.

    kind?: string | null

    BigQuery SELECT AS STRUCT / SELECT AS VALUE kind

    lateral_views: LateralView[]
    leading_comments: string[]

    Leading comments before the statement

    limit: Limit | null
    limit_by?: Expression[] | null

    ClickHouse LIMIT BY clause expressions

    locks: Lock[]

    FOR UPDATE/SHARE locking clauses

    offset: Offset | null
    operation_modifiers?: string[]

    MySQL operation modifiers (HIGH_PRIORITY, STRAIGHT_JOIN, SQL_CALC_FOUND_ROWS, etc.)

    option?: string | null

    TSQL OPTION clause (e.g., OPTION(LABEL = 'foo'))

    order_by: OrderBy | null

    Optionalpost_select_comments

    post_select_comments?: string[]

    Comments that appear after SELECT keyword (before expressions) Example: SELECT <comment> col -> post_select_comments: ["<comment>"]

    prewhere?: Expression | null

    ClickHouse PREWHERE clause

    qualify: Qualify | null
    qualify_after_window?: boolean

    Whether QUALIFY appears after WINDOW (DuckDB) vs before (Snowflake/BigQuery default)

    sample: Sample | null
    settings?: Expression[] | null

    ClickHouse SETTINGS clause (e.g., SETTINGS max_threads = 4)

    sort_by: SortBy | null
    top: Top | null
    where_clause: Where | null
    windows: NamedWindow[] | null
    with: With | null