Dialects

SQLSpec registers custom sqlglot dialects that extend built-in SQL grammars with extension-specific operators. These dialects enable the builder to parse and generate SQL that uses vendor-specific syntax (e.g., pgvector distance operators, ParadeDB search operators).

Import sqlspec.dialects to ensure all dialects are registered:

import sqlspec.dialects  # registers pgvector, paradedb, spanner, spangres

PostgreSQL Extensions

PGVector

class sqlspec.dialects.postgres.pgvector.PGVector[source]

Bases: Postgres

PostgreSQL dialect with pgvector extension support.

Tokenizer

alias of PGVectorTokenizer

Parser

alias of PGVectorParser

Generator

alias of PGVectorGenerator

SUPPORTS_COLUMN_JOIN_MARKS = False

Whether the old-style outer join (+) syntax is supported.

generator_class

alias of PGVectorGenerator

parser_class

alias of PGVectorParser

tokenizer_class

alias of PGVectorTokenizer

Adds support for pgvector distance operators:

Operator

Description

<->

L2 (Euclidean) distance

<#>

Negative inner product

<=>

Cosine distance

<+>

L1 (Manhattan) distance

<~>

Hamming distance (binary vectors)

<%>

Jaccard distance (binary vectors)

ParadeDB

class sqlspec.dialects.postgres.paradedb.ParadeDB[source]

Bases: PGVector

ParadeDB dialect with pg_search and pgvector extension support.

Tokenizer

alias of ParadeDBTokenizer

Parser

alias of ParadeDBParser

Generator

alias of ParadeDBGenerator

SUPPORTS_COLUMN_JOIN_MARKS = False

Whether the old-style outer join (+) syntax is supported.

generator_class

alias of ParadeDBGenerator

parser_class

alias of ParadeDBParser

tokenizer_class

alias of ParadeDBTokenizer

Extends PGVector with ParadeDB pg_search operators:

Operator

Description

@@@

BM25 full-text search

&&&

Boolean AND search

|||

Boolean OR search

===

Exact term match

###

Score/rank retrieval

##

Snippet/highlight retrieval

##>

Snippet/highlight with options

Spanner

class sqlspec.dialects.spanner.Spanner[source]

Bases: BigQuery

Google Cloud Spanner SQL dialect.

Tokenizer

alias of SpannerTokenizer

Parser

alias of SpannerParser

Generator

alias of SpannerGenerator

SUPPORTS_COLUMN_JOIN_MARKS = False

Whether the old-style outer join (+) syntax is supported.

UNESCAPED_SEQUENCES: t.Dict[str, str] = {'\\\\': '\\', '\\a': '\x07', '\\b': '\x08', '\\f': '\x0c', '\\n': '\n', '\\r': '\r', '\\t': '\t', '\\v': '\x0b'}

Mapping of an escaped sequence (n) to its unescaped version (` `).

generator_class

alias of SpannerGenerator

parser_class

alias of SpannerParser

tokenizer_class

alias of SpannerTokenizer

class sqlspec.dialects.spanner.Spangres[source]

Bases: Postgres

Spanner PostgreSQL-compatible dialect.

Parser

alias of SpangresParser

Generator

alias of SpangresGenerator

SUPPORTS_COLUMN_JOIN_MARKS = False

Whether the old-style outer join (+) syntax is supported.

generator_class

alias of SpangresGenerator

parser_class

alias of SpangresParser

Expression Types

class sqlspec.dialects.postgres.pgvector.VectorDistance[source]

Bases: Binary

Vector distance operation that preserves the original operator.

class sqlspec.dialects.postgres.paradedb.SearchOperator[source]

Bases: Binary

ParadeDB search operation that preserves the original operator.