Repository: pola-rs/polars
File: crates/polars-sql/src/context.rs (Rust)

Code before:
            having: _,
            projection: _,
            selection: _,

            // Metadata/token fields (can ignore)
            select_token: _,
            top_before_distinct: _,
            window_before_qualify: _,

            // Unsupported clauses
            ref cluster_by,
            ref connect_by,
            ref distribute_by,
            ref into,
            ref lateral_views,
            ref named_window,
            ref prewhere,
            ref qualify,
            ref sort_by,
            ref top,
            ref value_table_mode,
        } = *select_stmt;

        // Raise specific error messages for unsupported attributes
        if top.is_some() {
            polars_bail!(SQLInterface: "TOP clause is not supported; use LIMIT instead")
        }
        if into.is_some() {
            polars_bail!(SQLInterface: "SELECT INTO clause is not supported")
        }
        if !lateral_views.is_empty() {
            polars_bail!(SQLInterface: "LATERAL VIEW clause is not supported")
        }
        if prewhere.is_some() {
            polars_bail!(SQLInterface: "PREWHERE clause is not supported")
        }
        if !cluster_by.is_empty() {
            polars_bail!(SQLInterface: "CLUSTER BY clause is not supported")
        }
        if !distribute_by.is_empty() {
            polars_bail!(SQLInterface: "DISTRIBUTE BY clause is not supported")
        }
        if !sort_by.is_empty() {
            polars_bail!(SQLInterface: "SORT BY clause is not supported; use ORDER BY instead")
        }
        if !named_window.is_empty() {
            polars_bail!(SQLInterface: "WINDOW clause support is coming soon")
        }
        if qualify.is_some() {
            polars_bail!(SQLInterface: "QUALIFY clause is not currently supported")
        }

Review comment (suggestion):
nit: 

```rust
polars_ensure!(top.is_none(), SQLInterface: "TOP clause is not supported; use LIMIT instead")
polars_ensure!(into.is_none(), SQLInterface: "SELECT INTO clause is not supported")
...
```

Code after:
            having: _,
            projection: _,
            selection: _,

            // Metadata/token fields (can ignore)
            select_token: _,
            top_before_distinct: _,
            window_before_qualify: _,

            // Unsupported clauses
            ref cluster_by,
            ref connect_by,
            ref distribute_by,
            ref into,
            ref lateral_views,
            ref named_window,
            ref prewhere,
            ref qualify,
            ref sort_by,
            ref top,
            ref value_table_mode,
        } = *select_stmt;

        // Raise specific error messages for unsupported attributes
        polars_ensure!(cluster_by.is_empty(), SQLInterface: "CLUSTER BY clause is not supported");
        polars_ensure!(connect_by.is_none(), SQLInterface: "CONNECT BY clause is not supported");
        polars_ensure!(distribute_by.is_empty(), SQLInterface: "DISTRIBUTE BY clause is not supported");
        polars_ensure!(into.is_none(), SQLInterface: "SELECT INTO clause is not supported");
        polars_ensure!(lateral_views.is_empty(), SQLInterface: "LATERAL VIEW clause is not supported");
        polars_ensure!(named_window.is_empty(), SQLInterface: "WINDOW clause support is coming soon");
        polars_ensure!(prewhere.is_none(), SQLInterface: "PREWHERE clause is not supported");
        polars_ensure!(qualify.is_none(), SQLInterface: "QUALIFY clause is not currently supported");
        polars_ensure!(sort_by.is_empty(), SQLInterface: "SORT BY clause is not supported; use ORDER BY instead");
        polars_ensure!(top.is_none(), SQLInterface: "TOP clause is not supported; use LIMIT instead");
        polars_ensure!(value_table_mode.is_none(), SQLInterface: "SELECT AS VALUE/STRUCT is not supported");
        Ok(())
    }

    /// Execute the 'SELECT' part of the query.
    fn execute_select(&mut self, select_stmt: &Select, query: &Query) -> PolarsResult<LazyFrame> {
        // Check that the statement doesn't contain unsupported SELECT clauses
        self.validate_select(select_stmt)?;

        let mut lf = if select_stmt.from.is_empty() {
            DataFrame::empty().lazy()
        } else {
            // Note: implicit joins need more work to support properly,
            // explicit joins are preferred for now (ref: #16662)
            let from = select_stmt.clone().from;
            if from.len() > 1 {
                polars_bail!(SQLInterface: "multiple tables in FROM clause are not currently supported (found {}); use explicit JOIN syntax instead", from.len())