sqlspec 0.72.0__cp315-cp315-win_amd64.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.
- 6b29784d6b1cafc66758__mypyc.cp315-win_amd64.pyd +0 -0
- sqlspec/__init__.py +381 -0
- sqlspec/__main__.py +14 -0
- sqlspec/__metadata__.py +14 -0
- sqlspec/_typing.py +775 -0
- sqlspec/adapters/__init__.py +3 -0
- sqlspec/adapters/adbc/__init__.py +16 -0
- sqlspec/adapters/adbc/_typing.py +221 -0
- sqlspec/adapters/adbc/adk/__init__.py +11 -0
- sqlspec/adapters/adbc/adk/store.py +4101 -0
- sqlspec/adapters/adbc/config.py +843 -0
- sqlspec/adapters/adbc/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/core.py +3209 -0
- sqlspec/adapters/adbc/data_dictionary.py +1448 -0
- sqlspec/adapters/adbc/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/driver.py +1400 -0
- sqlspec/adapters/adbc/events/__init__.py +5 -0
- sqlspec/adapters/adbc/events/store.py +384 -0
- sqlspec/adapters/adbc/litestar/__init__.py +5 -0
- sqlspec/adapters/adbc/litestar/store.py +962 -0
- sqlspec/adapters/adbc/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/pool.py +242 -0
- sqlspec/adapters/adbc/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/adbc/type_converter.py +117 -0
- sqlspec/adapters/aiomysql/__init__.py +25 -0
- sqlspec/adapters/aiomysql/_typing.py +134 -0
- sqlspec/adapters/aiomysql/adk/__init__.py +5 -0
- sqlspec/adapters/aiomysql/adk/store.py +1542 -0
- sqlspec/adapters/aiomysql/config.py +634 -0
- sqlspec/adapters/aiomysql/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiomysql/core.py +922 -0
- sqlspec/adapters/aiomysql/data_dictionary.py +16 -0
- sqlspec/adapters/aiomysql/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiomysql/driver.py +494 -0
- sqlspec/adapters/aiomysql/events/__init__.py +5 -0
- sqlspec/adapters/aiomysql/events/store.py +72 -0
- sqlspec/adapters/aiomysql/litestar/__init__.py +5 -0
- sqlspec/adapters/aiomysql/litestar/store.py +345 -0
- sqlspec/adapters/aiosqlite/__init__.py +43 -0
- sqlspec/adapters/aiosqlite/_typing.py +75 -0
- sqlspec/adapters/aiosqlite/adk/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/adk/store.py +1546 -0
- sqlspec/adapters/aiosqlite/config.py +607 -0
- sqlspec/adapters/aiosqlite/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/core.py +1155 -0
- sqlspec/adapters/aiosqlite/data_dictionary.py +343 -0
- sqlspec/adapters/aiosqlite/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/driver.py +559 -0
- sqlspec/adapters/aiosqlite/events/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/events/store.py +54 -0
- sqlspec/adapters/aiosqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/litestar/store.py +315 -0
- sqlspec/adapters/aiosqlite/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/pool.py +1323 -0
- sqlspec/adapters/aiosqlite/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/aiosqlite/type_converter.py +114 -0
- sqlspec/adapters/arrow_odbc/__init__.py +32 -0
- sqlspec/adapters/arrow_odbc/_typing.py +131 -0
- sqlspec/adapters/arrow_odbc/adk/__init__.py +5 -0
- sqlspec/adapters/arrow_odbc/adk/store.py +1671 -0
- sqlspec/adapters/arrow_odbc/config.py +446 -0
- sqlspec/adapters/arrow_odbc/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/arrow_odbc/core.py +795 -0
- sqlspec/adapters/arrow_odbc/data_dictionary.py +345 -0
- sqlspec/adapters/arrow_odbc/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/arrow_odbc/driver.py +885 -0
- sqlspec/adapters/arrow_odbc/events/__init__.py +5 -0
- sqlspec/adapters/arrow_odbc/events/store.py +114 -0
- sqlspec/adapters/arrow_odbc/litestar/__init__.py +5 -0
- sqlspec/adapters/arrow_odbc/litestar/store.py +682 -0
- sqlspec/adapters/arrow_odbc/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/arrow_odbc/type_converter.py +95 -0
- sqlspec/adapters/asyncmy/__init__.py +27 -0
- sqlspec/adapters/asyncmy/_typing.py +215 -0
- sqlspec/adapters/asyncmy/adk/__init__.py +5 -0
- sqlspec/adapters/asyncmy/adk/store.py +1544 -0
- sqlspec/adapters/asyncmy/config.py +707 -0
- sqlspec/adapters/asyncmy/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncmy/core.py +917 -0
- sqlspec/adapters/asyncmy/data_dictionary.py +16 -0
- sqlspec/adapters/asyncmy/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncmy/driver.py +529 -0
- sqlspec/adapters/asyncmy/events/__init__.py +5 -0
- sqlspec/adapters/asyncmy/events/store.py +72 -0
- sqlspec/adapters/asyncmy/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncmy/litestar/store.py +348 -0
- sqlspec/adapters/asyncpg/__init__.py +28 -0
- sqlspec/adapters/asyncpg/_typing.py +113 -0
- sqlspec/adapters/asyncpg/adk/__init__.py +5 -0
- sqlspec/adapters/asyncpg/adk/store.py +1145 -0
- sqlspec/adapters/asyncpg/config.py +903 -0
- sqlspec/adapters/asyncpg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/core.py +797 -0
- sqlspec/adapters/asyncpg/data_dictionary.py +417 -0
- sqlspec/adapters/asyncpg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/driver.py +927 -0
- sqlspec/adapters/asyncpg/events/__init__.py +6 -0
- sqlspec/adapters/asyncpg/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/events/_hub.py +279 -0
- sqlspec/adapters/asyncpg/events/backend.py +410 -0
- sqlspec/adapters/asyncpg/events/store.py +57 -0
- sqlspec/adapters/asyncpg/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncpg/litestar/store.py +278 -0
- sqlspec/adapters/asyncpg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/asyncpg/tenant.py +140 -0
- sqlspec/adapters/bigquery/__init__.py +23 -0
- sqlspec/adapters/bigquery/_typing.py +184 -0
- sqlspec/adapters/bigquery/adk/__init__.py +5 -0
- sqlspec/adapters/bigquery/adk/store.py +920 -0
- sqlspec/adapters/bigquery/config.py +631 -0
- sqlspec/adapters/bigquery/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/bigquery/core.py +1433 -0
- sqlspec/adapters/bigquery/data_dictionary.py +502 -0
- sqlspec/adapters/bigquery/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/bigquery/driver.py +1266 -0
- sqlspec/adapters/bigquery/events/__init__.py +5 -0
- sqlspec/adapters/bigquery/events/store.py +158 -0
- sqlspec/adapters/bigquery/litestar/__init__.py +5 -0
- sqlspec/adapters/bigquery/litestar/store.py +359 -0
- sqlspec/adapters/cockroach_asyncpg/__init__.py +32 -0
- sqlspec/adapters/cockroach_asyncpg/_typing.py +54 -0
- sqlspec/adapters/cockroach_asyncpg/adk/__init__.py +9 -0
- sqlspec/adapters/cockroach_asyncpg/adk/store.py +1096 -0
- sqlspec/adapters/cockroach_asyncpg/config.py +653 -0
- sqlspec/adapters/cockroach_asyncpg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/core.py +835 -0
- sqlspec/adapters/cockroach_asyncpg/data_dictionary.py +371 -0
- sqlspec/adapters/cockroach_asyncpg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/driver.py +438 -0
- sqlspec/adapters/cockroach_asyncpg/events/__init__.py +5 -0
- sqlspec/adapters/cockroach_asyncpg/events/store.py +20 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/__init__.py +5 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/store.py +203 -0
- sqlspec/adapters/cockroach_asyncpg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_asyncpg/tenant.py +143 -0
- sqlspec/adapters/cockroach_psycopg/__init__.py +46 -0
- sqlspec/adapters/cockroach_psycopg/_typing.py +271 -0
- sqlspec/adapters/cockroach_psycopg/adk/__init__.py +17 -0
- sqlspec/adapters/cockroach_psycopg/adk/store.py +2274 -0
- sqlspec/adapters/cockroach_psycopg/config.py +1285 -0
- sqlspec/adapters/cockroach_psycopg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/core.py +667 -0
- sqlspec/adapters/cockroach_psycopg/data_dictionary.py +622 -0
- sqlspec/adapters/cockroach_psycopg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/driver.py +864 -0
- sqlspec/adapters/cockroach_psycopg/events/__init__.py +8 -0
- sqlspec/adapters/cockroach_psycopg/events/store.py +34 -0
- sqlspec/adapters/cockroach_psycopg/litestar/__init__.py +9 -0
- sqlspec/adapters/cockroach_psycopg/litestar/store.py +413 -0
- sqlspec/adapters/cockroach_psycopg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/cockroach_psycopg/tenant.py +222 -0
- sqlspec/adapters/db2/__init__.py +34 -0
- sqlspec/adapters/db2/_typing.py +357 -0
- sqlspec/adapters/db2/adk/__init__.py +10 -0
- sqlspec/adapters/db2/adk/store.py +1950 -0
- sqlspec/adapters/db2/config.py +550 -0
- sqlspec/adapters/db2/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/core.py +1021 -0
- sqlspec/adapters/db2/data_dictionary.py +493 -0
- sqlspec/adapters/db2/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/driver.py +898 -0
- sqlspec/adapters/db2/events/__init__.py +5 -0
- sqlspec/adapters/db2/events/store.py +77 -0
- sqlspec/adapters/db2/litestar/__init__.py +5 -0
- sqlspec/adapters/db2/litestar/store.py +519 -0
- sqlspec/adapters/db2/migrations.py +221 -0
- sqlspec/adapters/db2/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/pool.py +876 -0
- sqlspec/adapters/db2/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/db2/tenant.py +292 -0
- sqlspec/adapters/duckdb/__init__.py +30 -0
- sqlspec/adapters/duckdb/_typing.py +182 -0
- sqlspec/adapters/duckdb/adk/__init__.py +10 -0
- sqlspec/adapters/duckdb/adk/store.py +1672 -0
- sqlspec/adapters/duckdb/config.py +506 -0
- sqlspec/adapters/duckdb/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/core.py +1299 -0
- sqlspec/adapters/duckdb/data_dictionary.py +553 -0
- sqlspec/adapters/duckdb/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/driver.py +1214 -0
- sqlspec/adapters/duckdb/events/__init__.py +5 -0
- sqlspec/adapters/duckdb/events/store.py +38 -0
- sqlspec/adapters/duckdb/litestar/__init__.py +5 -0
- sqlspec/adapters/duckdb/litestar/store.py +313 -0
- sqlspec/adapters/duckdb/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/duckdb/pool.py +1121 -0
- sqlspec/adapters/mssql_python/__init__.py +42 -0
- sqlspec/adapters/mssql_python/_typing.py +135 -0
- sqlspec/adapters/mssql_python/adk/__init__.py +5 -0
- sqlspec/adapters/mssql_python/adk/store.py +1278 -0
- sqlspec/adapters/mssql_python/config.py +455 -0
- sqlspec/adapters/mssql_python/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/core.py +862 -0
- sqlspec/adapters/mssql_python/data_dictionary.py +417 -0
- sqlspec/adapters/mssql_python/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/driver.py +772 -0
- sqlspec/adapters/mssql_python/events/__init__.py +5 -0
- sqlspec/adapters/mssql_python/events/store.py +46 -0
- sqlspec/adapters/mssql_python/litestar/__init__.py +5 -0
- sqlspec/adapters/mssql_python/litestar/store.py +355 -0
- sqlspec/adapters/mssql_python/migrations.py +162 -0
- sqlspec/adapters/mssql_python/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/pool.py +165 -0
- sqlspec/adapters/mssql_python/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/tenant.py +74 -0
- sqlspec/adapters/mssql_python/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mssql_python/type_converter.py +98 -0
- sqlspec/adapters/mysqlconnector/__init__.py +47 -0
- sqlspec/adapters/mysqlconnector/_typing.py +205 -0
- sqlspec/adapters/mysqlconnector/adk/__init__.py +17 -0
- sqlspec/adapters/mysqlconnector/adk/store.py +2503 -0
- sqlspec/adapters/mysqlconnector/config.py +925 -0
- sqlspec/adapters/mysqlconnector/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mysqlconnector/core.py +1075 -0
- sqlspec/adapters/mysqlconnector/data_dictionary.py +23 -0
- sqlspec/adapters/mysqlconnector/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/mysqlconnector/driver.py +702 -0
- sqlspec/adapters/mysqlconnector/events/__init__.py +8 -0
- sqlspec/adapters/mysqlconnector/events/store.py +89 -0
- sqlspec/adapters/mysqlconnector/litestar/__init__.py +9 -0
- sqlspec/adapters/mysqlconnector/litestar/store.py +524 -0
- sqlspec/adapters/oracledb/__init__.py +159 -0
- sqlspec/adapters/oracledb/_json_handlers.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_json_handlers.py +208 -0
- sqlspec/adapters/oracledb/_param_types.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_param_types.py +65 -0
- sqlspec/adapters/oracledb/_plugins.py +137 -0
- sqlspec/adapters/oracledb/_storage.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_storage.py +138 -0
- sqlspec/adapters/oracledb/_typing.py +468 -0
- sqlspec/adapters/oracledb/_uuid_handlers.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_uuid_handlers.py +143 -0
- sqlspec/adapters/oracledb/_vector_handlers.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/_vector_handlers.py +252 -0
- sqlspec/adapters/oracledb/adk/__init__.py +27 -0
- sqlspec/adapters/oracledb/adk/store.py +4031 -0
- sqlspec/adapters/oracledb/config.py +1785 -0
- sqlspec/adapters/oracledb/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/core.py +5416 -0
- sqlspec/adapters/oracledb/data_dictionary.py +1264 -0
- sqlspec/adapters/oracledb/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/driver.py +3273 -0
- sqlspec/adapters/oracledb/events/__init__.py +29 -0
- sqlspec/adapters/oracledb/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/events/_hub.py +394 -0
- sqlspec/adapters/oracledb/events/backend.py +311 -0
- sqlspec/adapters/oracledb/events/store.py +842 -0
- sqlspec/adapters/oracledb/litestar/__init__.py +17 -0
- sqlspec/adapters/oracledb/litestar/store.py +862 -0
- sqlspec/adapters/oracledb/migrations.py +650 -0
- sqlspec/adapters/oracledb/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/tenant.py +990 -0
- sqlspec/adapters/oracledb/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/oracledb/type_converter.py +93 -0
- sqlspec/adapters/psqlpy/__init__.py +21 -0
- sqlspec/adapters/psqlpy/_typing.py +180 -0
- sqlspec/adapters/psqlpy/adk/__init__.py +5 -0
- sqlspec/adapters/psqlpy/adk/store.py +1514 -0
- sqlspec/adapters/psqlpy/config.py +828 -0
- sqlspec/adapters/psqlpy/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/core.py +1040 -0
- sqlspec/adapters/psqlpy/data_dictionary.py +399 -0
- sqlspec/adapters/psqlpy/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/driver.py +631 -0
- sqlspec/adapters/psqlpy/events/__init__.py +12 -0
- sqlspec/adapters/psqlpy/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/events/_hub.py +367 -0
- sqlspec/adapters/psqlpy/events/backend.py +415 -0
- sqlspec/adapters/psqlpy/events/store.py +46 -0
- sqlspec/adapters/psqlpy/litestar/__init__.py +5 -0
- sqlspec/adapters/psqlpy/litestar/store.py +270 -0
- sqlspec/adapters/psqlpy/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/tenant.py +137 -0
- sqlspec/adapters/psqlpy/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psqlpy/type_converter.py +21 -0
- sqlspec/adapters/psycopg/__init__.py +44 -0
- sqlspec/adapters/psycopg/_typing.py +408 -0
- sqlspec/adapters/psycopg/adk/__init__.py +17 -0
- sqlspec/adapters/psycopg/adk/store.py +2761 -0
- sqlspec/adapters/psycopg/config.py +1522 -0
- sqlspec/adapters/psycopg/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/core.py +1001 -0
- sqlspec/adapters/psycopg/data_dictionary.py +701 -0
- sqlspec/adapters/psycopg/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/driver.py +1629 -0
- sqlspec/adapters/psycopg/events/__init__.py +25 -0
- sqlspec/adapters/psycopg/events/_hub.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/events/_hub.py +646 -0
- sqlspec/adapters/psycopg/events/backend.py +739 -0
- sqlspec/adapters/psycopg/events/store.py +82 -0
- sqlspec/adapters/psycopg/litestar/__init__.py +5 -0
- sqlspec/adapters/psycopg/litestar/store.py +595 -0
- sqlspec/adapters/psycopg/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/tenant.py +226 -0
- sqlspec/adapters/psycopg/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/psycopg/type_converter.py +94 -0
- sqlspec/adapters/pymssql/__init__.py +29 -0
- sqlspec/adapters/pymssql/_typing.py +156 -0
- sqlspec/adapters/pymssql/adk/__init__.py +5 -0
- sqlspec/adapters/pymssql/adk/store.py +1270 -0
- sqlspec/adapters/pymssql/config.py +299 -0
- sqlspec/adapters/pymssql/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/core.py +527 -0
- sqlspec/adapters/pymssql/data_dictionary.py +417 -0
- sqlspec/adapters/pymssql/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/driver.py +527 -0
- sqlspec/adapters/pymssql/events/__init__.py +5 -0
- sqlspec/adapters/pymssql/events/store.py +46 -0
- sqlspec/adapters/pymssql/litestar/__init__.py +5 -0
- sqlspec/adapters/pymssql/litestar/store.py +350 -0
- sqlspec/adapters/pymssql/migrations.py +162 -0
- sqlspec/adapters/pymssql/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/pool.py +417 -0
- sqlspec/adapters/pymssql/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymssql/tenant.py +73 -0
- sqlspec/adapters/pymysql/__init__.py +27 -0
- sqlspec/adapters/pymysql/_typing.py +105 -0
- sqlspec/adapters/pymysql/adk/__init__.py +5 -0
- sqlspec/adapters/pymysql/adk/store.py +1646 -0
- sqlspec/adapters/pymysql/config.py +545 -0
- sqlspec/adapters/pymysql/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/core.py +909 -0
- sqlspec/adapters/pymysql/data_dictionary.py +16 -0
- sqlspec/adapters/pymysql/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/driver.py +370 -0
- sqlspec/adapters/pymysql/events/__init__.py +5 -0
- sqlspec/adapters/pymysql/events/store.py +42 -0
- sqlspec/adapters/pymysql/litestar/__init__.py +5 -0
- sqlspec/adapters/pymysql/litestar/store.py +299 -0
- sqlspec/adapters/pymysql/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/pymysql/pool.py +480 -0
- sqlspec/adapters/snowflake/__init__.py +36 -0
- sqlspec/adapters/snowflake/_typing.py +62 -0
- sqlspec/adapters/snowflake/adk/__init__.py +5 -0
- sqlspec/adapters/snowflake/adk/store.py +778 -0
- sqlspec/adapters/snowflake/config.py +333 -0
- sqlspec/adapters/snowflake/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/core.py +683 -0
- sqlspec/adapters/snowflake/data_dictionary.py +355 -0
- sqlspec/adapters/snowflake/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/driver.py +872 -0
- sqlspec/adapters/snowflake/events/__init__.py +5 -0
- sqlspec/adapters/snowflake/events/store.py +28 -0
- sqlspec/adapters/snowflake/litestar/__init__.py +5 -0
- sqlspec/adapters/snowflake/litestar/store.py +162 -0
- sqlspec/adapters/snowflake/migrations.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/migrations.py +76 -0
- sqlspec/adapters/snowflake/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/pool.py +385 -0
- sqlspec/adapters/snowflake/tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/tenant.py +200 -0
- sqlspec/adapters/snowflake/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/snowflake/type_converter.py +33 -0
- sqlspec/adapters/spanner/__init__.py +57 -0
- sqlspec/adapters/spanner/_typing.py +300 -0
- sqlspec/adapters/spanner/adk/__init__.py +22 -0
- sqlspec/adapters/spanner/adk/artifact_store.py +693 -0
- sqlspec/adapters/spanner/adk/store.py +3053 -0
- sqlspec/adapters/spanner/config.py +1578 -0
- sqlspec/adapters/spanner/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/core.py +1244 -0
- sqlspec/adapters/spanner/data_dictionary.py +706 -0
- sqlspec/adapters/spanner/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/driver.py +1673 -0
- sqlspec/adapters/spanner/events/__init__.py +5 -0
- sqlspec/adapters/spanner/events/store.py +357 -0
- sqlspec/adapters/spanner/litestar/__init__.py +5 -0
- sqlspec/adapters/spanner/litestar/store.py +570 -0
- sqlspec/adapters/spanner/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/spanner/type_converter.py +466 -0
- sqlspec/adapters/sqlanywhere/__init__.py +40 -0
- sqlspec/adapters/sqlanywhere/_typing.py +139 -0
- sqlspec/adapters/sqlanywhere/adk/__init__.py +5 -0
- sqlspec/adapters/sqlanywhere/adk/store.py +1136 -0
- sqlspec/adapters/sqlanywhere/config.py +359 -0
- sqlspec/adapters/sqlanywhere/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlanywhere/core.py +583 -0
- sqlspec/adapters/sqlanywhere/data_dictionary.py +282 -0
- sqlspec/adapters/sqlanywhere/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlanywhere/driver.py +480 -0
- sqlspec/adapters/sqlanywhere/events/__init__.py +5 -0
- sqlspec/adapters/sqlanywhere/events/store.py +28 -0
- sqlspec/adapters/sqlanywhere/litestar/__init__.py +5 -0
- sqlspec/adapters/sqlanywhere/litestar/store.py +237 -0
- sqlspec/adapters/sqlanywhere/migrations.py +178 -0
- sqlspec/adapters/sqlanywhere/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlanywhere/pool.py +397 -0
- sqlspec/adapters/sqlite/__init__.py +32 -0
- sqlspec/adapters/sqlite/_typing.py +91 -0
- sqlspec/adapters/sqlite/adk/__init__.py +5 -0
- sqlspec/adapters/sqlite/adk/store.py +1628 -0
- sqlspec/adapters/sqlite/config.py +520 -0
- sqlspec/adapters/sqlite/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/core.py +1035 -0
- sqlspec/adapters/sqlite/data_dictionary.py +327 -0
- sqlspec/adapters/sqlite/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/driver.py +432 -0
- sqlspec/adapters/sqlite/events/__init__.py +5 -0
- sqlspec/adapters/sqlite/events/store.py +54 -0
- sqlspec/adapters/sqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/sqlite/litestar/store.py +367 -0
- sqlspec/adapters/sqlite/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/pool.py +935 -0
- sqlspec/adapters/sqlite/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sqlite/type_converter.py +114 -0
- sqlspec/adapters/sybase/__init__.py +37 -0
- sqlspec/adapters/sybase/_typing.py +150 -0
- sqlspec/adapters/sybase/adk/__init__.py +5 -0
- sqlspec/adapters/sybase/adk/store.py +1370 -0
- sqlspec/adapters/sybase/config.py +276 -0
- sqlspec/adapters/sybase/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sybase/core.py +578 -0
- sqlspec/adapters/sybase/data_dictionary.py +358 -0
- sqlspec/adapters/sybase/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sybase/driver.py +497 -0
- sqlspec/adapters/sybase/events/__init__.py +5 -0
- sqlspec/adapters/sybase/events/store.py +88 -0
- sqlspec/adapters/sybase/litestar/__init__.py +5 -0
- sqlspec/adapters/sybase/litestar/store.py +328 -0
- sqlspec/adapters/sybase/migrations.py +178 -0
- sqlspec/adapters/sybase/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/sybase/pool.py +435 -0
- sqlspec/adapters/teradata/__init__.py +59 -0
- sqlspec/adapters/teradata/_typing.py +145 -0
- sqlspec/adapters/teradata/adk/__init__.py +5 -0
- sqlspec/adapters/teradata/adk/store.py +1300 -0
- sqlspec/adapters/teradata/config.py +324 -0
- sqlspec/adapters/teradata/core.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/core.py +437 -0
- sqlspec/adapters/teradata/data_dictionary.py +316 -0
- sqlspec/adapters/teradata/driver.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/driver.py +721 -0
- sqlspec/adapters/teradata/events/__init__.py +5 -0
- sqlspec/adapters/teradata/events/store.py +64 -0
- sqlspec/adapters/teradata/litestar/__init__.py +5 -0
- sqlspec/adapters/teradata/litestar/store.py +264 -0
- sqlspec/adapters/teradata/migrations.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/migrations.py +80 -0
- sqlspec/adapters/teradata/pool.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/pool.py +377 -0
- sqlspec/adapters/teradata/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/adapters/teradata/type_converter.py +95 -0
- sqlspec/base.cp315-win_amd64.pyd +0 -0
- sqlspec/base.py +1275 -0
- sqlspec/builder/__init__.py +330 -0
- sqlspec/builder/_base.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_base.py +1752 -0
- sqlspec/builder/_column.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_column.py +508 -0
- sqlspec/builder/_ddl.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_ddl.py +4503 -0
- sqlspec/builder/_delete.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_delete.py +75 -0
- sqlspec/builder/_dml.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_dml.py +639 -0
- sqlspec/builder/_explain.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_explain.py +650 -0
- sqlspec/builder/_expression_wrappers.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_expression_wrappers.py +77 -0
- sqlspec/builder/_factory.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_factory.py +1834 -0
- sqlspec/builder/_generation.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_generation.py +55 -0
- sqlspec/builder/_insert.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_insert.py +308 -0
- sqlspec/builder/_join.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_join.py +501 -0
- sqlspec/builder/_locking.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_locking.py +77 -0
- sqlspec/builder/_merge.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_merge.py +1047 -0
- sqlspec/builder/_parsing_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_parsing_utils.py +1197 -0
- sqlspec/builder/_select.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_select.py +1514 -0
- sqlspec/builder/_temporal.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_temporal.py +183 -0
- sqlspec/builder/_update.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_update.py +139 -0
- sqlspec/builder/_values.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_values.py +271 -0
- sqlspec/builder/_vector_distance.cp315-win_amd64.pyd +0 -0
- sqlspec/builder/_vector_distance.py +763 -0
- sqlspec/cli.py +1656 -0
- sqlspec/config.py +3402 -0
- sqlspec/core/__init__.py +542 -0
- sqlspec/core/_cursor.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_cursor.py +564 -0
- sqlspec/core/_operators.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_operators.py +167 -0
- sqlspec/core/_ordering.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_ordering.py +151 -0
- sqlspec/core/_pagination.py +66 -0
- sqlspec/core/_pipeline.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_pipeline.py +343 -0
- sqlspec/core/_pool.cp315-win_amd64.pyd +0 -0
- sqlspec/core/_pool.py +72 -0
- sqlspec/core/cache.cp315-win_amd64.pyd +0 -0
- sqlspec/core/cache.py +1503 -0
- sqlspec/core/capabilities.cp315-win_amd64.pyd +0 -0
- sqlspec/core/capabilities.py +67 -0
- sqlspec/core/compiler.cp315-win_amd64.pyd +0 -0
- sqlspec/core/compiler.py +1667 -0
- sqlspec/core/config_runtime.cp315-win_amd64.pyd +0 -0
- sqlspec/core/config_runtime.py +219 -0
- sqlspec/core/correlation.cp315-win_amd64.pyd +0 -0
- sqlspec/core/correlation.py +135 -0
- sqlspec/core/explain.cp315-win_amd64.pyd +0 -0
- sqlspec/core/explain.py +284 -0
- sqlspec/core/filters.cp315-win_amd64.pyd +0 -0
- sqlspec/core/filters.py +1442 -0
- sqlspec/core/hashing.cp315-win_amd64.pyd +0 -0
- sqlspec/core/hashing.py +394 -0
- sqlspec/core/metrics.cp315-win_amd64.pyd +0 -0
- sqlspec/core/metrics.py +86 -0
- sqlspec/core/parameters/__init__.py +174 -0
- sqlspec/core/parameters/_alignment.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_alignment.py +321 -0
- sqlspec/core/parameters/_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_converter.py +956 -0
- sqlspec/core/parameters/_declared.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_declared.py +154 -0
- sqlspec/core/parameters/_processor.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_processor.py +1646 -0
- sqlspec/core/parameters/_registry.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_registry.py +207 -0
- sqlspec/core/parameters/_transformers.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_transformers.py +318 -0
- sqlspec/core/parameters/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_types.py +658 -0
- sqlspec/core/parameters/_validator.cp315-win_amd64.pyd +0 -0
- sqlspec/core/parameters/_validator.py +699 -0
- sqlspec/core/query_modifiers.cp315-win_amd64.pyd +0 -0
- sqlspec/core/query_modifiers.py +559 -0
- sqlspec/core/result/__init__.py +67 -0
- sqlspec/core/result/_base.cp315-win_amd64.pyd +0 -0
- sqlspec/core/result/_base.py +1772 -0
- sqlspec/core/routing.cp315-win_amd64.pyd +0 -0
- sqlspec/core/routing.py +270 -0
- sqlspec/core/splitter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/splitter.py +1126 -0
- sqlspec/core/sqlcommenter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/sqlcommenter.py +509 -0
- sqlspec/core/stack.cp315-win_amd64.pyd +0 -0
- sqlspec/core/stack.py +167 -0
- sqlspec/core/statement.cp315-win_amd64.pyd +0 -0
- sqlspec/core/statement.py +2253 -0
- sqlspec/core/tenant/__init__.py +64 -0
- sqlspec/core/tenant/base.cp315-win_amd64.pyd +0 -0
- sqlspec/core/tenant/base.py +123 -0
- sqlspec/core/type_converter.cp315-win_amd64.pyd +0 -0
- sqlspec/core/type_converter.py +147 -0
- sqlspec/data_dictionary/__init__.py +237 -0
- sqlspec/data_dictionary/_capabilities.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_capabilities.py +142 -0
- sqlspec/data_dictionary/_dependencies.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_dependencies.py +602 -0
- sqlspec/data_dictionary/_index_ddl.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_index_ddl.py +562 -0
- sqlspec/data_dictionary/_loader.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_loader.py +344 -0
- sqlspec/data_dictionary/_registry.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_registry.py +152 -0
- sqlspec/data_dictionary/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/_types.py +1852 -0
- sqlspec/data_dictionary/dialects/__init__.py +34 -0
- sqlspec/data_dictionary/dialects/bigquery/__init__.py +15 -0
- sqlspec/data_dictionary/dialects/bigquery/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/bigquery/config.py +128 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/columns.sql +63 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/constraints.sql +37 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/datasets.sql +14 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/ddl.sql +51 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/dependencies.sql +22 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/foreign_keys.sql +34 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/indexes.sql +59 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/objects.sql +13 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/privileges.sql +13 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/routines.sql +50 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/system.sql +59 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/tables.sql +111 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/bigquery/sql/views.sql +31 -0
- sqlspec/data_dictionary/dialects/cockroachdb/__init__.py +17 -0
- sqlspec/data_dictionary/dialects/cockroachdb/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/cockroachdb/config.py +95 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/columns.sql +163 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/comments.sql +10 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/constraints.sql +67 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/crdb_internal.sql +11 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/ddl.sql +10 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/dependencies.sql +20 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/foreign_keys.sql +62 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/indexes.sql +32 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/objects.sql +15 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/privileges.sql +13 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/sequences.sql +14 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/tables.sql +15 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/cockroachdb/sql/views.sql +11 -0
- sqlspec/data_dictionary/dialects/db2/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/db2/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/db2/config.py +172 -0
- sqlspec/data_dictionary/dialects/db2/sql/columns.sql +98 -0
- sqlspec/data_dictionary/dialects/db2/sql/constraints.sql +49 -0
- sqlspec/data_dictionary/dialects/db2/sql/foreign_keys.sql +43 -0
- sqlspec/data_dictionary/dialects/db2/sql/indexes.sql +39 -0
- sqlspec/data_dictionary/dialects/db2/sql/objects.sql +53 -0
- sqlspec/data_dictionary/dialects/db2/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/db2/sql/tables.sql +77 -0
- sqlspec/data_dictionary/dialects/db2/sql/version.sql +8 -0
- sqlspec/data_dictionary/dialects/db2/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/duckdb/__init__.py +5 -0
- sqlspec/data_dictionary/dialects/duckdb/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/duckdb/config.py +66 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/columns.sql +150 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/constraints.sql +34 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/databases.sql +11 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/ddl.sql +221 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/dependencies.sql +50 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/extensions.sql +14 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/foreign_keys.sql +46 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/functions.sql +18 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/indexes.sql +34 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/objects.sql +30 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/sequences.sql +19 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/system.sql +21 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/tables.sql +59 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/types.sql +12 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/duckdb/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/mariadb/__init__.py +5 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/columns.sql +45 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/constraints.sql +30 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/ddl.sql +27 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/events.sql +29 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/foreign_keys.sql +42 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/indexes.sql +33 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/objects.sql +50 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/partitions.sql +27 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/plugins.sql +16 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/privileges.sql +24 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/routines.sql +21 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/system.sql +12 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/tables.sql +64 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/triggers.sql +21 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/version.sql +7 -0
- sqlspec/data_dictionary/dialects/mariadb/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/mssql/__init__.py +51 -0
- sqlspec/data_dictionary/dialects/mssql/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/mssql/config.py +558 -0
- sqlspec/data_dictionary/dialects/mssql/sql/columns.sql +120 -0
- sqlspec/data_dictionary/dialects/mssql/sql/constraints.sql +106 -0
- sqlspec/data_dictionary/dialects/mssql/sql/ddl.sql +89 -0
- sqlspec/data_dictionary/dialects/mssql/sql/dependencies.sql +17 -0
- sqlspec/data_dictionary/dialects/mssql/sql/extended_properties.sql +16 -0
- sqlspec/data_dictionary/dialects/mssql/sql/foreign_keys.sql +40 -0
- sqlspec/data_dictionary/dialects/mssql/sql/indexes.sql +86 -0
- sqlspec/data_dictionary/dialects/mssql/sql/modules.sql +19 -0
- sqlspec/data_dictionary/dialects/mssql/sql/objects.sql +16 -0
- sqlspec/data_dictionary/dialects/mssql/sql/permissions.sql +31 -0
- sqlspec/data_dictionary/dialects/mssql/sql/routines.sql +39 -0
- sqlspec/data_dictionary/dialects/mssql/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/mssql/sql/sequences.sql +18 -0
- sqlspec/data_dictionary/dialects/mssql/sql/storage.sql +22 -0
- sqlspec/data_dictionary/dialects/mssql/sql/system.sql +38 -0
- sqlspec/data_dictionary/dialects/mssql/sql/tables.sql +97 -0
- sqlspec/data_dictionary/dialects/mssql/sql/triggers.sql +21 -0
- sqlspec/data_dictionary/dialects/mssql/sql/version.sql +7 -0
- sqlspec/data_dictionary/dialects/mssql/sql/views.sql +18 -0
- sqlspec/data_dictionary/dialects/mysql/__init__.py +34 -0
- sqlspec/data_dictionary/dialects/mysql/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/mysql/config.py +363 -0
- sqlspec/data_dictionary/dialects/mysql/dictionary.py +650 -0
- sqlspec/data_dictionary/dialects/mysql/sql/columns.sql +45 -0
- sqlspec/data_dictionary/dialects/mysql/sql/components.sql +8 -0
- sqlspec/data_dictionary/dialects/mysql/sql/constraints.sql +30 -0
- sqlspec/data_dictionary/dialects/mysql/sql/ddl.sql +23 -0
- sqlspec/data_dictionary/dialects/mysql/sql/events.sql +29 -0
- sqlspec/data_dictionary/dialects/mysql/sql/foreign_keys.sql +42 -0
- sqlspec/data_dictionary/dialects/mysql/sql/indexes.sql +33 -0
- sqlspec/data_dictionary/dialects/mysql/sql/objects.sql +38 -0
- sqlspec/data_dictionary/dialects/mysql/sql/partitions.sql +27 -0
- sqlspec/data_dictionary/dialects/mysql/sql/plugins.sql +16 -0
- sqlspec/data_dictionary/dialects/mysql/sql/privileges.sql +26 -0
- sqlspec/data_dictionary/dialects/mysql/sql/routines.sql +21 -0
- sqlspec/data_dictionary/dialects/mysql/sql/schemas.sql +10 -0
- sqlspec/data_dictionary/dialects/mysql/sql/system.sql +25 -0
- sqlspec/data_dictionary/dialects/mysql/sql/tables.sql +64 -0
- sqlspec/data_dictionary/dialects/mysql/sql/triggers.sql +21 -0
- sqlspec/data_dictionary/dialects/mysql/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/mysql/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/oracle/__init__.py +39 -0
- sqlspec/data_dictionary/dialects/oracle/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/oracle/config.py +266 -0
- sqlspec/data_dictionary/dialects/oracle/sql/arguments.sql +29 -0
- sqlspec/data_dictionary/dialects/oracle/sql/columns.sql +103 -0
- sqlspec/data_dictionary/dialects/oracle/sql/comments.sql +22 -0
- sqlspec/data_dictionary/dialects/oracle/sql/constraints.sql +49 -0
- sqlspec/data_dictionary/dialects/oracle/sql/ddl.sql +4 -0
- sqlspec/data_dictionary/dialects/oracle/sql/dependencies.sql +16 -0
- sqlspec/data_dictionary/dialects/oracle/sql/foreign_keys.sql +48 -0
- sqlspec/data_dictionary/dialects/oracle/sql/grants.sql +34 -0
- sqlspec/data_dictionary/dialects/oracle/sql/indexes.sql +87 -0
- sqlspec/data_dictionary/dialects/oracle/sql/lob_storage.sql +28 -0
- sqlspec/data_dictionary/dialects/oracle/sql/materialized_views.sql +27 -0
- sqlspec/data_dictionary/dialects/oracle/sql/objects.sql +26 -0
- sqlspec/data_dictionary/dialects/oracle/sql/partitions.sql +44 -0
- sqlspec/data_dictionary/dialects/oracle/sql/routines.sql +21 -0
- sqlspec/data_dictionary/dialects/oracle/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/oracle/sql/sequences.sql +21 -0
- sqlspec/data_dictionary/dialects/oracle/sql/source.sql +13 -0
- sqlspec/data_dictionary/dialects/oracle/sql/system.sql +37 -0
- sqlspec/data_dictionary/dialects/oracle/sql/tables.sql +48 -0
- sqlspec/data_dictionary/dialects/oracle/sql/triggers.sql +29 -0
- sqlspec/data_dictionary/dialects/oracle/sql/version.sql +25 -0
- sqlspec/data_dictionary/dialects/oracle/sql/views.sql +49 -0
- sqlspec/data_dictionary/dialects/postgres/__init__.py +19 -0
- sqlspec/data_dictionary/dialects/postgres/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/postgres/config.py +119 -0
- sqlspec/data_dictionary/dialects/postgres/sql/columns.sql +130 -0
- sqlspec/data_dictionary/dialects/postgres/sql/comments.sql +27 -0
- sqlspec/data_dictionary/dialects/postgres/sql/constraints.sql +53 -0
- sqlspec/data_dictionary/dialects/postgres/sql/ddl.sql +55 -0
- sqlspec/data_dictionary/dialects/postgres/sql/dependencies.sql +42 -0
- sqlspec/data_dictionary/dialects/postgres/sql/extensions.sql +11 -0
- sqlspec/data_dictionary/dialects/postgres/sql/foreign_keys.sql +72 -0
- sqlspec/data_dictionary/dialects/postgres/sql/indexes.sql +84 -0
- sqlspec/data_dictionary/dialects/postgres/sql/materialized_views.sql +17 -0
- sqlspec/data_dictionary/dialects/postgres/sql/objects.sql +25 -0
- sqlspec/data_dictionary/dialects/postgres/sql/partitions.sql +19 -0
- sqlspec/data_dictionary/dialects/postgres/sql/privileges.sql +29 -0
- sqlspec/data_dictionary/dialects/postgres/sql/routines.sql +25 -0
- sqlspec/data_dictionary/dialects/postgres/sql/schemas.sql +13 -0
- sqlspec/data_dictionary/dialects/postgres/sql/sequences.sql +32 -0
- sqlspec/data_dictionary/dialects/postgres/sql/system.sql +53 -0
- sqlspec/data_dictionary/dialects/postgres/sql/tables.sql +67 -0
- sqlspec/data_dictionary/dialects/postgres/sql/triggers.sql +20 -0
- sqlspec/data_dictionary/dialects/postgres/sql/types.sql +21 -0
- sqlspec/data_dictionary/dialects/postgres/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/postgres/sql/views.sql +17 -0
- sqlspec/data_dictionary/dialects/snowflake/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/snowflake/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/snowflake/config.py +321 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/columns.sql +48 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/constraints.sql +64 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/ddl.sql +3 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/foreign_keys.sql +7 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/objects.sql +34 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/routines.sql +79 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/schemas.sql +19 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/sequences.sql +45 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/tables.sql +29 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/snowflake/sql/views.sql +37 -0
- sqlspec/data_dictionary/dialects/spanner/__init__.py +5 -0
- sqlspec/data_dictionary/dialects/spanner/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/spanner/config.py +67 -0
- sqlspec/data_dictionary/dialects/spanner/sql/columns.sql +58 -0
- sqlspec/data_dictionary/dialects/spanner/sql/foreign_keys.sql +91 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/change_streams.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/columns.sql +46 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/constraints.sql +63 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/database.sql +9 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/foreign_keys.sql +91 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/indexes.sql +66 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/objects.sql +10 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/placements.sql +8 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/privileges.sql +13 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/property_graphs.sql +11 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/routines.sql +33 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/sequences.sql +14 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/system.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/tables.sql +30 -0
- sqlspec/data_dictionary/dialects/spanner/sql/googlesql/views.sql +13 -0
- sqlspec/data_dictionary/dialects/spanner/sql/indexes.sql +30 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/change_streams.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/columns.sql +34 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/constraints.sql +63 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/foreign_keys.sql +91 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/indexes.sql +52 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/objects.sql +10 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/sequences.sql +14 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/system.sql +28 -0
- sqlspec/data_dictionary/dialects/spanner/sql/postgresql/tables.sql +22 -0
- sqlspec/data_dictionary/dialects/spanner/sql/tables.sql +9 -0
- sqlspec/data_dictionary/dialects/spanner/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/config.py +191 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/columns.sql +97 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/constraints.sql +43 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/foreign_keys.sql +45 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/indexes.sql +39 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/objects.sql +18 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/schemas.sql +15 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/tables.sql +86 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlanywhere/sql/views.sql +15 -0
- sqlspec/data_dictionary/dialects/sqlite/__init__.py +19 -0
- sqlspec/data_dictionary/dialects/sqlite/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sqlite/config.py +412 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/columns.sql +59 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/compile_options.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/constraints.sql +67 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/ddl.sql +37 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/foreign_keys.sql +45 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/functions.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/indexes.sql +76 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/modules.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/objects.sql +13 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/schemas.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/system.sql +7 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/tables.sql +64 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/triggers.sql +10 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sqlite/sql/views.sql +10 -0
- sqlspec/data_dictionary/dialects/sybase/__init__.py +31 -0
- sqlspec/data_dictionary/dialects/sybase/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/sybase/config.py +187 -0
- sqlspec/data_dictionary/dialects/sybase/sql/columns.sql +137 -0
- sqlspec/data_dictionary/dialects/sybase/sql/constraints.sql +85 -0
- sqlspec/data_dictionary/dialects/sybase/sql/foreign_keys.sql +81 -0
- sqlspec/data_dictionary/dialects/sybase/sql/indexes.sql +51 -0
- sqlspec/data_dictionary/dialects/sybase/sql/objects.sql +21 -0
- sqlspec/data_dictionary/dialects/sybase/sql/schemas.sql +16 -0
- sqlspec/data_dictionary/dialects/sybase/sql/tables.sql +46 -0
- sqlspec/data_dictionary/dialects/sybase/sql/version.sql +3 -0
- sqlspec/data_dictionary/dialects/sybase/sql/views.sql +19 -0
- sqlspec/data_dictionary/dialects/teradata/__init__.py +33 -0
- sqlspec/data_dictionary/dialects/teradata/config.cp315-win_amd64.pyd +0 -0
- sqlspec/data_dictionary/dialects/teradata/config.py +228 -0
- sqlspec/data_dictionary/dialects/teradata/sql/columns.sql +22 -0
- sqlspec/data_dictionary/dialects/teradata/sql/constraints.sql +19 -0
- sqlspec/data_dictionary/dialects/teradata/sql/foreign_keys.sql +9 -0
- sqlspec/data_dictionary/dialects/teradata/sql/indexes.sql +9 -0
- sqlspec/data_dictionary/dialects/teradata/sql/objects.sql +4 -0
- sqlspec/data_dictionary/dialects/teradata/sql/schemas.sql +9 -0
- sqlspec/data_dictionary/dialects/teradata/sql/tables.sql +22 -0
- sqlspec/data_dictionary/dialects/teradata/sql/version.sql +4 -0
- sqlspec/data_dictionary/dialects/teradata/sql/views.sql +4 -0
- sqlspec/dialects/__init__.py +44 -0
- sqlspec/dialects/db2/__init__.py +111 -0
- sqlspec/dialects/db2/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/db2/_generators.py +376 -0
- sqlspec/dialects/db2/_parsers.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/db2/_parsers.py +657 -0
- sqlspec/dialects/db2/_transforms.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/db2/_transforms.py +175 -0
- sqlspec/dialects/postgres/__init__.py +10 -0
- sqlspec/dialects/postgres/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/postgres/_generators.py +81 -0
- sqlspec/dialects/postgres/_operators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/postgres/_operators.py +95 -0
- sqlspec/dialects/postgres/_paradedb.py +44 -0
- sqlspec/dialects/postgres/_pg_textsearch.py +38 -0
- sqlspec/dialects/postgres/_pgvector.py +36 -0
- sqlspec/dialects/spanner/__init__.py +69 -0
- sqlspec/dialects/spanner/_expressions.py +247 -0
- sqlspec/dialects/spanner/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/spanner/_generators.py +961 -0
- sqlspec/dialects/spanner/_parsers.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/spanner/_parsers.py +871 -0
- sqlspec/dialects/spanner/_spangres.py +43 -0
- sqlspec/dialects/spanner/_spanner.py +57 -0
- sqlspec/dialects/sybase/__init__.py +115 -0
- sqlspec/dialects/sybase/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/sybase/_generators.py +379 -0
- sqlspec/dialects/sybase/_parsers.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/sybase/_parsers.py +225 -0
- sqlspec/dialects/sybase/_transforms.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/sybase/_transforms.py +68 -0
- sqlspec/dialects/teradata/__init__.py +42 -0
- sqlspec/dialects/teradata/_generators.cp315-win_amd64.pyd +0 -0
- sqlspec/dialects/teradata/_generators.py +203 -0
- sqlspec/driver/__init__.py +151 -0
- sqlspec/driver/_async.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_async.py +3244 -0
- sqlspec/driver/_common.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_common.py +4765 -0
- sqlspec/driver/_deferred.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_deferred.py +232 -0
- sqlspec/driver/_exception_handler.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_exception_handler.py +224 -0
- sqlspec/driver/_routing.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_routing.py +2891 -0
- sqlspec/driver/_session.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_session.py +180 -0
- sqlspec/driver/_sql_helpers.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_sql_helpers.py +140 -0
- sqlspec/driver/_stream.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_stream.py +392 -0
- sqlspec/driver/_sync.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_sync.py +3107 -0
- sqlspec/driver/_tenant.cp315-win_amd64.pyd +0 -0
- sqlspec/driver/_tenant.py +326 -0
- sqlspec/exceptions.cp315-win_amd64.pyd +0 -0
- sqlspec/exceptions.py +568 -0
- sqlspec/extensions/__init__.py +3 -0
- sqlspec/extensions/adk/__init__.py +136 -0
- sqlspec/extensions/adk/_config_utils.py +306 -0
- sqlspec/extensions/adk/_table_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/_table_utils.py +126 -0
- sqlspec/extensions/adk/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/_types.py +59 -0
- sqlspec/extensions/adk/artifact/__init__.py +18 -0
- sqlspec/extensions/adk/artifact/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/artifact/_types.py +41 -0
- sqlspec/extensions/adk/artifact/service.py +657 -0
- sqlspec/extensions/adk/artifact/store.py +444 -0
- sqlspec/extensions/adk/converters.py +230 -0
- sqlspec/extensions/adk/maintenance.py +262 -0
- sqlspec/extensions/adk/memory/__init__.py +36 -0
- sqlspec/extensions/adk/memory/_types.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/adk/memory/_types.py +48 -0
- sqlspec/extensions/adk/memory/converters.py +271 -0
- sqlspec/extensions/adk/memory/service.py +474 -0
- sqlspec/extensions/adk/memory/store.py +586 -0
- sqlspec/extensions/adk/migrations/0001_create_adk_tables.py +181 -0
- sqlspec/extensions/adk/migrations/0002_create_mssql_python_memory.py +51 -0
- sqlspec/extensions/adk/migrations/__init__.py +3 -0
- sqlspec/extensions/adk/migrations/reconcile.py +282 -0
- sqlspec/extensions/adk/service.py +463 -0
- sqlspec/extensions/adk/store.py +1239 -0
- sqlspec/extensions/events/__init__.py +132 -0
- sqlspec/extensions/events/_buffer.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_buffer.py +38 -0
- sqlspec/extensions/events/_channel.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_channel.py +1144 -0
- sqlspec/extensions/events/_hints.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_hints.py +38 -0
- sqlspec/extensions/events/_models.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_models.py +22 -0
- sqlspec/extensions/events/_names.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_names.py +27 -0
- sqlspec/extensions/events/_payload.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_payload.py +139 -0
- sqlspec/extensions/events/_protocols.py +154 -0
- sqlspec/extensions/events/_queue.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/_queue.py +1147 -0
- sqlspec/extensions/events/_store.py +318 -0
- sqlspec/extensions/events/migrations/0001_create_event_queue.py +106 -0
- sqlspec/extensions/events/migrations/__init__.py +3 -0
- sqlspec/extensions/events/migrations/reconcile.py +145 -0
- sqlspec/extensions/events/primitives.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/events/primitives.py +91 -0
- sqlspec/extensions/fastapi/__init__.py +26 -0
- sqlspec/extensions/fastapi/extension.py +360 -0
- sqlspec/extensions/fastapi/providers.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/fastapi/providers.py +1091 -0
- sqlspec/extensions/flask/__init__.py +20 -0
- sqlspec/extensions/flask/_portal.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/flask/_portal.py +212 -0
- sqlspec/extensions/flask/_state.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/flask/_state.py +135 -0
- sqlspec/extensions/flask/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/flask/_utils.py +171 -0
- sqlspec/extensions/flask/extension.py +1234 -0
- sqlspec/extensions/litestar/__init__.py +52 -0
- sqlspec/extensions/litestar/_tenant_resolution.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/_tenant_resolution.py +314 -0
- sqlspec/extensions/litestar/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/_utils.py +222 -0
- sqlspec/extensions/litestar/channels.py +249 -0
- sqlspec/extensions/litestar/cli.py +100 -0
- sqlspec/extensions/litestar/config.py +5 -0
- sqlspec/extensions/litestar/handlers.py +796 -0
- sqlspec/extensions/litestar/migrations/0001_create_session_table.py +138 -0
- sqlspec/extensions/litestar/migrations/__init__.py +3 -0
- sqlspec/extensions/litestar/migrations/reconcile.py +132 -0
- sqlspec/extensions/litestar/plugin.py +2172 -0
- sqlspec/extensions/litestar/providers.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/litestar/providers.py +1239 -0
- sqlspec/extensions/litestar/store.py +613 -0
- sqlspec/extensions/litestar/tenant.py +292 -0
- sqlspec/extensions/otel/__init__.py +58 -0
- sqlspec/extensions/prometheus/__init__.py +5 -0
- sqlspec/extensions/prometheus/_observer.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/prometheus/_observer.py +152 -0
- sqlspec/extensions/sanic/__init__.py +28 -0
- sqlspec/extensions/sanic/_state.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/sanic/_state.py +102 -0
- sqlspec/extensions/sanic/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/sanic/_utils.py +234 -0
- sqlspec/extensions/sanic/extension.py +1467 -0
- sqlspec/extensions/starlette/__init__.py +31 -0
- sqlspec/extensions/starlette/_state.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/starlette/_state.py +103 -0
- sqlspec/extensions/starlette/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/extensions/starlette/_utils.py +267 -0
- sqlspec/extensions/starlette/extension.py +691 -0
- sqlspec/extensions/starlette/middleware.py +845 -0
- sqlspec/loader.cp315-win_amd64.pyd +0 -0
- sqlspec/loader.py +1733 -0
- sqlspec/migrations/__init__.py +104 -0
- sqlspec/migrations/_backup.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/_backup.py +36 -0
- sqlspec/migrations/base.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/base.py +1688 -0
- sqlspec/migrations/commands.py +4002 -0
- sqlspec/migrations/context.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/context.py +158 -0
- sqlspec/migrations/fix.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/fix.py +193 -0
- sqlspec/migrations/loaders.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/loaders.py +835 -0
- sqlspec/migrations/runner.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/runner.py +2144 -0
- sqlspec/migrations/schema.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/schema.py +1266 -0
- sqlspec/migrations/squash.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/squash.py +2452 -0
- sqlspec/migrations/templates.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/templates.py +310 -0
- sqlspec/migrations/tracker.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/tracker.py +1529 -0
- sqlspec/migrations/utils.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/utils.py +534 -0
- sqlspec/migrations/validation.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/validation.py +355 -0
- sqlspec/migrations/version.cp315-win_amd64.pyd +0 -0
- sqlspec/migrations/version.py +455 -0
- sqlspec/observability/__init__.py +122 -0
- sqlspec/observability/_common.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_common.py +307 -0
- sqlspec/observability/_config.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_config.py +362 -0
- sqlspec/observability/_diagnostics.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_diagnostics.py +75 -0
- sqlspec/observability/_dispatcher.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_dispatcher.py +320 -0
- sqlspec/observability/_formatters/__init__.py +13 -0
- sqlspec/observability/_formatters/_aws.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_aws.py +90 -0
- sqlspec/observability/_formatters/_azure.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_azure.py +84 -0
- sqlspec/observability/_formatters/_base.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_base.py +40 -0
- sqlspec/observability/_formatters/_gcp.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatters/_gcp.py +119 -0
- sqlspec/observability/_formatting.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_formatting.py +76 -0
- sqlspec/observability/_observer.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_observer.py +445 -0
- sqlspec/observability/_runtime.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_runtime.py +740 -0
- sqlspec/observability/_sampling.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_sampling.py +169 -0
- sqlspec/observability/_spans.cp315-win_amd64.pyd +0 -0
- sqlspec/observability/_spans.py +212 -0
- sqlspec/protocols.py +1235 -0
- sqlspec/py.typed +0 -0
- sqlspec/service/__init__.py +5 -0
- sqlspec/service/_base.py +1051 -0
- sqlspec/service/_core.cp315-win_amd64.pyd +0 -0
- sqlspec/service/_core.py +625 -0
- sqlspec/storage/__init__.py +111 -0
- sqlspec/storage/_arrow_payload.py +802 -0
- sqlspec/storage/_arrow_stream.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_arrow_stream.py +134 -0
- sqlspec/storage/_ingest.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_ingest.py +810 -0
- sqlspec/storage/_paths.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_paths.py +313 -0
- sqlspec/storage/_staging_sql.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_staging_sql.py +695 -0
- sqlspec/storage/_utils.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/_utils.py +174 -0
- sqlspec/storage/backends/__init__.py +43 -0
- sqlspec/storage/backends/base.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/base.py +399 -0
- sqlspec/storage/backends/fsspec.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/fsspec.py +1390 -0
- sqlspec/storage/backends/local.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/local.py +968 -0
- sqlspec/storage/backends/obstore.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/backends/obstore.py +1974 -0
- sqlspec/storage/errors.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/errors.py +127 -0
- sqlspec/storage/pipeline.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/pipeline.py +1270 -0
- sqlspec/storage/registry.cp315-win_amd64.pyd +0 -0
- sqlspec/storage/registry.py +318 -0
- sqlspec/typing.py +261 -0
- sqlspec/utils/__init__.py +9 -0
- sqlspec/utils/adapters.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/adapters.py +186 -0
- sqlspec/utils/arrow_helpers.py +2157 -0
- sqlspec/utils/config_tools.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/config_tools.py +712 -0
- sqlspec/utils/correlation.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/correlation.py +137 -0
- sqlspec/utils/deprecation.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/deprecation.py +222 -0
- sqlspec/utils/dispatch.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/dispatch.py +104 -0
- sqlspec/utils/env.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/env.py +437 -0
- sqlspec/utils/fixtures.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/fixtures.py +2470 -0
- sqlspec/utils/logging.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/logging.py +267 -0
- sqlspec/utils/module_loader.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/module_loader.py +399 -0
- sqlspec/utils/portal.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/portal.py +411 -0
- sqlspec/utils/routing.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/routing.py +645 -0
- sqlspec/utils/schema.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/schema.py +1050 -0
- sqlspec/utils/serializers/__init__.py +69 -0
- sqlspec/utils/serializers/_json.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_json.py +525 -0
- sqlspec/utils/serializers/_numpy.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_numpy.py +65 -0
- sqlspec/utils/serializers/_schema.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/serializers/_schema.py +340 -0
- sqlspec/utils/sync_tools.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/sync_tools.py +502 -0
- sqlspec/utils/tenant/__init__.py +71 -0
- sqlspec/utils/tenant/_context.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_context.py +550 -0
- sqlspec/utils/tenant/_cursor.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_cursor.py +43 -0
- sqlspec/utils/tenant/_mssql.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_mssql.py +189 -0
- sqlspec/utils/tenant/_postgres.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/tenant/_postgres.py +142 -0
- sqlspec/utils/text.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/text.py +317 -0
- sqlspec/utils/type_converters.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/type_converters.py +220 -0
- sqlspec/utils/type_guards.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/type_guards.py +1505 -0
- sqlspec/utils/uuids.cp315-win_amd64.pyd +0 -0
- sqlspec/utils/uuids.py +263 -0
- sqlspec-0.72.0.dist-info/METADATA +228 -0
- sqlspec-0.72.0.dist-info/RECORD +1144 -0
- sqlspec-0.72.0.dist-info/WHEEL +4 -0
- sqlspec-0.72.0.dist-info/entry_points.txt +13 -0
- sqlspec-0.72.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,1673 @@
|
|
|
1
|
+
"""Spanner driver implementation."""
|
|
2
|
+
|
|
3
|
+
import contextvars
|
|
4
|
+
from collections.abc import AsyncIterator, Iterator
|
|
5
|
+
from typing import TYPE_CHECKING, Any, Literal, Protocol, cast, overload
|
|
6
|
+
|
|
7
|
+
from mypy_extensions import mypyc_attr
|
|
8
|
+
from sqlglot import exp as _sqlglot_exp
|
|
9
|
+
|
|
10
|
+
from sqlspec.adapters.spanner._typing import (
|
|
11
|
+
SpannerAsyncConnection,
|
|
12
|
+
SpannerAsyncCursor,
|
|
13
|
+
SpannerAsyncSessionContext,
|
|
14
|
+
SpannerAsyncTransaction,
|
|
15
|
+
SpannerGoogleAPICallError,
|
|
16
|
+
SpannerGoogleAPIError,
|
|
17
|
+
SpannerSyncCursor,
|
|
18
|
+
SpannerSyncSessionContext,
|
|
19
|
+
SpannerTransaction,
|
|
20
|
+
)
|
|
21
|
+
from sqlspec.adapters.spanner.core import (
|
|
22
|
+
SpannerAsyncStreamSource,
|
|
23
|
+
SpannerExecuteOptions,
|
|
24
|
+
SpannerSyncStreamSource,
|
|
25
|
+
build_execute_kwargs,
|
|
26
|
+
build_param_type_signature,
|
|
27
|
+
chunk_mutation_rows,
|
|
28
|
+
coerce_params,
|
|
29
|
+
collect_rows,
|
|
30
|
+
create_mapped_exception,
|
|
31
|
+
default_statement_config,
|
|
32
|
+
driver_profile,
|
|
33
|
+
execute_ddl_async,
|
|
34
|
+
execute_ddl_sync,
|
|
35
|
+
execute_partitioned_dml_async,
|
|
36
|
+
execute_partitioned_dml_sync,
|
|
37
|
+
infer_param_types,
|
|
38
|
+
is_ddl_statement,
|
|
39
|
+
is_query_statement,
|
|
40
|
+
pop_execute_options,
|
|
41
|
+
renew_transaction,
|
|
42
|
+
resolve_row_plan,
|
|
43
|
+
resolve_transaction_completion,
|
|
44
|
+
run_in_transaction_async,
|
|
45
|
+
run_in_transaction_sync,
|
|
46
|
+
supports_batch_update,
|
|
47
|
+
supports_write,
|
|
48
|
+
)
|
|
49
|
+
from sqlspec.adapters.spanner.data_dictionary import SpannerAsyncDataDictionary, SpannerSyncDataDictionary
|
|
50
|
+
from sqlspec.core.parameters._registry import register_driver_profile
|
|
51
|
+
from sqlspec.driver._async import AsyncDriverAdapterBase
|
|
52
|
+
from sqlspec.driver._common import ExecutionResult, validate_load_from_storage_kwargs
|
|
53
|
+
from sqlspec.driver._exception_handler import BaseAsyncExceptionHandler, BaseSyncExceptionHandler
|
|
54
|
+
from sqlspec.driver._stream import AsyncRowStream, SyncRowStream
|
|
55
|
+
from sqlspec.driver._sync import SyncDriverAdapterBase
|
|
56
|
+
from sqlspec.exceptions import ReadOnlyTransactionError, SQLConversionError, with_cause
|
|
57
|
+
from sqlspec.utils.serializers._json import from_json
|
|
58
|
+
from sqlspec.utils.sync_tools import exit_async_context
|
|
59
|
+
|
|
60
|
+
if TYPE_CHECKING:
|
|
61
|
+
from collections.abc import Awaitable, Callable, Mapping, Sequence
|
|
62
|
+
|
|
63
|
+
from sqlglot.dialects.dialect import DialectType
|
|
64
|
+
|
|
65
|
+
from sqlspec.adapters.spanner._typing import SpannerSyncConnection
|
|
66
|
+
from sqlspec.builder._base import QueryBuilder
|
|
67
|
+
from sqlspec.core.filters import StatementFilter
|
|
68
|
+
from sqlspec.core.result._base import ArrowResult, SQLResult
|
|
69
|
+
from sqlspec.core.statement import SQL, Statement, StatementConfig
|
|
70
|
+
from sqlspec.storage.pipeline import StorageBridgeJob, StorageDestination, StorageFormat, StorageTelemetry
|
|
71
|
+
from sqlspec.typing import SchemaT, StatementParameters
|
|
72
|
+
|
|
73
|
+
__all__ = (
|
|
74
|
+
"SpannerAsyncCursor",
|
|
75
|
+
"SpannerAsyncDriver",
|
|
76
|
+
"SpannerAsyncExceptionHandler",
|
|
77
|
+
"SpannerAsyncSessionContext",
|
|
78
|
+
"SpannerSyncCursor",
|
|
79
|
+
"SpannerSyncDriver",
|
|
80
|
+
"SpannerSyncExceptionHandler",
|
|
81
|
+
"SpannerSyncSessionContext",
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
_pending_spanner_options: contextvars.ContextVar[SpannerExecuteOptions | None] = contextvars.ContextVar(
|
|
85
|
+
"_pending_spanner_options", default=None
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
_READ_ONLY_SNAPSHOT_ERROR_MESSAGE = (
|
|
90
|
+
"Cannot execute DML in a read-only Snapshot context. "
|
|
91
|
+
"SpannerSyncConfig.provide_session() opens a write-capable Transaction by default; "
|
|
92
|
+
"the current session must have been opened via SpannerSyncConfig.provide_replica_session()."
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
_READ_ONLY_ASYNC_SNAPSHOT_ERROR_MESSAGE = (
|
|
96
|
+
"Cannot execute DML in a read-only Snapshot context. "
|
|
97
|
+
"SpannerAsyncConfig.provide_session() opens a write-capable Transaction by default; "
|
|
98
|
+
"the current session must have been opened via SpannerAsyncConfig.provide_replica_session()."
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
_READ_ONLY_SNAPSHOT_DDL_ERROR_MESSAGE = (
|
|
102
|
+
"Cannot execute DDL in a read-only Snapshot context. "
|
|
103
|
+
"Use SpannerSyncConfig.provide_session() or provide_write_session() for schema changes."
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
_READ_ONLY_ASYNC_SNAPSHOT_DDL_ERROR_MESSAGE = (
|
|
107
|
+
"Cannot execute DDL in a read-only Snapshot context. "
|
|
108
|
+
"Use SpannerAsyncConfig.provide_session() or provide_write_session() for schema changes."
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
@mypyc_attr(allow_interpreted_subclasses=True)
|
|
113
|
+
class SpannerSyncExceptionHandler(BaseSyncExceptionHandler):
|
|
114
|
+
"""Map Spanner client exceptions to SQLSpec exceptions stored on ``pending_exception``."""
|
|
115
|
+
|
|
116
|
+
__slots__ = ()
|
|
117
|
+
|
|
118
|
+
def _handle_exception(self, exc_type: "type[BaseException] | None", exc_val: "BaseException") -> bool:
|
|
119
|
+
if exc_type is None:
|
|
120
|
+
return False
|
|
121
|
+
|
|
122
|
+
if isinstance(exc_val, (SpannerGoogleAPICallError, SpannerGoogleAPIError)):
|
|
123
|
+
self.pending_exception = create_mapped_exception(exc_val)
|
|
124
|
+
return True
|
|
125
|
+
return False
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
@mypyc_attr(allow_interpreted_subclasses=True)
|
|
129
|
+
class SpannerAsyncExceptionHandler(BaseAsyncExceptionHandler):
|
|
130
|
+
"""Map async Spanner client exceptions to SQLSpec exceptions stored on ``pending_exception``."""
|
|
131
|
+
|
|
132
|
+
__slots__ = ()
|
|
133
|
+
|
|
134
|
+
def _handle_exception(self, exc_type: "type[BaseException] | None", exc_val: "BaseException") -> bool:
|
|
135
|
+
if exc_type is None:
|
|
136
|
+
return False
|
|
137
|
+
|
|
138
|
+
if isinstance(exc_val, (SpannerGoogleAPICallError, SpannerGoogleAPIError)):
|
|
139
|
+
self.pending_exception = create_mapped_exception(exc_val)
|
|
140
|
+
return True
|
|
141
|
+
return False
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
@mypyc_attr(allow_interpreted_subclasses=True)
|
|
145
|
+
class SpannerSyncDriver(SyncDriverAdapterBase):
|
|
146
|
+
"""Synchronous Spanner driver operating on Snapshot or Transaction contexts."""
|
|
147
|
+
|
|
148
|
+
dialect: "DialectType | None" = "spanner"
|
|
149
|
+
__slots__ = (
|
|
150
|
+
"_data_dictionary",
|
|
151
|
+
"_owns_transaction",
|
|
152
|
+
"_pending_execute_options",
|
|
153
|
+
"_row_plan_cache",
|
|
154
|
+
"_row_plan_deserializer",
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
def __init__(
|
|
158
|
+
self,
|
|
159
|
+
connection: "SpannerSyncConnection",
|
|
160
|
+
statement_config: "StatementConfig | None" = None,
|
|
161
|
+
driver_features: "dict[str, Any] | None" = None,
|
|
162
|
+
) -> None:
|
|
163
|
+
features = dict(driver_features) if driver_features else {}
|
|
164
|
+
if statement_config is None:
|
|
165
|
+
statement_config = default_statement_config
|
|
166
|
+
|
|
167
|
+
super().__init__(connection=connection, statement_config=statement_config, driver_features=features)
|
|
168
|
+
self._data_dictionary: SpannerSyncDataDictionary | None = None
|
|
169
|
+
self._owns_transaction = True
|
|
170
|
+
self._pending_execute_options: SpannerExecuteOptions | None = None
|
|
171
|
+
self._row_plan_cache: dict[int, tuple[Any, list[str], tuple[tuple[int, Any], ...] | None]] = {}
|
|
172
|
+
self._row_plan_deserializer = cast("Callable[[str], Any]", features.get("json_deserializer", from_json))
|
|
173
|
+
|
|
174
|
+
@property
|
|
175
|
+
def data_dictionary(self) -> "SpannerSyncDataDictionary":
|
|
176
|
+
if self._data_dictionary is None:
|
|
177
|
+
dialect_str = str(self.statement_config.dialect) if self.statement_config.dialect else "spanner"
|
|
178
|
+
mode = "postgresql" if dialect_str in {"spangres", "postgres", "postgresql"} else "googlesql"
|
|
179
|
+
self._data_dictionary = SpannerSyncDataDictionary(mode=mode)
|
|
180
|
+
return self._data_dictionary
|
|
181
|
+
|
|
182
|
+
def dispatch_execute(self, cursor: "SpannerSyncConnection", statement: "SQL") -> ExecutionResult:
|
|
183
|
+
sql, params = self._compiled_sql(statement, self.statement_config)
|
|
184
|
+
if is_ddl_statement(sql):
|
|
185
|
+
if not supports_write(cursor):
|
|
186
|
+
raise SQLConversionError(_READ_ONLY_SNAPSHOT_DDL_ERROR_MESSAGE)
|
|
187
|
+
self._commit_before_ddl()
|
|
188
|
+
execute_kwargs = self._execute_kwargs()
|
|
189
|
+
execute_ddl_sync(self._resolve_database(), [sql], timeout=execute_kwargs.get("timeout"))
|
|
190
|
+
return self.create_execution_result(cursor, rowcount_override=0)
|
|
191
|
+
if statement.is_modifying_operation() and not supports_write(cursor):
|
|
192
|
+
raise ReadOnlyTransactionError(_READ_ONLY_SNAPSHOT_ERROR_MESSAGE)
|
|
193
|
+
dict_params = cast("dict[str, Any]", params) if isinstance(params, dict) else None
|
|
194
|
+
param_types_map = self._infer_param_types(dict_params)
|
|
195
|
+
coerced_params = self._coerce_params(dict_params)
|
|
196
|
+
|
|
197
|
+
if statement.returns_rows():
|
|
198
|
+
reader = cast("_SpannerReadProtocol", cursor)
|
|
199
|
+
execute_kwargs = self._execute_kwargs(for_read=True)
|
|
200
|
+
result_set = reader.execute_sql(sql, params=coerced_params, param_types=param_types_map, **execute_kwargs)
|
|
201
|
+
rows = list(result_set)
|
|
202
|
+
try:
|
|
203
|
+
metadata = result_set.metadata
|
|
204
|
+
row_type = metadata.row_type
|
|
205
|
+
fields = row_type.fields
|
|
206
|
+
except AttributeError:
|
|
207
|
+
fields = None
|
|
208
|
+
if not fields:
|
|
209
|
+
msg = "Result set metadata not available."
|
|
210
|
+
raise SQLConversionError(msg)
|
|
211
|
+
column_names, column_plan = self._resolve_row_plan(fields)
|
|
212
|
+
data, column_names = collect_rows(rows, fields, column_names=column_names, column_plan=column_plan)
|
|
213
|
+
return self.create_execution_result(
|
|
214
|
+
cursor,
|
|
215
|
+
selected_data=data,
|
|
216
|
+
column_names=column_names,
|
|
217
|
+
data_row_count=len(data),
|
|
218
|
+
is_select_result=True,
|
|
219
|
+
row_format="tuple",
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
if supports_write(cursor):
|
|
223
|
+
writer = cast("_SpannerWriteProtocol", cursor)
|
|
224
|
+
execute_kwargs = self._execute_kwargs()
|
|
225
|
+
row_count = writer.execute_update(sql, params=coerced_params, param_types=param_types_map, **execute_kwargs)
|
|
226
|
+
return self.create_execution_result(cursor, rowcount_override=row_count)
|
|
227
|
+
|
|
228
|
+
raise ReadOnlyTransactionError(_READ_ONLY_SNAPSHOT_ERROR_MESSAGE)
|
|
229
|
+
|
|
230
|
+
def dispatch_select_stream(self, statement: "SQL", chunk_size: int) -> "SyncRowStream[dict[str, Any]] | None":
|
|
231
|
+
if not statement.returns_rows():
|
|
232
|
+
return None
|
|
233
|
+
sql, params = self._compiled_sql(statement, self.statement_config)
|
|
234
|
+
dict_params = cast("dict[str, Any]", params) if isinstance(params, dict) else None
|
|
235
|
+
param_types_map = self._infer_param_types(dict_params)
|
|
236
|
+
coerced_params = self._coerce_params(dict_params)
|
|
237
|
+
return SyncRowStream(
|
|
238
|
+
SpannerSyncStreamSource(
|
|
239
|
+
self, sql, coerced_params, param_types_map, chunk_size, self._execute_kwargs(for_read=True)
|
|
240
|
+
)
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
def dispatch_execute_many(self, cursor: "SpannerSyncConnection", statement: "SQL") -> ExecutionResult:
|
|
244
|
+
if not supports_write(cursor):
|
|
245
|
+
msg = "execute_many cannot modify a read-only Snapshot"
|
|
246
|
+
raise ReadOnlyTransactionError(msg)
|
|
247
|
+
if not supports_batch_update(cursor):
|
|
248
|
+
msg = "execute_many requires a Transaction context"
|
|
249
|
+
raise SQLConversionError(msg)
|
|
250
|
+
|
|
251
|
+
sql, prepared_parameters = self._compiled_sql(statement, self.statement_config)
|
|
252
|
+
|
|
253
|
+
if not isinstance(prepared_parameters, list):
|
|
254
|
+
msg = "execute_many requires a list of parameter sets"
|
|
255
|
+
raise SQLConversionError(msg)
|
|
256
|
+
|
|
257
|
+
_coerce = self._coerce_params
|
|
258
|
+
_infer = self._infer_param_types
|
|
259
|
+
execute_kwargs = self._execute_kwargs(for_batch=True)
|
|
260
|
+
param_types_cache: dict[tuple[tuple[str, type[Any], Any], ...], dict[str, Any]] = {}
|
|
261
|
+
empty_param_types: dict[str, Any] = {}
|
|
262
|
+
batch_args: list[tuple[str, dict[str, Any] | None, dict[str, Any]]] = []
|
|
263
|
+
append_batch_arg = batch_args.append
|
|
264
|
+
for params in prepared_parameters:
|
|
265
|
+
raw_params = cast("dict[str, Any]", params) if isinstance(params, dict) else None
|
|
266
|
+
coerced_params = _coerce(raw_params)
|
|
267
|
+
if not coerced_params:
|
|
268
|
+
append_batch_arg((sql, {}, empty_param_types))
|
|
269
|
+
continue
|
|
270
|
+
signature = build_param_type_signature(raw_params)
|
|
271
|
+
param_types = param_types_cache.get(signature)
|
|
272
|
+
if param_types is None:
|
|
273
|
+
param_types = _infer(raw_params)
|
|
274
|
+
param_types_cache[signature] = param_types
|
|
275
|
+
append_batch_arg((sql, coerced_params, param_types))
|
|
276
|
+
|
|
277
|
+
writer = cast("_SpannerWriteProtocol", cursor)
|
|
278
|
+
status, row_counts = writer.batch_update(batch_args, **execute_kwargs)
|
|
279
|
+
if status is not None and getattr(status, "code", 0) != 0:
|
|
280
|
+
raise create_mapped_exception(status)
|
|
281
|
+
total_rows = sum(row_counts) if row_counts else 0
|
|
282
|
+
|
|
283
|
+
return self.create_execution_result(cursor, rowcount_override=total_rows, is_many_result=True)
|
|
284
|
+
|
|
285
|
+
def dispatch_execute_script(self, cursor: "SpannerSyncConnection", statement: "SQL") -> ExecutionResult:
|
|
286
|
+
bound_statements = self._bound_script_statements(statement)
|
|
287
|
+
if bound_statements is None:
|
|
288
|
+
sql, params = self._compiled_sql(statement, self.statement_config)
|
|
289
|
+
statements = self.split_script_statements(sql, statement.statement_config, strip_trailing_semicolon=True)
|
|
290
|
+
entries = [(stmt, params) for stmt in statements]
|
|
291
|
+
else:
|
|
292
|
+
entries = [self._compiled_sql(piece, piece.statement_config) for piece in bound_statements]
|
|
293
|
+
statements = [entry[0] for entry in entries]
|
|
294
|
+
is_transaction = supports_write(cursor)
|
|
295
|
+
reader = cast("_SpannerReadProtocol", cursor)
|
|
296
|
+
|
|
297
|
+
count = 0
|
|
298
|
+
read_execute_kwargs = self._execute_kwargs(for_read=True)
|
|
299
|
+
write_execute_kwargs = self._execute_kwargs()
|
|
300
|
+
ddl_timeout = write_execute_kwargs.get("timeout")
|
|
301
|
+
dialect_str = str(self.dialect) if self.dialect else "spanner"
|
|
302
|
+
pending_ddl: list[str] = []
|
|
303
|
+
for index, (stmt, params) in enumerate(entries):
|
|
304
|
+
if is_ddl_statement(stmt):
|
|
305
|
+
if not is_transaction:
|
|
306
|
+
raise SQLConversionError(_READ_ONLY_SNAPSHOT_DDL_ERROR_MESSAGE)
|
|
307
|
+
pending_ddl.append(stmt)
|
|
308
|
+
count += 1
|
|
309
|
+
continue
|
|
310
|
+
if pending_ddl:
|
|
311
|
+
self._commit_before_ddl()
|
|
312
|
+
execute_ddl_sync(self._resolve_database(), pending_ddl, timeout=ddl_timeout)
|
|
313
|
+
pending_ddl = []
|
|
314
|
+
cursor = self.connection
|
|
315
|
+
reader = cast("_SpannerReadProtocol", cursor)
|
|
316
|
+
script_params = cast("dict[str, Any]", params) if isinstance(params, dict) else None
|
|
317
|
+
param_types_map = self._infer_param_types(script_params)
|
|
318
|
+
coerced_params = self._coerce_params(script_params)
|
|
319
|
+
is_select = is_query_statement(stmt, dialect_str)
|
|
320
|
+
if not is_select and not is_transaction:
|
|
321
|
+
raise ReadOnlyTransactionError(_READ_ONLY_SNAPSHOT_ERROR_MESSAGE)
|
|
322
|
+
if not is_select and is_transaction:
|
|
323
|
+
writer = cast("_SpannerWriteProtocol", cursor)
|
|
324
|
+
statement_kwargs = write_execute_kwargs
|
|
325
|
+
if "last_statement" in write_execute_kwargs and index != len(statements) - 1:
|
|
326
|
+
statement_kwargs = {
|
|
327
|
+
key: value for key, value in write_execute_kwargs.items() if key != "last_statement"
|
|
328
|
+
}
|
|
329
|
+
writer.execute_update(stmt, params=coerced_params, param_types=param_types_map, **statement_kwargs)
|
|
330
|
+
else:
|
|
331
|
+
_ = list(
|
|
332
|
+
reader.execute_sql(stmt, params=coerced_params, param_types=param_types_map, **read_execute_kwargs)
|
|
333
|
+
)
|
|
334
|
+
count += 1
|
|
335
|
+
|
|
336
|
+
if pending_ddl:
|
|
337
|
+
self._commit_before_ddl()
|
|
338
|
+
execute_ddl_sync(self._resolve_database(), pending_ddl, timeout=ddl_timeout)
|
|
339
|
+
return self.create_execution_result(
|
|
340
|
+
cursor, statement_count=count, successful_statements=count, is_script_result=True
|
|
341
|
+
)
|
|
342
|
+
|
|
343
|
+
def begin(self) -> None:
|
|
344
|
+
return None
|
|
345
|
+
|
|
346
|
+
def commit(self) -> None:
|
|
347
|
+
"""Commit the active transaction when it has work to commit."""
|
|
348
|
+
if not self._owns_transaction:
|
|
349
|
+
return
|
|
350
|
+
if isinstance(self.connection, SpannerTransaction):
|
|
351
|
+
exc_handler = self.handle_database_exceptions()
|
|
352
|
+
with exc_handler:
|
|
353
|
+
if resolve_transaction_completion(self.connection, failed=False) == "commit":
|
|
354
|
+
cast("_SpannerWriteProtocol", self.connection).commit()
|
|
355
|
+
self._check_pending_exception(exc_handler)
|
|
356
|
+
self._renew_finished_transaction()
|
|
357
|
+
|
|
358
|
+
def rollback(self) -> None:
|
|
359
|
+
"""Roll back the active transaction when it has begun."""
|
|
360
|
+
if not self._owns_transaction:
|
|
361
|
+
return
|
|
362
|
+
if isinstance(self.connection, SpannerTransaction):
|
|
363
|
+
exc_handler = self.handle_database_exceptions()
|
|
364
|
+
with exc_handler:
|
|
365
|
+
if resolve_transaction_completion(self.connection, failed=True) == "rollback":
|
|
366
|
+
cast("_SpannerWriteProtocol", self.connection).rollback()
|
|
367
|
+
self._check_pending_exception(exc_handler)
|
|
368
|
+
self._renew_finished_transaction()
|
|
369
|
+
|
|
370
|
+
def create_savepoint(self, name: str) -> None:
|
|
371
|
+
"""Raise because Spanner does not support savepoints.
|
|
372
|
+
|
|
373
|
+
Raises:
|
|
374
|
+
NotImplementedError: Always.
|
|
375
|
+
"""
|
|
376
|
+
msg = "Spanner does not support savepoints."
|
|
377
|
+
raise NotImplementedError(msg)
|
|
378
|
+
|
|
379
|
+
def release_savepoint(self, name: str) -> None:
|
|
380
|
+
"""Raise because Spanner does not support savepoints.
|
|
381
|
+
|
|
382
|
+
Raises:
|
|
383
|
+
NotImplementedError: Always.
|
|
384
|
+
"""
|
|
385
|
+
msg = "Spanner does not support savepoints."
|
|
386
|
+
raise NotImplementedError(msg)
|
|
387
|
+
|
|
388
|
+
def rollback_to_savepoint(self, name: str) -> None:
|
|
389
|
+
"""Raise because Spanner does not support savepoints.
|
|
390
|
+
|
|
391
|
+
Raises:
|
|
392
|
+
NotImplementedError: Always.
|
|
393
|
+
"""
|
|
394
|
+
msg = "Spanner does not support savepoints."
|
|
395
|
+
raise NotImplementedError(msg)
|
|
396
|
+
|
|
397
|
+
def with_cursor(self, connection: "SpannerSyncConnection") -> "SpannerSyncCursor":
|
|
398
|
+
return SpannerSyncCursor(connection)
|
|
399
|
+
|
|
400
|
+
def handle_database_exceptions(self) -> "SpannerSyncExceptionHandler":
|
|
401
|
+
return SpannerSyncExceptionHandler()
|
|
402
|
+
|
|
403
|
+
def execute(
|
|
404
|
+
self,
|
|
405
|
+
statement: "SQL | Statement | QueryBuilder",
|
|
406
|
+
/,
|
|
407
|
+
*parameters: "StatementParameters | StatementFilter",
|
|
408
|
+
statement_config: "StatementConfig | None" = None,
|
|
409
|
+
**kwargs: Any,
|
|
410
|
+
) -> "SQLResult":
|
|
411
|
+
"""Execute a statement with optional Spanner per-call request options."""
|
|
412
|
+
execute_options = pop_execute_options(kwargs)
|
|
413
|
+
if execute_options is None:
|
|
414
|
+
return super().execute(statement, *parameters, statement_config=statement_config, **kwargs)
|
|
415
|
+
token = _pending_spanner_options.set(execute_options)
|
|
416
|
+
try:
|
|
417
|
+
return super().execute(statement, *parameters, statement_config=statement_config, **kwargs)
|
|
418
|
+
finally:
|
|
419
|
+
_pending_spanner_options.reset(token)
|
|
420
|
+
|
|
421
|
+
def execute_many(
|
|
422
|
+
self,
|
|
423
|
+
statement: "SQL | Statement | QueryBuilder",
|
|
424
|
+
/,
|
|
425
|
+
parameters: "Sequence[StatementParameters]",
|
|
426
|
+
*filters: "StatementParameters | StatementFilter",
|
|
427
|
+
statement_config: "StatementConfig | None" = None,
|
|
428
|
+
**kwargs: Any,
|
|
429
|
+
) -> "SQLResult":
|
|
430
|
+
"""Execute a batch statement with optional Spanner per-call request options."""
|
|
431
|
+
execute_options = pop_execute_options(kwargs)
|
|
432
|
+
if execute_options is None:
|
|
433
|
+
return super().execute_many(statement, parameters, *filters, statement_config=statement_config, **kwargs)
|
|
434
|
+
token = _pending_spanner_options.set(execute_options)
|
|
435
|
+
try:
|
|
436
|
+
return super().execute_many(statement, parameters, *filters, statement_config=statement_config, **kwargs)
|
|
437
|
+
finally:
|
|
438
|
+
_pending_spanner_options.reset(token)
|
|
439
|
+
|
|
440
|
+
def execute_script(
|
|
441
|
+
self,
|
|
442
|
+
statement: "str | SQL",
|
|
443
|
+
/,
|
|
444
|
+
*parameters: "StatementParameters | StatementFilter",
|
|
445
|
+
statement_config: "StatementConfig | None" = None,
|
|
446
|
+
**kwargs: Any,
|
|
447
|
+
) -> "SQLResult":
|
|
448
|
+
"""Execute a multi-statement script with optional Spanner per-call request options."""
|
|
449
|
+
execute_options = pop_execute_options(kwargs)
|
|
450
|
+
if execute_options is None:
|
|
451
|
+
return super().execute_script(statement, *parameters, statement_config=statement_config, **kwargs)
|
|
452
|
+
token = _pending_spanner_options.set(execute_options)
|
|
453
|
+
try:
|
|
454
|
+
return super().execute_script(statement, *parameters, statement_config=statement_config, **kwargs)
|
|
455
|
+
finally:
|
|
456
|
+
_pending_spanner_options.reset(token)
|
|
457
|
+
|
|
458
|
+
@overload
|
|
459
|
+
def select_stream(
|
|
460
|
+
self,
|
|
461
|
+
statement: "SQL | Statement | QueryBuilder",
|
|
462
|
+
/,
|
|
463
|
+
*parameters: "StatementParameters | StatementFilter",
|
|
464
|
+
schema_type: "type[SchemaT]",
|
|
465
|
+
statement_config: "StatementConfig | None" = None,
|
|
466
|
+
chunk_size: int = 1000,
|
|
467
|
+
native_only: bool = False,
|
|
468
|
+
**kwargs: Any,
|
|
469
|
+
) -> "SyncRowStream[SchemaT]": ...
|
|
470
|
+
@overload
|
|
471
|
+
def select_stream(
|
|
472
|
+
self,
|
|
473
|
+
statement: "SQL | Statement | QueryBuilder",
|
|
474
|
+
/,
|
|
475
|
+
*parameters: "StatementParameters | StatementFilter",
|
|
476
|
+
schema_type: None = None,
|
|
477
|
+
statement_config: "StatementConfig | None" = None,
|
|
478
|
+
chunk_size: int = 1000,
|
|
479
|
+
native_only: bool = False,
|
|
480
|
+
**kwargs: Any,
|
|
481
|
+
) -> "SyncRowStream[dict[str, Any]]": ...
|
|
482
|
+
def select_stream(
|
|
483
|
+
self,
|
|
484
|
+
statement: "SQL | Statement | QueryBuilder",
|
|
485
|
+
/,
|
|
486
|
+
*parameters: "StatementParameters | StatementFilter",
|
|
487
|
+
schema_type: "type[SchemaT] | None" = None,
|
|
488
|
+
statement_config: "StatementConfig | None" = None,
|
|
489
|
+
chunk_size: int = 1000,
|
|
490
|
+
native_only: bool = False,
|
|
491
|
+
**kwargs: Any,
|
|
492
|
+
) -> "SyncRowStream[SchemaT] | SyncRowStream[dict[str, Any]]":
|
|
493
|
+
"""Execute a query and stream rows with optional Spanner per-call options."""
|
|
494
|
+
execute_options = pop_execute_options(kwargs)
|
|
495
|
+
if execute_options is None:
|
|
496
|
+
return super().select_stream(
|
|
497
|
+
statement,
|
|
498
|
+
*parameters,
|
|
499
|
+
schema_type=schema_type,
|
|
500
|
+
statement_config=statement_config,
|
|
501
|
+
chunk_size=chunk_size,
|
|
502
|
+
native_only=native_only,
|
|
503
|
+
**kwargs,
|
|
504
|
+
)
|
|
505
|
+
previous_options = self._pending_execute_options
|
|
506
|
+
self._pending_execute_options = execute_options
|
|
507
|
+
try:
|
|
508
|
+
return super().select_stream(
|
|
509
|
+
statement,
|
|
510
|
+
*parameters,
|
|
511
|
+
schema_type=schema_type,
|
|
512
|
+
statement_config=statement_config,
|
|
513
|
+
chunk_size=chunk_size,
|
|
514
|
+
native_only=native_only,
|
|
515
|
+
**kwargs,
|
|
516
|
+
)
|
|
517
|
+
finally:
|
|
518
|
+
self._pending_execute_options = previous_options
|
|
519
|
+
|
|
520
|
+
def select_to_storage(
|
|
521
|
+
self,
|
|
522
|
+
statement: "SQL | str",
|
|
523
|
+
destination: "StorageDestination",
|
|
524
|
+
/,
|
|
525
|
+
*parameters: Any,
|
|
526
|
+
statement_config: "StatementConfig | None" = None,
|
|
527
|
+
partitioner: "dict[str, object] | None" = None,
|
|
528
|
+
format_hint: "StorageFormat | None" = None,
|
|
529
|
+
telemetry: "StorageTelemetry | None" = None,
|
|
530
|
+
**kwargs: Any,
|
|
531
|
+
) -> "StorageBridgeJob":
|
|
532
|
+
"""Execute query and stream Arrow results to storage."""
|
|
533
|
+
self._require_capability("arrow_export_enabled")
|
|
534
|
+
arrow_result = self._select_for_storage(statement, *parameters, statement_config=statement_config, **kwargs)
|
|
535
|
+
sync_pipeline = self._storage_pipeline()
|
|
536
|
+
telemetry_payload = self._write_storage_result(
|
|
537
|
+
arrow_result, destination, format_hint=format_hint, pipeline=sync_pipeline
|
|
538
|
+
)
|
|
539
|
+
self._attach_partition_telemetry(telemetry_payload, partitioner)
|
|
540
|
+
return self._storage_job(telemetry_payload, telemetry)
|
|
541
|
+
|
|
542
|
+
def load_from_arrow(
|
|
543
|
+
self,
|
|
544
|
+
table: str,
|
|
545
|
+
source: "ArrowResult | Any",
|
|
546
|
+
*,
|
|
547
|
+
partitioner: "dict[str, object] | None" = None,
|
|
548
|
+
overwrite: bool = False,
|
|
549
|
+
telemetry: "StorageTelemetry | None" = None,
|
|
550
|
+
stage_table: "bool | str | None" = False,
|
|
551
|
+
conflict_keys: "Sequence[str] | None" = None,
|
|
552
|
+
on_conflict: Literal["update", "nothing"] = "update",
|
|
553
|
+
exclude_update_columns: "Sequence[str] | None" = None,
|
|
554
|
+
drop_stage_table: bool = True,
|
|
555
|
+
drop_indexes: bool = False,
|
|
556
|
+
concurrent_indexes: bool = True,
|
|
557
|
+
type_casts: "Mapping[str, str] | None" = None,
|
|
558
|
+
) -> "StorageBridgeJob":
|
|
559
|
+
"""Load Arrow data into Spanner table via batch mutations."""
|
|
560
|
+
self._require_capability("arrow_import_enabled")
|
|
561
|
+
if drop_indexes:
|
|
562
|
+
with self.without_indexes(table, concurrent=concurrent_indexes):
|
|
563
|
+
return self.load_from_arrow(
|
|
564
|
+
table,
|
|
565
|
+
source,
|
|
566
|
+
partitioner=partitioner,
|
|
567
|
+
overwrite=overwrite,
|
|
568
|
+
telemetry=telemetry,
|
|
569
|
+
stage_table=stage_table,
|
|
570
|
+
conflict_keys=conflict_keys,
|
|
571
|
+
on_conflict=on_conflict,
|
|
572
|
+
exclude_update_columns=exclude_update_columns,
|
|
573
|
+
drop_stage_table=drop_stage_table,
|
|
574
|
+
drop_indexes=False,
|
|
575
|
+
concurrent_indexes=concurrent_indexes,
|
|
576
|
+
type_casts=type_casts,
|
|
577
|
+
)
|
|
578
|
+
if stage_table or (
|
|
579
|
+
conflict_keys and on_conflict == "nothing" and not hasattr(self.connection, "insert_or_ignore")
|
|
580
|
+
):
|
|
581
|
+
return self._execute_staged_load_sync(
|
|
582
|
+
table,
|
|
583
|
+
source,
|
|
584
|
+
raw_loader=self.load_from_arrow,
|
|
585
|
+
partitioner=partitioner,
|
|
586
|
+
overwrite=overwrite,
|
|
587
|
+
telemetry=telemetry,
|
|
588
|
+
stage_table=stage_table,
|
|
589
|
+
conflict_keys=conflict_keys,
|
|
590
|
+
on_conflict=on_conflict,
|
|
591
|
+
exclude_update_columns=exclude_update_columns,
|
|
592
|
+
drop_stage_table=drop_stage_table,
|
|
593
|
+
drop_indexes=False,
|
|
594
|
+
concurrent_indexes=concurrent_indexes,
|
|
595
|
+
type_casts=type_casts,
|
|
596
|
+
)
|
|
597
|
+
arrow_table = self._coerce_arrow_table(source)
|
|
598
|
+
|
|
599
|
+
exc_handler = self.handle_database_exceptions()
|
|
600
|
+
with exc_handler:
|
|
601
|
+
if overwrite:
|
|
602
|
+
dialect_str = str(self.dialect) if self.dialect else "spanner"
|
|
603
|
+
table_sql = _sqlglot_exp.to_table(table, dialect=dialect_str).sql(dialect=dialect_str, identify=True)
|
|
604
|
+
delete_sql = f"DELETE FROM {table_sql} WHERE TRUE"
|
|
605
|
+
if isinstance(self.connection, SpannerTransaction):
|
|
606
|
+
writer = cast("_SpannerWriteProtocol", self.connection)
|
|
607
|
+
writer.execute_update(delete_sql, **self._execute_kwargs())
|
|
608
|
+
else:
|
|
609
|
+
msg = "Delete requires a Transaction context."
|
|
610
|
+
raise SQLConversionError(msg)
|
|
611
|
+
|
|
612
|
+
columns, records = self._arrow_table_to_rows(arrow_table)
|
|
613
|
+
if records:
|
|
614
|
+
chunks = self._chunk_mutation_rows(columns, records)
|
|
615
|
+
if self.driver_features.get("enable_batch_write_api") and not overwrite:
|
|
616
|
+
self._batch_write_mutations(table, columns, chunks)
|
|
617
|
+
else:
|
|
618
|
+
conn = self.connection
|
|
619
|
+
if not isinstance(conn, SpannerTransaction):
|
|
620
|
+
msg = "Arrow import requires a Transaction context."
|
|
621
|
+
raise SQLConversionError(msg)
|
|
622
|
+
writer = cast("_SpannerWriteProtocol", conn)
|
|
623
|
+
for idx, chunk in enumerate(chunks):
|
|
624
|
+
if conflict_keys and on_conflict == "nothing" and hasattr(writer, "insert_or_ignore"):
|
|
625
|
+
writer.insert_or_ignore(table, columns, chunk)
|
|
626
|
+
else:
|
|
627
|
+
writer.insert_or_update(table, columns, chunk)
|
|
628
|
+
if self._owns_transaction and idx < len(chunks) - 1 and hasattr(writer, "commit"):
|
|
629
|
+
writer.commit()
|
|
630
|
+
self._renew_finished_transaction()
|
|
631
|
+
writer = cast("_SpannerWriteProtocol", self.connection)
|
|
632
|
+
self._check_pending_exception(exc_handler)
|
|
633
|
+
|
|
634
|
+
telemetry_payload = self._ingest_telemetry(arrow_table)
|
|
635
|
+
telemetry_payload["destination"] = table
|
|
636
|
+
self._attach_partition_telemetry(telemetry_payload, partitioner)
|
|
637
|
+
return self._storage_job(telemetry_payload, telemetry)
|
|
638
|
+
|
|
639
|
+
def load_from_storage(
|
|
640
|
+
self,
|
|
641
|
+
table: str,
|
|
642
|
+
source: "StorageDestination",
|
|
643
|
+
*,
|
|
644
|
+
file_format: "StorageFormat",
|
|
645
|
+
partitioner: "dict[str, object] | None" = None,
|
|
646
|
+
overwrite: bool = False,
|
|
647
|
+
**kwargs: Any,
|
|
648
|
+
) -> "StorageBridgeJob":
|
|
649
|
+
"""Load artifacts from storage into Spanner table."""
|
|
650
|
+
if kwargs:
|
|
651
|
+
validate_load_from_storage_kwargs(kwargs)
|
|
652
|
+
return super().load_from_storage(
|
|
653
|
+
table,
|
|
654
|
+
source,
|
|
655
|
+
file_format=file_format,
|
|
656
|
+
partitioner=partitioner,
|
|
657
|
+
overwrite=overwrite,
|
|
658
|
+
storage_options=kwargs.get("storage_options"),
|
|
659
|
+
stage_table=kwargs.get("stage_table"),
|
|
660
|
+
conflict_keys=kwargs.get("conflict_keys"),
|
|
661
|
+
on_conflict=kwargs.get("on_conflict", "update"),
|
|
662
|
+
exclude_update_columns=kwargs.get("exclude_update_columns"),
|
|
663
|
+
drop_stage_table=kwargs.get("drop_stage_table", True),
|
|
664
|
+
drop_indexes=kwargs.get("drop_indexes", False),
|
|
665
|
+
concurrent_indexes=kwargs.get("concurrent_indexes", False),
|
|
666
|
+
checkpoint_table=kwargs.get("checkpoint_table"),
|
|
667
|
+
checkpoint_phase=kwargs.get("checkpoint_phase", "default"),
|
|
668
|
+
max_workers=kwargs.get("max_workers", 1),
|
|
669
|
+
executor=kwargs.get("executor", "thread"),
|
|
670
|
+
arrow_schema=kwargs.get("arrow_schema"),
|
|
671
|
+
type_casts=kwargs.get("type_casts"),
|
|
672
|
+
)
|
|
673
|
+
arrow_table, inbound = self._read_storage_arrow(source, file_format=file_format)
|
|
674
|
+
return self.load_from_arrow(table, arrow_table, partitioner=partitioner, overwrite=overwrite, telemetry=inbound)
|
|
675
|
+
|
|
676
|
+
def collect_rows(self, cursor: "SpannerSyncConnection", fetched: "list[Any]") -> "tuple[list[Any], list[str], int]":
|
|
677
|
+
"""Collect Spanner rows for the direct execution path.
|
|
678
|
+
|
|
679
|
+
Dict rows supply their keys as column names; other rows are returned
|
|
680
|
+
unchanged with no column names.
|
|
681
|
+
"""
|
|
682
|
+
if not fetched:
|
|
683
|
+
return [], [], 0
|
|
684
|
+
if isinstance(fetched[0], dict):
|
|
685
|
+
column_names = list(fetched[0].keys())
|
|
686
|
+
return fetched, column_names, len(fetched)
|
|
687
|
+
return fetched, [], len(fetched)
|
|
688
|
+
|
|
689
|
+
def resolve_rowcount(self, cursor: "SpannerSyncConnection") -> int:
|
|
690
|
+
"""Resolve rowcount from Spanner cursor for the direct execution path.
|
|
691
|
+
|
|
692
|
+
Spanner uses execute_update return value, not cursor.rowcount, so this
|
|
693
|
+
returns 0.
|
|
694
|
+
"""
|
|
695
|
+
return 0
|
|
696
|
+
|
|
697
|
+
def run_in_transaction(self, fn: "Callable[..., Any]", *args: Any, **kwargs: Any) -> Any:
|
|
698
|
+
"""Execute a callable inside Spanner's retryable transaction runner.
|
|
699
|
+
|
|
700
|
+
``fn`` is called as ``fn(driver, *args, **kwargs)`` with a driver bound
|
|
701
|
+
to the runner's transaction. A ``DeadlockError`` caused by
|
|
702
|
+
``google.api_core.exceptions.Aborted`` is unwrapped so the runner
|
|
703
|
+
retries, and a terminal ``Aborted`` is raised as ``DeadlockError``.
|
|
704
|
+
"""
|
|
705
|
+
return run_in_transaction_sync(self._resolve_database(), self._transaction_driver, fn, *args, **kwargs)
|
|
706
|
+
|
|
707
|
+
def execute_partitioned_dml(
|
|
708
|
+
self,
|
|
709
|
+
sql: str,
|
|
710
|
+
params: "dict[str, Any] | None" = None,
|
|
711
|
+
param_types: "dict[str, Any] | None" = None,
|
|
712
|
+
**kwargs: Any,
|
|
713
|
+
) -> int:
|
|
714
|
+
"""Execute a Partitioned DML statement against the Spanner database."""
|
|
715
|
+
call_kwargs = {**self._execute_kwargs(), **kwargs}
|
|
716
|
+
return execute_partitioned_dml_sync(
|
|
717
|
+
self._resolve_database(),
|
|
718
|
+
sql,
|
|
719
|
+
params=params,
|
|
720
|
+
param_types=param_types,
|
|
721
|
+
json_serializer=self.driver_features.get("json_serializer"),
|
|
722
|
+
enable_uuid_conversion=self.driver_features.get("enable_uuid_conversion", True),
|
|
723
|
+
**call_kwargs,
|
|
724
|
+
)
|
|
725
|
+
|
|
726
|
+
def write_insert(self, table: str, columns: "Sequence[str]", values: "Sequence[Sequence[Any]]") -> None:
|
|
727
|
+
"""Buffer Spanner INSERT mutations on the active transaction or batch."""
|
|
728
|
+
self._apply_mutation(table, columns, values, method_name="insert")
|
|
729
|
+
|
|
730
|
+
def write_upsert(self, table: str, columns: "Sequence[str]", values: "Sequence[Sequence[Any]]") -> None:
|
|
731
|
+
"""Buffer Spanner INSERT_OR_UPDATE mutations on the active transaction or batch."""
|
|
732
|
+
self._apply_mutation(table, columns, values, method_name="insert_or_update")
|
|
733
|
+
|
|
734
|
+
def write_update(self, table: str, columns: "Sequence[str]", values: "Sequence[Sequence[Any]]") -> None:
|
|
735
|
+
"""Buffer Spanner UPDATE mutations on the active transaction or batch."""
|
|
736
|
+
self._apply_mutation(table, columns, values, method_name="update")
|
|
737
|
+
|
|
738
|
+
def write_delete(self, table: str, keyset: Any) -> None:
|
|
739
|
+
"""Buffer a Spanner DELETE mutation on the active transaction or batch."""
|
|
740
|
+
if not supports_write(self.connection):
|
|
741
|
+
raise ReadOnlyTransactionError(_READ_ONLY_SNAPSHOT_ERROR_MESSAGE)
|
|
742
|
+
writer = cast("_SpannerWriteProtocol", self.connection)
|
|
743
|
+
exc_handler = self.handle_database_exceptions()
|
|
744
|
+
with exc_handler:
|
|
745
|
+
writer.delete(table, keyset)
|
|
746
|
+
self._check_pending_exception(exc_handler)
|
|
747
|
+
|
|
748
|
+
def bind_external_transaction(self) -> None:
|
|
749
|
+
"""Mark the driver as bound to an externally managed transaction runner."""
|
|
750
|
+
self._owns_transaction = False
|
|
751
|
+
|
|
752
|
+
def _apply_mutation(
|
|
753
|
+
self, table: str, columns: "Sequence[str]", values: "Sequence[Sequence[Any]]", *, method_name: str
|
|
754
|
+
) -> None:
|
|
755
|
+
if not supports_write(self.connection):
|
|
756
|
+
raise ReadOnlyTransactionError(_READ_ONLY_SNAPSHOT_ERROR_MESSAGE)
|
|
757
|
+
column_list = list(columns)
|
|
758
|
+
records = [tuple(row) for row in values]
|
|
759
|
+
if not records:
|
|
760
|
+
return
|
|
761
|
+
chunks = self._chunk_mutation_rows(column_list, records)
|
|
762
|
+
mutation_fn = getattr(self.connection, method_name)
|
|
763
|
+
exc_handler = self.handle_database_exceptions()
|
|
764
|
+
with exc_handler:
|
|
765
|
+
for idx, chunk in enumerate(chunks):
|
|
766
|
+
mutation_fn = getattr(self.connection, method_name)
|
|
767
|
+
mutation_fn(table, column_list, chunk)
|
|
768
|
+
if self._owns_transaction and idx < len(chunks) - 1 and isinstance(self.connection, SpannerTransaction):
|
|
769
|
+
cast("_SpannerWriteProtocol", self.connection).commit()
|
|
770
|
+
self._renew_finished_transaction()
|
|
771
|
+
self._check_pending_exception(exc_handler)
|
|
772
|
+
|
|
773
|
+
def _execute_kwargs(self, *, for_read: bool = False, for_batch: bool = False) -> dict[str, Any]:
|
|
774
|
+
options = _pending_spanner_options.get() or self._pending_execute_options
|
|
775
|
+
return build_execute_kwargs(self.driver_features, options, for_read=for_read, for_batch=for_batch)
|
|
776
|
+
|
|
777
|
+
def _chunk_mutation_rows(self, columns: "list[str]", records: "list[tuple[Any, ...]]") -> "list[list[list[Any]]]":
|
|
778
|
+
return chunk_mutation_rows(columns, records, self._coerce_params)
|
|
779
|
+
|
|
780
|
+
def _resolve_database(self) -> Any:
|
|
781
|
+
return cast("Any", self.connection)._session._database
|
|
782
|
+
|
|
783
|
+
def _batch_write_mutations(self, table: str, columns: "list[str]", chunks: "list[list[list[Any]]]") -> None:
|
|
784
|
+
"""High-throughput ingest via the Spanner Batch Write API (one mutation group per chunk)."""
|
|
785
|
+
database = self._resolve_database()
|
|
786
|
+
with database.mutation_groups() as mutation_groups:
|
|
787
|
+
for chunk in chunks:
|
|
788
|
+
group = mutation_groups.group()
|
|
789
|
+
group.insert_or_update(table, columns, chunk)
|
|
790
|
+
for response in mutation_groups.batch_write():
|
|
791
|
+
status = response.status
|
|
792
|
+
if status is not None and status.code:
|
|
793
|
+
msg = f"Spanner batch_write group failed: {status.message}"
|
|
794
|
+
raise SQLConversionError(msg)
|
|
795
|
+
|
|
796
|
+
def _commit_before_ddl(self) -> None:
|
|
797
|
+
"""Commit a begun session transaction before a schema change, as DDL does on MySQL or Oracle."""
|
|
798
|
+
if self._owns_transaction and isinstance(self.connection, SpannerTransaction):
|
|
799
|
+
self.commit()
|
|
800
|
+
|
|
801
|
+
def _renew_finished_transaction(self) -> None:
|
|
802
|
+
"""Start a new transaction on the session once the owned transaction has finished."""
|
|
803
|
+
connection = cast("Any", self.connection)
|
|
804
|
+
if self._owns_transaction and (connection.committed is not None or connection.rolled_back):
|
|
805
|
+
self.connection = renew_transaction(connection)
|
|
806
|
+
|
|
807
|
+
def _transaction_driver(self, transaction: "SpannerSyncConnection") -> "SpannerSyncDriver":
|
|
808
|
+
driver = type(self)(
|
|
809
|
+
connection=transaction, statement_config=self.statement_config, driver_features=self.driver_features
|
|
810
|
+
)
|
|
811
|
+
driver._owns_transaction = False
|
|
812
|
+
if self._observability is not None:
|
|
813
|
+
driver.attach_observability(self._observability)
|
|
814
|
+
return driver
|
|
815
|
+
|
|
816
|
+
def _connection_in_transaction(self) -> bool:
|
|
817
|
+
"""Check if connection is in transaction."""
|
|
818
|
+
if not self._owns_transaction:
|
|
819
|
+
return True
|
|
820
|
+
conn = self.connection
|
|
821
|
+
return bool(
|
|
822
|
+
isinstance(conn, (SpannerTransaction, SpannerAsyncTransaction))
|
|
823
|
+
and (conn._transaction_id is not None or bool(conn._mutations))
|
|
824
|
+
and getattr(conn, "committed", None) is None
|
|
825
|
+
and not getattr(conn, "rolled_back", False)
|
|
826
|
+
)
|
|
827
|
+
|
|
828
|
+
def _coerce_params(self, params: "dict[str, Any] | list[Any] | tuple[Any, ...] | None") -> "dict[str, Any] | None":
|
|
829
|
+
return coerce_params(
|
|
830
|
+
params,
|
|
831
|
+
json_serializer=self.driver_features.get("json_serializer"),
|
|
832
|
+
enable_uuid_conversion=self.driver_features.get("enable_uuid_conversion", True),
|
|
833
|
+
)
|
|
834
|
+
|
|
835
|
+
def _infer_param_types(self, params: "dict[str, Any] | list[Any] | tuple[Any, ...] | None") -> "dict[str, Any]":
|
|
836
|
+
return infer_param_types(params)
|
|
837
|
+
|
|
838
|
+
def _resolve_row_plan(self, fields: Any) -> "tuple[list[str], tuple[tuple[int, Any], ...] | None]":
|
|
839
|
+
json_deserializer = cast("Callable[[str], Any]", self.driver_features.get("json_deserializer", from_json))
|
|
840
|
+
if json_deserializer is not self._row_plan_deserializer:
|
|
841
|
+
self._row_plan_cache.clear()
|
|
842
|
+
self._row_plan_deserializer = json_deserializer
|
|
843
|
+
return resolve_row_plan(fields, self._row_plan_cache, json_deserializer=json_deserializer)
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
@mypyc_attr(allow_interpreted_subclasses=True)
|
|
847
|
+
class SpannerAsyncDriver(AsyncDriverAdapterBase):
|
|
848
|
+
"""Asynchronous Spanner driver operating on AsyncSnapshot or AsyncTransaction contexts."""
|
|
849
|
+
|
|
850
|
+
dialect: "DialectType | None" = "spanner"
|
|
851
|
+
__slots__ = (
|
|
852
|
+
"_data_dictionary",
|
|
853
|
+
"_owns_transaction",
|
|
854
|
+
"_pending_execute_options",
|
|
855
|
+
"_row_plan_cache",
|
|
856
|
+
"_row_plan_deserializer",
|
|
857
|
+
)
|
|
858
|
+
|
|
859
|
+
def __init__(
|
|
860
|
+
self,
|
|
861
|
+
connection: "SpannerAsyncConnection",
|
|
862
|
+
statement_config: "StatementConfig | None" = None,
|
|
863
|
+
driver_features: "dict[str, Any] | None" = None,
|
|
864
|
+
) -> None:
|
|
865
|
+
features = dict(driver_features) if driver_features else {}
|
|
866
|
+
if statement_config is None:
|
|
867
|
+
statement_config = default_statement_config
|
|
868
|
+
|
|
869
|
+
super().__init__(connection=connection, statement_config=statement_config, driver_features=features)
|
|
870
|
+
self._data_dictionary: SpannerAsyncDataDictionary | None = None
|
|
871
|
+
self._owns_transaction = True
|
|
872
|
+
self._pending_execute_options: SpannerExecuteOptions | None = None
|
|
873
|
+
self._row_plan_cache: dict[int, tuple[Any, list[str], tuple[tuple[int, Any], ...] | None]] = {}
|
|
874
|
+
self._row_plan_deserializer = cast("Callable[[str], Any]", features.get("json_deserializer", from_json))
|
|
875
|
+
|
|
876
|
+
@property
|
|
877
|
+
def data_dictionary(self) -> "SpannerAsyncDataDictionary":
|
|
878
|
+
if self._data_dictionary is None:
|
|
879
|
+
dialect_str = str(self.statement_config.dialect) if self.statement_config.dialect else "spanner"
|
|
880
|
+
mode = "postgresql" if dialect_str in {"spangres", "postgres", "postgresql"} else "googlesql"
|
|
881
|
+
self._data_dictionary = SpannerAsyncDataDictionary(mode=mode)
|
|
882
|
+
return self._data_dictionary
|
|
883
|
+
|
|
884
|
+
async def dispatch_execute(self, cursor: "SpannerAsyncConnection", statement: "SQL") -> ExecutionResult:
|
|
885
|
+
sql, params = self._compiled_sql(statement, self.statement_config)
|
|
886
|
+
if is_ddl_statement(sql):
|
|
887
|
+
if not supports_write(cursor):
|
|
888
|
+
raise SQLConversionError(_READ_ONLY_ASYNC_SNAPSHOT_DDL_ERROR_MESSAGE)
|
|
889
|
+
await self._commit_before_ddl()
|
|
890
|
+
execute_kwargs = self._execute_kwargs()
|
|
891
|
+
await execute_ddl_async(self._resolve_database(), [sql], timeout=execute_kwargs.get("timeout"))
|
|
892
|
+
return self.create_execution_result(cursor, rowcount_override=0)
|
|
893
|
+
if statement.is_modifying_operation() and not supports_write(cursor):
|
|
894
|
+
raise ReadOnlyTransactionError(_READ_ONLY_ASYNC_SNAPSHOT_ERROR_MESSAGE)
|
|
895
|
+
dict_params = cast("dict[str, Any]", params) if isinstance(params, dict) else None
|
|
896
|
+
param_types_map = self._infer_param_types(dict_params)
|
|
897
|
+
coerced_params = self._coerce_params(dict_params)
|
|
898
|
+
|
|
899
|
+
if statement.returns_rows():
|
|
900
|
+
reader = cast("_SpannerAsyncReadProtocol", cursor)
|
|
901
|
+
execute_kwargs = self._execute_kwargs(for_read=True)
|
|
902
|
+
result_set = await reader.execute_sql(
|
|
903
|
+
sql, params=coerced_params, param_types=param_types_map, **execute_kwargs
|
|
904
|
+
)
|
|
905
|
+
rows = [row async for row in result_set]
|
|
906
|
+
try:
|
|
907
|
+
metadata = result_set.metadata
|
|
908
|
+
row_type = metadata.row_type
|
|
909
|
+
fields = row_type.fields
|
|
910
|
+
except AttributeError:
|
|
911
|
+
fields = None
|
|
912
|
+
if not fields:
|
|
913
|
+
msg = "Result set metadata not available."
|
|
914
|
+
raise SQLConversionError(msg)
|
|
915
|
+
column_names, column_plan = self._resolve_row_plan(fields)
|
|
916
|
+
data, column_names = collect_rows(rows, fields, column_names=column_names, column_plan=column_plan)
|
|
917
|
+
return self.create_execution_result(
|
|
918
|
+
cursor,
|
|
919
|
+
selected_data=data,
|
|
920
|
+
column_names=column_names,
|
|
921
|
+
data_row_count=len(data),
|
|
922
|
+
is_select_result=True,
|
|
923
|
+
row_format="tuple",
|
|
924
|
+
)
|
|
925
|
+
|
|
926
|
+
if supports_write(cursor):
|
|
927
|
+
writer = cast("_SpannerAsyncWriteProtocol", cursor)
|
|
928
|
+
execute_kwargs = self._execute_kwargs()
|
|
929
|
+
row_count = await writer.execute_update(
|
|
930
|
+
sql, params=coerced_params, param_types=param_types_map, **execute_kwargs
|
|
931
|
+
)
|
|
932
|
+
return self.create_execution_result(cursor, rowcount_override=row_count)
|
|
933
|
+
|
|
934
|
+
raise ReadOnlyTransactionError(_READ_ONLY_ASYNC_SNAPSHOT_ERROR_MESSAGE)
|
|
935
|
+
|
|
936
|
+
def dispatch_select_stream(self, statement: "SQL", chunk_size: int) -> "AsyncRowStream[dict[str, Any]] | None":
|
|
937
|
+
if not statement.returns_rows():
|
|
938
|
+
return None
|
|
939
|
+
sql, params = self._compiled_sql(statement, self.statement_config)
|
|
940
|
+
dict_params = cast("dict[str, Any]", params) if isinstance(params, dict) else None
|
|
941
|
+
param_types_map = self._infer_param_types(dict_params)
|
|
942
|
+
coerced_params = self._coerce_params(dict_params)
|
|
943
|
+
return AsyncRowStream(
|
|
944
|
+
SpannerAsyncStreamSource(
|
|
945
|
+
self, sql, coerced_params, param_types_map, chunk_size, self._execute_kwargs(for_read=True)
|
|
946
|
+
)
|
|
947
|
+
)
|
|
948
|
+
|
|
949
|
+
async def dispatch_execute_many(self, cursor: "SpannerAsyncConnection", statement: "SQL") -> ExecutionResult:
|
|
950
|
+
if not supports_write(cursor):
|
|
951
|
+
msg = "execute_many cannot modify a read-only Snapshot"
|
|
952
|
+
raise ReadOnlyTransactionError(msg)
|
|
953
|
+
if not supports_batch_update(cursor):
|
|
954
|
+
msg = "execute_many requires a Transaction context"
|
|
955
|
+
raise SQLConversionError(msg)
|
|
956
|
+
|
|
957
|
+
sql, prepared_parameters = self._compiled_sql(statement, self.statement_config)
|
|
958
|
+
|
|
959
|
+
if not isinstance(prepared_parameters, list):
|
|
960
|
+
msg = "execute_many requires a list of parameter sets"
|
|
961
|
+
raise SQLConversionError(msg)
|
|
962
|
+
|
|
963
|
+
_coerce = self._coerce_params
|
|
964
|
+
_infer = self._infer_param_types
|
|
965
|
+
execute_kwargs = self._execute_kwargs(for_batch=True)
|
|
966
|
+
param_types_cache: dict[tuple[tuple[str, type[Any], Any], ...], dict[str, Any]] = {}
|
|
967
|
+
empty_param_types: dict[str, Any] = {}
|
|
968
|
+
batch_args: list[tuple[str, dict[str, Any] | None, dict[str, Any]]] = []
|
|
969
|
+
append_batch_arg = batch_args.append
|
|
970
|
+
for params in prepared_parameters:
|
|
971
|
+
raw_params = cast("dict[str, Any]", params) if isinstance(params, dict) else None
|
|
972
|
+
coerced_params = _coerce(raw_params)
|
|
973
|
+
if not coerced_params:
|
|
974
|
+
append_batch_arg((sql, {}, empty_param_types))
|
|
975
|
+
continue
|
|
976
|
+
signature = build_param_type_signature(raw_params)
|
|
977
|
+
param_types = param_types_cache.get(signature)
|
|
978
|
+
if param_types is None:
|
|
979
|
+
param_types = _infer(raw_params)
|
|
980
|
+
param_types_cache[signature] = param_types
|
|
981
|
+
append_batch_arg((sql, coerced_params, param_types))
|
|
982
|
+
|
|
983
|
+
writer = cast("_SpannerAsyncWriteProtocol", cursor)
|
|
984
|
+
status, row_counts = await writer.batch_update(batch_args, **execute_kwargs)
|
|
985
|
+
if status is not None and getattr(status, "code", 0) != 0:
|
|
986
|
+
raise create_mapped_exception(status)
|
|
987
|
+
total_rows = sum(row_counts) if row_counts else 0
|
|
988
|
+
|
|
989
|
+
return self.create_execution_result(cursor, rowcount_override=total_rows, is_many_result=True)
|
|
990
|
+
|
|
991
|
+
async def dispatch_execute_script(self, cursor: "SpannerAsyncConnection", statement: "SQL") -> ExecutionResult:
|
|
992
|
+
bound_statements = self._bound_script_statements(statement)
|
|
993
|
+
if bound_statements is None:
|
|
994
|
+
sql, params = self._compiled_sql(statement, self.statement_config)
|
|
995
|
+
statements = self.split_script_statements(sql, statement.statement_config, strip_trailing_semicolon=True)
|
|
996
|
+
entries = [(stmt, params) for stmt in statements]
|
|
997
|
+
else:
|
|
998
|
+
entries = [self._compiled_sql(piece, piece.statement_config) for piece in bound_statements]
|
|
999
|
+
statements = [entry[0] for entry in entries]
|
|
1000
|
+
is_transaction = supports_write(cursor)
|
|
1001
|
+
reader = cast("_SpannerAsyncReadProtocol", cursor)
|
|
1002
|
+
|
|
1003
|
+
count = 0
|
|
1004
|
+
read_execute_kwargs = self._execute_kwargs(for_read=True)
|
|
1005
|
+
write_execute_kwargs = self._execute_kwargs()
|
|
1006
|
+
ddl_timeout = write_execute_kwargs.get("timeout")
|
|
1007
|
+
dialect_str = str(self.dialect) if self.dialect else "spanner"
|
|
1008
|
+
pending_ddl: list[str] = []
|
|
1009
|
+
for index, (stmt, params) in enumerate(entries):
|
|
1010
|
+
if is_ddl_statement(stmt):
|
|
1011
|
+
if not is_transaction:
|
|
1012
|
+
raise SQLConversionError(_READ_ONLY_ASYNC_SNAPSHOT_DDL_ERROR_MESSAGE)
|
|
1013
|
+
pending_ddl.append(stmt)
|
|
1014
|
+
count += 1
|
|
1015
|
+
continue
|
|
1016
|
+
if pending_ddl:
|
|
1017
|
+
await self._commit_before_ddl()
|
|
1018
|
+
await execute_ddl_async(self._resolve_database(), pending_ddl, timeout=ddl_timeout)
|
|
1019
|
+
pending_ddl = []
|
|
1020
|
+
cursor = self.connection
|
|
1021
|
+
reader = cast("_SpannerAsyncReadProtocol", cursor)
|
|
1022
|
+
script_params = cast("dict[str, Any]", params) if isinstance(params, dict) else None
|
|
1023
|
+
param_types_map = self._infer_param_types(script_params)
|
|
1024
|
+
coerced_params = self._coerce_params(script_params)
|
|
1025
|
+
is_select = is_query_statement(stmt, dialect_str)
|
|
1026
|
+
if not is_select and not is_transaction:
|
|
1027
|
+
raise ReadOnlyTransactionError(_READ_ONLY_ASYNC_SNAPSHOT_ERROR_MESSAGE)
|
|
1028
|
+
if not is_select and is_transaction:
|
|
1029
|
+
writer = cast("_SpannerAsyncWriteProtocol", cursor)
|
|
1030
|
+
statement_kwargs = write_execute_kwargs
|
|
1031
|
+
if "last_statement" in write_execute_kwargs and index != len(statements) - 1:
|
|
1032
|
+
statement_kwargs = {
|
|
1033
|
+
key: value for key, value in write_execute_kwargs.items() if key != "last_statement"
|
|
1034
|
+
}
|
|
1035
|
+
await writer.execute_update(
|
|
1036
|
+
stmt, params=coerced_params, param_types=param_types_map, **statement_kwargs
|
|
1037
|
+
)
|
|
1038
|
+
else:
|
|
1039
|
+
rs = await reader.execute_sql(
|
|
1040
|
+
stmt, params=coerced_params, param_types=param_types_map, **read_execute_kwargs
|
|
1041
|
+
)
|
|
1042
|
+
_ = [row async for row in rs]
|
|
1043
|
+
count += 1
|
|
1044
|
+
|
|
1045
|
+
if pending_ddl:
|
|
1046
|
+
await self._commit_before_ddl()
|
|
1047
|
+
await execute_ddl_async(self._resolve_database(), pending_ddl, timeout=ddl_timeout)
|
|
1048
|
+
return self.create_execution_result(
|
|
1049
|
+
cursor, statement_count=count, successful_statements=count, is_script_result=True
|
|
1050
|
+
)
|
|
1051
|
+
|
|
1052
|
+
async def begin(self) -> None:
|
|
1053
|
+
return None
|
|
1054
|
+
|
|
1055
|
+
async def commit(self) -> None:
|
|
1056
|
+
"""Commit the active transaction when it has work to commit."""
|
|
1057
|
+
if not self._owns_transaction:
|
|
1058
|
+
return
|
|
1059
|
+
if isinstance(self.connection, SpannerAsyncTransaction):
|
|
1060
|
+
exc_handler = self.handle_database_exceptions()
|
|
1061
|
+
async with exc_handler:
|
|
1062
|
+
if resolve_transaction_completion(self.connection, failed=False) == "commit":
|
|
1063
|
+
await cast("_SpannerAsyncWriteProtocol", self.connection).commit()
|
|
1064
|
+
self._check_pending_exception(exc_handler)
|
|
1065
|
+
self._renew_finished_transaction()
|
|
1066
|
+
|
|
1067
|
+
async def rollback(self) -> None:
|
|
1068
|
+
"""Roll back the active transaction when it has begun."""
|
|
1069
|
+
if not self._owns_transaction:
|
|
1070
|
+
return
|
|
1071
|
+
if isinstance(self.connection, SpannerAsyncTransaction):
|
|
1072
|
+
exc_handler = self.handle_database_exceptions()
|
|
1073
|
+
async with exc_handler:
|
|
1074
|
+
if resolve_transaction_completion(self.connection, failed=True) == "rollback":
|
|
1075
|
+
await cast("_SpannerAsyncWriteProtocol", self.connection).rollback()
|
|
1076
|
+
self._check_pending_exception(exc_handler)
|
|
1077
|
+
self._renew_finished_transaction()
|
|
1078
|
+
|
|
1079
|
+
async def create_savepoint(self, name: str) -> None:
|
|
1080
|
+
"""Raise because Spanner does not support savepoints.
|
|
1081
|
+
|
|
1082
|
+
Raises:
|
|
1083
|
+
NotImplementedError: Always.
|
|
1084
|
+
"""
|
|
1085
|
+
msg = "Spanner does not support savepoints."
|
|
1086
|
+
raise NotImplementedError(msg)
|
|
1087
|
+
|
|
1088
|
+
async def release_savepoint(self, name: str) -> None:
|
|
1089
|
+
"""Raise because Spanner does not support savepoints.
|
|
1090
|
+
|
|
1091
|
+
Raises:
|
|
1092
|
+
NotImplementedError: Always.
|
|
1093
|
+
"""
|
|
1094
|
+
msg = "Spanner does not support savepoints."
|
|
1095
|
+
raise NotImplementedError(msg)
|
|
1096
|
+
|
|
1097
|
+
async def rollback_to_savepoint(self, name: str) -> None:
|
|
1098
|
+
"""Raise because Spanner does not support savepoints.
|
|
1099
|
+
|
|
1100
|
+
Raises:
|
|
1101
|
+
NotImplementedError: Always.
|
|
1102
|
+
"""
|
|
1103
|
+
msg = "Spanner does not support savepoints."
|
|
1104
|
+
raise NotImplementedError(msg)
|
|
1105
|
+
|
|
1106
|
+
def with_cursor(self, connection: "SpannerAsyncConnection") -> "SpannerAsyncCursor":
|
|
1107
|
+
return SpannerAsyncCursor(connection)
|
|
1108
|
+
|
|
1109
|
+
def handle_database_exceptions(self) -> "SpannerAsyncExceptionHandler":
|
|
1110
|
+
return SpannerAsyncExceptionHandler()
|
|
1111
|
+
|
|
1112
|
+
async def execute(
|
|
1113
|
+
self,
|
|
1114
|
+
statement: "SQL | Statement | QueryBuilder",
|
|
1115
|
+
/,
|
|
1116
|
+
*parameters: "StatementParameters | StatementFilter",
|
|
1117
|
+
statement_config: "StatementConfig | None" = None,
|
|
1118
|
+
**kwargs: Any,
|
|
1119
|
+
) -> "SQLResult":
|
|
1120
|
+
"""Execute a statement with optional Spanner per-call request options."""
|
|
1121
|
+
execute_options = pop_execute_options(kwargs)
|
|
1122
|
+
if execute_options is None:
|
|
1123
|
+
return await super().execute(statement, *parameters, statement_config=statement_config, **kwargs)
|
|
1124
|
+
token = _pending_spanner_options.set(execute_options)
|
|
1125
|
+
try:
|
|
1126
|
+
return await super().execute(statement, *parameters, statement_config=statement_config, **kwargs)
|
|
1127
|
+
finally:
|
|
1128
|
+
_pending_spanner_options.reset(token)
|
|
1129
|
+
|
|
1130
|
+
async def execute_many(
|
|
1131
|
+
self,
|
|
1132
|
+
statement: "SQL | Statement | QueryBuilder",
|
|
1133
|
+
/,
|
|
1134
|
+
parameters: "Sequence[StatementParameters]",
|
|
1135
|
+
*filters: "StatementParameters | StatementFilter",
|
|
1136
|
+
statement_config: "StatementConfig | None" = None,
|
|
1137
|
+
**kwargs: Any,
|
|
1138
|
+
) -> "SQLResult":
|
|
1139
|
+
"""Execute a batch statement with optional Spanner per-call request options."""
|
|
1140
|
+
execute_options = pop_execute_options(kwargs)
|
|
1141
|
+
if execute_options is None:
|
|
1142
|
+
return await super().execute_many(
|
|
1143
|
+
statement, parameters, *filters, statement_config=statement_config, **kwargs
|
|
1144
|
+
)
|
|
1145
|
+
token = _pending_spanner_options.set(execute_options)
|
|
1146
|
+
try:
|
|
1147
|
+
return await super().execute_many(
|
|
1148
|
+
statement, parameters, *filters, statement_config=statement_config, **kwargs
|
|
1149
|
+
)
|
|
1150
|
+
finally:
|
|
1151
|
+
_pending_spanner_options.reset(token)
|
|
1152
|
+
|
|
1153
|
+
async def execute_script(
|
|
1154
|
+
self,
|
|
1155
|
+
statement: "str | SQL",
|
|
1156
|
+
/,
|
|
1157
|
+
*parameters: "StatementParameters | StatementFilter",
|
|
1158
|
+
statement_config: "StatementConfig | None" = None,
|
|
1159
|
+
**kwargs: Any,
|
|
1160
|
+
) -> "SQLResult":
|
|
1161
|
+
"""Execute a multi-statement script with optional Spanner per-call request options."""
|
|
1162
|
+
execute_options = pop_execute_options(kwargs)
|
|
1163
|
+
if execute_options is None:
|
|
1164
|
+
return await super().execute_script(statement, *parameters, statement_config=statement_config, **kwargs)
|
|
1165
|
+
token = _pending_spanner_options.set(execute_options)
|
|
1166
|
+
try:
|
|
1167
|
+
return await super().execute_script(statement, *parameters, statement_config=statement_config, **kwargs)
|
|
1168
|
+
finally:
|
|
1169
|
+
_pending_spanner_options.reset(token)
|
|
1170
|
+
|
|
1171
|
+
@overload
|
|
1172
|
+
def select_stream(
|
|
1173
|
+
self,
|
|
1174
|
+
statement: "SQL | Statement | QueryBuilder",
|
|
1175
|
+
/,
|
|
1176
|
+
*parameters: "StatementParameters | StatementFilter",
|
|
1177
|
+
schema_type: "type[SchemaT]",
|
|
1178
|
+
statement_config: "StatementConfig | None" = None,
|
|
1179
|
+
chunk_size: int = 1000,
|
|
1180
|
+
native_only: bool = False,
|
|
1181
|
+
**kwargs: Any,
|
|
1182
|
+
) -> "AsyncRowStream[SchemaT]": ...
|
|
1183
|
+
@overload
|
|
1184
|
+
def select_stream(
|
|
1185
|
+
self,
|
|
1186
|
+
statement: "SQL | Statement | QueryBuilder",
|
|
1187
|
+
/,
|
|
1188
|
+
*parameters: "StatementParameters | StatementFilter",
|
|
1189
|
+
schema_type: None = None,
|
|
1190
|
+
statement_config: "StatementConfig | None" = None,
|
|
1191
|
+
chunk_size: int = 1000,
|
|
1192
|
+
native_only: bool = False,
|
|
1193
|
+
**kwargs: Any,
|
|
1194
|
+
) -> "AsyncRowStream[dict[str, Any]]": ...
|
|
1195
|
+
def select_stream(
|
|
1196
|
+
self,
|
|
1197
|
+
statement: "SQL | Statement | QueryBuilder",
|
|
1198
|
+
/,
|
|
1199
|
+
*parameters: "StatementParameters | StatementFilter",
|
|
1200
|
+
schema_type: "type[SchemaT] | None" = None,
|
|
1201
|
+
statement_config: "StatementConfig | None" = None,
|
|
1202
|
+
chunk_size: int = 1000,
|
|
1203
|
+
native_only: bool = False,
|
|
1204
|
+
**kwargs: Any,
|
|
1205
|
+
) -> "AsyncRowStream[SchemaT] | AsyncRowStream[dict[str, Any]]":
|
|
1206
|
+
"""Execute a query and stream rows with optional Spanner per-call options."""
|
|
1207
|
+
execute_options = pop_execute_options(kwargs)
|
|
1208
|
+
if execute_options is None:
|
|
1209
|
+
return super().select_stream(
|
|
1210
|
+
statement,
|
|
1211
|
+
*parameters,
|
|
1212
|
+
schema_type=schema_type,
|
|
1213
|
+
statement_config=statement_config,
|
|
1214
|
+
chunk_size=chunk_size,
|
|
1215
|
+
native_only=native_only,
|
|
1216
|
+
**kwargs,
|
|
1217
|
+
)
|
|
1218
|
+
token = _pending_spanner_options.set(execute_options)
|
|
1219
|
+
try:
|
|
1220
|
+
return super().select_stream(
|
|
1221
|
+
statement,
|
|
1222
|
+
*parameters,
|
|
1223
|
+
schema_type=schema_type,
|
|
1224
|
+
statement_config=statement_config,
|
|
1225
|
+
chunk_size=chunk_size,
|
|
1226
|
+
native_only=native_only,
|
|
1227
|
+
**kwargs,
|
|
1228
|
+
)
|
|
1229
|
+
finally:
|
|
1230
|
+
_pending_spanner_options.reset(token)
|
|
1231
|
+
|
|
1232
|
+
async def select_to_storage(
|
|
1233
|
+
self,
|
|
1234
|
+
statement: "SQL | str",
|
|
1235
|
+
destination: "StorageDestination",
|
|
1236
|
+
/,
|
|
1237
|
+
*parameters: Any,
|
|
1238
|
+
statement_config: "StatementConfig | None" = None,
|
|
1239
|
+
partitioner: "dict[str, object] | None" = None,
|
|
1240
|
+
format_hint: "StorageFormat | None" = None,
|
|
1241
|
+
telemetry: "StorageTelemetry | None" = None,
|
|
1242
|
+
**kwargs: Any,
|
|
1243
|
+
) -> "StorageBridgeJob":
|
|
1244
|
+
"""Execute query and stream Arrow results to storage asynchronously."""
|
|
1245
|
+
self._require_capability("arrow_export_enabled")
|
|
1246
|
+
arrow_result = await self._select_for_storage(
|
|
1247
|
+
statement, *parameters, statement_config=statement_config, **kwargs
|
|
1248
|
+
)
|
|
1249
|
+
async_pipeline = self._storage_pipeline()
|
|
1250
|
+
telemetry_payload = await self._write_storage_result(
|
|
1251
|
+
arrow_result, destination, format_hint=format_hint, pipeline=async_pipeline
|
|
1252
|
+
)
|
|
1253
|
+
self._attach_partition_telemetry(telemetry_payload, partitioner)
|
|
1254
|
+
return self._storage_job(telemetry_payload, telemetry)
|
|
1255
|
+
|
|
1256
|
+
async def load_from_arrow(
|
|
1257
|
+
self,
|
|
1258
|
+
table: str,
|
|
1259
|
+
source: "ArrowResult | Any",
|
|
1260
|
+
*,
|
|
1261
|
+
partitioner: "dict[str, object] | None" = None,
|
|
1262
|
+
overwrite: bool = False,
|
|
1263
|
+
telemetry: "StorageTelemetry | None" = None,
|
|
1264
|
+
stage_table: "bool | str | None" = False,
|
|
1265
|
+
conflict_keys: "Sequence[str] | None" = None,
|
|
1266
|
+
on_conflict: Literal["update", "nothing"] = "update",
|
|
1267
|
+
exclude_update_columns: "Sequence[str] | None" = None,
|
|
1268
|
+
drop_stage_table: bool = True,
|
|
1269
|
+
drop_indexes: bool = False,
|
|
1270
|
+
concurrent_indexes: bool = True,
|
|
1271
|
+
type_casts: "Mapping[str, str] | None" = None,
|
|
1272
|
+
) -> "StorageBridgeJob":
|
|
1273
|
+
"""Load Arrow data into Spanner table via batch mutations."""
|
|
1274
|
+
self._require_capability("arrow_import_enabled")
|
|
1275
|
+
if drop_indexes:
|
|
1276
|
+
index_context = self.without_indexes(table, concurrent=concurrent_indexes)
|
|
1277
|
+
await index_context.__aenter__()
|
|
1278
|
+
index_error: BaseException | None = None
|
|
1279
|
+
index_job: StorageBridgeJob | None = None
|
|
1280
|
+
try:
|
|
1281
|
+
index_job = await self.load_from_arrow(
|
|
1282
|
+
table,
|
|
1283
|
+
source,
|
|
1284
|
+
partitioner=partitioner,
|
|
1285
|
+
overwrite=overwrite,
|
|
1286
|
+
telemetry=telemetry,
|
|
1287
|
+
stage_table=stage_table,
|
|
1288
|
+
conflict_keys=conflict_keys,
|
|
1289
|
+
on_conflict=on_conflict,
|
|
1290
|
+
exclude_update_columns=exclude_update_columns,
|
|
1291
|
+
drop_stage_table=drop_stage_table,
|
|
1292
|
+
drop_indexes=False,
|
|
1293
|
+
concurrent_indexes=concurrent_indexes,
|
|
1294
|
+
type_casts=type_casts,
|
|
1295
|
+
)
|
|
1296
|
+
except BaseException as exc:
|
|
1297
|
+
index_error = exc
|
|
1298
|
+
await exit_async_context(index_context, index_error)
|
|
1299
|
+
assert index_job is not None
|
|
1300
|
+
return index_job
|
|
1301
|
+
if stage_table or (
|
|
1302
|
+
conflict_keys and on_conflict == "nothing" and not hasattr(self.connection, "insert_or_ignore")
|
|
1303
|
+
):
|
|
1304
|
+
return await self._execute_staged_load_async(
|
|
1305
|
+
table,
|
|
1306
|
+
source,
|
|
1307
|
+
raw_loader=self.load_from_arrow,
|
|
1308
|
+
partitioner=partitioner,
|
|
1309
|
+
overwrite=overwrite,
|
|
1310
|
+
telemetry=telemetry,
|
|
1311
|
+
stage_table=stage_table,
|
|
1312
|
+
conflict_keys=conflict_keys,
|
|
1313
|
+
on_conflict=on_conflict,
|
|
1314
|
+
exclude_update_columns=exclude_update_columns,
|
|
1315
|
+
drop_stage_table=drop_stage_table,
|
|
1316
|
+
drop_indexes=False,
|
|
1317
|
+
concurrent_indexes=concurrent_indexes,
|
|
1318
|
+
type_casts=type_casts,
|
|
1319
|
+
)
|
|
1320
|
+
arrow_table = self._coerce_arrow_table(source)
|
|
1321
|
+
|
|
1322
|
+
exc_handler = self.handle_database_exceptions()
|
|
1323
|
+
async with exc_handler:
|
|
1324
|
+
if overwrite:
|
|
1325
|
+
dialect_str = str(self.dialect) if self.dialect else "spanner"
|
|
1326
|
+
table_sql = _sqlglot_exp.to_table(table, dialect=dialect_str).sql(dialect=dialect_str, identify=True)
|
|
1327
|
+
delete_sql = f"DELETE FROM {table_sql} WHERE TRUE"
|
|
1328
|
+
if isinstance(self.connection, SpannerAsyncTransaction):
|
|
1329
|
+
writer = cast("_SpannerAsyncWriteProtocol", self.connection)
|
|
1330
|
+
await writer.execute_update(delete_sql, **self._execute_kwargs())
|
|
1331
|
+
else:
|
|
1332
|
+
msg = "Delete requires a Transaction context."
|
|
1333
|
+
raise SQLConversionError(msg)
|
|
1334
|
+
|
|
1335
|
+
columns, records = self._arrow_table_to_rows(arrow_table)
|
|
1336
|
+
if records:
|
|
1337
|
+
chunks = self._chunk_mutation_rows(columns, records)
|
|
1338
|
+
if self.driver_features.get("enable_batch_write_api") and not overwrite:
|
|
1339
|
+
await self._batch_write_mutations(table, columns, chunks)
|
|
1340
|
+
else:
|
|
1341
|
+
conn = self.connection
|
|
1342
|
+
if not isinstance(conn, SpannerAsyncTransaction):
|
|
1343
|
+
msg = "Arrow import requires a Transaction context."
|
|
1344
|
+
raise SQLConversionError(msg)
|
|
1345
|
+
writer = cast("_SpannerAsyncWriteProtocol", conn)
|
|
1346
|
+
for idx, chunk in enumerate(chunks):
|
|
1347
|
+
if conflict_keys and on_conflict == "nothing" and hasattr(writer, "insert_or_ignore"):
|
|
1348
|
+
writer.insert_or_ignore(table, columns, chunk)
|
|
1349
|
+
else:
|
|
1350
|
+
writer.insert_or_update(table, columns, chunk)
|
|
1351
|
+
if self._owns_transaction and idx < len(chunks) - 1 and hasattr(writer, "commit"):
|
|
1352
|
+
await writer.commit()
|
|
1353
|
+
self._renew_finished_transaction()
|
|
1354
|
+
writer = cast("_SpannerAsyncWriteProtocol", self.connection)
|
|
1355
|
+
self._check_pending_exception(exc_handler)
|
|
1356
|
+
|
|
1357
|
+
telemetry_payload = self._ingest_telemetry(arrow_table)
|
|
1358
|
+
telemetry_payload["destination"] = table
|
|
1359
|
+
self._attach_partition_telemetry(telemetry_payload, partitioner)
|
|
1360
|
+
return self._storage_job(telemetry_payload, telemetry)
|
|
1361
|
+
|
|
1362
|
+
async def load_from_storage(
|
|
1363
|
+
self,
|
|
1364
|
+
table: str,
|
|
1365
|
+
source: "StorageDestination",
|
|
1366
|
+
*,
|
|
1367
|
+
file_format: "StorageFormat",
|
|
1368
|
+
partitioner: "dict[str, object] | None" = None,
|
|
1369
|
+
overwrite: bool = False,
|
|
1370
|
+
**kwargs: Any,
|
|
1371
|
+
) -> "StorageBridgeJob":
|
|
1372
|
+
"""Load artifacts from storage into Spanner table asynchronously."""
|
|
1373
|
+
if kwargs:
|
|
1374
|
+
validate_load_from_storage_kwargs(kwargs)
|
|
1375
|
+
return await super().load_from_storage(
|
|
1376
|
+
table,
|
|
1377
|
+
source,
|
|
1378
|
+
file_format=file_format,
|
|
1379
|
+
partitioner=partitioner,
|
|
1380
|
+
overwrite=overwrite,
|
|
1381
|
+
storage_options=kwargs.get("storage_options"),
|
|
1382
|
+
stage_table=kwargs.get("stage_table"),
|
|
1383
|
+
conflict_keys=kwargs.get("conflict_keys"),
|
|
1384
|
+
on_conflict=kwargs.get("on_conflict", "update"),
|
|
1385
|
+
exclude_update_columns=kwargs.get("exclude_update_columns"),
|
|
1386
|
+
drop_stage_table=kwargs.get("drop_stage_table", True),
|
|
1387
|
+
drop_indexes=kwargs.get("drop_indexes", False),
|
|
1388
|
+
concurrent_indexes=kwargs.get("concurrent_indexes", False),
|
|
1389
|
+
checkpoint_table=kwargs.get("checkpoint_table"),
|
|
1390
|
+
checkpoint_phase=kwargs.get("checkpoint_phase", "default"),
|
|
1391
|
+
max_workers=kwargs.get("max_workers", 1),
|
|
1392
|
+
executor=kwargs.get("executor", "thread"),
|
|
1393
|
+
arrow_schema=kwargs.get("arrow_schema"),
|
|
1394
|
+
type_casts=kwargs.get("type_casts"),
|
|
1395
|
+
)
|
|
1396
|
+
arrow_table, inbound = await self._read_storage_arrow(source, file_format=file_format)
|
|
1397
|
+
return await self.load_from_arrow(
|
|
1398
|
+
table, arrow_table, partitioner=partitioner, overwrite=overwrite, telemetry=inbound
|
|
1399
|
+
)
|
|
1400
|
+
|
|
1401
|
+
def collect_rows(
|
|
1402
|
+
self, cursor: "SpannerAsyncConnection", fetched: "list[Any]"
|
|
1403
|
+
) -> "tuple[list[Any], list[str], int]":
|
|
1404
|
+
"""Collect Spanner rows for the direct execution path.
|
|
1405
|
+
|
|
1406
|
+
Dict rows supply their keys as column names; other rows are returned
|
|
1407
|
+
unchanged with no column names.
|
|
1408
|
+
"""
|
|
1409
|
+
if not fetched:
|
|
1410
|
+
return [], [], 0
|
|
1411
|
+
if isinstance(fetched[0], dict):
|
|
1412
|
+
column_names = list(fetched[0].keys())
|
|
1413
|
+
return fetched, column_names, len(fetched)
|
|
1414
|
+
return fetched, [], len(fetched)
|
|
1415
|
+
|
|
1416
|
+
def resolve_rowcount(self, cursor: "SpannerAsyncConnection") -> int:
|
|
1417
|
+
"""Resolve rowcount from Spanner cursor for the direct execution path.
|
|
1418
|
+
|
|
1419
|
+
Spanner uses execute_update return value, not cursor.rowcount, so this
|
|
1420
|
+
returns 0.
|
|
1421
|
+
"""
|
|
1422
|
+
return 0
|
|
1423
|
+
|
|
1424
|
+
async def run_in_transaction(self, fn: "Callable[..., Awaitable[Any]]", *args: Any, **kwargs: Any) -> Any:
|
|
1425
|
+
"""Execute a coroutine function inside Spanner's async retryable transaction runner.
|
|
1426
|
+
|
|
1427
|
+
``fn`` is awaited as ``fn(driver, *args, **kwargs)`` with a driver bound
|
|
1428
|
+
to the runner's transaction. A ``DeadlockError`` caused by
|
|
1429
|
+
``google.api_core.exceptions.Aborted`` is unwrapped so the runner
|
|
1430
|
+
retries, and a terminal ``Aborted`` is raised as ``DeadlockError``.
|
|
1431
|
+
"""
|
|
1432
|
+
return await run_in_transaction_async(self._resolve_database(), self._transaction_driver, fn, *args, **kwargs)
|
|
1433
|
+
|
|
1434
|
+
async def execute_partitioned_dml(
|
|
1435
|
+
self,
|
|
1436
|
+
sql: str,
|
|
1437
|
+
params: "dict[str, Any] | None" = None,
|
|
1438
|
+
param_types: "dict[str, Any] | None" = None,
|
|
1439
|
+
**kwargs: Any,
|
|
1440
|
+
) -> int:
|
|
1441
|
+
"""Execute a Partitioned DML statement against the async Spanner database."""
|
|
1442
|
+
call_kwargs = {**self._execute_kwargs(), **kwargs}
|
|
1443
|
+
return await execute_partitioned_dml_async(
|
|
1444
|
+
self._resolve_database(),
|
|
1445
|
+
sql,
|
|
1446
|
+
params=params,
|
|
1447
|
+
param_types=param_types,
|
|
1448
|
+
json_serializer=self.driver_features.get("json_serializer"),
|
|
1449
|
+
enable_uuid_conversion=self.driver_features.get("enable_uuid_conversion", True),
|
|
1450
|
+
**call_kwargs,
|
|
1451
|
+
)
|
|
1452
|
+
|
|
1453
|
+
def write_insert(self, table: str, columns: "Sequence[str]", values: "Sequence[Sequence[Any]]") -> None:
|
|
1454
|
+
"""Buffer Spanner INSERT mutations on the active async transaction or batch."""
|
|
1455
|
+
self._apply_mutation(table, columns, values, method_name="insert")
|
|
1456
|
+
|
|
1457
|
+
def write_upsert(self, table: str, columns: "Sequence[str]", values: "Sequence[Sequence[Any]]") -> None:
|
|
1458
|
+
"""Buffer Spanner INSERT_OR_UPDATE mutations on the active async transaction or batch."""
|
|
1459
|
+
self._apply_mutation(table, columns, values, method_name="insert_or_update")
|
|
1460
|
+
|
|
1461
|
+
def write_update(self, table: str, columns: "Sequence[str]", values: "Sequence[Sequence[Any]]") -> None:
|
|
1462
|
+
"""Buffer Spanner UPDATE mutations on the active async transaction or batch."""
|
|
1463
|
+
self._apply_mutation(table, columns, values, method_name="update")
|
|
1464
|
+
|
|
1465
|
+
def write_delete(self, table: str, keyset: Any) -> None:
|
|
1466
|
+
"""Buffer a Spanner DELETE mutation on the active async transaction or batch."""
|
|
1467
|
+
if not supports_write(self.connection):
|
|
1468
|
+
raise ReadOnlyTransactionError(_READ_ONLY_ASYNC_SNAPSHOT_ERROR_MESSAGE)
|
|
1469
|
+
writer = cast("_SpannerAsyncWriteProtocol", self.connection)
|
|
1470
|
+
try:
|
|
1471
|
+
writer.delete(table, keyset)
|
|
1472
|
+
except SpannerGoogleAPICallError as exc:
|
|
1473
|
+
raise with_cause(create_mapped_exception(exc), exc) from exc
|
|
1474
|
+
|
|
1475
|
+
def bind_external_transaction(self) -> None:
|
|
1476
|
+
"""Mark the driver as bound to an externally managed transaction runner."""
|
|
1477
|
+
self._owns_transaction = False
|
|
1478
|
+
|
|
1479
|
+
def _apply_mutation(
|
|
1480
|
+
self, table: str, columns: "Sequence[str]", values: "Sequence[Sequence[Any]]", *, method_name: str
|
|
1481
|
+
) -> None:
|
|
1482
|
+
if not supports_write(self.connection):
|
|
1483
|
+
raise ReadOnlyTransactionError(_READ_ONLY_ASYNC_SNAPSHOT_ERROR_MESSAGE)
|
|
1484
|
+
column_list = list(columns)
|
|
1485
|
+
records = [tuple(row) for row in values]
|
|
1486
|
+
if not records:
|
|
1487
|
+
return
|
|
1488
|
+
chunks = self._chunk_mutation_rows(column_list, records)
|
|
1489
|
+
mutation_fn = getattr(self.connection, method_name)
|
|
1490
|
+
try:
|
|
1491
|
+
for chunk in chunks:
|
|
1492
|
+
mutation_fn(table, column_list, chunk)
|
|
1493
|
+
except SpannerGoogleAPICallError as exc:
|
|
1494
|
+
raise with_cause(create_mapped_exception(exc), exc) from exc
|
|
1495
|
+
|
|
1496
|
+
def _execute_kwargs(self, *, for_read: bool = False, for_batch: bool = False) -> dict[str, Any]:
|
|
1497
|
+
options = _pending_spanner_options.get() or self._pending_execute_options
|
|
1498
|
+
return build_execute_kwargs(self.driver_features, options, for_read=for_read, for_batch=for_batch)
|
|
1499
|
+
|
|
1500
|
+
def _chunk_mutation_rows(self, columns: "list[str]", records: "list[tuple[Any, ...]]") -> "list[list[list[Any]]]":
|
|
1501
|
+
return chunk_mutation_rows(columns, records, self._coerce_params)
|
|
1502
|
+
|
|
1503
|
+
def _resolve_database(self) -> Any:
|
|
1504
|
+
return cast("Any", self.connection)._session._database
|
|
1505
|
+
|
|
1506
|
+
async def _batch_write_mutations(self, table: str, columns: "list[str]", chunks: "list[list[list[Any]]]") -> None:
|
|
1507
|
+
"""High-throughput async ingest via the Spanner Batch Write API (one mutation group per chunk)."""
|
|
1508
|
+
database = self._resolve_database()
|
|
1509
|
+
groups_context = database.mutation_groups()
|
|
1510
|
+
mutation_groups = await groups_context.__aenter__()
|
|
1511
|
+
groups_error: BaseException | None = None
|
|
1512
|
+
try:
|
|
1513
|
+
await self._write_mutation_groups(mutation_groups, table, columns, chunks)
|
|
1514
|
+
except BaseException as exc:
|
|
1515
|
+
groups_error = exc
|
|
1516
|
+
await exit_async_context(groups_context, groups_error)
|
|
1517
|
+
|
|
1518
|
+
async def _write_mutation_groups(
|
|
1519
|
+
self, mutation_groups: Any, table: str, columns: "list[str]", chunks: "list[list[list[Any]]]"
|
|
1520
|
+
) -> None:
|
|
1521
|
+
"""Queue one mutation group per chunk, send them, and raise on the first failed group."""
|
|
1522
|
+
for chunk in chunks:
|
|
1523
|
+
group = mutation_groups.group()
|
|
1524
|
+
group.insert_or_update(table, columns, chunk)
|
|
1525
|
+
async for response in await mutation_groups.batch_write():
|
|
1526
|
+
status = response.status
|
|
1527
|
+
if status is not None and status.code:
|
|
1528
|
+
msg = f"Spanner batch_write group failed: {status.message}"
|
|
1529
|
+
raise SQLConversionError(msg)
|
|
1530
|
+
|
|
1531
|
+
async def _commit_before_ddl(self) -> None:
|
|
1532
|
+
"""Commit a begun session transaction before a schema change, as DDL does on MySQL or Oracle."""
|
|
1533
|
+
if self._owns_transaction and isinstance(self.connection, SpannerAsyncTransaction):
|
|
1534
|
+
await self.commit()
|
|
1535
|
+
|
|
1536
|
+
def _renew_finished_transaction(self) -> None:
|
|
1537
|
+
"""Start a new transaction on the session once the owned transaction has finished."""
|
|
1538
|
+
connection = cast("Any", self.connection)
|
|
1539
|
+
if self._owns_transaction and (connection.committed is not None or connection.rolled_back):
|
|
1540
|
+
self.connection = renew_transaction(connection)
|
|
1541
|
+
|
|
1542
|
+
def _transaction_driver(self, transaction: "SpannerAsyncConnection") -> "SpannerAsyncDriver":
|
|
1543
|
+
driver = type(self)(
|
|
1544
|
+
connection=transaction, statement_config=self.statement_config, driver_features=self.driver_features
|
|
1545
|
+
)
|
|
1546
|
+
driver._owns_transaction = False
|
|
1547
|
+
if self._observability is not None:
|
|
1548
|
+
driver.attach_observability(self._observability)
|
|
1549
|
+
return driver
|
|
1550
|
+
|
|
1551
|
+
def _connection_in_transaction(self) -> bool:
|
|
1552
|
+
"""Check if connection is in transaction."""
|
|
1553
|
+
if not self._owns_transaction:
|
|
1554
|
+
return True
|
|
1555
|
+
conn = self.connection
|
|
1556
|
+
return bool(
|
|
1557
|
+
isinstance(conn, (SpannerTransaction, SpannerAsyncTransaction))
|
|
1558
|
+
and (conn._transaction_id is not None or bool(conn._mutations))
|
|
1559
|
+
and getattr(conn, "committed", None) is None
|
|
1560
|
+
and not getattr(conn, "rolled_back", False)
|
|
1561
|
+
)
|
|
1562
|
+
|
|
1563
|
+
def _coerce_params(self, params: "dict[str, Any] | list[Any] | tuple[Any, ...] | None") -> "dict[str, Any] | None":
|
|
1564
|
+
return coerce_params(
|
|
1565
|
+
params,
|
|
1566
|
+
json_serializer=self.driver_features.get("json_serializer"),
|
|
1567
|
+
enable_uuid_conversion=self.driver_features.get("enable_uuid_conversion", True),
|
|
1568
|
+
)
|
|
1569
|
+
|
|
1570
|
+
def _infer_param_types(self, params: "dict[str, Any] | list[Any] | tuple[Any, ...] | None") -> "dict[str, Any]":
|
|
1571
|
+
return infer_param_types(params)
|
|
1572
|
+
|
|
1573
|
+
def _resolve_row_plan(self, fields: Any) -> "tuple[list[str], tuple[tuple[int, Any], ...] | None]":
|
|
1574
|
+
json_deserializer = cast("Callable[[str], Any]", self.driver_features.get("json_deserializer", from_json))
|
|
1575
|
+
if json_deserializer is not self._row_plan_deserializer:
|
|
1576
|
+
self._row_plan_cache.clear()
|
|
1577
|
+
self._row_plan_deserializer = json_deserializer
|
|
1578
|
+
return resolve_row_plan(fields, self._row_plan_cache, json_deserializer=json_deserializer)
|
|
1579
|
+
|
|
1580
|
+
|
|
1581
|
+
class _SpannerResultSetProtocol(Protocol):
|
|
1582
|
+
metadata: Any
|
|
1583
|
+
|
|
1584
|
+
def __iter__(self) -> Iterator[Any]: ...
|
|
1585
|
+
|
|
1586
|
+
|
|
1587
|
+
class _SpannerReadProtocol(Protocol):
|
|
1588
|
+
def execute_sql(
|
|
1589
|
+
self,
|
|
1590
|
+
sql: str,
|
|
1591
|
+
params: "dict[str, Any] | None" = None,
|
|
1592
|
+
param_types: "dict[str, Any] | None" = None,
|
|
1593
|
+
**kwargs: Any,
|
|
1594
|
+
) -> _SpannerResultSetProtocol: ...
|
|
1595
|
+
|
|
1596
|
+
|
|
1597
|
+
class _SpannerWriteProtocol(_SpannerReadProtocol, Protocol):
|
|
1598
|
+
committed: "Any | None"
|
|
1599
|
+
|
|
1600
|
+
def execute_update(
|
|
1601
|
+
self,
|
|
1602
|
+
sql: str,
|
|
1603
|
+
params: "dict[str, Any] | None" = None,
|
|
1604
|
+
param_types: "dict[str, Any] | None" = None,
|
|
1605
|
+
**kwargs: Any,
|
|
1606
|
+
) -> int: ...
|
|
1607
|
+
|
|
1608
|
+
def batch_update(
|
|
1609
|
+
self, batch: "list[tuple[str, dict[str, Any] | None, dict[str, Any]]]", **kwargs: Any
|
|
1610
|
+
) -> "tuple[Any, list[int]]": ...
|
|
1611
|
+
|
|
1612
|
+
def insert(self, table: str, columns: "list[str]", values: "list[list[Any]]") -> None: ...
|
|
1613
|
+
|
|
1614
|
+
def insert_or_ignore(self, table: str, columns: "list[str]", values: "list[list[Any]]") -> None: ...
|
|
1615
|
+
|
|
1616
|
+
def insert_or_update(self, table: str, columns: "list[str]", values: "list[list[Any]]") -> None: ...
|
|
1617
|
+
|
|
1618
|
+
def update(self, table: str, columns: "list[str]", values: "list[list[Any]]") -> None: ...
|
|
1619
|
+
|
|
1620
|
+
def delete(self, table: str, keyset: Any) -> None: ...
|
|
1621
|
+
|
|
1622
|
+
def commit(self) -> None: ...
|
|
1623
|
+
|
|
1624
|
+
def rollback(self) -> None: ...
|
|
1625
|
+
|
|
1626
|
+
|
|
1627
|
+
class _SpannerAsyncResultSetProtocol(Protocol):
|
|
1628
|
+
metadata: Any
|
|
1629
|
+
|
|
1630
|
+
def __aiter__(self) -> AsyncIterator[Any]: ...
|
|
1631
|
+
|
|
1632
|
+
|
|
1633
|
+
class _SpannerAsyncReadProtocol(Protocol):
|
|
1634
|
+
async def execute_sql(
|
|
1635
|
+
self,
|
|
1636
|
+
sql: str,
|
|
1637
|
+
params: "dict[str, Any] | None" = None,
|
|
1638
|
+
param_types: "dict[str, Any] | None" = None,
|
|
1639
|
+
**kwargs: Any,
|
|
1640
|
+
) -> _SpannerAsyncResultSetProtocol: ...
|
|
1641
|
+
|
|
1642
|
+
|
|
1643
|
+
class _SpannerAsyncWriteProtocol(_SpannerAsyncReadProtocol, Protocol):
|
|
1644
|
+
committed: "Any | None"
|
|
1645
|
+
|
|
1646
|
+
async def execute_update(
|
|
1647
|
+
self,
|
|
1648
|
+
sql: str,
|
|
1649
|
+
params: "dict[str, Any] | None" = None,
|
|
1650
|
+
param_types: "dict[str, Any] | None" = None,
|
|
1651
|
+
**kwargs: Any,
|
|
1652
|
+
) -> int: ...
|
|
1653
|
+
|
|
1654
|
+
async def batch_update(
|
|
1655
|
+
self, batch: "list[tuple[str, dict[str, Any] | None, dict[str, Any]]]", **kwargs: Any
|
|
1656
|
+
) -> "tuple[Any, list[int]]": ...
|
|
1657
|
+
|
|
1658
|
+
def insert(self, table: str, columns: "list[str]", values: "list[list[Any]]") -> None: ...
|
|
1659
|
+
|
|
1660
|
+
def insert_or_ignore(self, table: str, columns: "list[str]", values: "list[list[Any]]") -> None: ...
|
|
1661
|
+
|
|
1662
|
+
def insert_or_update(self, table: str, columns: "list[str]", values: "list[list[Any]]") -> None: ...
|
|
1663
|
+
|
|
1664
|
+
def update(self, table: str, columns: "list[str]", values: "list[list[Any]]") -> None: ...
|
|
1665
|
+
|
|
1666
|
+
def delete(self, table: str, keyset: Any) -> None: ...
|
|
1667
|
+
|
|
1668
|
+
async def commit(self) -> None: ...
|
|
1669
|
+
|
|
1670
|
+
async def rollback(self) -> None: ...
|
|
1671
|
+
|
|
1672
|
+
|
|
1673
|
+
register_driver_profile("spanner", driver_profile)
|