How to read a syntax diagram

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

This section describes the various patterns of syntax used throughout the SQL reference.

Base components

Keyword

SELECT

Keywords in SQL are always capitalized in this document, but they are case insensitive.

Token

( )
<  >
.
*
,

The SQL language includes round braces ((, )) as well as angled braces (<, >), dots (.), commas (,), and a few other characters. When these characters are present in a syntax diagram you must enter them as is.

Clause

LIMIT clause

SELECT named_expression

named_expression
  expression AS alias

A clause represents a named subsection of syntax. A local clause is described in the same syntax diagram that invokes it. If the clause is common, it links to another section of the Databricks SQL reference. Some clauses are known by their main keyword and are depicted with a capital keyword followed by clause. Other clauses are always lower case and use underscore (_) where appropriate. Local clauses are fully explained within the following section. All other clauses have a short description with a link to the main page.

Argument

mapExpr

Arguments to functions are specified in camelCase. Databricks SQL describes the meaning of arguments in the Arguments section.

Chain of tokens

SELECT expr

Components separated by whitespace must be entered in order, unconditionally, and be separated only by whitespace or comments. Databricks SQL supports comments of the form /* ... */ (C-style), and -- ..., which extends to end of the line.

Choice

Specifies a fork in the syntax.

Mandatory choice

{ INT | INTEGER }

Curly braces { ... } mean you must specify exactly one of the multiple components. Each choice is separated by a |.

Optional choice

[ ASC | DESC ]

Square brackets [ ... ] indicate you can choose at most one of multiple components. Each choice is separated by a |.

Grouping

{ SELECT expr }

{ SELECT
 expr }

Curly braces { ... } specify that you must provide all the embedded components. If a syntax diagram spans multiple lines, this form clarifies that it depicts the same syntax.

Option

[ NOT NULL ]

Square brackets [...] specify that the enclosed components are optional.

Repetition

col_option [...]

col_alias [, ...]

{ expr [ AS ] col_alias } [, ...]

The [...] ellipsis notation indicates that you can repeat the immediately preceding component, grouping, or choice multiple times. If the ellipsis is preceded by another character, such as a separated dot [. ...], or a comma [, ...], you must separate each repetition by that character.