// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ClusterBy } from "./ClusterBy";
import type { DistributeBy } from "./DistributeBy";
import type { Expression } from "./Expression";
import type { Identifier } from "./Identifier";
import type { Limit } from "./Limit";
import type { Offset } from "./Offset";
import type { OrderBy } from "./OrderBy";
import type { SortBy } from "./SortBy";

/**
 * Represent a parenthesized subquery expression.
 *
 * A subquery wraps an inner query (typically a SELECT, UNION, etc.) in
 * parentheses and optionally applies an alias, column aliases, ORDER BY,
 * LIMIT, and OFFSET. The `modifiers_inside` flag controls whether the
 * modifiers are rendered inside or outside the parentheses.
 *
 * Subqueries appear in many SQL contexts: FROM clauses, WHERE IN/EXISTS,
 * scalar subqueries in select-lists, and derived tables.
 */
export type Subquery = { 
/**
 * The inner query expression.
 */
this: Expression, 
/**
 * Optional alias for the derived table.
 */
alias: Identifier | null, 
/**
 * Optional column aliases: AS t(c1, c2)
 */
column_aliases: Array<Identifier>, 
/**
 * ORDER BY clause (for parenthesized queries)
 */
order_by: OrderBy | null, 
/**
 * LIMIT clause
 */
limit: Limit | null, 
/**
 * OFFSET clause
 */
offset: Offset | null, 
/**
 * DISTRIBUTE BY clause (Hive/Spark)
 */
distribute_by?: DistributeBy | null, 
/**
 * SORT BY clause (Hive/Spark)
 */
sort_by?: SortBy | null, 
/**
 * CLUSTER BY clause (Hive/Spark)
 */
cluster_by?: ClusterBy | null, 
/**
 * Whether this is a LATERAL subquery (can reference earlier tables in FROM)
 */
lateral: boolean, 
/**
 * Whether modifiers (ORDER BY, LIMIT, OFFSET) should be generated inside the parentheses
 * true: (SELECT 1 LIMIT 1)  - modifiers inside
 * false: (SELECT 1) LIMIT 1 - modifiers outside
 */
modifiers_inside: boolean, 
/**
 * Trailing comments after the closing paren
 */
trailing_comments: Array<string>, };
