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,1390 @@
|
|
|
1
|
+
"""Storage backend using fsspec."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import contextlib
|
|
5
|
+
from collections.abc import AsyncIterator, Iterator
|
|
6
|
+
from contextlib import AbstractAsyncContextManager, AbstractContextManager
|
|
7
|
+
from functools import partial
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import TYPE_CHECKING, Any, ClassVar, Final, Literal, TypeAlias, cast, overload
|
|
10
|
+
from urllib.parse import urlparse
|
|
11
|
+
|
|
12
|
+
from mypy_extensions import mypyc_attr
|
|
13
|
+
|
|
14
|
+
from sqlspec.exceptions import StorageCapabilityError
|
|
15
|
+
from sqlspec.storage._arrow_payload import (
|
|
16
|
+
StorageFormat,
|
|
17
|
+
encode_arrow_payload,
|
|
18
|
+
encode_arrow_to_async_sink,
|
|
19
|
+
encode_arrow_to_sink,
|
|
20
|
+
join_shielded,
|
|
21
|
+
validate_arrow_write_options,
|
|
22
|
+
)
|
|
23
|
+
from sqlspec.storage._arrow_stream import iter_parquet_row_groups, validate_parquet_stream_options
|
|
24
|
+
from sqlspec.storage._paths import (
|
|
25
|
+
_GLOB_MAGIC,
|
|
26
|
+
check_local_delete_target,
|
|
27
|
+
ensure_path_within_root,
|
|
28
|
+
is_file_destination,
|
|
29
|
+
parse_file_uri_path,
|
|
30
|
+
reject_parent_traversal,
|
|
31
|
+
resolve_storage_path,
|
|
32
|
+
)
|
|
33
|
+
from sqlspec.storage._utils import import_fsspec, import_pyarrow, import_pyarrow_parquet, log_storage_event
|
|
34
|
+
from sqlspec.storage.backends.base import AsyncArrowBatchIterator, AsyncThreadedBytesIterator
|
|
35
|
+
from sqlspec.storage.backends.local import (
|
|
36
|
+
_STAGE_PREFIX,
|
|
37
|
+
_abort_local_stage,
|
|
38
|
+
_close_and_publish_local_stage,
|
|
39
|
+
_open_local_stage,
|
|
40
|
+
)
|
|
41
|
+
from sqlspec.storage.errors import execute_async_storage_operation, execute_sync_storage_operation, raise_storage_error
|
|
42
|
+
from sqlspec.utils.sync_tools import async_, exit_async_context
|
|
43
|
+
from sqlspec.utils.uuids import uuid4
|
|
44
|
+
|
|
45
|
+
if TYPE_CHECKING:
|
|
46
|
+
from sqlspec.protocols import AsyncWritableBytesSink, WritableBytesSink
|
|
47
|
+
from sqlspec.typing import ArrowRecordBatch, ArrowTable
|
|
48
|
+
|
|
49
|
+
__all__ = ("FSSpecBackend",)
|
|
50
|
+
|
|
51
|
+
_FsspecStrategy: TypeAlias = Literal["local", "commit", "block", "staged"]
|
|
52
|
+
|
|
53
|
+
_OBJECT_STORE_PROTOCOLS = {"s3", "gs", "az", "gcs"}
|
|
54
|
+
_FSSPEC_VALIDATED_PROTOCOLS: Final[frozenset[str]] = frozenset({"file", "memory"})
|
|
55
|
+
_FSSPEC_BASIC_OPEN_OPTIONS: Final[frozenset[str]] = frozenset({
|
|
56
|
+
"autocommit",
|
|
57
|
+
"block_size",
|
|
58
|
+
"cache_options",
|
|
59
|
+
"compression",
|
|
60
|
+
})
|
|
61
|
+
_FSSPEC_ARROW_FORMATS: Final[frozenset[str]] = frozenset({"parquet", "arrow-ipc", "csv"})
|
|
62
|
+
_COMMIT_PROTOCOLS: Final[frozenset[str]] = frozenset({"s3", "s3a", "gs", "gcs"})
|
|
63
|
+
_BLOCK_PROTOCOLS: Final[frozenset[str]] = frozenset({"az", "abfs", "abfss"})
|
|
64
|
+
_LOCAL_PROTOCOLS: Final[frozenset[str]] = frozenset({"file", "local"})
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@mypyc_attr(allow_interpreted_subclasses=True)
|
|
68
|
+
class FSSpecBackend:
|
|
69
|
+
"""Storage backend using fsspec.
|
|
70
|
+
|
|
71
|
+
Implements ObjectStoreProtocol using fsspec for various protocols
|
|
72
|
+
including HTTP, HTTPS, FTP, and cloud storage services.
|
|
73
|
+
|
|
74
|
+
All synchronous methods use the *_sync suffix for consistency with async methods.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
__slots__ = ("_fs_uri", "base_path", "fs", "protocol")
|
|
78
|
+
|
|
79
|
+
backend_type: ClassVar[str] = "fsspec"
|
|
80
|
+
|
|
81
|
+
def __init__(self, uri: str, **kwargs: Any) -> None:
|
|
82
|
+
"""Initialize the fsspec-backed storage backend.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
uri: Filesystem URI (protocol://path).
|
|
86
|
+
**kwargs: Additional fsspec configuration options, including an optional base_path.
|
|
87
|
+
|
|
88
|
+
For cloud URIs (S3/GS/Azure) and file:// URIs, we derive a default base_path from the
|
|
89
|
+
URI path when no explicit base_path is provided. When both URI and base_path are provided,
|
|
90
|
+
they are combined (base_path is appended to URI-derived path).
|
|
91
|
+
"""
|
|
92
|
+
fsspec = import_fsspec()
|
|
93
|
+
|
|
94
|
+
explicit_base_path = kwargs.pop("base_path", "")
|
|
95
|
+
|
|
96
|
+
if "://" in uri:
|
|
97
|
+
self.protocol = uri.split("://", maxsplit=1)[0]
|
|
98
|
+
self._fs_uri = uri
|
|
99
|
+
|
|
100
|
+
if self.protocol in _OBJECT_STORE_PROTOCOLS:
|
|
101
|
+
parsed = urlparse(uri)
|
|
102
|
+
if parsed.netloc:
|
|
103
|
+
uri_base_path = parsed.netloc
|
|
104
|
+
if parsed.path and parsed.path != "/":
|
|
105
|
+
uri_base_path = f"{uri_base_path}{parsed.path}"
|
|
106
|
+
if explicit_base_path:
|
|
107
|
+
uri_base_path = f"{uri_base_path.rstrip('/')}/{explicit_base_path.lstrip('/')}"
|
|
108
|
+
explicit_base_path = uri_base_path
|
|
109
|
+
elif self.protocol in _LOCAL_PROTOCOLS:
|
|
110
|
+
parsed_path = parse_file_uri_path(uri)
|
|
111
|
+
if parsed_path and parsed_path != "/":
|
|
112
|
+
path_obj = Path(parsed_path)
|
|
113
|
+
if not explicit_base_path and is_file_destination(path_obj):
|
|
114
|
+
parsed_path = str(path_obj.parent)
|
|
115
|
+
uri_base_path = parsed_path
|
|
116
|
+
if explicit_base_path:
|
|
117
|
+
uri_base_path = f"{uri_base_path.rstrip('/')}/{explicit_base_path.lstrip('/')}"
|
|
118
|
+
explicit_base_path = uri_base_path
|
|
119
|
+
else:
|
|
120
|
+
self.protocol = uri
|
|
121
|
+
self._fs_uri = f"{uri}://"
|
|
122
|
+
|
|
123
|
+
if self.protocol in _LOCAL_PROTOCOLS:
|
|
124
|
+
resolved_base = Path(explicit_base_path).resolve() if explicit_base_path else Path.cwd().resolve()
|
|
125
|
+
self.base_path = str(resolved_base)
|
|
126
|
+
else:
|
|
127
|
+
self.base_path = explicit_base_path.rstrip("/") if explicit_base_path else ""
|
|
128
|
+
|
|
129
|
+
self.fs = fsspec.filesystem(self.protocol, **kwargs)
|
|
130
|
+
log_storage_event(
|
|
131
|
+
"storage.backend.ready",
|
|
132
|
+
backend_type=self.backend_type,
|
|
133
|
+
protocol=self.protocol,
|
|
134
|
+
operation="init",
|
|
135
|
+
path=self._fs_uri,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
@property
|
|
139
|
+
def base_uri(self) -> str:
|
|
140
|
+
return self._fs_uri
|
|
141
|
+
|
|
142
|
+
@property
|
|
143
|
+
def supports_signing(self) -> bool:
|
|
144
|
+
"""Whether this backend supports URL signing.
|
|
145
|
+
|
|
146
|
+
FSSpec backends do not support URL signing. Use ObStoreBackend
|
|
147
|
+
for S3, GCS, or Azure if you need signed URLs.
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
Always False for fsspec backends.
|
|
151
|
+
"""
|
|
152
|
+
return False
|
|
153
|
+
|
|
154
|
+
def supports_direct_arrow_write(self, file_format: StorageFormat, *, overwrite: bool = True) -> bool:
|
|
155
|
+
"""Return whether direct streaming Arrow writes are supported for the protocol and overwrite mode.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
file_format: Target storage format.
|
|
159
|
+
overwrite: Whether existing objects may be replaced.
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
True when the format and protocol strategy support direct streaming.
|
|
163
|
+
"""
|
|
164
|
+
strategy = _fsspec_write_strategy(self.protocol)
|
|
165
|
+
return file_format in _FSSPEC_ARROW_FORMATS and (overwrite or strategy != "staged")
|
|
166
|
+
|
|
167
|
+
def open_write_stream_sync(
|
|
168
|
+
self, path: "str | Path", *, overwrite: bool = True, **kwargs: Any
|
|
169
|
+
) -> "AbstractContextManager[WritableBytesSink]":
|
|
170
|
+
"""Open a synchronous direct write stream using the protocol's commit strategy."""
|
|
171
|
+
strategy, open_mode, options = _prepare_fsspec_stream_options(self.protocol, overwrite, kwargs)
|
|
172
|
+
destination = self._resolve_path(path)
|
|
173
|
+
return _FsspecWriteStream(
|
|
174
|
+
self.fs,
|
|
175
|
+
destination,
|
|
176
|
+
strategy=strategy,
|
|
177
|
+
mode=open_mode,
|
|
178
|
+
options=options,
|
|
179
|
+
overwrite=overwrite,
|
|
180
|
+
backend_type=self.backend_type,
|
|
181
|
+
log_fields={"protocol": self.protocol, "operation": "write_stream", "mode": "sync"},
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
def open_write_stream_async(
|
|
185
|
+
self, path: "str | Path", *, overwrite: bool = True, **kwargs: Any
|
|
186
|
+
) -> "AbstractAsyncContextManager[AsyncWritableBytesSink]":
|
|
187
|
+
"""Open an asynchronous direct write stream using the protocol's commit strategy."""
|
|
188
|
+
strategy, open_mode, options = _prepare_fsspec_stream_options(self.protocol, overwrite, kwargs)
|
|
189
|
+
destination = self._resolve_path(path)
|
|
190
|
+
return _AsyncFsspecWriteStream(
|
|
191
|
+
self.fs,
|
|
192
|
+
destination,
|
|
193
|
+
strategy=strategy,
|
|
194
|
+
mode=open_mode,
|
|
195
|
+
options=options,
|
|
196
|
+
overwrite=overwrite,
|
|
197
|
+
backend_type=self.backend_type,
|
|
198
|
+
log_fields={"protocol": self.protocol, "operation": "write_stream", "mode": "async"},
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
@classmethod
|
|
202
|
+
def from_config(cls, config: "dict[str, Any]") -> "FSSpecBackend":
|
|
203
|
+
protocol = config["protocol"]
|
|
204
|
+
fs_config = config.get("fs_config", {})
|
|
205
|
+
base_path = config.get("base_path", "")
|
|
206
|
+
|
|
207
|
+
uri = f"{protocol}://"
|
|
208
|
+
kwargs = dict(fs_config)
|
|
209
|
+
if base_path:
|
|
210
|
+
kwargs["base_path"] = base_path
|
|
211
|
+
|
|
212
|
+
return cls(uri=uri, **kwargs)
|
|
213
|
+
|
|
214
|
+
def resolve_uri(self, path: str | Path) -> str:
|
|
215
|
+
"""Resolve a backend-relative path to an unsigned address.
|
|
216
|
+
|
|
217
|
+
Args:
|
|
218
|
+
path: The same backend-relative path accepted by read and write methods.
|
|
219
|
+
|
|
220
|
+
Returns:
|
|
221
|
+
An absolute filesystem path for ``file`` or a protocol-qualified URI
|
|
222
|
+
for other filesystems. The target does not need to exist.
|
|
223
|
+
"""
|
|
224
|
+
resolved_path = self._resolve_path(path)
|
|
225
|
+
if self.protocol == "file":
|
|
226
|
+
return str(Path(resolved_path).resolve())
|
|
227
|
+
return str(self.fs.unstrip_protocol(resolved_path))
|
|
228
|
+
|
|
229
|
+
def read_bytes_sync(self, path: str | Path, **kwargs: Any) -> bytes:
|
|
230
|
+
"""Read bytes from an object synchronously."""
|
|
231
|
+
resolved_path = self._resolve_path(path)
|
|
232
|
+
read_fn = getattr(self.fs, "cat_file", None)
|
|
233
|
+
reader = (
|
|
234
|
+
partial(read_fn, resolved_path, **kwargs)
|
|
235
|
+
if callable(read_fn)
|
|
236
|
+
else partial(self.fs.cat, resolved_path, **kwargs)
|
|
237
|
+
)
|
|
238
|
+
result = cast(
|
|
239
|
+
"bytes",
|
|
240
|
+
execute_sync_storage_operation(
|
|
241
|
+
reader, backend=self.backend_type, operation="read_bytes", path=resolved_path
|
|
242
|
+
),
|
|
243
|
+
)
|
|
244
|
+
log_storage_event(
|
|
245
|
+
"storage.read",
|
|
246
|
+
backend_type=self.backend_type,
|
|
247
|
+
protocol=self.protocol,
|
|
248
|
+
operation="read_bytes",
|
|
249
|
+
path=resolved_path,
|
|
250
|
+
)
|
|
251
|
+
return result
|
|
252
|
+
|
|
253
|
+
def write_bytes_sync(self, path: str | Path, data: bytes, *, overwrite: bool = True, **kwargs: Any) -> None:
|
|
254
|
+
"""Write bytes to an object synchronously."""
|
|
255
|
+
open_mode, options = _resolve_fsspec_write_options(self.protocol, overwrite, kwargs)
|
|
256
|
+
resolved_path = self._resolve_path(path)
|
|
257
|
+
|
|
258
|
+
if self.protocol == "file":
|
|
259
|
+
parent_dir = str(Path(resolved_path).parent)
|
|
260
|
+
if parent_dir and not self.fs.exists(parent_dir):
|
|
261
|
+
self.fs.makedirs(parent_dir, exist_ok=True)
|
|
262
|
+
|
|
263
|
+
execute_sync_storage_operation(
|
|
264
|
+
partial(_write_fsspec_bytes, self.fs, resolved_path, data, open_mode, options),
|
|
265
|
+
backend=self.backend_type,
|
|
266
|
+
operation="write_bytes",
|
|
267
|
+
path=resolved_path,
|
|
268
|
+
)
|
|
269
|
+
log_storage_event(
|
|
270
|
+
"storage.write",
|
|
271
|
+
backend_type=self.backend_type,
|
|
272
|
+
protocol=self.protocol,
|
|
273
|
+
operation="write_bytes",
|
|
274
|
+
path=resolved_path,
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
def read_text_sync(self, path: str | Path, encoding: str = "utf-8", **kwargs: Any) -> str:
|
|
278
|
+
"""Read text from an object synchronously."""
|
|
279
|
+
data = self.read_bytes_sync(path, **kwargs)
|
|
280
|
+
return data.decode(encoding)
|
|
281
|
+
|
|
282
|
+
def write_text_sync(
|
|
283
|
+
self, path: str | Path, data: str, encoding: str = "utf-8", *, overwrite: bool = True, **kwargs: Any
|
|
284
|
+
) -> None:
|
|
285
|
+
"""Write text to an object synchronously."""
|
|
286
|
+
self.write_bytes_sync(path, data.encode(encoding), overwrite=overwrite, **kwargs)
|
|
287
|
+
|
|
288
|
+
def exists_sync(self, path: str | Path, **kwargs: Any) -> bool:
|
|
289
|
+
"""Check if an object exists synchronously."""
|
|
290
|
+
resolved_path = self._resolve_path(path)
|
|
291
|
+
exists = bool(self.fs.exists(resolved_path, **kwargs))
|
|
292
|
+
log_storage_event(
|
|
293
|
+
"storage.read",
|
|
294
|
+
backend_type=self.backend_type,
|
|
295
|
+
protocol=self.protocol,
|
|
296
|
+
operation="exists",
|
|
297
|
+
path=resolved_path,
|
|
298
|
+
exists=bool(exists),
|
|
299
|
+
)
|
|
300
|
+
return exists
|
|
301
|
+
|
|
302
|
+
def delete_sync(self, path: str | Path, *, recursive: bool = False, **kwargs: Any) -> None:
|
|
303
|
+
"""Delete an object synchronously.
|
|
304
|
+
|
|
305
|
+
Args:
|
|
306
|
+
path: Path relative to ``base_path``.
|
|
307
|
+
recursive: Allow deleting directories and their contents. Local ``file`` protocol only
|
|
308
|
+
deletes directories when this is True; other protocols forward it to the filesystem.
|
|
309
|
+
**kwargs: Additional options forwarded to the filesystem.
|
|
310
|
+
|
|
311
|
+
Raises:
|
|
312
|
+
StorageOperationFailedError: On the ``file`` protocol, if ``path`` is the store root or a
|
|
313
|
+
directory and ``recursive`` is False.
|
|
314
|
+
"""
|
|
315
|
+
resolved_path = self._resolve_path(path)
|
|
316
|
+
if self.protocol in _LOCAL_PROTOCOLS:
|
|
317
|
+
check_local_delete_target(resolved_path, self.base_path, recursive=recursive)
|
|
318
|
+
delete_fn = (
|
|
319
|
+
partial(_delete_fsspec_tree, self.fs, resolved_path, kwargs, self.protocol in _LOCAL_PROTOCOLS)
|
|
320
|
+
if recursive
|
|
321
|
+
else partial(_delete_fsspec_object, self.fs, resolved_path, kwargs)
|
|
322
|
+
)
|
|
323
|
+
execute_sync_storage_operation(delete_fn, backend=self.backend_type, operation="delete", path=resolved_path)
|
|
324
|
+
log_storage_event(
|
|
325
|
+
"storage.write",
|
|
326
|
+
backend_type=self.backend_type,
|
|
327
|
+
protocol=self.protocol,
|
|
328
|
+
operation="delete",
|
|
329
|
+
path=resolved_path,
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
def copy_sync(self, source: str | Path, destination: str | Path, **kwargs: Any) -> None:
|
|
333
|
+
"""Copy an object synchronously."""
|
|
334
|
+
source_path = self._resolve_path(source)
|
|
335
|
+
dest_path = self._resolve_path(destination)
|
|
336
|
+
execute_sync_storage_operation(
|
|
337
|
+
partial(_copy_fsspec_object, self.fs, source_path, dest_path, kwargs),
|
|
338
|
+
backend=self.backend_type,
|
|
339
|
+
operation="copy",
|
|
340
|
+
path=f"{source_path}->{dest_path}",
|
|
341
|
+
)
|
|
342
|
+
log_storage_event(
|
|
343
|
+
"storage.write",
|
|
344
|
+
backend_type=self.backend_type,
|
|
345
|
+
protocol=self.protocol,
|
|
346
|
+
operation="copy",
|
|
347
|
+
source_path=source_path,
|
|
348
|
+
destination_path=dest_path,
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
def move_sync(self, source: str | Path, destination: str | Path, **kwargs: Any) -> None:
|
|
352
|
+
"""Move an object synchronously."""
|
|
353
|
+
source_path = self._resolve_path(source)
|
|
354
|
+
dest_path = self._resolve_path(destination)
|
|
355
|
+
execute_sync_storage_operation(
|
|
356
|
+
partial(_move_fsspec_object, self.fs, source_path, dest_path, kwargs, self.protocol in _LOCAL_PROTOCOLS),
|
|
357
|
+
backend=self.backend_type,
|
|
358
|
+
operation="move",
|
|
359
|
+
path=f"{source_path}->{dest_path}",
|
|
360
|
+
)
|
|
361
|
+
log_storage_event(
|
|
362
|
+
"storage.write",
|
|
363
|
+
backend_type=self.backend_type,
|
|
364
|
+
protocol=self.protocol,
|
|
365
|
+
operation="move",
|
|
366
|
+
source_path=source_path,
|
|
367
|
+
destination_path=dest_path,
|
|
368
|
+
)
|
|
369
|
+
|
|
370
|
+
def read_arrow_sync(self, path: str | Path, **kwargs: Any) -> "ArrowTable":
|
|
371
|
+
"""Read an Arrow table from storage synchronously."""
|
|
372
|
+
pq = import_pyarrow_parquet()
|
|
373
|
+
|
|
374
|
+
resolved_path = self._resolve_path(path)
|
|
375
|
+
result = cast(
|
|
376
|
+
"ArrowTable",
|
|
377
|
+
execute_sync_storage_operation(
|
|
378
|
+
partial(self._read_parquet_table, resolved_path, pq, kwargs),
|
|
379
|
+
backend=self.backend_type,
|
|
380
|
+
operation="read_arrow",
|
|
381
|
+
path=resolved_path,
|
|
382
|
+
),
|
|
383
|
+
)
|
|
384
|
+
log_storage_event(
|
|
385
|
+
"storage.read",
|
|
386
|
+
backend_type=self.backend_type,
|
|
387
|
+
protocol=self.protocol,
|
|
388
|
+
operation="read_arrow",
|
|
389
|
+
path=resolved_path,
|
|
390
|
+
)
|
|
391
|
+
return result
|
|
392
|
+
|
|
393
|
+
def write_arrow_sync(self, path: str | Path, table: "ArrowTable", *, overwrite: bool = True, **kwargs: Any) -> None:
|
|
394
|
+
"""Write an Arrow table to storage synchronously."""
|
|
395
|
+
format_hint, compression, merged_write_options = _prepare_fsspec_arrow_write(kwargs)
|
|
396
|
+
resolved_path = self._resolve_path(path)
|
|
397
|
+
|
|
398
|
+
if self.supports_direct_arrow_write(format_hint, overwrite=overwrite):
|
|
399
|
+
strategy = _fsspec_write_strategy(self.protocol)
|
|
400
|
+
open_mode = "wb" if overwrite else "xb"
|
|
401
|
+
|
|
402
|
+
def _do_stream_write() -> None:
|
|
403
|
+
with _FsspecWriteStream(
|
|
404
|
+
self.fs,
|
|
405
|
+
resolved_path,
|
|
406
|
+
strategy=strategy,
|
|
407
|
+
mode=open_mode,
|
|
408
|
+
options={},
|
|
409
|
+
overwrite=overwrite,
|
|
410
|
+
backend_type=self.backend_type,
|
|
411
|
+
log_fields=None,
|
|
412
|
+
) as sink:
|
|
413
|
+
encode_arrow_to_sink(
|
|
414
|
+
table,
|
|
415
|
+
sink,
|
|
416
|
+
format_hint=format_hint,
|
|
417
|
+
compression=compression,
|
|
418
|
+
write_options=merged_write_options,
|
|
419
|
+
)
|
|
420
|
+
|
|
421
|
+
execute_sync_storage_operation(
|
|
422
|
+
_do_stream_write, backend=self.backend_type, operation="write_arrow", path=resolved_path
|
|
423
|
+
)
|
|
424
|
+
else:
|
|
425
|
+
|
|
426
|
+
def _do_buffered_write() -> None:
|
|
427
|
+
payload = encode_arrow_payload(
|
|
428
|
+
table, format_hint, compression=compression, write_options=merged_write_options
|
|
429
|
+
)
|
|
430
|
+
_write_fsspec_bytes(self.fs, resolved_path, payload, "xb", {})
|
|
431
|
+
|
|
432
|
+
execute_sync_storage_operation(
|
|
433
|
+
_do_buffered_write, backend=self.backend_type, operation="write_arrow", path=resolved_path
|
|
434
|
+
)
|
|
435
|
+
|
|
436
|
+
log_storage_event(
|
|
437
|
+
"storage.write",
|
|
438
|
+
backend_type=self.backend_type,
|
|
439
|
+
protocol=self.protocol,
|
|
440
|
+
operation="write_arrow",
|
|
441
|
+
path=resolved_path,
|
|
442
|
+
)
|
|
443
|
+
|
|
444
|
+
def list_objects_sync(self, prefix: str = "", recursive: bool = True, **kwargs: Any) -> "list[str]":
|
|
445
|
+
"""List objects with optional prefix synchronously."""
|
|
446
|
+
resolved_prefix = (
|
|
447
|
+
(self._resolve_path(prefix) if prefix else self.base_path)
|
|
448
|
+
if self.protocol in _LOCAL_PROTOCOLS
|
|
449
|
+
else resolve_storage_path(prefix, self.base_path, self.protocol, strip_file_scheme=False)
|
|
450
|
+
)
|
|
451
|
+
if recursive:
|
|
452
|
+
raw_results = execute_sync_storage_operation(
|
|
453
|
+
partial(self.fs.find, resolved_prefix, **kwargs),
|
|
454
|
+
backend=self.backend_type,
|
|
455
|
+
operation="list_objects",
|
|
456
|
+
path=resolved_prefix,
|
|
457
|
+
)
|
|
458
|
+
else:
|
|
459
|
+
raw_results = execute_sync_storage_operation(
|
|
460
|
+
partial(self.fs.ls, resolved_prefix, detail=False, **kwargs),
|
|
461
|
+
backend=self.backend_type,
|
|
462
|
+
operation="list_objects",
|
|
463
|
+
path=resolved_prefix,
|
|
464
|
+
)
|
|
465
|
+
if self.protocol in _LOCAL_PROTOCOLS:
|
|
466
|
+
raw_results = [item for item in raw_results if _is_within_local_root(item, self.base_path)]
|
|
467
|
+
results = sorted(raw_results)
|
|
468
|
+
log_storage_event(
|
|
469
|
+
"storage.list",
|
|
470
|
+
backend_type=self.backend_type,
|
|
471
|
+
protocol=self.protocol,
|
|
472
|
+
operation="list_objects",
|
|
473
|
+
path=resolved_prefix,
|
|
474
|
+
count=len(results),
|
|
475
|
+
)
|
|
476
|
+
return results
|
|
477
|
+
|
|
478
|
+
def glob_sync(self, pattern: str, **kwargs: Any) -> "list[str]":
|
|
479
|
+
"""Find objects matching a glob pattern synchronously."""
|
|
480
|
+
resolved_pattern = resolve_storage_path(pattern, self.base_path, self.protocol, strip_file_scheme=False)
|
|
481
|
+
raw_results = execute_sync_storage_operation(
|
|
482
|
+
partial(self.fs.glob, resolved_pattern, **kwargs),
|
|
483
|
+
backend=self.backend_type,
|
|
484
|
+
operation="glob",
|
|
485
|
+
path=resolved_pattern,
|
|
486
|
+
)
|
|
487
|
+
if self.protocol in _LOCAL_PROTOCOLS:
|
|
488
|
+
raw_results = [item for item in raw_results if _is_within_local_root(item, self.base_path)]
|
|
489
|
+
results = cast("list[str]", sorted(raw_results))
|
|
490
|
+
log_storage_event(
|
|
491
|
+
"storage.list",
|
|
492
|
+
backend_type=self.backend_type,
|
|
493
|
+
protocol=self.protocol,
|
|
494
|
+
operation="glob",
|
|
495
|
+
path=resolved_pattern,
|
|
496
|
+
count=len(results),
|
|
497
|
+
)
|
|
498
|
+
return results
|
|
499
|
+
|
|
500
|
+
def is_object_sync(self, path: str | Path) -> bool:
|
|
501
|
+
"""Check if path points to an object synchronously."""
|
|
502
|
+
resolved_path = self._resolve_path(path)
|
|
503
|
+
return self.fs.exists(resolved_path) and not self.fs.isdir(resolved_path)
|
|
504
|
+
|
|
505
|
+
def is_path_sync(self, path: str | Path) -> bool:
|
|
506
|
+
"""Check if path points to a prefix (directory-like) synchronously."""
|
|
507
|
+
resolved_path = self._resolve_path(path)
|
|
508
|
+
return self.fs.isdir(resolved_path) # type: ignore[no-any-return]
|
|
509
|
+
|
|
510
|
+
def get_metadata_sync(self, path: str | Path, **kwargs: Any) -> "dict[str, object]":
|
|
511
|
+
"""Get object metadata synchronously."""
|
|
512
|
+
resolved_path = self._resolve_path(path)
|
|
513
|
+
try:
|
|
514
|
+
info = self.fs.info(resolved_path, **kwargs)
|
|
515
|
+
except FileNotFoundError:
|
|
516
|
+
return {"path": resolved_path, "exists": False}
|
|
517
|
+
else:
|
|
518
|
+
if isinstance(info, dict):
|
|
519
|
+
return {
|
|
520
|
+
"path": resolved_path,
|
|
521
|
+
"exists": True,
|
|
522
|
+
"size": info.get("size"),
|
|
523
|
+
"last_modified": info.get("mtime"),
|
|
524
|
+
"type": info.get("type", "file"),
|
|
525
|
+
}
|
|
526
|
+
return {
|
|
527
|
+
"path": resolved_path,
|
|
528
|
+
"exists": True,
|
|
529
|
+
"size": info.size,
|
|
530
|
+
"last_modified": info.mtime,
|
|
531
|
+
"type": info.type,
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
@overload
|
|
535
|
+
def sign_sync(self, paths: str, expires_in: int = 3600, for_upload: bool = False) -> str: ...
|
|
536
|
+
@overload
|
|
537
|
+
def sign_sync(self, paths: "list[str]", expires_in: int = 3600, for_upload: bool = False) -> "list[str]": ...
|
|
538
|
+
def sign_sync(
|
|
539
|
+
self, paths: "str | list[str]", expires_in: int = 3600, for_upload: bool = False
|
|
540
|
+
) -> "str | list[str]":
|
|
541
|
+
"""Generate signed URL(s).
|
|
542
|
+
|
|
543
|
+
Raises:
|
|
544
|
+
NotImplementedError: fsspec backends do not support URL signing.
|
|
545
|
+
Use obstore backend for S3, GCS, or Azure if you need signed URLs.
|
|
546
|
+
"""
|
|
547
|
+
msg = (
|
|
548
|
+
f"URL signing is not supported for fsspec backend (protocol: {self.protocol}). "
|
|
549
|
+
"For S3, GCS, or Azure signed URLs, use ObStoreBackend instead."
|
|
550
|
+
)
|
|
551
|
+
raise NotImplementedError(msg)
|
|
552
|
+
|
|
553
|
+
def stream_read_sync(self, path: "str | Path", chunk_size: "int | None" = None, **kwargs: Any) -> Iterator[bytes]:
|
|
554
|
+
"""Stream bytes from storage synchronously.
|
|
555
|
+
|
|
556
|
+
Yields:
|
|
557
|
+
Chunks of bytes from the file, with size determined by chunk_size (default: 65536 bytes).
|
|
558
|
+
"""
|
|
559
|
+
resolved_path = self._resolve_path(path)
|
|
560
|
+
chunk_size = chunk_size or 65536
|
|
561
|
+
|
|
562
|
+
file_handle = execute_sync_storage_operation(
|
|
563
|
+
partial(self.fs.open, resolved_path, mode="rb", **kwargs),
|
|
564
|
+
backend=self.backend_type,
|
|
565
|
+
operation="stream_read",
|
|
566
|
+
path=resolved_path,
|
|
567
|
+
)
|
|
568
|
+
with file_handle as f:
|
|
569
|
+
while True:
|
|
570
|
+
chunk = f.read(chunk_size)
|
|
571
|
+
if not chunk:
|
|
572
|
+
break
|
|
573
|
+
yield cast("bytes", chunk)
|
|
574
|
+
|
|
575
|
+
def stream_arrow_sync(
|
|
576
|
+
self, pattern: str, *, file_format: Literal["parquet"] = "parquet", batch_size: int = 65_536, **kwargs: Any
|
|
577
|
+
) -> Iterator["ArrowRecordBatch"]:
|
|
578
|
+
"""Stream Arrow record batches from storage synchronously.
|
|
579
|
+
|
|
580
|
+
Args:
|
|
581
|
+
pattern: The glob pattern to match.
|
|
582
|
+
file_format: Storage format. Only Parquet supports bounded batch streaming.
|
|
583
|
+
batch_size: Maximum number of rows in each yielded record batch.
|
|
584
|
+
**kwargs: Additional arguments passed to PyArrow batch iteration.
|
|
585
|
+
|
|
586
|
+
Yields:
|
|
587
|
+
Arrow record batches from matching files.
|
|
588
|
+
"""
|
|
589
|
+
validate_parquet_stream_options(pattern, file_format, batch_size)
|
|
590
|
+
pq = import_pyarrow_parquet()
|
|
591
|
+
arrow_schema = kwargs.pop("arrow_schema", None)
|
|
592
|
+
kwargs.pop("read_buffer_bytes", None)
|
|
593
|
+
for obj_path in self.glob_sync(pattern):
|
|
594
|
+
if self.protocol in _LOCAL_PROTOCOLS:
|
|
595
|
+
ensure_path_within_root(obj_path, self.base_path)
|
|
596
|
+
file_handle = execute_sync_storage_operation(
|
|
597
|
+
partial(self.fs.open, obj_path, mode="rb"),
|
|
598
|
+
backend=self.backend_type,
|
|
599
|
+
operation="stream_open",
|
|
600
|
+
path=str(obj_path),
|
|
601
|
+
)
|
|
602
|
+
with file_handle as stream:
|
|
603
|
+
parquet_file = execute_sync_storage_operation(
|
|
604
|
+
partial(pq.ParquetFile, stream),
|
|
605
|
+
backend=self.backend_type,
|
|
606
|
+
operation="stream_arrow",
|
|
607
|
+
path=str(obj_path),
|
|
608
|
+
)
|
|
609
|
+
yield from iter_parquet_row_groups(
|
|
610
|
+
parquet_file, batch_size=batch_size, arrow_schema=arrow_schema, **kwargs
|
|
611
|
+
)
|
|
612
|
+
|
|
613
|
+
async def read_bytes_async(self, path: "str | Path", **kwargs: Any) -> bytes:
|
|
614
|
+
"""Read bytes from storage asynchronously."""
|
|
615
|
+
return await async_(self.read_bytes_sync)(path, **kwargs)
|
|
616
|
+
|
|
617
|
+
async def write_bytes_async(
|
|
618
|
+
self, path: "str | Path", data: bytes, *, overwrite: bool = True, **kwargs: Any
|
|
619
|
+
) -> None:
|
|
620
|
+
"""Write bytes to storage asynchronously."""
|
|
621
|
+
await async_(self.write_bytes_sync)(path, data, overwrite=overwrite, **kwargs)
|
|
622
|
+
|
|
623
|
+
async def stream_read_async(
|
|
624
|
+
self, path: "str | Path", chunk_size: "int | None" = None, **kwargs: Any
|
|
625
|
+
) -> AsyncIterator[bytes]:
|
|
626
|
+
"""Stream bytes from storage asynchronously.
|
|
627
|
+
|
|
628
|
+
Uses AsyncThreadedBytesIterator to read chunks of the file in a thread pool,
|
|
629
|
+
ensuring the event loop is not blocked while avoiding buffering the
|
|
630
|
+
entire file into memory.
|
|
631
|
+
|
|
632
|
+
Args:
|
|
633
|
+
path: Path to the file to read.
|
|
634
|
+
chunk_size: Size of chunks to yield (default: 65536 bytes).
|
|
635
|
+
**kwargs: Additional arguments passed to fs.open.
|
|
636
|
+
|
|
637
|
+
Returns:
|
|
638
|
+
AsyncIterator yielding chunks of bytes.
|
|
639
|
+
"""
|
|
640
|
+
resolved_path = self._resolve_path(path)
|
|
641
|
+
chunk_size = chunk_size or 65536
|
|
642
|
+
|
|
643
|
+
file_obj = await execute_async_storage_operation(
|
|
644
|
+
partial(async_(self.fs.open), resolved_path, mode="rb", **kwargs),
|
|
645
|
+
backend=self.backend_type,
|
|
646
|
+
operation="stream_read",
|
|
647
|
+
path=resolved_path,
|
|
648
|
+
)
|
|
649
|
+
|
|
650
|
+
return AsyncThreadedBytesIterator(file_obj, chunk_size)
|
|
651
|
+
|
|
652
|
+
def stream_arrow_async(
|
|
653
|
+
self, pattern: str, *, file_format: Literal["parquet"] = "parquet", batch_size: int = 65_536, **kwargs: Any
|
|
654
|
+
) -> AsyncIterator["ArrowRecordBatch"]:
|
|
655
|
+
"""Stream Arrow record batches from storage asynchronously.
|
|
656
|
+
|
|
657
|
+
Args:
|
|
658
|
+
pattern: The glob pattern to match.
|
|
659
|
+
file_format: Storage format. Only Parquet supports bounded batch streaming.
|
|
660
|
+
batch_size: Maximum number of rows in each yielded record batch.
|
|
661
|
+
**kwargs: Additional arguments passed to PyArrow batch iteration.
|
|
662
|
+
|
|
663
|
+
Returns:
|
|
664
|
+
AsyncIterator yielding Arrow record batches.
|
|
665
|
+
"""
|
|
666
|
+
return AsyncArrowBatchIterator(
|
|
667
|
+
self.stream_arrow_sync(pattern, file_format=file_format, batch_size=batch_size, **kwargs)
|
|
668
|
+
)
|
|
669
|
+
|
|
670
|
+
async def read_text_async(self, path: "str | Path", encoding: str = "utf-8", **kwargs: Any) -> str:
|
|
671
|
+
"""Read text from storage asynchronously."""
|
|
672
|
+
return await async_(self.read_text_sync)(path, encoding, **kwargs)
|
|
673
|
+
|
|
674
|
+
async def write_text_async(
|
|
675
|
+
self, path: str | Path, data: str, encoding: str = "utf-8", *, overwrite: bool = True, **kwargs: Any
|
|
676
|
+
) -> None:
|
|
677
|
+
"""Write text to storage asynchronously."""
|
|
678
|
+
await async_(self.write_text_sync)(path, data, encoding, overwrite=overwrite, **kwargs)
|
|
679
|
+
|
|
680
|
+
async def list_objects_async(self, prefix: str = "", recursive: bool = True, **kwargs: Any) -> "list[str]":
|
|
681
|
+
"""List objects in storage asynchronously."""
|
|
682
|
+
return await async_(self.list_objects_sync)(prefix, recursive, **kwargs)
|
|
683
|
+
|
|
684
|
+
async def exists_async(self, path: str | Path, **kwargs: Any) -> bool:
|
|
685
|
+
"""Check if object exists in storage asynchronously."""
|
|
686
|
+
return await async_(self.exists_sync)(path, **kwargs)
|
|
687
|
+
|
|
688
|
+
async def delete_async(self, path: str | Path, *, recursive: bool = False, **kwargs: Any) -> None:
|
|
689
|
+
"""Delete object from storage asynchronously."""
|
|
690
|
+
await async_(self.delete_sync)(path, recursive=recursive, **kwargs)
|
|
691
|
+
|
|
692
|
+
async def copy_async(self, source: str | Path, destination: str | Path, **kwargs: Any) -> None:
|
|
693
|
+
"""Copy object in storage asynchronously."""
|
|
694
|
+
await async_(self.copy_sync)(source, destination, **kwargs)
|
|
695
|
+
|
|
696
|
+
async def move_async(self, source: str | Path, destination: str | Path, **kwargs: Any) -> None:
|
|
697
|
+
"""Move object in storage asynchronously."""
|
|
698
|
+
await async_(self.move_sync)(source, destination, **kwargs)
|
|
699
|
+
|
|
700
|
+
async def get_metadata_async(self, path: str | Path, **kwargs: Any) -> "dict[str, object]":
|
|
701
|
+
"""Get object metadata from storage asynchronously."""
|
|
702
|
+
return await async_(self.get_metadata_sync)(path, **kwargs)
|
|
703
|
+
|
|
704
|
+
@overload
|
|
705
|
+
async def sign_async(self, paths: str, expires_in: int = 3600, for_upload: bool = False) -> str: ...
|
|
706
|
+
@overload
|
|
707
|
+
async def sign_async(self, paths: "list[str]", expires_in: int = 3600, for_upload: bool = False) -> "list[str]": ...
|
|
708
|
+
async def sign_async(
|
|
709
|
+
self, paths: "str | list[str]", expires_in: int = 3600, for_upload: bool = False
|
|
710
|
+
) -> "str | list[str]":
|
|
711
|
+
"""Generate signed URL(s) asynchronously."""
|
|
712
|
+
return await async_(self.sign_sync)(paths, expires_in, for_upload) # type: ignore[arg-type]
|
|
713
|
+
|
|
714
|
+
async def read_arrow_async(self, path: str | Path, **kwargs: Any) -> "ArrowTable":
|
|
715
|
+
"""Read Arrow table from storage asynchronously.
|
|
716
|
+
|
|
717
|
+
Uses async_() with storage limiter to offload blocking PyArrow I/O to thread pool.
|
|
718
|
+
"""
|
|
719
|
+
return await async_(self.read_arrow_sync)(path, **kwargs)
|
|
720
|
+
|
|
721
|
+
async def write_arrow_async(
|
|
722
|
+
self, path: str | Path, table: "ArrowTable", *, overwrite: bool = True, **kwargs: Any
|
|
723
|
+
) -> None:
|
|
724
|
+
"""Write an Arrow table to storage asynchronously."""
|
|
725
|
+
format_hint, compression, merged_write_options = _prepare_fsspec_arrow_write(kwargs)
|
|
726
|
+
resolved_path = self._resolve_path(path)
|
|
727
|
+
|
|
728
|
+
if self.supports_direct_arrow_write(format_hint, overwrite=overwrite):
|
|
729
|
+
strategy = _fsspec_write_strategy(self.protocol)
|
|
730
|
+
open_mode = "wb" if overwrite else "xb"
|
|
731
|
+
|
|
732
|
+
async def _do_stream_write_async() -> None:
|
|
733
|
+
stream_context = _AsyncFsspecWriteStream(
|
|
734
|
+
self.fs,
|
|
735
|
+
resolved_path,
|
|
736
|
+
strategy=strategy,
|
|
737
|
+
mode=open_mode,
|
|
738
|
+
options={},
|
|
739
|
+
overwrite=overwrite,
|
|
740
|
+
backend_type=self.backend_type,
|
|
741
|
+
log_fields=None,
|
|
742
|
+
)
|
|
743
|
+
sink = await stream_context.__aenter__()
|
|
744
|
+
stream_error: BaseException | None = None
|
|
745
|
+
try:
|
|
746
|
+
await encode_arrow_to_async_sink(
|
|
747
|
+
table,
|
|
748
|
+
sink,
|
|
749
|
+
format_hint=format_hint,
|
|
750
|
+
compression=compression,
|
|
751
|
+
write_options=merged_write_options,
|
|
752
|
+
)
|
|
753
|
+
except BaseException as caught:
|
|
754
|
+
stream_error = caught
|
|
755
|
+
await exit_async_context(stream_context, stream_error)
|
|
756
|
+
|
|
757
|
+
await execute_async_storage_operation(
|
|
758
|
+
_do_stream_write_async, backend=self.backend_type, operation="write_arrow", path=resolved_path
|
|
759
|
+
)
|
|
760
|
+
else:
|
|
761
|
+
|
|
762
|
+
def _encode_and_write_xb() -> None:
|
|
763
|
+
payload = encode_arrow_payload(
|
|
764
|
+
table, format_hint, compression=compression, write_options=merged_write_options
|
|
765
|
+
)
|
|
766
|
+
_write_fsspec_bytes(self.fs, resolved_path, payload, "xb", {})
|
|
767
|
+
|
|
768
|
+
await execute_async_storage_operation(
|
|
769
|
+
async_(_encode_and_write_xb), backend=self.backend_type, operation="write_arrow", path=resolved_path
|
|
770
|
+
)
|
|
771
|
+
|
|
772
|
+
log_storage_event(
|
|
773
|
+
"storage.write",
|
|
774
|
+
backend_type=self.backend_type,
|
|
775
|
+
protocol=self.protocol,
|
|
776
|
+
operation="write_arrow",
|
|
777
|
+
path=resolved_path,
|
|
778
|
+
)
|
|
779
|
+
|
|
780
|
+
def _resolve_path(self, path: str | Path) -> str:
|
|
781
|
+
if self.protocol in _LOCAL_PROTOCOLS:
|
|
782
|
+
reject_parent_traversal(path)
|
|
783
|
+
target = str(path)
|
|
784
|
+
if target.startswith("file://"):
|
|
785
|
+
target = parse_file_uri_path(target)
|
|
786
|
+
rel = ensure_path_within_root(target, self.base_path)
|
|
787
|
+
return self.base_path if not rel else f"{self.base_path}/{rel}"
|
|
788
|
+
return resolve_storage_path(path, self.base_path, self.protocol, strip_file_scheme=False)
|
|
789
|
+
|
|
790
|
+
def _read_parquet_table(self, resolved_path: str, pq: Any, options: "dict[str, Any]") -> Any:
|
|
791
|
+
with self.fs.open(resolved_path, mode="rb", **options) as file_obj:
|
|
792
|
+
return pq.read_table(file_obj)
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
def _is_within_local_root(candidate: str | Path, root: str | Path) -> bool:
|
|
796
|
+
"""Return True when ``candidate`` resolves within ``root``."""
|
|
797
|
+
try:
|
|
798
|
+
root_obj = Path(str(root)).resolve()
|
|
799
|
+
resolved = Path(str(candidate)).resolve()
|
|
800
|
+
except OSError:
|
|
801
|
+
return False
|
|
802
|
+
return resolved == root_obj or root_obj in resolved.parents
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
def _delete_fsspec_object(fs: Any, path: str, options: "dict[str, Any]") -> None:
|
|
806
|
+
"""Delete one object by its literal key, using ``rm`` when the filesystem has no ``rm_file``."""
|
|
807
|
+
rm_file = getattr(fs, "rm_file", None)
|
|
808
|
+
if callable(rm_file):
|
|
809
|
+
try:
|
|
810
|
+
rm_file(path, **options)
|
|
811
|
+
except NotImplementedError:
|
|
812
|
+
pass
|
|
813
|
+
else:
|
|
814
|
+
return
|
|
815
|
+
fs.rm(path, recursive=False, **options)
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
def _delete_fsspec_tree(fs: Any, path: str, options: "dict[str, Any]", literal_rm: bool) -> None:
|
|
819
|
+
"""Delete ``path`` and everything beneath it, never expanding glob characters in the key.
|
|
820
|
+
|
|
821
|
+
Args:
|
|
822
|
+
fs: The fsspec filesystem.
|
|
823
|
+
path: Resolved key or prefix to delete.
|
|
824
|
+
options: Additional options forwarded to the filesystem.
|
|
825
|
+
literal_rm: Whether ``fs.rm`` already treats every path literally.
|
|
826
|
+
|
|
827
|
+
Raises:
|
|
828
|
+
FileNotFoundError: If nothing exists at ``path``.
|
|
829
|
+
"""
|
|
830
|
+
if literal_rm or _GLOB_MAGIC.search(path) is None:
|
|
831
|
+
fs.rm(path, recursive=True, **options)
|
|
832
|
+
return
|
|
833
|
+
found = fs.find(path, withdirs=True, detail=True)
|
|
834
|
+
if not found:
|
|
835
|
+
raise FileNotFoundError(path)
|
|
836
|
+
entries: dict[str, Any] = found if isinstance(found, dict) else {member: {} for member in found}
|
|
837
|
+
for member in sorted(entries, reverse=True):
|
|
838
|
+
if entries[member].get("type") == "directory":
|
|
839
|
+
with contextlib.suppress(FileNotFoundError, FileExistsError, NotImplementedError):
|
|
840
|
+
fs.rmdir(member)
|
|
841
|
+
else:
|
|
842
|
+
_delete_fsspec_object(fs, member, options)
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
def _copy_fsspec_object(fs: Any, source: str, destination: str, options: "dict[str, Any]") -> None:
|
|
846
|
+
"""Copy one object, treating a source key that contains glob characters literally."""
|
|
847
|
+
if _GLOB_MAGIC.search(source) is None:
|
|
848
|
+
fs.copy(source, destination, **options)
|
|
849
|
+
return
|
|
850
|
+
try:
|
|
851
|
+
fs.cp_file(source, destination, **options)
|
|
852
|
+
except NotImplementedError:
|
|
853
|
+
fs.copy(source, destination, **options)
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
def _move_fsspec_object(fs: Any, source: str, destination: str, options: "dict[str, Any]", literal_mv: bool) -> None:
|
|
857
|
+
"""Move one object, treating a source key that contains glob characters literally.
|
|
858
|
+
|
|
859
|
+
Args:
|
|
860
|
+
fs: The fsspec filesystem.
|
|
861
|
+
source: Resolved source key.
|
|
862
|
+
destination: Resolved destination key.
|
|
863
|
+
options: Additional options forwarded to the filesystem.
|
|
864
|
+
literal_mv: Whether ``fs.mv`` already treats every path literally.
|
|
865
|
+
"""
|
|
866
|
+
if literal_mv or _GLOB_MAGIC.search(source) is None:
|
|
867
|
+
fs.mv(source, destination, **options)
|
|
868
|
+
return
|
|
869
|
+
if source == destination:
|
|
870
|
+
return
|
|
871
|
+
try:
|
|
872
|
+
fs.cp_file(source, destination, **options)
|
|
873
|
+
except NotImplementedError:
|
|
874
|
+
fs.mv(source, destination, **options)
|
|
875
|
+
return
|
|
876
|
+
_delete_fsspec_object(fs, source, {})
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
def _resolve_fsspec_write_options(
|
|
880
|
+
protocol: str, overwrite: bool, kwargs: "dict[str, Any]"
|
|
881
|
+
) -> "tuple[str, dict[str, Any]]":
|
|
882
|
+
"""Validate and resolve fsspec open mode and options for byte writes.
|
|
883
|
+
|
|
884
|
+
Local and in-memory filesystems silently accept unknown ``open`` options, so
|
|
885
|
+
only the options they honor are allowed there. Remote filesystems receive
|
|
886
|
+
every option unchanged.
|
|
887
|
+
|
|
888
|
+
Args:
|
|
889
|
+
protocol: The fsspec protocol of the backend.
|
|
890
|
+
overwrite: Whether an existing object may be replaced.
|
|
891
|
+
kwargs: Caller-supplied ``fs.open`` options.
|
|
892
|
+
|
|
893
|
+
Returns:
|
|
894
|
+
The ``open`` mode (``"wb"`` or ``"xb"``) and the options to pass to ``fs.open``.
|
|
895
|
+
|
|
896
|
+
Raises:
|
|
897
|
+
TypeError: If ``mode`` or an option the local or in-memory filesystem ignores is passed.
|
|
898
|
+
"""
|
|
899
|
+
if kwargs:
|
|
900
|
+
if "mode" in kwargs:
|
|
901
|
+
msg = "Unsupported keyword argument 'mode' for write_bytes; use 'overwrite' instead."
|
|
902
|
+
raise TypeError(msg)
|
|
903
|
+
if protocol in _FSSPEC_VALIDATED_PROTOCOLS:
|
|
904
|
+
unsupported = [name for name in kwargs if name not in _FSSPEC_BASIC_OPEN_OPTIONS]
|
|
905
|
+
if unsupported:
|
|
906
|
+
names = ", ".join(sorted(unsupported))
|
|
907
|
+
msg = f"Unsupported write keyword argument(s) for FSSpecBackend ({protocol}): {names}"
|
|
908
|
+
raise TypeError(msg)
|
|
909
|
+
return ("wb" if overwrite else "xb"), kwargs
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
def _write_fsspec_bytes(fs: Any, resolved_path: str, data: bytes, open_mode: str, options: "dict[str, Any]") -> None:
|
|
913
|
+
"""Write raw bytes via an fsspec filesystem handle."""
|
|
914
|
+
with fs.open(resolved_path, mode=open_mode, **options) as file_obj:
|
|
915
|
+
file_obj.write(data) # pyright: ignore
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
def _prepare_fsspec_arrow_write(kwargs: "dict[str, Any]") -> "tuple[StorageFormat, str | None, dict[str, Any]]":
|
|
919
|
+
"""Validate and extract format_hint, compression, and writer options for FSSpecBackend Arrow writes."""
|
|
920
|
+
import_pyarrow()
|
|
921
|
+
format_hint: StorageFormat = kwargs.pop("format_hint", "parquet")
|
|
922
|
+
if format_hint == "parquet":
|
|
923
|
+
import_pyarrow_parquet()
|
|
924
|
+
if format_hint not in _FSSPEC_ARROW_FORMATS:
|
|
925
|
+
msg = f"Arrow storage writes support only Parquet, Arrow IPC, and CSV formats, got {format_hint!r}"
|
|
926
|
+
raise StorageCapabilityError(
|
|
927
|
+
msg, capability="arrow_write", remediation="Write row payloads with the row storage APIs instead."
|
|
928
|
+
)
|
|
929
|
+
|
|
930
|
+
write_options_arg = kwargs.pop("write_options", None)
|
|
931
|
+
merged_write_options: dict[str, Any] = dict(write_options_arg) if write_options_arg else {}
|
|
932
|
+
has_compression_in_kwargs = "compression" in kwargs
|
|
933
|
+
compression_arg = kwargs.pop("compression", None)
|
|
934
|
+
merged_write_options.update(kwargs)
|
|
935
|
+
|
|
936
|
+
if has_compression_in_kwargs:
|
|
937
|
+
compression: str | None = compression_arg
|
|
938
|
+
elif "compression" in merged_write_options:
|
|
939
|
+
compression = merged_write_options.get("compression")
|
|
940
|
+
elif format_hint == "parquet":
|
|
941
|
+
compression = "snappy"
|
|
942
|
+
else:
|
|
943
|
+
compression = None
|
|
944
|
+
|
|
945
|
+
validate_arrow_write_options(format_hint, merged_write_options)
|
|
946
|
+
return format_hint, compression, merged_write_options
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
def _fsspec_write_strategy(protocol: str) -> "_FsspecStrategy":
|
|
950
|
+
"""Return the direct-stream commit strategy for an fsspec protocol."""
|
|
951
|
+
if protocol in _LOCAL_PROTOCOLS:
|
|
952
|
+
return "local"
|
|
953
|
+
if protocol in _COMMIT_PROTOCOLS:
|
|
954
|
+
return "commit"
|
|
955
|
+
if protocol in _BLOCK_PROTOCOLS:
|
|
956
|
+
return "block"
|
|
957
|
+
return "staged"
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
def _prepare_fsspec_stream_options(
|
|
961
|
+
protocol: str, overwrite: bool, kwargs: "dict[str, Any]"
|
|
962
|
+
) -> "tuple[_FsspecStrategy, str, dict[str, Any]]":
|
|
963
|
+
"""Validate stream options and resolve strategy, open mode, and fs.open kwargs."""
|
|
964
|
+
if "autocommit" in kwargs:
|
|
965
|
+
msg = "Unsupported keyword argument 'autocommit' for open_write_stream; commit lifecycle is managed by the stream."
|
|
966
|
+
raise TypeError(msg)
|
|
967
|
+
open_mode, options = _resolve_fsspec_write_options(protocol, overwrite, dict(kwargs))
|
|
968
|
+
strategy = _fsspec_write_strategy(protocol)
|
|
969
|
+
if strategy == "staged" and not overwrite:
|
|
970
|
+
msg = f"Direct write streams do not support overwrite=False for fsspec protocol {protocol!r}"
|
|
971
|
+
raise StorageCapabilityError(msg, capability="overwrite_false_stream")
|
|
972
|
+
return strategy, open_mode, options
|
|
973
|
+
|
|
974
|
+
|
|
975
|
+
def _as_create_conflict(error: Exception, path: str) -> Exception:
|
|
976
|
+
"""Return FileExistsError for an S3 precondition failure, otherwise the original error."""
|
|
977
|
+
cause = getattr(error, "__cause__", None)
|
|
978
|
+
response = getattr(cause, "response", None)
|
|
979
|
+
if isinstance(response, dict):
|
|
980
|
+
error_payload = response.get("Error")
|
|
981
|
+
if isinstance(error_payload, dict) and error_payload.get("Code") == "PreconditionFailed":
|
|
982
|
+
return FileExistsError(path)
|
|
983
|
+
return error
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
def _forget_transaction_file(fs: Any, file: Any) -> None:
|
|
987
|
+
"""Remove a deferred-commit file from the filesystem's cached transaction list."""
|
|
988
|
+
tx = getattr(fs, "transaction", None)
|
|
989
|
+
files = getattr(tx, "files", None)
|
|
990
|
+
if files is None:
|
|
991
|
+
return
|
|
992
|
+
remove_fn = getattr(files, "remove", None)
|
|
993
|
+
if not callable(remove_fn):
|
|
994
|
+
return
|
|
995
|
+
for _ in range(3):
|
|
996
|
+
try:
|
|
997
|
+
remove_fn(file)
|
|
998
|
+
except ValueError:
|
|
999
|
+
return
|
|
1000
|
+
except IndexError:
|
|
1001
|
+
continue
|
|
1002
|
+
else:
|
|
1003
|
+
return
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
def _fsspec_stage_key(destination: str) -> str:
|
|
1007
|
+
"""Construct a hidden sibling stage key in the destination's parent prefix."""
|
|
1008
|
+
if "/" in destination:
|
|
1009
|
+
parent, _ = destination.rsplit("/", 1)
|
|
1010
|
+
return f"{parent}/{_STAGE_PREFIX}{uuid4().hex}" if parent else f"/{_STAGE_PREFIX}{uuid4().hex}"
|
|
1011
|
+
return f"{_STAGE_PREFIX}{uuid4().hex}"
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
def _open_fsspec_stream_target(
|
|
1015
|
+
strategy: "_FsspecStrategy", fs: Any, destination: str, mode: str, options: "dict[str, Any]"
|
|
1016
|
+
) -> "tuple[str | None, Any]":
|
|
1017
|
+
"""Open the underlying file handle for an fsspec direct write stream."""
|
|
1018
|
+
if strategy == "local":
|
|
1019
|
+
stage_path, file_obj = _open_local_stage(Path(destination))
|
|
1020
|
+
return str(stage_path), file_obj
|
|
1021
|
+
if strategy == "commit":
|
|
1022
|
+
committed_file = fs.open(destination, mode=mode, autocommit=False, **options)
|
|
1023
|
+
_forget_transaction_file(fs, committed_file)
|
|
1024
|
+
return None, committed_file
|
|
1025
|
+
if strategy == "block":
|
|
1026
|
+
return None, fs.open(destination, mode=mode, **options)
|
|
1027
|
+
stage_key = _fsspec_stage_key(destination)
|
|
1028
|
+
return stage_key, fs.open(stage_key, mode="wb", **options)
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
def _close_and_publish_fsspec_stream(
|
|
1032
|
+
strategy: "_FsspecStrategy", fs: Any, stage: "str | None", file_obj: Any, destination: str, *, overwrite: bool
|
|
1033
|
+
) -> None:
|
|
1034
|
+
"""Close and atomically publish an fsspec direct write stream."""
|
|
1035
|
+
if strategy == "local":
|
|
1036
|
+
assert stage is not None
|
|
1037
|
+
_close_and_publish_local_stage(Path(stage), file_obj, Path(destination), overwrite=overwrite)
|
|
1038
|
+
return
|
|
1039
|
+
if strategy == "commit":
|
|
1040
|
+
try:
|
|
1041
|
+
file_obj.close()
|
|
1042
|
+
file_obj.commit()
|
|
1043
|
+
except Exception as error:
|
|
1044
|
+
with contextlib.suppress(Exception):
|
|
1045
|
+
file_obj.discard()
|
|
1046
|
+
with contextlib.suppress(Exception):
|
|
1047
|
+
file_obj.closed = True
|
|
1048
|
+
mapped = _as_create_conflict(error, destination)
|
|
1049
|
+
if mapped is not error:
|
|
1050
|
+
mapped.__cause__ = error
|
|
1051
|
+
raise mapped from error
|
|
1052
|
+
raise
|
|
1053
|
+
except BaseException:
|
|
1054
|
+
with contextlib.suppress(Exception):
|
|
1055
|
+
file_obj.discard()
|
|
1056
|
+
with contextlib.suppress(Exception):
|
|
1057
|
+
file_obj.closed = True
|
|
1058
|
+
raise
|
|
1059
|
+
return
|
|
1060
|
+
if strategy == "block":
|
|
1061
|
+
file_obj.close()
|
|
1062
|
+
return
|
|
1063
|
+
assert stage is not None
|
|
1064
|
+
try:
|
|
1065
|
+
file_obj.close()
|
|
1066
|
+
_move_fsspec_object(fs, stage, destination, {}, False)
|
|
1067
|
+
finally:
|
|
1068
|
+
with contextlib.suppress(Exception):
|
|
1069
|
+
if fs.exists(stage):
|
|
1070
|
+
_delete_fsspec_object(fs, stage, {})
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
def _abort_fsspec_stream(strategy: "_FsspecStrategy", fs: Any, stage: "str | None", file_obj: Any) -> None:
|
|
1074
|
+
"""Abort an fsspec direct write stream without touching the destination."""
|
|
1075
|
+
if strategy == "local":
|
|
1076
|
+
if stage is not None:
|
|
1077
|
+
_abort_local_stage(Path(stage), file_obj)
|
|
1078
|
+
return
|
|
1079
|
+
if strategy == "commit":
|
|
1080
|
+
with contextlib.suppress(Exception):
|
|
1081
|
+
file_obj.discard()
|
|
1082
|
+
with contextlib.suppress(Exception):
|
|
1083
|
+
file_obj.closed = True
|
|
1084
|
+
return
|
|
1085
|
+
if strategy == "block":
|
|
1086
|
+
with contextlib.suppress(Exception):
|
|
1087
|
+
file_obj.forced = True
|
|
1088
|
+
with contextlib.suppress(Exception):
|
|
1089
|
+
file_obj.close()
|
|
1090
|
+
return
|
|
1091
|
+
with contextlib.suppress(Exception):
|
|
1092
|
+
file_obj.close()
|
|
1093
|
+
if stage is not None:
|
|
1094
|
+
with contextlib.suppress(Exception):
|
|
1095
|
+
_delete_fsspec_object(fs, stage, {})
|
|
1096
|
+
|
|
1097
|
+
|
|
1098
|
+
async def _abort_fsspec_stream_async(strategy: "_FsspecStrategy", fs: Any, stage: "str | None", file_obj: Any) -> None:
|
|
1099
|
+
"""Abort an opened fsspec write stream under cancellation shield."""
|
|
1100
|
+
try:
|
|
1101
|
+
await join_shielded(
|
|
1102
|
+
asyncio.ensure_future(async_(_abort_fsspec_stream)(strategy, fs, stage, file_obj)), suppress_result=True
|
|
1103
|
+
)
|
|
1104
|
+
except asyncio.CancelledError:
|
|
1105
|
+
return
|
|
1106
|
+
except Exception:
|
|
1107
|
+
return
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
1111
|
+
class _FsspecSink:
|
|
1112
|
+
"""Write to one fsspec file, normalizing storage failures."""
|
|
1113
|
+
|
|
1114
|
+
__slots__ = ("_backend", "_closed", "_file", "_path")
|
|
1115
|
+
|
|
1116
|
+
def __init__(self, file: Any, *, backend: str, path: str) -> None:
|
|
1117
|
+
self._file = file
|
|
1118
|
+
self._backend = backend
|
|
1119
|
+
self._path = path
|
|
1120
|
+
self._closed = False
|
|
1121
|
+
|
|
1122
|
+
@property
|
|
1123
|
+
def closed(self) -> bool:
|
|
1124
|
+
return self._closed or bool(getattr(self._file, "closed", False))
|
|
1125
|
+
|
|
1126
|
+
def write(self, data: Any, /) -> int:
|
|
1127
|
+
if self._closed:
|
|
1128
|
+
return 0
|
|
1129
|
+
payload = bytes(data) if isinstance(data, (bytearray, memoryview)) else data
|
|
1130
|
+
if not payload:
|
|
1131
|
+
return 0
|
|
1132
|
+
try:
|
|
1133
|
+
return int(self._file.write(payload))
|
|
1134
|
+
except Exception as error:
|
|
1135
|
+
raise_storage_error(error, backend=self._backend, operation="write_stream", path=self._path)
|
|
1136
|
+
|
|
1137
|
+
def flush(self) -> None:
|
|
1138
|
+
if self._closed:
|
|
1139
|
+
return
|
|
1140
|
+
flush_fn = getattr(self._file, "flush", None)
|
|
1141
|
+
if callable(flush_fn):
|
|
1142
|
+
try:
|
|
1143
|
+
flush_fn()
|
|
1144
|
+
except Exception as error:
|
|
1145
|
+
raise_storage_error(error, backend=self._backend, operation="write_stream", path=self._path)
|
|
1146
|
+
|
|
1147
|
+
def close(self) -> None:
|
|
1148
|
+
self._closed = True
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
1152
|
+
class _AsyncFsspecSink:
|
|
1153
|
+
"""Run fsspec file writes off the event loop, normalizing storage failures."""
|
|
1154
|
+
|
|
1155
|
+
__slots__ = ("_backend", "_closed", "_file", "_path")
|
|
1156
|
+
|
|
1157
|
+
def __init__(self, file: Any, *, backend: str, path: str) -> None:
|
|
1158
|
+
self._file = file
|
|
1159
|
+
self._backend = backend
|
|
1160
|
+
self._path = path
|
|
1161
|
+
self._closed = False
|
|
1162
|
+
|
|
1163
|
+
@property
|
|
1164
|
+
def closed(self) -> bool:
|
|
1165
|
+
return self._closed or bool(getattr(self._file, "closed", False))
|
|
1166
|
+
|
|
1167
|
+
async def write(self, data: Any, /) -> int:
|
|
1168
|
+
if self._closed:
|
|
1169
|
+
return 0
|
|
1170
|
+
payload = bytes(data) if isinstance(data, (bytearray, memoryview)) else data
|
|
1171
|
+
if not payload:
|
|
1172
|
+
return 0
|
|
1173
|
+
try:
|
|
1174
|
+
return int(await async_(self._file.write)(payload))
|
|
1175
|
+
except Exception as error:
|
|
1176
|
+
raise_storage_error(error, backend=self._backend, operation="write_stream", path=self._path)
|
|
1177
|
+
|
|
1178
|
+
async def flush(self) -> None:
|
|
1179
|
+
if self._closed:
|
|
1180
|
+
return
|
|
1181
|
+
flush_fn = getattr(self._file, "flush", None)
|
|
1182
|
+
if callable(flush_fn):
|
|
1183
|
+
try:
|
|
1184
|
+
await async_(flush_fn)()
|
|
1185
|
+
except Exception as error:
|
|
1186
|
+
raise_storage_error(error, backend=self._backend, operation="write_stream", path=self._path)
|
|
1187
|
+
|
|
1188
|
+
async def close(self) -> None:
|
|
1189
|
+
self._closed = True
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
1193
|
+
class _FsspecWriteStream:
|
|
1194
|
+
"""Synchronous fsspec write stream context manager."""
|
|
1195
|
+
|
|
1196
|
+
__slots__ = (
|
|
1197
|
+
"_backend_type",
|
|
1198
|
+
"_destination",
|
|
1199
|
+
"_file",
|
|
1200
|
+
"_fs",
|
|
1201
|
+
"_log_fields",
|
|
1202
|
+
"_mode",
|
|
1203
|
+
"_options",
|
|
1204
|
+
"_overwrite",
|
|
1205
|
+
"_sink",
|
|
1206
|
+
"_stage",
|
|
1207
|
+
"_strategy",
|
|
1208
|
+
)
|
|
1209
|
+
|
|
1210
|
+
def __init__(
|
|
1211
|
+
self,
|
|
1212
|
+
fs: Any,
|
|
1213
|
+
destination: str,
|
|
1214
|
+
*,
|
|
1215
|
+
strategy: "_FsspecStrategy",
|
|
1216
|
+
mode: str,
|
|
1217
|
+
options: "dict[str, Any]",
|
|
1218
|
+
overwrite: bool,
|
|
1219
|
+
backend_type: str,
|
|
1220
|
+
log_fields: "dict[str, Any] | None",
|
|
1221
|
+
) -> None:
|
|
1222
|
+
self._fs = fs
|
|
1223
|
+
self._destination = destination
|
|
1224
|
+
self._strategy: _FsspecStrategy = strategy
|
|
1225
|
+
self._mode = mode
|
|
1226
|
+
self._options = options
|
|
1227
|
+
self._overwrite = overwrite
|
|
1228
|
+
self._backend_type = backend_type
|
|
1229
|
+
self._log_fields = log_fields
|
|
1230
|
+
self._stage: str | None = None
|
|
1231
|
+
self._file: Any = None
|
|
1232
|
+
self._sink: _FsspecSink | None = None
|
|
1233
|
+
|
|
1234
|
+
def __enter__(self) -> "_FsspecSink":
|
|
1235
|
+
stage, file_obj = execute_sync_storage_operation(
|
|
1236
|
+
lambda: _open_fsspec_stream_target(self._strategy, self._fs, self._destination, self._mode, self._options),
|
|
1237
|
+
backend=self._backend_type,
|
|
1238
|
+
operation="open_write_stream",
|
|
1239
|
+
path=self._destination,
|
|
1240
|
+
)
|
|
1241
|
+
self._stage = stage
|
|
1242
|
+
self._file = file_obj
|
|
1243
|
+
sink = _FsspecSink(file_obj, backend=self._backend_type, path=self._destination)
|
|
1244
|
+
self._sink = sink
|
|
1245
|
+
return sink
|
|
1246
|
+
|
|
1247
|
+
def __exit__(self, exc_type: Any, exc: Any, traceback: Any) -> None:
|
|
1248
|
+
_ = (exc, traceback)
|
|
1249
|
+
sink = self._sink
|
|
1250
|
+
if sink is not None:
|
|
1251
|
+
sink._closed = True
|
|
1252
|
+
file_obj = self._file
|
|
1253
|
+
if file_obj is None:
|
|
1254
|
+
return
|
|
1255
|
+
if exc_type is None:
|
|
1256
|
+
execute_sync_storage_operation(
|
|
1257
|
+
partial(
|
|
1258
|
+
_close_and_publish_fsspec_stream,
|
|
1259
|
+
self._strategy,
|
|
1260
|
+
self._fs,
|
|
1261
|
+
self._stage,
|
|
1262
|
+
file_obj,
|
|
1263
|
+
self._destination,
|
|
1264
|
+
overwrite=self._overwrite,
|
|
1265
|
+
),
|
|
1266
|
+
backend=self._backend_type,
|
|
1267
|
+
operation="write_stream_close",
|
|
1268
|
+
path=self._destination,
|
|
1269
|
+
)
|
|
1270
|
+
if self._log_fields is not None:
|
|
1271
|
+
log_storage_event(
|
|
1272
|
+
"storage.write", backend_type=self._backend_type, path=self._destination, **self._log_fields
|
|
1273
|
+
)
|
|
1274
|
+
else:
|
|
1275
|
+
_abort_fsspec_stream(self._strategy, self._fs, self._stage, file_obj)
|
|
1276
|
+
|
|
1277
|
+
|
|
1278
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
1279
|
+
class _AsyncFsspecWriteStream:
|
|
1280
|
+
"""Asynchronous fsspec write stream context manager with shielded completion."""
|
|
1281
|
+
|
|
1282
|
+
__slots__ = (
|
|
1283
|
+
"_backend_type",
|
|
1284
|
+
"_destination",
|
|
1285
|
+
"_file",
|
|
1286
|
+
"_fs",
|
|
1287
|
+
"_log_fields",
|
|
1288
|
+
"_mode",
|
|
1289
|
+
"_options",
|
|
1290
|
+
"_overwrite",
|
|
1291
|
+
"_sink",
|
|
1292
|
+
"_stage",
|
|
1293
|
+
"_strategy",
|
|
1294
|
+
)
|
|
1295
|
+
|
|
1296
|
+
def __init__(
|
|
1297
|
+
self,
|
|
1298
|
+
fs: Any,
|
|
1299
|
+
destination: str,
|
|
1300
|
+
*,
|
|
1301
|
+
strategy: "_FsspecStrategy",
|
|
1302
|
+
mode: str,
|
|
1303
|
+
options: "dict[str, Any]",
|
|
1304
|
+
overwrite: bool,
|
|
1305
|
+
backend_type: str,
|
|
1306
|
+
log_fields: "dict[str, Any] | None",
|
|
1307
|
+
) -> None:
|
|
1308
|
+
self._fs = fs
|
|
1309
|
+
self._destination = destination
|
|
1310
|
+
self._strategy: _FsspecStrategy = strategy
|
|
1311
|
+
self._mode = mode
|
|
1312
|
+
self._options = options
|
|
1313
|
+
self._overwrite = overwrite
|
|
1314
|
+
self._backend_type = backend_type
|
|
1315
|
+
self._log_fields = log_fields
|
|
1316
|
+
self._stage: str | None = None
|
|
1317
|
+
self._file: Any = None
|
|
1318
|
+
self._sink: _AsyncFsspecSink | None = None
|
|
1319
|
+
|
|
1320
|
+
async def __aenter__(self) -> "_AsyncFsspecSink":
|
|
1321
|
+
open_fut = asyncio.ensure_future(
|
|
1322
|
+
async_(
|
|
1323
|
+
lambda: _open_fsspec_stream_target(
|
|
1324
|
+
self._strategy, self._fs, self._destination, self._mode, self._options
|
|
1325
|
+
)
|
|
1326
|
+
)()
|
|
1327
|
+
)
|
|
1328
|
+
opened: tuple[str | None, Any] | None = None
|
|
1329
|
+
cancel_exc: asyncio.CancelledError | None = None
|
|
1330
|
+
try:
|
|
1331
|
+
opened = await execute_async_storage_operation(
|
|
1332
|
+
partial(join_shielded, open_fut),
|
|
1333
|
+
backend=self._backend_type,
|
|
1334
|
+
operation="open_write_stream",
|
|
1335
|
+
path=self._destination,
|
|
1336
|
+
)
|
|
1337
|
+
except asyncio.CancelledError as caught_cancel:
|
|
1338
|
+
cancel_exc = caught_cancel
|
|
1339
|
+
if cancel_exc is not None:
|
|
1340
|
+
if open_fut.done() and not open_fut.cancelled() and open_fut.exception() is None:
|
|
1341
|
+
opened_stage, opened_file = open_fut.result()
|
|
1342
|
+
await _abort_fsspec_stream_async(self._strategy, self._fs, opened_stage, opened_file)
|
|
1343
|
+
raise cancel_exc
|
|
1344
|
+
if opened is None:
|
|
1345
|
+
msg = "Unreachable"
|
|
1346
|
+
raise RuntimeError(msg)
|
|
1347
|
+
stage, file_obj = opened
|
|
1348
|
+
self._stage = stage
|
|
1349
|
+
self._file = file_obj
|
|
1350
|
+
sink = _AsyncFsspecSink(file_obj, backend=self._backend_type, path=self._destination)
|
|
1351
|
+
self._sink = sink
|
|
1352
|
+
return sink
|
|
1353
|
+
|
|
1354
|
+
async def __aexit__(self, exc_type: Any, exc: Any, traceback: Any) -> None:
|
|
1355
|
+
_ = (exc, traceback)
|
|
1356
|
+
sink = self._sink
|
|
1357
|
+
if sink is not None:
|
|
1358
|
+
sink._closed = True
|
|
1359
|
+
file_obj = self._file
|
|
1360
|
+
if file_obj is None:
|
|
1361
|
+
return
|
|
1362
|
+
if exc_type is None:
|
|
1363
|
+
publish_fut = asyncio.ensure_future(
|
|
1364
|
+
async_(
|
|
1365
|
+
partial(
|
|
1366
|
+
_close_and_publish_fsspec_stream,
|
|
1367
|
+
self._strategy,
|
|
1368
|
+
self._fs,
|
|
1369
|
+
self._stage,
|
|
1370
|
+
file_obj,
|
|
1371
|
+
self._destination,
|
|
1372
|
+
overwrite=self._overwrite,
|
|
1373
|
+
)
|
|
1374
|
+
)()
|
|
1375
|
+
)
|
|
1376
|
+
await execute_async_storage_operation(
|
|
1377
|
+
partial(join_shielded, publish_fut),
|
|
1378
|
+
backend=self._backend_type,
|
|
1379
|
+
operation="write_stream_close",
|
|
1380
|
+
path=self._destination,
|
|
1381
|
+
)
|
|
1382
|
+
if self._log_fields is not None:
|
|
1383
|
+
log_storage_event(
|
|
1384
|
+
"storage.write", backend_type=self._backend_type, path=self._destination, **self._log_fields
|
|
1385
|
+
)
|
|
1386
|
+
else:
|
|
1387
|
+
abort_fut = asyncio.ensure_future(
|
|
1388
|
+
async_(_abort_fsspec_stream)(self._strategy, self._fs, self._stage, file_obj)
|
|
1389
|
+
)
|
|
1390
|
+
await join_shielded(abort_fut, suppress_result=True)
|