Skip to main content

trino-sql-validator

Fast Trino SQL syntax validator — a Python library whose core is written in Rust and compiled to a native extension via PyO3 + maturin.

Installable from PyPI:

pip install trino-sql-validator

Quickstart

from trino_sql_validator import validate, validate_file

# A string with one or many statements
result = validate("SELECT 1; SELECT * FROM t WHERE a > 0;")
assert result.valid
assert result.statement_count == 2

# Invalid SQL returns a value, never raises
result = validate("SELECT * FORM t")
assert not result.valid
print(result.error)          # e.g. "Expected: end of statement, found: FORM at line 1, column 10"
print(result.error.line)     # 1

# Validate a file
result = validate_file("queries.sql", dialect="trino")

Invalid SQL (and files containing it) is returned as a ValidationResult; it is not raised as an exception. Only genuine misuse (unknown dialect, unreadable file) raises.

Function-name warnings

For dialect="trino", validate() also checks that every function called in the SQL exists in the documented Trino catalog. Unknown names are reported as non-fatal warningsvalid stays True because syntax is fine:

result = validate("SELECT marh(1.5)")      # round() misspelled
assert result.valid
print(result.warnings)                     # (FunctionWarning(name='marh', line=1, column=8),)
print(result.unknown_functions)            # ['marh']

The catalog is auto-generated from the Trino docs and only checks name existence, not argument count or types. hive/generic dialects skip this check.

Dialects

  • "trino" (default) — Trino-flavored with a custom override tuned for Presto/Trino syntax (LIMIT ALL, backslash escapes, etc.).
  • "hive" and "generic" — offered as permissive alternates.

Known limitations

sqlparser-rs (the parser we use) performs syntax validation, not semantic analysis. It may accept SQL that Trino would reject at analysis time (unknown columns/tables, duplicate columns), and it can reject exotic Trino-specific DDL. For the overwhelming majority of SELECT/DDL statements the results are accurate. See plan/roadmap.md for the path toward stricter Trino fidelity.

Development

See AGENTS.md for setup, internal conventions, and release steps. Key commands:

python3 -m venv .venv && source .venv/bin/activate
pip install -U pip maturin && pip install -e ".[dev]"
maturin develop          # build + install native ext into the venv
cargo test               # Rust tests
pytest -q                # Python tests
cargo fmt --check        # formatting
cargo clippy --all-targets -- -D warnings

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trino_sql_validator-0.2.0.tar.gz (28.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

trino_sql_validator-0.2.0-cp310-abi3-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.10+Windows x86-64

trino_sql_validator-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

trino_sql_validator-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.8 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

trino_sql_validator-0.2.0-cp310-abi3-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

trino_sql_validator-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file trino_sql_validator-0.2.0.tar.gz.

File metadata

  • Download URL: trino_sql_validator-0.2.0.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for trino_sql_validator-0.2.0.tar.gz
Algorithm Hash digest
SHA256 17ae35fbcb5a9693286ed9ddc5cf2127d4905ab15da97a2661e8e247cc29fa55
MD5 23de97a2616b2d72930ab69219b36aca
BLAKE2b-256 65fac85a2b32bd4ef822d8ce20508391a199b2302fa7ab37d1a646a45ab608de

See more details on using hashes here.

Provenance

The following attestation bundles were made for trino_sql_validator-0.2.0.tar.gz:

Publisher: release.yml on ivanshamaev/trino-sql-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trino_sql_validator-0.2.0-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for trino_sql_validator-0.2.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2b577a740e30fc9277135ed434eab7c604a8113fe81da678dff3ab65103b5577
MD5 07e75d52ba176804cb08278c0895e99f
BLAKE2b-256 fc0f13d26741d031cae9c068d8ef6b4ad883127ca4fc880554b238308c09d8d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for trino_sql_validator-0.2.0-cp310-abi3-win_amd64.whl:

Publisher: release.yml on ivanshamaev/trino-sql-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trino_sql_validator-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for trino_sql_validator-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 34bbb28e84274c79f3bcfc8e38674b238f133e87e432b68679826c889eac2729
MD5 27f06cf131ce0eccef672019a04f823e
BLAKE2b-256 cec9bd1ea95277d5ec39f7c4063f7f182fbc3bcdb5a02ad83ca5bc5aa80c9712

See more details on using hashes here.

Provenance

The following attestation bundles were made for trino_sql_validator-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on ivanshamaev/trino-sql-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trino_sql_validator-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for trino_sql_validator-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 23bc6c00520e8b63a7c861fc4d24b264b482d810f365228138b6a0c0ec812168
MD5 038b2afdc917a23e90a00ed5482ca13a
BLAKE2b-256 20ee5f2131ec010c7cd10a9306881ff68d56334903bb11d7c7fb3e5435d638bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for trino_sql_validator-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on ivanshamaev/trino-sql-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trino_sql_validator-0.2.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for trino_sql_validator-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2612de96f48423667a80f6357789f4f85c827e48974e05e94dda7ea644354080
MD5 7462bdd77a8a8315a5333ab0a53925c8
BLAKE2b-256 1a7bc749c973f66dabc62ebb04787804740e8f39d98bd64c095d49e1a517df88

See more details on using hashes here.

Provenance

The following attestation bundles were made for trino_sql_validator-0.2.0-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on ivanshamaev/trino-sql-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trino_sql_validator-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for trino_sql_validator-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c604765ea060d60aa03da7e97a99a2c2c79457797932a5e79d5aea14fb114b31
MD5 ae11f9a103e8d3bcc017f83b4d23f609
BLAKE2b-256 8dcc1e2d26d088e0a7c2d1659ee694b7330d0cc6e21c34aa45d7d40299858c57

See more details on using hashes here.

Provenance

The following attestation bundles were made for trino_sql_validator-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on ivanshamaev/trino-sql-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.0 This release

6 files

0.1.0

6 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page