sqlspec 0.36.0__cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
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.
- ac8f31065839703b4e70__mypyc.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/__init__.py +140 -0
- sqlspec/__main__.py +12 -0
- sqlspec/__metadata__.py +14 -0
- sqlspec/_serialization.py +315 -0
- sqlspec/_typing.py +700 -0
- sqlspec/adapters/__init__.py +0 -0
- sqlspec/adapters/adbc/__init__.py +5 -0
- sqlspec/adapters/adbc/_typing.py +82 -0
- sqlspec/adapters/adbc/adk/__init__.py +5 -0
- sqlspec/adapters/adbc/adk/store.py +1273 -0
- sqlspec/adapters/adbc/config.py +295 -0
- sqlspec/adapters/adbc/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/adbc/core.py +735 -0
- sqlspec/adapters/adbc/data_dictionary.py +334 -0
- sqlspec/adapters/adbc/driver.py +529 -0
- sqlspec/adapters/adbc/events/__init__.py +5 -0
- sqlspec/adapters/adbc/events/store.py +285 -0
- sqlspec/adapters/adbc/litestar/__init__.py +5 -0
- sqlspec/adapters/adbc/litestar/store.py +502 -0
- sqlspec/adapters/adbc/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/adbc/type_converter.py +140 -0
- sqlspec/adapters/aiosqlite/__init__.py +25 -0
- sqlspec/adapters/aiosqlite/_typing.py +82 -0
- sqlspec/adapters/aiosqlite/adk/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/adk/store.py +818 -0
- sqlspec/adapters/aiosqlite/config.py +334 -0
- sqlspec/adapters/aiosqlite/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/aiosqlite/core.py +315 -0
- sqlspec/adapters/aiosqlite/data_dictionary.py +208 -0
- sqlspec/adapters/aiosqlite/driver.py +313 -0
- sqlspec/adapters/aiosqlite/events/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/events/store.py +20 -0
- sqlspec/adapters/aiosqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/litestar/store.py +279 -0
- sqlspec/adapters/aiosqlite/pool.py +533 -0
- sqlspec/adapters/asyncmy/__init__.py +21 -0
- sqlspec/adapters/asyncmy/_typing.py +87 -0
- sqlspec/adapters/asyncmy/adk/__init__.py +5 -0
- sqlspec/adapters/asyncmy/adk/store.py +703 -0
- sqlspec/adapters/asyncmy/config.py +302 -0
- sqlspec/adapters/asyncmy/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/asyncmy/core.py +360 -0
- sqlspec/adapters/asyncmy/data_dictionary.py +124 -0
- sqlspec/adapters/asyncmy/driver.py +383 -0
- sqlspec/adapters/asyncmy/events/__init__.py +5 -0
- sqlspec/adapters/asyncmy/events/store.py +104 -0
- sqlspec/adapters/asyncmy/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncmy/litestar/store.py +296 -0
- sqlspec/adapters/asyncpg/__init__.py +19 -0
- sqlspec/adapters/asyncpg/_typing.py +88 -0
- sqlspec/adapters/asyncpg/adk/__init__.py +5 -0
- sqlspec/adapters/asyncpg/adk/store.py +748 -0
- sqlspec/adapters/asyncpg/config.py +569 -0
- sqlspec/adapters/asyncpg/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/asyncpg/core.py +367 -0
- sqlspec/adapters/asyncpg/data_dictionary.py +162 -0
- sqlspec/adapters/asyncpg/driver.py +487 -0
- sqlspec/adapters/asyncpg/events/__init__.py +6 -0
- sqlspec/adapters/asyncpg/events/backend.py +286 -0
- sqlspec/adapters/asyncpg/events/store.py +40 -0
- sqlspec/adapters/asyncpg/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncpg/litestar/store.py +251 -0
- sqlspec/adapters/bigquery/__init__.py +14 -0
- sqlspec/adapters/bigquery/_typing.py +86 -0
- sqlspec/adapters/bigquery/adk/__init__.py +5 -0
- sqlspec/adapters/bigquery/adk/store.py +827 -0
- sqlspec/adapters/bigquery/config.py +353 -0
- sqlspec/adapters/bigquery/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/bigquery/core.py +715 -0
- sqlspec/adapters/bigquery/data_dictionary.py +128 -0
- sqlspec/adapters/bigquery/driver.py +548 -0
- sqlspec/adapters/bigquery/events/__init__.py +5 -0
- sqlspec/adapters/bigquery/events/store.py +139 -0
- sqlspec/adapters/bigquery/litestar/__init__.py +5 -0
- sqlspec/adapters/bigquery/litestar/store.py +325 -0
- sqlspec/adapters/bigquery/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/bigquery/type_converter.py +107 -0
- sqlspec/adapters/cockroach_asyncpg/__init__.py +24 -0
- sqlspec/adapters/cockroach_asyncpg/_typing.py +72 -0
- sqlspec/adapters/cockroach_asyncpg/adk/__init__.py +3 -0
- sqlspec/adapters/cockroach_asyncpg/adk/store.py +410 -0
- sqlspec/adapters/cockroach_asyncpg/config.py +238 -0
- sqlspec/adapters/cockroach_asyncpg/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/cockroach_asyncpg/core.py +55 -0
- sqlspec/adapters/cockroach_asyncpg/data_dictionary.py +107 -0
- sqlspec/adapters/cockroach_asyncpg/driver.py +144 -0
- sqlspec/adapters/cockroach_asyncpg/events/__init__.py +3 -0
- sqlspec/adapters/cockroach_asyncpg/events/store.py +20 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/__init__.py +3 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/store.py +142 -0
- sqlspec/adapters/cockroach_psycopg/__init__.py +38 -0
- sqlspec/adapters/cockroach_psycopg/_typing.py +129 -0
- sqlspec/adapters/cockroach_psycopg/adk/__init__.py +13 -0
- sqlspec/adapters/cockroach_psycopg/adk/store.py +868 -0
- sqlspec/adapters/cockroach_psycopg/config.py +484 -0
- sqlspec/adapters/cockroach_psycopg/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/cockroach_psycopg/core.py +63 -0
- sqlspec/adapters/cockroach_psycopg/data_dictionary.py +215 -0
- sqlspec/adapters/cockroach_psycopg/driver.py +284 -0
- sqlspec/adapters/cockroach_psycopg/events/__init__.py +6 -0
- sqlspec/adapters/cockroach_psycopg/events/store.py +34 -0
- sqlspec/adapters/cockroach_psycopg/litestar/__init__.py +3 -0
- sqlspec/adapters/cockroach_psycopg/litestar/store.py +325 -0
- sqlspec/adapters/duckdb/__init__.py +25 -0
- sqlspec/adapters/duckdb/_typing.py +81 -0
- sqlspec/adapters/duckdb/adk/__init__.py +14 -0
- sqlspec/adapters/duckdb/adk/store.py +850 -0
- sqlspec/adapters/duckdb/config.py +463 -0
- sqlspec/adapters/duckdb/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/duckdb/core.py +257 -0
- sqlspec/adapters/duckdb/data_dictionary.py +140 -0
- sqlspec/adapters/duckdb/driver.py +430 -0
- sqlspec/adapters/duckdb/events/__init__.py +5 -0
- sqlspec/adapters/duckdb/events/store.py +57 -0
- sqlspec/adapters/duckdb/litestar/__init__.py +5 -0
- sqlspec/adapters/duckdb/litestar/store.py +330 -0
- sqlspec/adapters/duckdb/pool.py +293 -0
- sqlspec/adapters/duckdb/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/duckdb/type_converter.py +118 -0
- sqlspec/adapters/mock/__init__.py +72 -0
- sqlspec/adapters/mock/_typing.py +147 -0
- sqlspec/adapters/mock/config.py +483 -0
- sqlspec/adapters/mock/core.py +319 -0
- sqlspec/adapters/mock/data_dictionary.py +366 -0
- sqlspec/adapters/mock/driver.py +721 -0
- sqlspec/adapters/mysqlconnector/__init__.py +36 -0
- sqlspec/adapters/mysqlconnector/_typing.py +141 -0
- sqlspec/adapters/mysqlconnector/adk/__init__.py +15 -0
- sqlspec/adapters/mysqlconnector/adk/store.py +1060 -0
- sqlspec/adapters/mysqlconnector/config.py +394 -0
- sqlspec/adapters/mysqlconnector/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/mysqlconnector/core.py +303 -0
- sqlspec/adapters/mysqlconnector/data_dictionary.py +235 -0
- sqlspec/adapters/mysqlconnector/driver.py +483 -0
- sqlspec/adapters/mysqlconnector/events/__init__.py +8 -0
- sqlspec/adapters/mysqlconnector/events/store.py +98 -0
- sqlspec/adapters/mysqlconnector/litestar/__init__.py +5 -0
- sqlspec/adapters/mysqlconnector/litestar/store.py +426 -0
- sqlspec/adapters/oracledb/__init__.py +60 -0
- sqlspec/adapters/oracledb/_numpy_handlers.py +141 -0
- sqlspec/adapters/oracledb/_typing.py +182 -0
- sqlspec/adapters/oracledb/_uuid_handlers.py +166 -0
- sqlspec/adapters/oracledb/adk/__init__.py +10 -0
- sqlspec/adapters/oracledb/adk/store.py +2369 -0
- sqlspec/adapters/oracledb/config.py +550 -0
- sqlspec/adapters/oracledb/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/oracledb/core.py +543 -0
- sqlspec/adapters/oracledb/data_dictionary.py +536 -0
- sqlspec/adapters/oracledb/driver.py +1229 -0
- sqlspec/adapters/oracledb/events/__init__.py +16 -0
- sqlspec/adapters/oracledb/events/backend.py +347 -0
- sqlspec/adapters/oracledb/events/store.py +420 -0
- sqlspec/adapters/oracledb/litestar/__init__.py +5 -0
- sqlspec/adapters/oracledb/litestar/store.py +781 -0
- sqlspec/adapters/oracledb/migrations.py +535 -0
- sqlspec/adapters/oracledb/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/oracledb/type_converter.py +211 -0
- sqlspec/adapters/psqlpy/__init__.py +17 -0
- sqlspec/adapters/psqlpy/_typing.py +79 -0
- sqlspec/adapters/psqlpy/adk/__init__.py +5 -0
- sqlspec/adapters/psqlpy/adk/store.py +766 -0
- sqlspec/adapters/psqlpy/config.py +304 -0
- sqlspec/adapters/psqlpy/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/psqlpy/core.py +480 -0
- sqlspec/adapters/psqlpy/data_dictionary.py +126 -0
- sqlspec/adapters/psqlpy/driver.py +438 -0
- sqlspec/adapters/psqlpy/events/__init__.py +6 -0
- sqlspec/adapters/psqlpy/events/backend.py +310 -0
- sqlspec/adapters/psqlpy/events/store.py +20 -0
- sqlspec/adapters/psqlpy/litestar/__init__.py +5 -0
- sqlspec/adapters/psqlpy/litestar/store.py +270 -0
- sqlspec/adapters/psqlpy/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/psqlpy/type_converter.py +113 -0
- sqlspec/adapters/psycopg/__init__.py +32 -0
- sqlspec/adapters/psycopg/_typing.py +164 -0
- sqlspec/adapters/psycopg/adk/__init__.py +10 -0
- sqlspec/adapters/psycopg/adk/store.py +1387 -0
- sqlspec/adapters/psycopg/config.py +576 -0
- sqlspec/adapters/psycopg/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/psycopg/core.py +450 -0
- sqlspec/adapters/psycopg/data_dictionary.py +289 -0
- sqlspec/adapters/psycopg/driver.py +975 -0
- sqlspec/adapters/psycopg/events/__init__.py +20 -0
- sqlspec/adapters/psycopg/events/backend.py +458 -0
- sqlspec/adapters/psycopg/events/store.py +42 -0
- sqlspec/adapters/psycopg/litestar/__init__.py +5 -0
- sqlspec/adapters/psycopg/litestar/store.py +552 -0
- sqlspec/adapters/psycopg/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/psycopg/type_converter.py +93 -0
- sqlspec/adapters/pymysql/__init__.py +21 -0
- sqlspec/adapters/pymysql/_typing.py +71 -0
- sqlspec/adapters/pymysql/adk/__init__.py +5 -0
- sqlspec/adapters/pymysql/adk/store.py +540 -0
- sqlspec/adapters/pymysql/config.py +195 -0
- sqlspec/adapters/pymysql/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/pymysql/core.py +299 -0
- sqlspec/adapters/pymysql/data_dictionary.py +122 -0
- sqlspec/adapters/pymysql/driver.py +259 -0
- sqlspec/adapters/pymysql/events/__init__.py +5 -0
- sqlspec/adapters/pymysql/events/store.py +50 -0
- sqlspec/adapters/pymysql/litestar/__init__.py +5 -0
- sqlspec/adapters/pymysql/litestar/store.py +232 -0
- sqlspec/adapters/pymysql/pool.py +137 -0
- sqlspec/adapters/spanner/__init__.py +40 -0
- sqlspec/adapters/spanner/_typing.py +86 -0
- sqlspec/adapters/spanner/adk/__init__.py +5 -0
- sqlspec/adapters/spanner/adk/store.py +732 -0
- sqlspec/adapters/spanner/config.py +352 -0
- sqlspec/adapters/spanner/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/spanner/core.py +188 -0
- sqlspec/adapters/spanner/data_dictionary.py +120 -0
- sqlspec/adapters/spanner/dialect/__init__.py +6 -0
- sqlspec/adapters/spanner/dialect/_spangres.py +57 -0
- sqlspec/adapters/spanner/dialect/_spanner.py +130 -0
- sqlspec/adapters/spanner/driver.py +373 -0
- sqlspec/adapters/spanner/events/__init__.py +5 -0
- sqlspec/adapters/spanner/events/store.py +187 -0
- sqlspec/adapters/spanner/litestar/__init__.py +5 -0
- sqlspec/adapters/spanner/litestar/store.py +291 -0
- sqlspec/adapters/spanner/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/spanner/type_converter.py +331 -0
- sqlspec/adapters/sqlite/__init__.py +19 -0
- sqlspec/adapters/sqlite/_typing.py +80 -0
- sqlspec/adapters/sqlite/adk/__init__.py +5 -0
- sqlspec/adapters/sqlite/adk/store.py +958 -0
- sqlspec/adapters/sqlite/config.py +280 -0
- sqlspec/adapters/sqlite/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/sqlite/core.py +312 -0
- sqlspec/adapters/sqlite/data_dictionary.py +202 -0
- sqlspec/adapters/sqlite/driver.py +359 -0
- sqlspec/adapters/sqlite/events/__init__.py +5 -0
- sqlspec/adapters/sqlite/events/store.py +20 -0
- sqlspec/adapters/sqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/sqlite/litestar/store.py +316 -0
- sqlspec/adapters/sqlite/pool.py +198 -0
- sqlspec/adapters/sqlite/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/sqlite/type_converter.py +114 -0
- sqlspec/base.py +747 -0
- sqlspec/builder/__init__.py +179 -0
- sqlspec/builder/_base.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_base.py +1022 -0
- sqlspec/builder/_column.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_column.py +521 -0
- sqlspec/builder/_ddl.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_ddl.py +1642 -0
- sqlspec/builder/_delete.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_delete.py +95 -0
- sqlspec/builder/_dml.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_dml.py +365 -0
- sqlspec/builder/_explain.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_explain.py +579 -0
- sqlspec/builder/_expression_wrappers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_expression_wrappers.py +46 -0
- sqlspec/builder/_factory.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_factory.py +1697 -0
- sqlspec/builder/_insert.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_insert.py +328 -0
- sqlspec/builder/_join.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_join.py +499 -0
- sqlspec/builder/_merge.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_merge.py +821 -0
- sqlspec/builder/_parsing_utils.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_parsing_utils.py +297 -0
- sqlspec/builder/_select.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_select.py +1660 -0
- sqlspec/builder/_temporal.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_temporal.py +139 -0
- sqlspec/builder/_update.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_update.py +173 -0
- sqlspec/builder/_vector_expressions.py +267 -0
- sqlspec/cli.py +911 -0
- sqlspec/config.py +1755 -0
- sqlspec/core/__init__.py +374 -0
- sqlspec/core/_correlation.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/_correlation.py +176 -0
- sqlspec/core/cache.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/cache.py +1069 -0
- sqlspec/core/compiler.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/compiler.py +954 -0
- sqlspec/core/explain.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/explain.py +275 -0
- sqlspec/core/filters.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/filters.py +952 -0
- sqlspec/core/hashing.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/hashing.py +262 -0
- sqlspec/core/metrics.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/metrics.py +83 -0
- sqlspec/core/parameters/__init__.py +71 -0
- sqlspec/core/parameters/_alignment.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_alignment.py +270 -0
- sqlspec/core/parameters/_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_converter.py +543 -0
- sqlspec/core/parameters/_processor.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_processor.py +505 -0
- sqlspec/core/parameters/_registry.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_registry.py +206 -0
- sqlspec/core/parameters/_transformers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_transformers.py +292 -0
- sqlspec/core/parameters/_types.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_types.py +499 -0
- sqlspec/core/parameters/_validator.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_validator.py +180 -0
- sqlspec/core/pipeline.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/pipeline.py +319 -0
- sqlspec/core/query_modifiers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/query_modifiers.py +437 -0
- sqlspec/core/result/__init__.py +23 -0
- sqlspec/core/result/_base.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/result/_base.py +1121 -0
- sqlspec/core/result/_io.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/result/_io.py +28 -0
- sqlspec/core/splitter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/splitter.py +966 -0
- sqlspec/core/stack.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/stack.py +163 -0
- sqlspec/core/statement.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/statement.py +1503 -0
- sqlspec/core/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/type_converter.py +339 -0
- sqlspec/data_dictionary/__init__.py +22 -0
- sqlspec/data_dictionary/_loader.py +123 -0
- sqlspec/data_dictionary/_registry.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/_registry.py +74 -0
- sqlspec/data_dictionary/_types.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/_types.py +121 -0
- sqlspec/data_dictionary/dialects/__init__.py +21 -0
- sqlspec/data_dictionary/dialects/bigquery.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/bigquery.py +49 -0
- sqlspec/data_dictionary/dialects/cockroachdb.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/cockroachdb.py +43 -0
- sqlspec/data_dictionary/dialects/duckdb.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/duckdb.py +47 -0
- sqlspec/data_dictionary/dialects/mysql.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/mysql.py +42 -0
- sqlspec/data_dictionary/dialects/oracle.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/oracle.py +34 -0
- sqlspec/data_dictionary/dialects/postgres.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/postgres.py +46 -0
- sqlspec/data_dictionary/dialects/spanner.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/spanner.py +37 -0
- sqlspec/data_dictionary/dialects/sqlite.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/sqlite.py +42 -0
- sqlspec/data_dictionary/sql/.gitkeep +0 -0
- sqlspec/data_dictionary/sql/bigquery/columns.sql +23 -0
- sqlspec/data_dictionary/sql/bigquery/foreign_keys.sql +34 -0
- sqlspec/data_dictionary/sql/bigquery/indexes.sql +19 -0
- sqlspec/data_dictionary/sql/bigquery/tables.sql +33 -0
- sqlspec/data_dictionary/sql/bigquery/version.sql +3 -0
- sqlspec/data_dictionary/sql/cockroachdb/columns.sql +34 -0
- sqlspec/data_dictionary/sql/cockroachdb/foreign_keys.sql +40 -0
- sqlspec/data_dictionary/sql/cockroachdb/indexes.sql +32 -0
- sqlspec/data_dictionary/sql/cockroachdb/tables.sql +44 -0
- sqlspec/data_dictionary/sql/cockroachdb/version.sql +3 -0
- sqlspec/data_dictionary/sql/duckdb/columns.sql +23 -0
- sqlspec/data_dictionary/sql/duckdb/foreign_keys.sql +36 -0
- sqlspec/data_dictionary/sql/duckdb/indexes.sql +19 -0
- sqlspec/data_dictionary/sql/duckdb/tables.sql +38 -0
- sqlspec/data_dictionary/sql/duckdb/version.sql +3 -0
- sqlspec/data_dictionary/sql/mysql/columns.sql +23 -0
- sqlspec/data_dictionary/sql/mysql/foreign_keys.sql +28 -0
- sqlspec/data_dictionary/sql/mysql/indexes.sql +26 -0
- sqlspec/data_dictionary/sql/mysql/tables.sql +33 -0
- sqlspec/data_dictionary/sql/mysql/version.sql +3 -0
- sqlspec/data_dictionary/sql/oracle/columns.sql +23 -0
- sqlspec/data_dictionary/sql/oracle/foreign_keys.sql +48 -0
- sqlspec/data_dictionary/sql/oracle/indexes.sql +44 -0
- sqlspec/data_dictionary/sql/oracle/tables.sql +25 -0
- sqlspec/data_dictionary/sql/oracle/version.sql +20 -0
- sqlspec/data_dictionary/sql/postgres/columns.sql +34 -0
- sqlspec/data_dictionary/sql/postgres/foreign_keys.sql +40 -0
- sqlspec/data_dictionary/sql/postgres/indexes.sql +56 -0
- sqlspec/data_dictionary/sql/postgres/tables.sql +44 -0
- sqlspec/data_dictionary/sql/postgres/version.sql +3 -0
- sqlspec/data_dictionary/sql/spanner/columns.sql +23 -0
- sqlspec/data_dictionary/sql/spanner/foreign_keys.sql +70 -0
- sqlspec/data_dictionary/sql/spanner/indexes.sql +30 -0
- sqlspec/data_dictionary/sql/spanner/tables.sql +9 -0
- sqlspec/data_dictionary/sql/spanner/version.sql +3 -0
- sqlspec/data_dictionary/sql/sqlite/columns.sql +23 -0
- sqlspec/data_dictionary/sql/sqlite/foreign_keys.sql +22 -0
- sqlspec/data_dictionary/sql/sqlite/indexes.sql +7 -0
- sqlspec/data_dictionary/sql/sqlite/tables.sql +28 -0
- sqlspec/data_dictionary/sql/sqlite/version.sql +3 -0
- sqlspec/driver/__init__.py +32 -0
- sqlspec/driver/_async.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/driver/_async.py +1737 -0
- sqlspec/driver/_common.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/driver/_common.py +1478 -0
- sqlspec/driver/_sql_helpers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/driver/_sql_helpers.py +148 -0
- sqlspec/driver/_storage_helpers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/driver/_storage_helpers.py +144 -0
- sqlspec/driver/_sync.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/driver/_sync.py +1710 -0
- sqlspec/exceptions.py +338 -0
- sqlspec/extensions/__init__.py +0 -0
- sqlspec/extensions/adk/__init__.py +70 -0
- sqlspec/extensions/adk/_types.py +51 -0
- sqlspec/extensions/adk/converters.py +172 -0
- sqlspec/extensions/adk/memory/__init__.py +69 -0
- sqlspec/extensions/adk/memory/_types.py +30 -0
- sqlspec/extensions/adk/memory/converters.py +149 -0
- sqlspec/extensions/adk/memory/service.py +217 -0
- sqlspec/extensions/adk/memory/store.py +569 -0
- sqlspec/extensions/adk/migrations/0001_create_adk_tables.py +246 -0
- sqlspec/extensions/adk/migrations/__init__.py +0 -0
- sqlspec/extensions/adk/service.py +225 -0
- sqlspec/extensions/adk/store.py +567 -0
- sqlspec/extensions/events/__init__.py +51 -0
- sqlspec/extensions/events/_channel.py +703 -0
- sqlspec/extensions/events/_hints.py +45 -0
- sqlspec/extensions/events/_models.py +23 -0
- sqlspec/extensions/events/_payload.py +69 -0
- sqlspec/extensions/events/_protocols.py +134 -0
- sqlspec/extensions/events/_queue.py +461 -0
- sqlspec/extensions/events/_store.py +209 -0
- sqlspec/extensions/events/migrations/0001_create_event_queue.py +59 -0
- sqlspec/extensions/events/migrations/__init__.py +3 -0
- sqlspec/extensions/fastapi/__init__.py +19 -0
- sqlspec/extensions/fastapi/extension.py +351 -0
- sqlspec/extensions/fastapi/providers.py +607 -0
- sqlspec/extensions/flask/__init__.py +37 -0
- sqlspec/extensions/flask/_state.py +76 -0
- sqlspec/extensions/flask/_utils.py +71 -0
- sqlspec/extensions/flask/extension.py +519 -0
- sqlspec/extensions/litestar/__init__.py +28 -0
- sqlspec/extensions/litestar/_utils.py +52 -0
- sqlspec/extensions/litestar/channels.py +165 -0
- sqlspec/extensions/litestar/cli.py +102 -0
- sqlspec/extensions/litestar/config.py +90 -0
- sqlspec/extensions/litestar/handlers.py +316 -0
- sqlspec/extensions/litestar/migrations/0001_create_session_table.py +137 -0
- sqlspec/extensions/litestar/migrations/__init__.py +3 -0
- sqlspec/extensions/litestar/plugin.py +671 -0
- sqlspec/extensions/litestar/providers.py +526 -0
- sqlspec/extensions/litestar/store.py +296 -0
- sqlspec/extensions/otel/__init__.py +58 -0
- sqlspec/extensions/prometheus/__init__.py +113 -0
- sqlspec/extensions/starlette/__init__.py +19 -0
- sqlspec/extensions/starlette/_state.py +30 -0
- sqlspec/extensions/starlette/_utils.py +96 -0
- sqlspec/extensions/starlette/extension.py +346 -0
- sqlspec/extensions/starlette/middleware.py +235 -0
- sqlspec/loader.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/loader.py +702 -0
- sqlspec/migrations/__init__.py +36 -0
- sqlspec/migrations/base.py +731 -0
- sqlspec/migrations/commands.py +1232 -0
- sqlspec/migrations/context.py +157 -0
- sqlspec/migrations/fix.py +204 -0
- sqlspec/migrations/loaders.py +443 -0
- sqlspec/migrations/runner.py +1172 -0
- sqlspec/migrations/templates.py +234 -0
- sqlspec/migrations/tracker.py +611 -0
- sqlspec/migrations/utils.py +256 -0
- sqlspec/migrations/validation.py +207 -0
- sqlspec/migrations/version.py +446 -0
- sqlspec/observability/__init__.py +55 -0
- sqlspec/observability/_common.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_common.py +77 -0
- sqlspec/observability/_config.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_config.py +348 -0
- sqlspec/observability/_diagnostics.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_diagnostics.py +74 -0
- sqlspec/observability/_dispatcher.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_dispatcher.py +152 -0
- sqlspec/observability/_formatters/__init__.py +13 -0
- sqlspec/observability/_formatters/_aws.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_formatters/_aws.py +102 -0
- sqlspec/observability/_formatters/_azure.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_formatters/_azure.py +96 -0
- sqlspec/observability/_formatters/_base.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_formatters/_base.py +57 -0
- sqlspec/observability/_formatters/_gcp.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_formatters/_gcp.py +131 -0
- sqlspec/observability/_formatting.py +58 -0
- sqlspec/observability/_observer.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_observer.py +357 -0
- sqlspec/observability/_runtime.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_runtime.py +420 -0
- sqlspec/observability/_sampling.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_sampling.py +188 -0
- sqlspec/observability/_spans.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_spans.py +161 -0
- sqlspec/protocols.py +916 -0
- sqlspec/py.typed +0 -0
- sqlspec/storage/__init__.py +48 -0
- sqlspec/storage/_utils.py +104 -0
- sqlspec/storage/backends/__init__.py +1 -0
- sqlspec/storage/backends/base.py +253 -0
- sqlspec/storage/backends/fsspec.py +529 -0
- sqlspec/storage/backends/local.py +441 -0
- sqlspec/storage/backends/obstore.py +916 -0
- sqlspec/storage/errors.py +104 -0
- sqlspec/storage/pipeline.py +582 -0
- sqlspec/storage/registry.py +301 -0
- sqlspec/typing.py +395 -0
- sqlspec/utils/__init__.py +7 -0
- sqlspec/utils/arrow_helpers.py +318 -0
- sqlspec/utils/config_tools.py +332 -0
- sqlspec/utils/correlation.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/correlation.py +134 -0
- sqlspec/utils/deprecation.py +190 -0
- sqlspec/utils/fixtures.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/fixtures.py +258 -0
- sqlspec/utils/logging.py +222 -0
- sqlspec/utils/module_loader.py +306 -0
- sqlspec/utils/portal.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/portal.py +375 -0
- sqlspec/utils/schema.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/schema.py +485 -0
- sqlspec/utils/serializers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/serializers.py +408 -0
- sqlspec/utils/singleton.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/singleton.py +41 -0
- sqlspec/utils/sync_tools.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/sync_tools.py +311 -0
- sqlspec/utils/text.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/text.py +108 -0
- sqlspec/utils/type_converters.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/type_converters.py +128 -0
- sqlspec/utils/type_guards.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/type_guards.py +1360 -0
- sqlspec/utils/uuids.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/uuids.py +225 -0
- sqlspec-0.36.0.dist-info/METADATA +205 -0
- sqlspec-0.36.0.dist-info/RECORD +531 -0
- sqlspec-0.36.0.dist-info/WHEEL +7 -0
- sqlspec-0.36.0.dist-info/entry_points.txt +2 -0
- sqlspec-0.36.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
r"""Google Cloud Spanner PostgreSQL-interface dialect ("Spangres")."""
|
|
2
|
+
|
|
3
|
+
from typing import cast
|
|
4
|
+
|
|
5
|
+
from sqlglot import exp
|
|
6
|
+
from sqlglot.dialects.postgres import Postgres
|
|
7
|
+
from sqlglot.tokens import TokenType
|
|
8
|
+
|
|
9
|
+
__all__ = ("Spangres",)
|
|
10
|
+
|
|
11
|
+
_ROW_DELETION_NAME = "ROW_DELETION_POLICY"
|
|
12
|
+
_TTL_MIN_COMPONENTS = 2
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class SpangresParser(Postgres.Parser):
|
|
16
|
+
"""Parse Spanner row deletion policies."""
|
|
17
|
+
|
|
18
|
+
def _parse_property(self) -> exp.Expression:
|
|
19
|
+
if self._match_text_seq("ROW", "DELETION", "POLICY"): # type: ignore[no-untyped-call]
|
|
20
|
+
self._match(TokenType.L_PAREN) # type: ignore[no-untyped-call]
|
|
21
|
+
self._match_text_seq("OLDER_THAN") # type: ignore[no-untyped-call]
|
|
22
|
+
self._match(TokenType.L_PAREN) # type: ignore[no-untyped-call]
|
|
23
|
+
column = cast("exp.Expression", self._parse_id_var())
|
|
24
|
+
self._match(TokenType.COMMA) # type: ignore[no-untyped-call]
|
|
25
|
+
self._match_text_seq("INTERVAL") # type: ignore[no-untyped-call]
|
|
26
|
+
interval = cast("exp.Expression", self._parse_expression())
|
|
27
|
+
self._match(TokenType.R_PAREN) # type: ignore[no-untyped-call]
|
|
28
|
+
self._match(TokenType.R_PAREN) # type: ignore[no-untyped-call]
|
|
29
|
+
|
|
30
|
+
return exp.Property(
|
|
31
|
+
this=exp.Literal.string(_ROW_DELETION_NAME), value=exp.Tuple(expressions=[column, interval])
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
return cast("exp.Expression", super()._parse_property())
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class SpangresGenerator(Postgres.Generator):
|
|
38
|
+
"""Generate Spanner row deletion policies."""
|
|
39
|
+
|
|
40
|
+
def property_sql(self, expression: exp.Property) -> str:
|
|
41
|
+
if isinstance(expression.this, exp.Literal) and expression.this.name.upper() == _ROW_DELETION_NAME:
|
|
42
|
+
values = expression.args.get("value")
|
|
43
|
+
if isinstance(values, exp.Tuple) and len(values.expressions) >= _TTL_MIN_COMPONENTS:
|
|
44
|
+
column = self.sql(values.expressions[0])
|
|
45
|
+
interval_sql = self.sql(values.expressions[1])
|
|
46
|
+
if not interval_sql.upper().startswith("INTERVAL"):
|
|
47
|
+
interval_sql = f"INTERVAL {interval_sql}"
|
|
48
|
+
return f"ROW DELETION POLICY (OLDER_THAN({column}, {interval_sql}))"
|
|
49
|
+
|
|
50
|
+
return super().property_sql(expression)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class Spangres(Postgres):
|
|
54
|
+
"""Spanner PostgreSQL-compatible dialect."""
|
|
55
|
+
|
|
56
|
+
Parser = SpangresParser
|
|
57
|
+
Generator = SpangresGenerator
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"""Google Cloud Spanner SQL dialect (GoogleSQL variant).
|
|
2
|
+
|
|
3
|
+
Extends the BigQuery dialect with Spanner-only DDL features:
|
|
4
|
+
`INTERLEAVE IN PARENT` for interleaved tables and `ROW DELETION POLICY`
|
|
5
|
+
for row-level time-to-live policies (GoogleSQL).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import cast
|
|
9
|
+
|
|
10
|
+
from sqlglot import exp
|
|
11
|
+
from sqlglot.dialects.bigquery import BigQuery
|
|
12
|
+
from sqlglot.tokens import TokenType
|
|
13
|
+
|
|
14
|
+
__all__ = ("Spanner",)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
_SPANNER_KEYWORDS: "dict[str, TokenType]" = {}
|
|
18
|
+
interleave_token = cast("TokenType | None", TokenType.__dict__.get("INTERLEAVE"))
|
|
19
|
+
if interleave_token is not None:
|
|
20
|
+
_SPANNER_KEYWORDS["INTERLEAVE"] = interleave_token
|
|
21
|
+
ttl_token = cast("TokenType | None", TokenType.__dict__.get("TTL"))
|
|
22
|
+
if ttl_token is not None:
|
|
23
|
+
_SPANNER_KEYWORDS["TTL"] = ttl_token
|
|
24
|
+
|
|
25
|
+
_TTL_MIN_COMPONENTS = 2
|
|
26
|
+
_ROW_DELETION_NAME = "ROW_DELETION_POLICY"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class SpannerTokenizer(BigQuery.Tokenizer):
|
|
30
|
+
"""Tokenizer adds Spanner-only keywords when supported by sqlglot."""
|
|
31
|
+
|
|
32
|
+
KEYWORDS = {**BigQuery.Tokenizer.KEYWORDS, **_SPANNER_KEYWORDS}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class SpannerParser(BigQuery.Parser):
|
|
36
|
+
"""Parse Spanner extensions such as INTERLEAVE and row deletion policies."""
|
|
37
|
+
|
|
38
|
+
def _parse_table_parts(
|
|
39
|
+
self, schema: "bool" = False, is_db_reference: "bool" = False, wildcard: "bool" = False
|
|
40
|
+
) -> exp.Table:
|
|
41
|
+
"""Parse Spanner table options including interleaving metadata."""
|
|
42
|
+
table = super()._parse_table_parts(schema=schema, is_db_reference=is_db_reference, wildcard=wildcard)
|
|
43
|
+
|
|
44
|
+
if self._match_text_seq("INTERLEAVE", "IN", "PARENT"): # type: ignore[no-untyped-call]
|
|
45
|
+
parent = cast("exp.Expression", self._parse_table(schema=True, is_db_reference=True))
|
|
46
|
+
on_delete: str | None = None
|
|
47
|
+
|
|
48
|
+
if self._match_text_seq("ON", "DELETE"): # type: ignore[no-untyped-call]
|
|
49
|
+
if self._match_text_seq("CASCADE"): # type: ignore[no-untyped-call]
|
|
50
|
+
on_delete = "CASCADE"
|
|
51
|
+
elif self._match_text_seq("NO", "ACTION"): # type: ignore[no-untyped-call]
|
|
52
|
+
on_delete = "NO ACTION"
|
|
53
|
+
|
|
54
|
+
table.set("interleave_parent", parent)
|
|
55
|
+
if on_delete:
|
|
56
|
+
table.set("interleave_on_delete", on_delete)
|
|
57
|
+
|
|
58
|
+
return table
|
|
59
|
+
|
|
60
|
+
def _parse_property(self) -> exp.Expression:
|
|
61
|
+
"""Parse Spanner row deletion policy or PostgreSQL-style TTL."""
|
|
62
|
+
if self._match_text_seq("ROW", "DELETION", "POLICY"): # type: ignore[no-untyped-call]
|
|
63
|
+
self._match(TokenType.L_PAREN) # type: ignore[no-untyped-call]
|
|
64
|
+
self._match_text_seq("OLDER_THAN") # type: ignore[no-untyped-call]
|
|
65
|
+
self._match(TokenType.L_PAREN) # type: ignore[no-untyped-call]
|
|
66
|
+
column = cast("exp.Expression", self._parse_id_var())
|
|
67
|
+
self._match(TokenType.COMMA) # type: ignore[no-untyped-call]
|
|
68
|
+
self._match_text_seq("INTERVAL") # type: ignore[no-untyped-call]
|
|
69
|
+
interval = cast("exp.Expression", self._parse_expression())
|
|
70
|
+
self._match(TokenType.R_PAREN) # type: ignore[no-untyped-call]
|
|
71
|
+
self._match(TokenType.R_PAREN) # type: ignore[no-untyped-call]
|
|
72
|
+
|
|
73
|
+
return exp.Property(
|
|
74
|
+
this=exp.Literal.string(_ROW_DELETION_NAME), value=exp.Tuple(expressions=[column, interval])
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
if self._match_text_seq("TTL"): # type: ignore[no-untyped-call] # PostgreSQL-dialect style, keep for compatibility
|
|
78
|
+
self._match_text_seq("INTERVAL") # type: ignore[no-untyped-call]
|
|
79
|
+
interval = cast("exp.Expression", self._parse_expression())
|
|
80
|
+
self._match_text_seq("ON") # type: ignore[no-untyped-call]
|
|
81
|
+
column = cast("exp.Expression", self._parse_id_var())
|
|
82
|
+
|
|
83
|
+
return exp.Property(this=exp.Literal.string("TTL"), value=exp.Tuple(expressions=[interval, column]))
|
|
84
|
+
|
|
85
|
+
return cast("exp.Expression", super()._parse_property())
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class SpannerGenerator(BigQuery.Generator):
|
|
89
|
+
"""Generate Spanner-specific DDL syntax."""
|
|
90
|
+
|
|
91
|
+
def table_sql(self, expression: exp.Table, sep: str = " ") -> str:
|
|
92
|
+
"""Render INTERLEAVE clause when present on a table expression."""
|
|
93
|
+
sql = super().table_sql(expression, sep=sep)
|
|
94
|
+
|
|
95
|
+
parent = expression.args.get("interleave_parent")
|
|
96
|
+
if parent:
|
|
97
|
+
sql = f"{sql}\nINTERLEAVE IN PARENT {self.sql(parent)}"
|
|
98
|
+
on_delete = expression.args.get("interleave_on_delete")
|
|
99
|
+
if on_delete:
|
|
100
|
+
sql = f"{sql} ON DELETE {on_delete}"
|
|
101
|
+
|
|
102
|
+
return sql
|
|
103
|
+
|
|
104
|
+
def property_sql(self, expression: exp.Property) -> str:
|
|
105
|
+
"""Render row deletion policy or TTL."""
|
|
106
|
+
if isinstance(expression.this, exp.Literal) and expression.this.name.upper() == _ROW_DELETION_NAME:
|
|
107
|
+
values = expression.args.get("value")
|
|
108
|
+
if isinstance(values, exp.Tuple) and len(values.expressions) >= _TTL_MIN_COMPONENTS:
|
|
109
|
+
column = self.sql(values.expressions[0])
|
|
110
|
+
interval_sql = self.sql(values.expressions[1])
|
|
111
|
+
if not interval_sql.upper().startswith("INTERVAL"):
|
|
112
|
+
interval_sql = f"INTERVAL {interval_sql}"
|
|
113
|
+
return f"ROW DELETION POLICY (OLDER_THAN({column}, {interval_sql}))"
|
|
114
|
+
|
|
115
|
+
if isinstance(expression.this, exp.Literal) and expression.this.name.upper() == "TTL":
|
|
116
|
+
values = expression.args.get("value")
|
|
117
|
+
if isinstance(values, exp.Tuple) and len(values.expressions) >= _TTL_MIN_COMPONENTS:
|
|
118
|
+
interval = self.sql(values.expressions[0])
|
|
119
|
+
column = self.sql(values.expressions[1])
|
|
120
|
+
return f"TTL INTERVAL {interval} ON {column}"
|
|
121
|
+
|
|
122
|
+
return super().property_sql(expression)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class Spanner(BigQuery):
|
|
126
|
+
"""Google Cloud Spanner SQL dialect."""
|
|
127
|
+
|
|
128
|
+
Tokenizer = SpannerTokenizer
|
|
129
|
+
Parser = SpannerParser
|
|
130
|
+
Generator = SpannerGenerator
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
"""Spanner driver implementation."""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Iterator
|
|
4
|
+
from typing import TYPE_CHECKING, Any, Protocol, cast
|
|
5
|
+
|
|
6
|
+
from google.api_core import exceptions as api_exceptions
|
|
7
|
+
from google.cloud.spanner_v1.transaction import Transaction
|
|
8
|
+
|
|
9
|
+
from sqlspec.adapters.spanner._typing import SpannerSessionContext
|
|
10
|
+
from sqlspec.adapters.spanner.core import (
|
|
11
|
+
coerce_params,
|
|
12
|
+
collect_rows,
|
|
13
|
+
create_arrow_data,
|
|
14
|
+
create_mapped_exception,
|
|
15
|
+
default_statement_config,
|
|
16
|
+
driver_profile,
|
|
17
|
+
infer_param_types,
|
|
18
|
+
supports_batch_update,
|
|
19
|
+
supports_write,
|
|
20
|
+
)
|
|
21
|
+
from sqlspec.adapters.spanner.data_dictionary import SpannerDataDictionary
|
|
22
|
+
from sqlspec.adapters.spanner.type_converter import SpannerOutputConverter
|
|
23
|
+
from sqlspec.core import StatementConfig, create_arrow_result, register_driver_profile
|
|
24
|
+
from sqlspec.driver import ExecutionResult, SyncDriverAdapterBase
|
|
25
|
+
from sqlspec.exceptions import SQLConversionError
|
|
26
|
+
from sqlspec.utils.serializers import from_json
|
|
27
|
+
|
|
28
|
+
if TYPE_CHECKING:
|
|
29
|
+
from collections.abc import Callable
|
|
30
|
+
|
|
31
|
+
from sqlglot.dialects.dialect import DialectType
|
|
32
|
+
|
|
33
|
+
from sqlspec.adapters.spanner._typing import SpannerConnection
|
|
34
|
+
from sqlspec.core import ArrowResult
|
|
35
|
+
from sqlspec.core.statement import SQL
|
|
36
|
+
from sqlspec.storage import StorageBridgeJob, StorageDestination, StorageFormat, StorageTelemetry
|
|
37
|
+
from sqlspec.typing import ArrowReturnFormat
|
|
38
|
+
|
|
39
|
+
__all__ = (
|
|
40
|
+
"SpannerDataDictionary",
|
|
41
|
+
"SpannerExceptionHandler",
|
|
42
|
+
"SpannerSessionContext",
|
|
43
|
+
"SpannerSyncCursor",
|
|
44
|
+
"SpannerSyncDriver",
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class _SpannerResultSetProtocol(Protocol):
|
|
49
|
+
metadata: Any
|
|
50
|
+
|
|
51
|
+
def __iter__(self) -> Iterator[Any]: ...
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class _SpannerReadProtocol(Protocol):
|
|
55
|
+
def execute_sql(
|
|
56
|
+
self, sql: str, params: "dict[str, Any] | None" = None, param_types: "dict[str, Any] | None" = None
|
|
57
|
+
) -> _SpannerResultSetProtocol: ...
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class _SpannerWriteProtocol(_SpannerReadProtocol, Protocol):
|
|
61
|
+
committed: "Any | None"
|
|
62
|
+
|
|
63
|
+
def execute_update(
|
|
64
|
+
self, sql: str, params: "dict[str, Any] | None" = None, param_types: "dict[str, Any] | None" = None
|
|
65
|
+
) -> int: ...
|
|
66
|
+
|
|
67
|
+
def batch_update(
|
|
68
|
+
self, batch: "list[tuple[str, dict[str, Any] | None, dict[str, Any]]]"
|
|
69
|
+
) -> "tuple[Any, list[int]]": ...
|
|
70
|
+
|
|
71
|
+
def commit(self) -> None: ...
|
|
72
|
+
|
|
73
|
+
def rollback(self) -> None: ...
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class SpannerExceptionHandler:
|
|
77
|
+
"""Map Spanner client exceptions to SQLSpec exceptions.
|
|
78
|
+
|
|
79
|
+
Uses deferred exception pattern for mypyc compatibility: exceptions
|
|
80
|
+
are stored in pending_exception rather than raised from __exit__
|
|
81
|
+
to avoid ABI boundary violations with compiled code.
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
__slots__ = ("pending_exception",)
|
|
85
|
+
|
|
86
|
+
def __init__(self) -> None:
|
|
87
|
+
self.pending_exception: Exception | None = None
|
|
88
|
+
|
|
89
|
+
def __enter__(self) -> "SpannerExceptionHandler":
|
|
90
|
+
return self
|
|
91
|
+
|
|
92
|
+
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool:
|
|
93
|
+
_ = exc_tb
|
|
94
|
+
if exc_type is None:
|
|
95
|
+
return False
|
|
96
|
+
|
|
97
|
+
if isinstance(exc_val, api_exceptions.GoogleAPICallError):
|
|
98
|
+
self.pending_exception = create_mapped_exception(exc_val)
|
|
99
|
+
return True
|
|
100
|
+
return False
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class SpannerSyncCursor:
|
|
104
|
+
"""Context manager that yields the active Spanner connection."""
|
|
105
|
+
|
|
106
|
+
__slots__ = ("connection",)
|
|
107
|
+
|
|
108
|
+
def __init__(self, connection: "SpannerConnection") -> None:
|
|
109
|
+
self.connection = connection
|
|
110
|
+
|
|
111
|
+
def __enter__(self) -> "SpannerConnection":
|
|
112
|
+
return self.connection
|
|
113
|
+
|
|
114
|
+
def __exit__(self, *_: Any) -> None:
|
|
115
|
+
return None
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class SpannerSyncDriver(SyncDriverAdapterBase):
|
|
119
|
+
"""Synchronous Spanner driver operating on Snapshot or Transaction contexts."""
|
|
120
|
+
|
|
121
|
+
dialect: "DialectType" = "spanner"
|
|
122
|
+
__slots__ = ("_data_dictionary", "_type_converter")
|
|
123
|
+
|
|
124
|
+
def __init__(
|
|
125
|
+
self,
|
|
126
|
+
connection: "SpannerConnection",
|
|
127
|
+
statement_config: "StatementConfig | None" = None,
|
|
128
|
+
driver_features: "dict[str, Any] | None" = None,
|
|
129
|
+
) -> None:
|
|
130
|
+
features = dict(driver_features) if driver_features else {}
|
|
131
|
+
if statement_config is None:
|
|
132
|
+
statement_config = default_statement_config
|
|
133
|
+
|
|
134
|
+
super().__init__(connection=connection, statement_config=statement_config, driver_features=features)
|
|
135
|
+
|
|
136
|
+
json_deserializer = features.get("json_deserializer")
|
|
137
|
+
self._type_converter = SpannerOutputConverter(
|
|
138
|
+
enable_uuid_conversion=features.get("enable_uuid_conversion", True),
|
|
139
|
+
json_deserializer=cast("Callable[[str], Any]", json_deserializer or from_json),
|
|
140
|
+
)
|
|
141
|
+
self._data_dictionary: SpannerDataDictionary | None = None
|
|
142
|
+
|
|
143
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
144
|
+
# CORE DISPATCH METHODS - The Execution Engine
|
|
145
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
146
|
+
|
|
147
|
+
def dispatch_execute(self, cursor: "SpannerConnection", statement: "SQL") -> ExecutionResult:
|
|
148
|
+
sql, params = self._get_compiled_sql(statement, self.statement_config)
|
|
149
|
+
params = cast("dict[str, Any] | None", params)
|
|
150
|
+
coerced_params = self._coerce_params(params)
|
|
151
|
+
param_types_map = self._infer_param_types(coerced_params)
|
|
152
|
+
|
|
153
|
+
if statement.returns_rows():
|
|
154
|
+
reader = cast("_SpannerReadProtocol", cursor)
|
|
155
|
+
result_set = reader.execute_sql(sql, params=coerced_params, param_types=param_types_map)
|
|
156
|
+
rows = list(result_set)
|
|
157
|
+
try:
|
|
158
|
+
metadata = result_set.metadata
|
|
159
|
+
row_type = metadata.row_type
|
|
160
|
+
fields = row_type.fields
|
|
161
|
+
except AttributeError:
|
|
162
|
+
fields = None
|
|
163
|
+
if not fields:
|
|
164
|
+
msg = "Result set metadata not available."
|
|
165
|
+
raise SQLConversionError(msg)
|
|
166
|
+
data, column_names = collect_rows(rows, fields, self._type_converter)
|
|
167
|
+
return self.create_execution_result(
|
|
168
|
+
cursor, selected_data=data, column_names=column_names, data_row_count=len(data), is_select_result=True
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
if supports_write(cursor):
|
|
172
|
+
writer = cast("_SpannerWriteProtocol", cursor)
|
|
173
|
+
row_count = writer.execute_update(sql, params=coerced_params, param_types=param_types_map)
|
|
174
|
+
return self.create_execution_result(cursor, rowcount_override=row_count)
|
|
175
|
+
|
|
176
|
+
msg = "Cannot execute DML in a read-only Snapshot context."
|
|
177
|
+
raise SQLConversionError(msg)
|
|
178
|
+
|
|
179
|
+
def dispatch_execute_many(self, cursor: "SpannerConnection", statement: "SQL") -> ExecutionResult:
|
|
180
|
+
if not supports_batch_update(cursor):
|
|
181
|
+
msg = "execute_many requires a Transaction context"
|
|
182
|
+
raise SQLConversionError(msg)
|
|
183
|
+
|
|
184
|
+
sql, prepared_parameters = self._get_compiled_sql(statement, self.statement_config)
|
|
185
|
+
|
|
186
|
+
if not prepared_parameters or not isinstance(prepared_parameters, list):
|
|
187
|
+
msg = "execute_many requires at least one parameter set"
|
|
188
|
+
raise SQLConversionError(msg)
|
|
189
|
+
|
|
190
|
+
batch_args: list[tuple[str, dict[str, Any] | None, dict[str, Any]]] = []
|
|
191
|
+
for params in prepared_parameters:
|
|
192
|
+
coerced_params = self._coerce_params(cast("dict[str, Any] | None", params))
|
|
193
|
+
if coerced_params is None:
|
|
194
|
+
coerced_params = {}
|
|
195
|
+
batch_args.append((sql, coerced_params, self._infer_param_types(coerced_params)))
|
|
196
|
+
|
|
197
|
+
writer = cast("_SpannerWriteProtocol", cursor)
|
|
198
|
+
_status, row_counts = writer.batch_update(batch_args)
|
|
199
|
+
total_rows = sum(row_counts) if row_counts else 0
|
|
200
|
+
|
|
201
|
+
return self.create_execution_result(cursor, rowcount_override=total_rows, is_many_result=True)
|
|
202
|
+
|
|
203
|
+
def dispatch_execute_script(self, cursor: "SpannerConnection", statement: "SQL") -> ExecutionResult:
|
|
204
|
+
sql, params = self._get_compiled_sql(statement, self.statement_config)
|
|
205
|
+
statements = self.split_script_statements(sql, statement.statement_config, strip_trailing_semicolon=True)
|
|
206
|
+
is_transaction = supports_write(cursor)
|
|
207
|
+
reader = cast("_SpannerReadProtocol", cursor)
|
|
208
|
+
|
|
209
|
+
count = 0
|
|
210
|
+
script_params = cast("dict[str, Any] | None", params)
|
|
211
|
+
for stmt in statements:
|
|
212
|
+
is_select = stmt.upper().strip().startswith("SELECT")
|
|
213
|
+
coerced_params = self._coerce_params(script_params)
|
|
214
|
+
if not is_select and not is_transaction:
|
|
215
|
+
msg = "Cannot execute DML in a read-only Snapshot context."
|
|
216
|
+
raise SQLConversionError(msg)
|
|
217
|
+
if not is_select and is_transaction:
|
|
218
|
+
writer = cast("_SpannerWriteProtocol", cursor)
|
|
219
|
+
writer.execute_update(stmt, params=coerced_params, param_types=self._infer_param_types(coerced_params))
|
|
220
|
+
else:
|
|
221
|
+
_ = list(
|
|
222
|
+
reader.execute_sql(stmt, params=coerced_params, param_types=self._infer_param_types(coerced_params))
|
|
223
|
+
)
|
|
224
|
+
count += 1
|
|
225
|
+
|
|
226
|
+
return self.create_execution_result(
|
|
227
|
+
cursor, statement_count=count, successful_statements=count, is_script_result=True
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
231
|
+
# TRANSACTION MANAGEMENT
|
|
232
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
233
|
+
|
|
234
|
+
def begin(self) -> None:
|
|
235
|
+
return None
|
|
236
|
+
|
|
237
|
+
def commit(self) -> None:
|
|
238
|
+
if isinstance(self.connection, Transaction):
|
|
239
|
+
writer = cast("_SpannerWriteProtocol", self.connection)
|
|
240
|
+
if writer.committed is not None:
|
|
241
|
+
return
|
|
242
|
+
writer.commit()
|
|
243
|
+
|
|
244
|
+
def rollback(self) -> None:
|
|
245
|
+
if isinstance(self.connection, Transaction):
|
|
246
|
+
writer = cast("_SpannerWriteProtocol", self.connection)
|
|
247
|
+
writer.rollback()
|
|
248
|
+
|
|
249
|
+
def with_cursor(self, connection: "SpannerConnection") -> "SpannerSyncCursor":
|
|
250
|
+
return SpannerSyncCursor(connection)
|
|
251
|
+
|
|
252
|
+
def handle_database_exceptions(self) -> "SpannerExceptionHandler":
|
|
253
|
+
return SpannerExceptionHandler()
|
|
254
|
+
|
|
255
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
256
|
+
# ARROW API METHODS
|
|
257
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
258
|
+
|
|
259
|
+
def select_to_arrow(self, statement: "Any", /, *parameters: "Any", **kwargs: Any) -> "ArrowResult":
|
|
260
|
+
result = self.execute(statement, *parameters, **kwargs)
|
|
261
|
+
|
|
262
|
+
return_format = cast("ArrowReturnFormat", kwargs.get("return_format", "table"))
|
|
263
|
+
arrow_data = create_arrow_data(result.data or [], return_format)
|
|
264
|
+
return create_arrow_result(result.statement, arrow_data, rows_affected=result.rows_affected)
|
|
265
|
+
|
|
266
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
267
|
+
# STORAGE API METHODS
|
|
268
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
269
|
+
|
|
270
|
+
def select_to_storage(
|
|
271
|
+
self,
|
|
272
|
+
statement: "SQL | str",
|
|
273
|
+
destination: "StorageDestination",
|
|
274
|
+
/,
|
|
275
|
+
*parameters: Any,
|
|
276
|
+
statement_config: "StatementConfig | None" = None,
|
|
277
|
+
partitioner: "dict[str, object] | None" = None,
|
|
278
|
+
format_hint: "StorageFormat | None" = None,
|
|
279
|
+
telemetry: "StorageTelemetry | None" = None,
|
|
280
|
+
**kwargs: Any,
|
|
281
|
+
) -> "StorageBridgeJob":
|
|
282
|
+
"""Execute query and stream Arrow results to storage."""
|
|
283
|
+
self._require_capability("arrow_export_enabled")
|
|
284
|
+
arrow_result = self.select_to_arrow(statement, *parameters, statement_config=statement_config, **kwargs)
|
|
285
|
+
sync_pipeline = self._storage_pipeline()
|
|
286
|
+
telemetry_payload = self._write_result_to_storage_sync(
|
|
287
|
+
arrow_result, destination, format_hint=format_hint, pipeline=sync_pipeline
|
|
288
|
+
)
|
|
289
|
+
self._attach_partition_telemetry(telemetry_payload, partitioner)
|
|
290
|
+
return self._create_storage_job(telemetry_payload, telemetry)
|
|
291
|
+
|
|
292
|
+
def load_from_arrow(
|
|
293
|
+
self,
|
|
294
|
+
table: str,
|
|
295
|
+
source: "ArrowResult | Any",
|
|
296
|
+
*,
|
|
297
|
+
partitioner: "dict[str, object] | None" = None,
|
|
298
|
+
overwrite: bool = False,
|
|
299
|
+
telemetry: "StorageTelemetry | None" = None,
|
|
300
|
+
) -> "StorageBridgeJob":
|
|
301
|
+
"""Load Arrow data into Spanner table via batch mutations."""
|
|
302
|
+
self._require_capability("arrow_import_enabled")
|
|
303
|
+
arrow_table = self._coerce_arrow_table(source)
|
|
304
|
+
|
|
305
|
+
if overwrite:
|
|
306
|
+
delete_sql = f"DELETE FROM {table} WHERE TRUE"
|
|
307
|
+
if isinstance(self.connection, Transaction):
|
|
308
|
+
writer = cast("_SpannerWriteProtocol", self.connection)
|
|
309
|
+
writer.execute_update(delete_sql)
|
|
310
|
+
else:
|
|
311
|
+
msg = "Delete requires a Transaction context."
|
|
312
|
+
raise SQLConversionError(msg)
|
|
313
|
+
|
|
314
|
+
columns, records = self._arrow_table_to_rows(arrow_table)
|
|
315
|
+
if records:
|
|
316
|
+
insert_sql = f"INSERT INTO {table} ({', '.join(columns)}) VALUES ({', '.join('@p' + str(i) for i in range(len(columns)))})"
|
|
317
|
+
batch_args: list[tuple[str, dict[str, Any] | None, dict[str, Any]]] = []
|
|
318
|
+
for record in records:
|
|
319
|
+
params = {f"p{i}": val for i, val in enumerate(record)}
|
|
320
|
+
coerced = self._coerce_params(params)
|
|
321
|
+
batch_args.append((insert_sql, coerced, self._infer_param_types(coerced)))
|
|
322
|
+
|
|
323
|
+
conn = self.connection
|
|
324
|
+
if not isinstance(conn, Transaction):
|
|
325
|
+
msg = "Arrow import requires a Transaction context."
|
|
326
|
+
raise SQLConversionError(msg)
|
|
327
|
+
writer = cast("_SpannerWriteProtocol", conn)
|
|
328
|
+
writer.batch_update(batch_args)
|
|
329
|
+
|
|
330
|
+
telemetry_payload = self._build_ingest_telemetry(arrow_table)
|
|
331
|
+
telemetry_payload["destination"] = table
|
|
332
|
+
self._attach_partition_telemetry(telemetry_payload, partitioner)
|
|
333
|
+
return self._create_storage_job(telemetry_payload, telemetry)
|
|
334
|
+
|
|
335
|
+
def load_from_storage(
|
|
336
|
+
self,
|
|
337
|
+
table: str,
|
|
338
|
+
source: "StorageDestination",
|
|
339
|
+
*,
|
|
340
|
+
file_format: "StorageFormat",
|
|
341
|
+
partitioner: "dict[str, object] | None" = None,
|
|
342
|
+
overwrite: bool = False,
|
|
343
|
+
) -> "StorageBridgeJob":
|
|
344
|
+
"""Load artifacts from storage into Spanner table."""
|
|
345
|
+
arrow_table, inbound = self._read_arrow_from_storage_sync(source, file_format=file_format)
|
|
346
|
+
return self.load_from_arrow(table, arrow_table, partitioner=partitioner, overwrite=overwrite, telemetry=inbound)
|
|
347
|
+
|
|
348
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
349
|
+
# UTILITY METHODS
|
|
350
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
351
|
+
|
|
352
|
+
@property
|
|
353
|
+
def data_dictionary(self) -> "SpannerDataDictionary":
|
|
354
|
+
if self._data_dictionary is None:
|
|
355
|
+
self._data_dictionary = SpannerDataDictionary()
|
|
356
|
+
return self._data_dictionary
|
|
357
|
+
|
|
358
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
359
|
+
# PRIVATE/INTERNAL METHODS
|
|
360
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
361
|
+
|
|
362
|
+
def _connection_in_transaction(self) -> bool:
|
|
363
|
+
"""Check if connection is in transaction."""
|
|
364
|
+
return False
|
|
365
|
+
|
|
366
|
+
def _coerce_params(self, params: "dict[str, Any] | list[Any] | tuple[Any, ...] | None") -> "dict[str, Any] | None":
|
|
367
|
+
return coerce_params(params, json_serializer=self.driver_features.get("json_serializer"))
|
|
368
|
+
|
|
369
|
+
def _infer_param_types(self, params: "dict[str, Any] | list[Any] | tuple[Any, ...] | None") -> "dict[str, Any]":
|
|
370
|
+
return infer_param_types(params)
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
register_driver_profile("spanner", driver_profile)
|