Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions docs/sql-ref-syntax-qry-select.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,23 @@ select_statement [ { UNION | INTERSECT | EXCEPT } [ ALL | DISTINCT ] select_stat

While `select_statement` is defined as
```sql
SELECT [ hints , ... ] [ ALL | DISTINCT ] { [ [ named_expression | regex_column_names | star ] [ , ... ] | TRANSFORM (...) ] }
SELECT [ hints , ... ] [ ALL | DISTINCT ] { [ [ named_expression | regex_column_names | star_clause ] [ , ... ] | TRANSFORM (...) ] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should do star [ except_clause ] instead of having except_clause inside the star_clause.

Copy link
Contributor Author

@panbingkun panbingkun Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am referring to this doc https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-qry-select.html, as follows:
image
Based on my understanding, I think one possible reason is that EXCEPT cannot exist independently of STAR, which seems to emphasize this relationship.

FROM { from_item [ , ... ] }
[ PIVOT clause ]
[ UNPIVOT clause ]
[ LATERAL VIEW clause ] [ ... ]
[ WHERE boolean_expression ]
[ GROUP BY expression [ , ... ] ]
[ HAVING boolean_expression ]

named_expression
expression [ [ AS ] alias ]

star_clause
[ { table_name | view_name } . ] * [ except_clause ]

except_clause
EXCEPT ( { column_name | field_name } [, ...] )
```

### Parameters
Expand Down Expand Up @@ -76,11 +85,9 @@ SELECT [ hints , ... ] [ ALL | DISTINCT ] { [ [ named_expression | regex_column_

An expression with an assigned name. In general, it denotes a column expression.

**Syntax:** `expression [[AS] alias]`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have already moved this up.


* **star**
* **star_clause**

The `*` (star) clause is used to select all or most columns from one or all relations in a FROM clause.
A shorthand to name all the referenceable columns in the FROM clause or a specific table reference’s columns or fields in the FROM clause.

* **from_item**

Expand Down