trino-sql-validator 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- trino_sql_validator-0.1.0/.github/workflows/ci.yml +61 -0
- trino_sql_validator-0.1.0/.github/workflows/release.yml +115 -0
- trino_sql_validator-0.1.0/.gitignore +25 -0
- trino_sql_validator-0.1.0/AGENTS.md +89 -0
- trino_sql_validator-0.1.0/CHANGELOG.md +25 -0
- trino_sql_validator-0.1.0/Cargo.lock +298 -0
- trino_sql_validator-0.1.0/Cargo.toml +27 -0
- trino_sql_validator-0.1.0/LICENSE +21 -0
- trino_sql_validator-0.1.0/PKG-INFO +97 -0
- trino_sql_validator-0.1.0/README.md +70 -0
- trino_sql_validator-0.1.0/plan/plan.md +307 -0
- trino_sql_validator-0.1.0/plan/roadmap.md +32 -0
- trino_sql_validator-0.1.0/pyproject.toml +48 -0
- trino_sql_validator-0.1.0/python/trino_sql_validator/__init__.py +99 -0
- trino_sql_validator-0.1.0/python/trino_sql_validator/_native.pyi +11 -0
- trino_sql_validator-0.1.0/python/trino_sql_validator/py.typed +0 -0
- trino_sql_validator-0.1.0/rust-toolchain.toml +2 -0
- trino_sql_validator-0.1.0/src/dialects/mod.rs +106 -0
- trino_sql_validator-0.1.0/src/lib.rs +159 -0
- trino_sql_validator-0.1.0/tests/conftest.py +0 -0
- trino_sql_validator-0.1.0/tests/fixtures/ddl_multi.sql +13 -0
- trino_sql_validator-0.1.0/tests/fixtures/empty.sql +2 -0
- trino_sql_validator-0.1.0/tests/fixtures/invalid_one.sql +2 -0
- trino_sql_validator-0.1.0/tests/fixtures/trino_specific.sql +6 -0
- trino_sql_validator-0.1.0/tests/fixtures/valid_multi.sql +4 -0
- trino_sql_validator-0.1.0/tests/test_validator.py +120 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
concurrency:
|
|
9
|
+
group: ci-${{ github.ref }}
|
|
10
|
+
cancel-in-progress: true
|
|
11
|
+
|
|
12
|
+
env:
|
|
13
|
+
CARGO_TERM_COLOR: always
|
|
14
|
+
RUSTFLAGS: -D warnings
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
rust:
|
|
18
|
+
name: Rust ${{ matrix.check }}
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
strategy:
|
|
21
|
+
fail-fast: false
|
|
22
|
+
matrix:
|
|
23
|
+
check: [fmt, clippy, test]
|
|
24
|
+
include:
|
|
25
|
+
- check: fmt
|
|
26
|
+
args: fmt --check
|
|
27
|
+
- check: clippy
|
|
28
|
+
args: clippy --all-targets
|
|
29
|
+
- check: test
|
|
30
|
+
args: test
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
34
|
+
- uses: Swatinem/rust-cache@v2
|
|
35
|
+
- name: ${{ matrix.check }}
|
|
36
|
+
run: cargo ${{ matrix.args }}
|
|
37
|
+
|
|
38
|
+
python:
|
|
39
|
+
name: Python ${{ matrix.python-version }}
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
strategy:
|
|
42
|
+
fail-fast: false
|
|
43
|
+
matrix:
|
|
44
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@v4
|
|
47
|
+
- uses: actions/setup-python@v5
|
|
48
|
+
with:
|
|
49
|
+
python-version: ${{ matrix.python-version }}
|
|
50
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
51
|
+
- uses: Swatinem/rust-cache@v2
|
|
52
|
+
- name: Install build tools
|
|
53
|
+
run: pip install -U pip maturin
|
|
54
|
+
- name: Install package + dev deps (builds native extension)
|
|
55
|
+
run: pip install -e ".[dev]"
|
|
56
|
+
- name: Tests
|
|
57
|
+
run: pytest -q
|
|
58
|
+
- name: Lint (ruff)
|
|
59
|
+
run: ruff check .
|
|
60
|
+
- name: Type check (mypy)
|
|
61
|
+
run: mypy python/trino_sql_validator
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
concurrency:
|
|
8
|
+
group: release-${{ github.ref }}
|
|
9
|
+
cancel-in-progress: true
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
build-sdist:
|
|
16
|
+
name: Source distribution
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
- uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: "3.12"
|
|
23
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
24
|
+
- uses: Swatinem/rust-cache@v2
|
|
25
|
+
- run: pip install -U pip maturin
|
|
26
|
+
- run: maturin sdist --out dist
|
|
27
|
+
- uses: actions/upload-artifact@v4
|
|
28
|
+
with:
|
|
29
|
+
name: sdist
|
|
30
|
+
path: dist/*.tar.gz
|
|
31
|
+
|
|
32
|
+
build-wheels:
|
|
33
|
+
name: Wheels / ${{ matrix.target }}
|
|
34
|
+
runs-on: ${{ matrix.os }}
|
|
35
|
+
strategy:
|
|
36
|
+
fail-fast: false
|
|
37
|
+
matrix:
|
|
38
|
+
include:
|
|
39
|
+
- target: x86_64-unknown-linux-gnu
|
|
40
|
+
os: ubuntu-latest
|
|
41
|
+
manylinux: "2_17"
|
|
42
|
+
architecture: x64
|
|
43
|
+
- target: aarch64-unknown-linux-gnu
|
|
44
|
+
os: ubuntu-latest
|
|
45
|
+
manylinux: "2_17"
|
|
46
|
+
- target: x86_64-apple-darwin
|
|
47
|
+
os: macos-14
|
|
48
|
+
architecture: x64
|
|
49
|
+
- target: aarch64-apple-darwin
|
|
50
|
+
os: macos-14
|
|
51
|
+
architecture: arm64
|
|
52
|
+
- target: x86_64-pc-windows-msvc
|
|
53
|
+
os: windows-latest
|
|
54
|
+
architecture: x64
|
|
55
|
+
steps:
|
|
56
|
+
- uses: actions/checkout@v4
|
|
57
|
+
- uses: actions/setup-python@v5
|
|
58
|
+
with:
|
|
59
|
+
python-version: "3.12"
|
|
60
|
+
architecture: ${{ matrix.architecture }}
|
|
61
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
62
|
+
with:
|
|
63
|
+
targets: ${{ matrix.target }}
|
|
64
|
+
- uses: Swatinem/rust-cache@v2
|
|
65
|
+
- name: Build wheel
|
|
66
|
+
uses: PyO3/maturin-action@v1
|
|
67
|
+
with:
|
|
68
|
+
target: ${{ matrix.target }}
|
|
69
|
+
manylinux: ${{ matrix.manylinux || 'auto' }}
|
|
70
|
+
args: --release --out dist -i 3.12
|
|
71
|
+
- uses: actions/upload-artifact@v4
|
|
72
|
+
with:
|
|
73
|
+
name: wheels-${{ matrix.target }}
|
|
74
|
+
path: dist/*.whl
|
|
75
|
+
|
|
76
|
+
publish:
|
|
77
|
+
name: Publish to PyPI
|
|
78
|
+
needs: [build-sdist, build-wheels]
|
|
79
|
+
runs-on: ubuntu-latest
|
|
80
|
+
environment: release
|
|
81
|
+
permissions:
|
|
82
|
+
id-token: write
|
|
83
|
+
contents: write
|
|
84
|
+
steps:
|
|
85
|
+
- uses: actions/download-artifact@v4
|
|
86
|
+
with:
|
|
87
|
+
path: dist
|
|
88
|
+
merge-multiple: true
|
|
89
|
+
pattern: "{sdist,wheels-*}"
|
|
90
|
+
- name: List artifacts
|
|
91
|
+
run: ls -lh dist/
|
|
92
|
+
- name: Publish to PyPI
|
|
93
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
94
|
+
with:
|
|
95
|
+
attestations: true
|
|
96
|
+
skip-existing: true
|
|
97
|
+
|
|
98
|
+
github-release:
|
|
99
|
+
name: Create GitHub Release
|
|
100
|
+
needs: [build-sdist, build-wheels]
|
|
101
|
+
runs-on: ubuntu-latest
|
|
102
|
+
permissions:
|
|
103
|
+
contents: write
|
|
104
|
+
steps:
|
|
105
|
+
- uses: actions/download-artifact@v4
|
|
106
|
+
with:
|
|
107
|
+
path: dist
|
|
108
|
+
merge-multiple: true
|
|
109
|
+
pattern: "{sdist,wheels-*}"
|
|
110
|
+
- name: Create release
|
|
111
|
+
uses: softprops/action-gh-release@v2
|
|
112
|
+
with:
|
|
113
|
+
files: dist/*
|
|
114
|
+
generate_release_notes: true
|
|
115
|
+
draft: false
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.venv/
|
|
6
|
+
venv/
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
|
|
10
|
+
# Rust
|
|
11
|
+
target/
|
|
12
|
+
|
|
13
|
+
# maturin
|
|
14
|
+
*.so
|
|
15
|
+
|
|
16
|
+
# IDE / OS
|
|
17
|
+
.DS_Store
|
|
18
|
+
.idea/
|
|
19
|
+
.vscode/
|
|
20
|
+
*.swp
|
|
21
|
+
|
|
22
|
+
# Tooling caches
|
|
23
|
+
.ruff_cache
|
|
24
|
+
.mypy_cache
|
|
25
|
+
.pytest_cache
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
Guidance for AI agents and humans working in `trino-sql-validator`.
|
|
4
|
+
|
|
5
|
+
## What this project is
|
|
6
|
+
|
|
7
|
+
A Python library, backed by Rust, that validates Trino SQL syntax.
|
|
8
|
+
Built with PyO3 + maturin. Distributed as wheels + sdist on PyPI.
|
|
9
|
+
|
|
10
|
+
Layout:
|
|
11
|
+
- `src/` — Rust crate (the compiled `_native` extension). `src/lib.rs` holds the
|
|
12
|
+
`#[pymodule] fn _native`. `src/dialects/` holds the `TrinoDialect`/`SqlDialect`.
|
|
13
|
+
- `python/trino_sql_validator/` — pure-Python public API (`__init__.py`), type
|
|
14
|
+
stubs (`_native.pyi`), `py.typed`.
|
|
15
|
+
- `tests/` — pytest suite for the public API (+ `.sql` fixtures).
|
|
16
|
+
- `plan/` — planning docs (`plan.md`, `roadmap.md`).
|
|
17
|
+
|
|
18
|
+
## Source of truth
|
|
19
|
+
|
|
20
|
+
- **Version:** single source of truth is `Cargo.toml` `[package] version`.
|
|
21
|
+
Bump it there; keep `pyproject.toml` `[project]` consistent. Do NOT bump only one.
|
|
22
|
+
- **Public API:** defined once in `python/trino_sql_validator/__init__.py`; mirror
|
|
23
|
+
the native functions via the `#[pyfunction]`s in `src/lib.rs`.
|
|
24
|
+
- **Tools:** Rust stable (see `rust-toolchain.toml`), Python >= 3.9, maturin,
|
|
25
|
+
pytest, ruff, mypy.
|
|
26
|
+
|
|
27
|
+
## Commands
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Set up
|
|
31
|
+
python3 -m venv .venv && source .venv/bin/activate
|
|
32
|
+
pip install -U pip maturin; pip install -e ".[dev]" # installs build+test tooling
|
|
33
|
+
|
|
34
|
+
# Build & install the native extension into the venv (fast dev loop)
|
|
35
|
+
maturin develop
|
|
36
|
+
|
|
37
|
+
# Rust checks
|
|
38
|
+
cargo fmt --check
|
|
39
|
+
cargo clippy --all-targets -- -D warnings
|
|
40
|
+
cargo test
|
|
41
|
+
|
|
42
|
+
# Python checks
|
|
43
|
+
pytest -q
|
|
44
|
+
ruff check .
|
|
45
|
+
mypy python/trino_sql_validator
|
|
46
|
+
|
|
47
|
+
# Produce distributable artifacts
|
|
48
|
+
maturin build --release # wheels
|
|
49
|
+
maturin sdist # source distribution
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Conventions / rules
|
|
53
|
+
|
|
54
|
+
1. **Rust-native only.** Do not introduce a JVM or a subprocess dependency. The
|
|
55
|
+
parser is `sqlparser-rs`; add dialect overrides in `src/dialects/` rather than
|
|
56
|
+
vendoring whole grammars.
|
|
57
|
+
2. **`_native` name is fixed** — `[lib] name = "_native"` in `Cargo.toml` must equal
|
|
58
|
+
the `#[pymodule]` name. Do not rename without updating `pyproject.toml`
|
|
59
|
+
(`module-name = "trino_sql_validator._native"`).
|
|
60
|
+
3. **Do not raise on invalid SQL.** `validate()`/`validate_file()` return a
|
|
61
|
+
`ValidationResult`; the whole design treats bad syntax as a *value*, not an
|
|
62
|
+
exception. Only real programming errors raise.
|
|
63
|
+
4. **Type-preserving Python.** Any function exposed to Python needs a `.pyi` stub
|
|
64
|
+
and a `py.typed` marker. Keep the pure-Python `__init__.py` thin (re-export +
|
|
65
|
+
convenience wrappers only).
|
|
66
|
+
5. **Comment-free Rust unless needed** per opencode style; keep docs in `plan/`
|
|
67
|
+
and doc comments for public API only.
|
|
68
|
+
6. **Keep CI green.** `fmt`, `clippy -D warnings`, `cargo test`, `pytest`, `ruff`,
|
|
69
|
+
`mypy` all must pass before merging. Do not skip clippy lints.
|
|
70
|
+
7. **Testing:** logic tests belong in Rust (`#[cfg(test)]`, `cargo test`), and
|
|
71
|
+
integration tests through the real extension belong in `tests/*.py` (pytest).
|
|
72
|
+
Adding a Python API feature without pytest tests is not done.
|
|
73
|
+
|
|
74
|
+
## CI/CD
|
|
75
|
+
|
|
76
|
+
- `.github/workflows/ci.yml` — fmt/clippy/test/pytest/ruff/mypy on every push & PR.
|
|
77
|
+
- `.github/workflows/release.yml` — builds wheels (manylinux, macOS, Windows) + sdist
|
|
78
|
+
and publishes to PyPI when a tag `v*` is pushed. Uses PyPI **Trusted Publishing**
|
|
79
|
+
(OIDC); no API tokens in constants.
|
|
80
|
+
- To cut a release: bump versions (see "Source of truth"), summarize in
|
|
81
|
+
`CHANGELOG.md`, then `git tag vX.Y.Z && git push origin vX.Y.Z`. Do not push
|
|
82
|
+
releases unless explicitly asked.
|
|
83
|
+
|
|
84
|
+
## Known limitation (keep in mind when working here)
|
|
85
|
+
|
|
86
|
+
`sqlparser-rs` does syntax, not semantics. It accepts some SQL Trino rejects at
|
|
87
|
+
semantic analysis and can reject exotic Trino-specific DDL. This is a documented,
|
|
88
|
+
accepted limitation (see README + plan/roadmap.md). Do not "fix" by loosening the
|
|
89
|
+
dialect to Generic by default for `dialect="trino"`.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-09-06
|
|
9
|
+
|
|
10
|
+
Initial release.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `validate(sql, dialect=...)` — validate a string containing one or more Trino SQL
|
|
15
|
+
statements.
|
|
16
|
+
- `validate_file(path, dialect=...)` — validate a UTF-8 `.sql` file.
|
|
17
|
+
- `ValidationResult` / `Error` result objects: invalid SQL is a value, not an
|
|
18
|
+
exception; errors report message + line/column.
|
|
19
|
+
- Dialects: `trino` (custom `TrinoDialect` refusing backquoted identifiers),
|
|
20
|
+
`hive`, `generic`.
|
|
21
|
+
- Rust core via PyO3 + `sqlparser-rs`: ABI3 wheel for Python >= 3.10.
|
|
22
|
+
- CI (`.github/workflows/ci.yml`): fmt, clippy, Rust + Python tests, ruff, mypy.
|
|
23
|
+
- Release pipeline (`.github/workflows/release.yml`): wheels for Linux
|
|
24
|
+
(x86_64/aarch64 manylinux), macOS (arm64/x86_64), Windows (x86_64) + sdist,
|
|
25
|
+
published to PyPI via Trusted Publishing on tag `v*`.
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 3
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "aho-corasick"
|
|
7
|
+
version = "1.1.5"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"memchr",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[[package]]
|
|
15
|
+
name = "ar_archive_writer"
|
|
16
|
+
version = "0.5.3"
|
|
17
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
18
|
+
checksum = "73cd58deff2140a0a8eae87e417bd01db68a33e148aa93d1e8cd837e55e312b6"
|
|
19
|
+
dependencies = [
|
|
20
|
+
"object",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "cc"
|
|
25
|
+
version = "1.4.5"
|
|
26
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
+
checksum = "005ec2760ca554fae18df7a11195552ec576cd665632a881bc011d5bb2fd4d80"
|
|
28
|
+
dependencies = [
|
|
29
|
+
"find-msvc-tools",
|
|
30
|
+
"shlex",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[[package]]
|
|
34
|
+
name = "cfg-if"
|
|
35
|
+
version = "1.0.4"
|
|
36
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
37
|
+
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
|
38
|
+
|
|
39
|
+
[[package]]
|
|
40
|
+
name = "find-msvc-tools"
|
|
41
|
+
version = "0.1.12"
|
|
42
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
43
|
+
checksum = "3e0f1c7c3a72c66fd80abe965175f7523475c0489a87d3ff9d6e8c87d87a9d2d"
|
|
44
|
+
|
|
45
|
+
[[package]]
|
|
46
|
+
name = "heck"
|
|
47
|
+
version = "0.5.0"
|
|
48
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
49
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
50
|
+
|
|
51
|
+
[[package]]
|
|
52
|
+
name = "libc"
|
|
53
|
+
version = "0.2.189"
|
|
54
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
55
|
+
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
|
56
|
+
|
|
57
|
+
[[package]]
|
|
58
|
+
name = "log"
|
|
59
|
+
version = "0.4.34"
|
|
60
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
61
|
+
checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
|
|
62
|
+
|
|
63
|
+
[[package]]
|
|
64
|
+
name = "memchr"
|
|
65
|
+
version = "2.8.3"
|
|
66
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
67
|
+
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
68
|
+
|
|
69
|
+
[[package]]
|
|
70
|
+
name = "object"
|
|
71
|
+
version = "0.39.1"
|
|
72
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
73
|
+
checksum = "2e5a6c098c7a3b6547378093f5cc30bc54fd361ce711e05293a5cc589562739b"
|
|
74
|
+
dependencies = [
|
|
75
|
+
"memchr",
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
[[package]]
|
|
79
|
+
name = "once_cell"
|
|
80
|
+
version = "1.21.4"
|
|
81
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
82
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
83
|
+
|
|
84
|
+
[[package]]
|
|
85
|
+
name = "portable-atomic"
|
|
86
|
+
version = "1.15.0"
|
|
87
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
88
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
89
|
+
|
|
90
|
+
[[package]]
|
|
91
|
+
name = "proc-macro2"
|
|
92
|
+
version = "1.0.107"
|
|
93
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
94
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
95
|
+
dependencies = [
|
|
96
|
+
"unicode-ident",
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
[[package]]
|
|
100
|
+
name = "psm"
|
|
101
|
+
version = "0.1.32"
|
|
102
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
103
|
+
checksum = "4dcd034599e63b970727f70d79e02d62390a4a84f7c6b827c27c46d5ac3fa622"
|
|
104
|
+
dependencies = [
|
|
105
|
+
"ar_archive_writer",
|
|
106
|
+
"cc",
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
[[package]]
|
|
110
|
+
name = "pyo3"
|
|
111
|
+
version = "0.29.2"
|
|
112
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
113
|
+
checksum = "4688ddedf473e32662b9b067670129a8afb8c18e351482c70d62ba4a88171e8b"
|
|
114
|
+
dependencies = [
|
|
115
|
+
"libc",
|
|
116
|
+
"once_cell",
|
|
117
|
+
"portable-atomic",
|
|
118
|
+
"pyo3-build-config",
|
|
119
|
+
"pyo3-ffi",
|
|
120
|
+
"pyo3-macros",
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
[[package]]
|
|
124
|
+
name = "pyo3-build-config"
|
|
125
|
+
version = "0.29.2"
|
|
126
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
127
|
+
checksum = "f41027e41b4bd03f6e60f9f417fe24a6341a6bb744edd62b6f709f2a52ea30e9"
|
|
128
|
+
dependencies = [
|
|
129
|
+
"target-lexicon",
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
[[package]]
|
|
133
|
+
name = "pyo3-ffi"
|
|
134
|
+
version = "0.29.2"
|
|
135
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
136
|
+
checksum = "e591a95526fead067432c3b3a33fc74770b87b1e04e73671090d9c2055a2b327"
|
|
137
|
+
dependencies = [
|
|
138
|
+
"libc",
|
|
139
|
+
"pyo3-build-config",
|
|
140
|
+
]
|
|
141
|
+
|
|
142
|
+
[[package]]
|
|
143
|
+
name = "pyo3-macros"
|
|
144
|
+
version = "0.29.2"
|
|
145
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
146
|
+
checksum = "73225868fc1cd84eef2c3c230ddb91273bf1de46aeb8a4248da76d32a0924a1c"
|
|
147
|
+
dependencies = [
|
|
148
|
+
"proc-macro2",
|
|
149
|
+
"pyo3-macros-backend",
|
|
150
|
+
"quote",
|
|
151
|
+
"syn",
|
|
152
|
+
]
|
|
153
|
+
|
|
154
|
+
[[package]]
|
|
155
|
+
name = "pyo3-macros-backend"
|
|
156
|
+
version = "0.29.2"
|
|
157
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
158
|
+
checksum = "571575aa3749fa6216757dd47d2a3e7ef360f329a40f0666a9fbd14889024952"
|
|
159
|
+
dependencies = [
|
|
160
|
+
"heck",
|
|
161
|
+
"proc-macro2",
|
|
162
|
+
"quote",
|
|
163
|
+
"syn",
|
|
164
|
+
]
|
|
165
|
+
|
|
166
|
+
[[package]]
|
|
167
|
+
name = "quote"
|
|
168
|
+
version = "1.0.47"
|
|
169
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
170
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
171
|
+
dependencies = [
|
|
172
|
+
"proc-macro2",
|
|
173
|
+
]
|
|
174
|
+
|
|
175
|
+
[[package]]
|
|
176
|
+
name = "recursive"
|
|
177
|
+
version = "0.1.1"
|
|
178
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
179
|
+
checksum = "0786a43debb760f491b1bc0269fe5e84155353c67482b9e60d0cfb596054b43e"
|
|
180
|
+
dependencies = [
|
|
181
|
+
"recursive-proc-macro-impl",
|
|
182
|
+
"stacker",
|
|
183
|
+
]
|
|
184
|
+
|
|
185
|
+
[[package]]
|
|
186
|
+
name = "recursive-proc-macro-impl"
|
|
187
|
+
version = "0.1.1"
|
|
188
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
189
|
+
checksum = "76009fbe0614077fc1a2ce255e3a1881a2e3a3527097d5dc6d8212c585e7e38b"
|
|
190
|
+
dependencies = [
|
|
191
|
+
"quote",
|
|
192
|
+
"syn",
|
|
193
|
+
]
|
|
194
|
+
|
|
195
|
+
[[package]]
|
|
196
|
+
name = "regex"
|
|
197
|
+
version = "1.13.1"
|
|
198
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
199
|
+
checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
|
|
200
|
+
dependencies = [
|
|
201
|
+
"aho-corasick",
|
|
202
|
+
"memchr",
|
|
203
|
+
"regex-automata",
|
|
204
|
+
"regex-syntax",
|
|
205
|
+
]
|
|
206
|
+
|
|
207
|
+
[[package]]
|
|
208
|
+
name = "regex-automata"
|
|
209
|
+
version = "0.4.18"
|
|
210
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
211
|
+
checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
|
|
212
|
+
dependencies = [
|
|
213
|
+
"aho-corasick",
|
|
214
|
+
"memchr",
|
|
215
|
+
"regex-syntax",
|
|
216
|
+
]
|
|
217
|
+
|
|
218
|
+
[[package]]
|
|
219
|
+
name = "regex-syntax"
|
|
220
|
+
version = "0.8.11"
|
|
221
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
222
|
+
checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
|
223
|
+
|
|
224
|
+
[[package]]
|
|
225
|
+
name = "shlex"
|
|
226
|
+
version = "2.0.1"
|
|
227
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
228
|
+
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
|
229
|
+
|
|
230
|
+
[[package]]
|
|
231
|
+
name = "sqlparser"
|
|
232
|
+
version = "0.62.0"
|
|
233
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
234
|
+
checksum = "13c6d1b651dc4edf07eead2a0c6c78016ce971bc2c10da5266861b13f25e7cec"
|
|
235
|
+
dependencies = [
|
|
236
|
+
"log",
|
|
237
|
+
"recursive",
|
|
238
|
+
]
|
|
239
|
+
|
|
240
|
+
[[package]]
|
|
241
|
+
name = "stacker"
|
|
242
|
+
version = "0.1.25"
|
|
243
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
244
|
+
checksum = "707f49d46706bacf8a2b00d51dace3f9de527c13eec3778f570c411f89e69967"
|
|
245
|
+
dependencies = [
|
|
246
|
+
"cc",
|
|
247
|
+
"cfg-if",
|
|
248
|
+
"libc",
|
|
249
|
+
"psm",
|
|
250
|
+
"windows-sys",
|
|
251
|
+
]
|
|
252
|
+
|
|
253
|
+
[[package]]
|
|
254
|
+
name = "syn"
|
|
255
|
+
version = "2.0.119"
|
|
256
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
257
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
258
|
+
dependencies = [
|
|
259
|
+
"proc-macro2",
|
|
260
|
+
"quote",
|
|
261
|
+
"unicode-ident",
|
|
262
|
+
]
|
|
263
|
+
|
|
264
|
+
[[package]]
|
|
265
|
+
name = "target-lexicon"
|
|
266
|
+
version = "0.13.5"
|
|
267
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
268
|
+
checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
|
269
|
+
|
|
270
|
+
[[package]]
|
|
271
|
+
name = "trino-sql-validator"
|
|
272
|
+
version = "0.1.0"
|
|
273
|
+
dependencies = [
|
|
274
|
+
"pyo3",
|
|
275
|
+
"regex",
|
|
276
|
+
"sqlparser",
|
|
277
|
+
]
|
|
278
|
+
|
|
279
|
+
[[package]]
|
|
280
|
+
name = "unicode-ident"
|
|
281
|
+
version = "1.0.24"
|
|
282
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
283
|
+
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
284
|
+
|
|
285
|
+
[[package]]
|
|
286
|
+
name = "windows-link"
|
|
287
|
+
version = "0.2.1"
|
|
288
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
289
|
+
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
|
290
|
+
|
|
291
|
+
[[package]]
|
|
292
|
+
name = "windows-sys"
|
|
293
|
+
version = "0.61.2"
|
|
294
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
295
|
+
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
|
296
|
+
dependencies = [
|
|
297
|
+
"windows-link",
|
|
298
|
+
]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "trino-sql-validator"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
description = "Fast Trino SQL syntax validator — Python library backed by Rust"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
repository = "https://github.com/ivanshamaev/trino-sql-validator"
|
|
9
|
+
keywords = ["trino", "sql", "validator", "pyo3"]
|
|
10
|
+
categories = ["programming-language", "parser-implementations"]
|
|
11
|
+
rust-version = "1.80"
|
|
12
|
+
|
|
13
|
+
[lib]
|
|
14
|
+
name = "_native"
|
|
15
|
+
crate-type = ["cdylib"]
|
|
16
|
+
|
|
17
|
+
[dependencies]
|
|
18
|
+
pyo3 = { version = "0.29", features = ["abi3-py310"] }
|
|
19
|
+
sqlparser = { version = "0.62", default-features = true }
|
|
20
|
+
regex = "1"
|
|
21
|
+
|
|
22
|
+
[dev-dependencies]
|
|
23
|
+
|
|
24
|
+
[profile.release]
|
|
25
|
+
lto = true
|
|
26
|
+
codegen-units = 1
|
|
27
|
+
strip = true
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ivan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|