Skip to main content
This page is a formal grammar reference for Sync Streams: it shows the syntax the compiler accepts using railroad diagrams. This page complements the Supported SQL guide, which explains in prose what you can write, with examples and restrictions. When to use this page: If you need to check whether a construct is valid, see how rules nest (e.g. subqueries, CTEs, JOINs), or you’re used to grammar specs, use the diagrams and the “Used by” / “References” links to navigate. For most users just getting started, see Supported SQL and Writing Queries.

SelectStatement

SelectStatement syntax diagram References: FromSource, JoinClause, SelectItem, WhereClause

SelectItem

SelectItem syntax diagram References: Expression, Identifier, Reference

Reference

Reference syntax diagram References: Identifier

FromSource

FromSource syntax diagram References: SubquerySource, TableSource, TableValuedSource

TableSource

TableSource syntax diagram References: Identifier, Reference

TableValuedCall

TableValuedCall syntax diagram References: Expression, Identifier

TableValuedSource

TableValuedSource syntax diagram References: Identifier, TableValuedCall

SubquerySource

SubquerySource syntax diagram References: Identifier, Subquery

JoinClause

JoinClause syntax diagram References: FromSource, WhereClause

WhereClause

WhereClause syntax diagram References: Condition

Condition

Condition syntax diagram References: Expression, PredicateTail, WhereClause

PredicateTail

PredicateTail syntax diagram References: Expression, InSource

InSource

InSource syntax diagram References: Expression, Identifier, Subquery

Expression

Expression syntax diagram

Operators

Binary operators supported in scalar expressions, listed from highest to lowest precedence.
PowerSync evaluates all binary operators with equal precedence (left to right). Use parentheses to control evaluation order.
References: PrimaryExpression, PropertyAccess

PropertyAccess

PropertyAccess syntax diagram References: IntegerLiteral, StringLiteral

PrimaryExpression

PrimaryExpression syntax diagram References: CaseExpression, CastExpression, Expression, FunctionCall, NumericLiteral, Reference, StringLiteral

CaseExpression

CaseExpression syntax diagram References: SearchedCase, SimpleCase

SearchedCase

SearchedCase syntax diagram References: Expression, WhenClause

WhenClause

WhenClause syntax diagram References: CaseCondition, Expression, WhenClause

CaseCondition

CaseCondition syntax diagram References: Condition

SimpleCase

SimpleCase syntax diagram References: Expression, WhenValueClause

WhenValueClause

WhenValueClause syntax diagram References: Expression, WhenValueClause

CastExpression

CastExpression syntax diagram References: Expression

FunctionCall

FunctionCall syntax diagram References: Expression, Reference

Subquery

Subquery syntax diagram References: FromSource, JoinClause, SelectItem, WhereClause

CteDefinition

CteDefinition syntax diagram References: Expression, FromSource, Identifier, JoinClause, WhereClause

Lexical Rules

Identifier

Bare identifiers are normalized to lower case and may contain letters, digits, and underscores. Double-quoted identifiers (“name”) allow any printable character and support escaped quotes ("").

StringLiteral

Single-quoted string literal. Embedded single quotes are escaped by doubling them (”).

IntegerLiteral

One or more decimal digits (0-9).

NumericLiteral

Decimal number: one or more digits with an optional fractional part (.digits).