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,1974 @@
|
|
|
1
|
+
"""Object storage backend using obstore.
|
|
2
|
+
|
|
3
|
+
Implements the ObjectStoreProtocol using obstore for S3, GCS, Azure,
|
|
4
|
+
and local file storage.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import asyncio
|
|
8
|
+
import contextlib
|
|
9
|
+
import inspect
|
|
10
|
+
import os
|
|
11
|
+
import shutil
|
|
12
|
+
from collections.abc import AsyncIterator, Awaitable, Callable, Iterator
|
|
13
|
+
from contextlib import AbstractAsyncContextManager, AbstractContextManager
|
|
14
|
+
from datetime import timedelta
|
|
15
|
+
from functools import partial
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
from typing import TYPE_CHECKING, Any, ClassVar, Final, Literal, Self, cast, overload
|
|
18
|
+
from urllib.parse import urlparse
|
|
19
|
+
|
|
20
|
+
from mypy_extensions import mypyc_attr
|
|
21
|
+
|
|
22
|
+
from sqlspec.exceptions import (
|
|
23
|
+
StorageCapabilityError,
|
|
24
|
+
StorageOperationFailedError,
|
|
25
|
+
StoragePathTraversalError,
|
|
26
|
+
with_cause,
|
|
27
|
+
)
|
|
28
|
+
from sqlspec.storage._arrow_payload import (
|
|
29
|
+
StorageFormat,
|
|
30
|
+
encode_arrow_payload,
|
|
31
|
+
encode_arrow_to_async_sink,
|
|
32
|
+
encode_arrow_to_sink,
|
|
33
|
+
join_shielded,
|
|
34
|
+
validate_arrow_write_options,
|
|
35
|
+
)
|
|
36
|
+
from sqlspec.storage._arrow_stream import iter_parquet_row_groups, validate_parquet_stream_options
|
|
37
|
+
from sqlspec.storage._paths import (
|
|
38
|
+
check_local_delete_target,
|
|
39
|
+
ensure_path_within_root,
|
|
40
|
+
extract_glob_static_prefix,
|
|
41
|
+
glob_to_regex,
|
|
42
|
+
is_file_destination,
|
|
43
|
+
parse_file_uri_path,
|
|
44
|
+
reject_parent_traversal,
|
|
45
|
+
resolve_storage_path,
|
|
46
|
+
)
|
|
47
|
+
from sqlspec.storage._utils import (
|
|
48
|
+
import_obstore,
|
|
49
|
+
import_obstore_store,
|
|
50
|
+
import_pyarrow,
|
|
51
|
+
import_pyarrow_parquet,
|
|
52
|
+
log_storage_event,
|
|
53
|
+
sanitize_uri_for_log,
|
|
54
|
+
)
|
|
55
|
+
from sqlspec.storage.backends.base import AsyncArrowBatchIterator, AsyncObStoreStreamIterator
|
|
56
|
+
|
|
57
|
+
if TYPE_CHECKING:
|
|
58
|
+
from obstore import Bytes
|
|
59
|
+
from obstore.store import ObjectStore
|
|
60
|
+
|
|
61
|
+
from sqlspec.protocols import AsyncWritableBytesSink, WritableBytesSink
|
|
62
|
+
from sqlspec.typing import ArrowRecordBatch, ArrowTable
|
|
63
|
+
|
|
64
|
+
from sqlspec.storage.errors import execute_async_storage_operation, execute_sync_storage_operation, raise_storage_error
|
|
65
|
+
from sqlspec.utils.module_loader import ensure_obstore
|
|
66
|
+
from sqlspec.utils.sync_tools import async_, exit_async_context
|
|
67
|
+
from sqlspec.utils.uuids import uuid4
|
|
68
|
+
|
|
69
|
+
_MAX_SIGN_EXPIRES_SECONDS: Final[int] = 604800
|
|
70
|
+
_SIGNABLE_PROTOCOLS: Final[frozenset[str]] = frozenset({"s3", "gs", "gcs", "az", "azure"})
|
|
71
|
+
_SUPPORTED_WRITE_KWARGS: Final[frozenset[str]] = frozenset({
|
|
72
|
+
"attributes",
|
|
73
|
+
"tags",
|
|
74
|
+
"mode",
|
|
75
|
+
"use_multipart",
|
|
76
|
+
"chunk_size",
|
|
77
|
+
"max_concurrency",
|
|
78
|
+
})
|
|
79
|
+
_DIRECT_ARROW_FORMATS: Final[frozenset[str]] = frozenset({"parquet", "arrow-ipc", "csv"})
|
|
80
|
+
_SUPPORTED_WRITER_KWARGS: Final[frozenset[str]] = frozenset({
|
|
81
|
+
"attributes",
|
|
82
|
+
"tags",
|
|
83
|
+
"mode",
|
|
84
|
+
"buffer_size",
|
|
85
|
+
"chunk_size",
|
|
86
|
+
"max_concurrency",
|
|
87
|
+
})
|
|
88
|
+
_OBSTORE_ARROW_STORE_KWARGS: Final[frozenset[str]] = frozenset({
|
|
89
|
+
"attributes",
|
|
90
|
+
"tags",
|
|
91
|
+
"mode",
|
|
92
|
+
"use_multipart",
|
|
93
|
+
"buffer_size",
|
|
94
|
+
"chunk_size",
|
|
95
|
+
"max_concurrency",
|
|
96
|
+
})
|
|
97
|
+
_STAGE_PREFIX: Final[str] = ".sqlspec-stage-"
|
|
98
|
+
_ATOMIC_COPY_CREATE_PROTOCOLS: Final[frozenset[str]] = frozenset({
|
|
99
|
+
"memory",
|
|
100
|
+
"file",
|
|
101
|
+
"gs",
|
|
102
|
+
"gcs",
|
|
103
|
+
"az",
|
|
104
|
+
"azure",
|
|
105
|
+
"abfs",
|
|
106
|
+
"abfss",
|
|
107
|
+
})
|
|
108
|
+
_S3_PROTOCOLS: Final[frozenset[str]] = frozenset({"s3", "s3a"})
|
|
109
|
+
|
|
110
|
+
__all__ = ("ObStoreBackend",)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@mypyc_attr(allow_interpreted_subclasses=True)
|
|
114
|
+
class ObStoreBackend:
|
|
115
|
+
"""Object storage backend using obstore.
|
|
116
|
+
|
|
117
|
+
Implements ObjectStoreProtocol using obstore's Rust-based implementation
|
|
118
|
+
for storage operations. Supports AWS S3, Google Cloud Storage, Azure Blob Storage,
|
|
119
|
+
local filesystem, and HTTP endpoints.
|
|
120
|
+
|
|
121
|
+
All synchronous methods use the *_sync suffix for consistency with async methods.
|
|
122
|
+
|
|
123
|
+
Implementation Details & Invariants:
|
|
124
|
+
- LocalStore Paths: For LocalStore, the base_path is already included in the store
|
|
125
|
+
root (combined with the URI path; if base_path is absolute, Path division will
|
|
126
|
+
use it directly). Hence, we use an empty prefix when resolving paths for LocalStore,
|
|
127
|
+
whereas cloud stores use base_path as a prefix.
|
|
128
|
+
- Native Streaming: Uses obstore's native streaming yielding Buffer objects, which
|
|
129
|
+
are converted to bytes.
|
|
130
|
+
- Seekable Streams: PyArrow's ParquetFile reads through obstore's seekable
|
|
131
|
+
``open_reader`` interface without draining the object into memory.
|
|
132
|
+
- Thread Offloading: Uses async_() with a storage limiter to offload blocking
|
|
133
|
+
PyArrow serialization/parsing to a thread pool, preventing event loop blocking.
|
|
134
|
+
"""
|
|
135
|
+
|
|
136
|
+
__slots__ = ("_is_local_store", "_local_store_root", "base_path", "protocol", "store", "store_options", "store_uri")
|
|
137
|
+
|
|
138
|
+
backend_type: ClassVar[str] = "obstore"
|
|
139
|
+
|
|
140
|
+
def __init__(self, uri: str, **kwargs: Any) -> None:
|
|
141
|
+
"""Initialize obstore backend.
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
uri: Storage URI. Supported formats:
|
|
145
|
+
- file:///absolute/path - Local filesystem
|
|
146
|
+
- s3://bucket/prefix - AWS S3
|
|
147
|
+
- gs://bucket/prefix - Google Cloud Storage
|
|
148
|
+
- az://container/prefix - Azure Blob Storage
|
|
149
|
+
- memory:// - In-memory storage (for testing)
|
|
150
|
+
**kwargs: Additional options:
|
|
151
|
+
- base_path (str): For local files (file://), this is combined with
|
|
152
|
+
the URI path to form the storage root. For example:
|
|
153
|
+
uri="file:///data" + base_path="uploads" → /data/uploads
|
|
154
|
+
If base_path is absolute, it overrides the URI path (backward compat).
|
|
155
|
+
For cloud storage, base_path is used as an object key prefix.
|
|
156
|
+
- Other obstore configuration options (timeouts, credentials, etc.)
|
|
157
|
+
"""
|
|
158
|
+
ensure_obstore()
|
|
159
|
+
obs_store = import_obstore_store()
|
|
160
|
+
base_path = kwargs.pop("base_path", "")
|
|
161
|
+
|
|
162
|
+
self.store_uri = uri
|
|
163
|
+
self.base_path = base_path.rstrip("/") if base_path else ""
|
|
164
|
+
self.store_options = kwargs
|
|
165
|
+
self.store: ObjectStore | Any
|
|
166
|
+
self._is_local_store = False
|
|
167
|
+
self._local_store_root = ""
|
|
168
|
+
self.protocol = uri.split("://", 1)[0] if "://" in uri else "file"
|
|
169
|
+
try:
|
|
170
|
+
if uri.startswith("memory://"):
|
|
171
|
+
self.store = obs_store.MemoryStore()
|
|
172
|
+
elif uri.startswith("file://"):
|
|
173
|
+
path_str = parse_file_uri_path(uri)
|
|
174
|
+
if path_str:
|
|
175
|
+
path_obj = Path(path_str)
|
|
176
|
+
if is_file_destination(path_obj):
|
|
177
|
+
path_str = str(path_obj.parent)
|
|
178
|
+
local_store_root_obj = Path(path_str)
|
|
179
|
+
else:
|
|
180
|
+
local_store_root_obj = Path.cwd().resolve()
|
|
181
|
+
if self.base_path:
|
|
182
|
+
local_store_root_obj /= self.base_path
|
|
183
|
+
|
|
184
|
+
self._is_local_store = True
|
|
185
|
+
self._local_store_root = str(local_store_root_obj.resolve())
|
|
186
|
+
self.store = obs_store.LocalStore(self._local_store_root, mkdir=True)
|
|
187
|
+
else:
|
|
188
|
+
self.store = obs_store.from_url(uri, **kwargs)
|
|
189
|
+
|
|
190
|
+
log_storage_event(
|
|
191
|
+
"storage.backend.ready",
|
|
192
|
+
backend_type=self.backend_type,
|
|
193
|
+
protocol=self.protocol,
|
|
194
|
+
operation="init",
|
|
195
|
+
mode="sync",
|
|
196
|
+
path=uri,
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
except StoragePathTraversalError:
|
|
200
|
+
raise
|
|
201
|
+
except Exception as exc:
|
|
202
|
+
msg = f"Failed to initialize obstore backend for {sanitize_uri_for_log(uri)}"
|
|
203
|
+
raise with_cause(StorageOperationFailedError(msg), exc) from exc
|
|
204
|
+
|
|
205
|
+
@property
|
|
206
|
+
def supports_signing(self) -> bool:
|
|
207
|
+
"""Whether this backend supports URL signing.
|
|
208
|
+
|
|
209
|
+
Only S3, GCS, and Azure backends support pre-signed URLs.
|
|
210
|
+
Local file storage does not support URL signing.
|
|
211
|
+
|
|
212
|
+
Returns:
|
|
213
|
+
True if the protocol supports signing, False otherwise.
|
|
214
|
+
"""
|
|
215
|
+
return self.protocol in _SIGNABLE_PROTOCOLS
|
|
216
|
+
|
|
217
|
+
@classmethod
|
|
218
|
+
def from_config(cls, config: "dict[str, Any]") -> "ObStoreBackend":
|
|
219
|
+
"""Create backend from configuration dictionary."""
|
|
220
|
+
store_uri = config["store_uri"]
|
|
221
|
+
base_path = config.get("base_path", "")
|
|
222
|
+
store_options = config.get("store_options", {})
|
|
223
|
+
|
|
224
|
+
kwargs = dict(store_options)
|
|
225
|
+
if base_path:
|
|
226
|
+
kwargs["base_path"] = base_path
|
|
227
|
+
|
|
228
|
+
return cls(uri=store_uri, **kwargs)
|
|
229
|
+
|
|
230
|
+
def resolve_uri(self, path: "str | Path") -> str:
|
|
231
|
+
"""Resolve a backend-relative path to an unsigned address.
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
path: The same backend-relative path accepted by read and write methods.
|
|
235
|
+
|
|
236
|
+
Returns:
|
|
237
|
+
An absolute filesystem path for local stores or a protocol-qualified
|
|
238
|
+
URI for remote stores. The target does not need to exist.
|
|
239
|
+
"""
|
|
240
|
+
resolved_path = self._resolve_path(path)
|
|
241
|
+
if getattr(self, "_is_local_store", False):
|
|
242
|
+
return str((Path(self._local_store_root) / resolved_path).resolve())
|
|
243
|
+
|
|
244
|
+
parsed = urlparse(self.store_uri)
|
|
245
|
+
joined_path = "/".join(part.strip("/") for part in (parsed.path, resolved_path) if part.strip("/"))
|
|
246
|
+
authority = f"{parsed.scheme}://{parsed.netloc}"
|
|
247
|
+
address = f"{authority}/{joined_path}" if parsed.netloc else f"{authority}{joined_path}"
|
|
248
|
+
if parsed.query:
|
|
249
|
+
address = f"{address}?{parsed.query}"
|
|
250
|
+
if parsed.fragment:
|
|
251
|
+
address = f"{address}#{parsed.fragment}"
|
|
252
|
+
return address
|
|
253
|
+
|
|
254
|
+
def read_bytes_sync(self, path: "str | Path", **kwargs: Any) -> bytes:
|
|
255
|
+
"""Read bytes using obstore synchronously."""
|
|
256
|
+
_ = kwargs
|
|
257
|
+
resolved_path = self._resolve_path(path)
|
|
258
|
+
return self._read_bytes_resolved_sync(resolved_path)
|
|
259
|
+
|
|
260
|
+
def write_bytes_sync(self, path: "str | Path", data: bytes, *, overwrite: bool = True, **kwargs: Any) -> None:
|
|
261
|
+
"""Write bytes using obstore synchronously."""
|
|
262
|
+
options = _resolve_obstore_put_options(overwrite, kwargs)
|
|
263
|
+
resolved_path = self._resolve_path(path)
|
|
264
|
+
self._write_bytes_resolved_sync(resolved_path, data, options)
|
|
265
|
+
|
|
266
|
+
def read_text_sync(self, path: "str | Path", encoding: str = "utf-8", **kwargs: Any) -> str:
|
|
267
|
+
"""Read text using obstore synchronously."""
|
|
268
|
+
return self.read_bytes_sync(path, **kwargs).decode(encoding)
|
|
269
|
+
|
|
270
|
+
def write_text_sync(
|
|
271
|
+
self, path: "str | Path", data: str, encoding: str = "utf-8", *, overwrite: bool = True, **kwargs: Any
|
|
272
|
+
) -> None:
|
|
273
|
+
"""Write text using obstore synchronously."""
|
|
274
|
+
self.write_bytes_sync(path, data.encode(encoding), overwrite=overwrite, **kwargs)
|
|
275
|
+
|
|
276
|
+
def list_objects_sync(self, prefix: str = "", recursive: bool = True, **kwargs: Any) -> "list[str]":
|
|
277
|
+
"""List objects using obstore synchronously."""
|
|
278
|
+
_ = kwargs
|
|
279
|
+
resolved_prefix = self._resolve_list_prefix(prefix)
|
|
280
|
+
paths = self._list_resolved_sync(resolved_prefix, recursive)
|
|
281
|
+
log_storage_event(
|
|
282
|
+
"storage.list",
|
|
283
|
+
backend_type=self.backend_type,
|
|
284
|
+
protocol=self.protocol,
|
|
285
|
+
operation="list_objects",
|
|
286
|
+
mode="sync",
|
|
287
|
+
path=resolved_prefix,
|
|
288
|
+
count=len(paths),
|
|
289
|
+
)
|
|
290
|
+
return paths
|
|
291
|
+
|
|
292
|
+
def exists_sync(self, path: "str | Path", **kwargs: Any) -> bool:
|
|
293
|
+
"""Check if object exists using obstore synchronously."""
|
|
294
|
+
_ = kwargs
|
|
295
|
+
resolved_path = self._resolve_path(path)
|
|
296
|
+
try:
|
|
297
|
+
self.store.head(resolved_path) # pyright: ignore[reportUnknownMemberType]
|
|
298
|
+
except Exception:
|
|
299
|
+
log_storage_event(
|
|
300
|
+
"storage.read",
|
|
301
|
+
backend_type=self.backend_type,
|
|
302
|
+
protocol=self.protocol,
|
|
303
|
+
operation="exists",
|
|
304
|
+
mode="sync",
|
|
305
|
+
path=str(path),
|
|
306
|
+
exists=False,
|
|
307
|
+
)
|
|
308
|
+
return False
|
|
309
|
+
log_storage_event(
|
|
310
|
+
"storage.read",
|
|
311
|
+
backend_type=self.backend_type,
|
|
312
|
+
protocol=self.protocol,
|
|
313
|
+
operation="exists",
|
|
314
|
+
mode="sync",
|
|
315
|
+
path=resolved_path,
|
|
316
|
+
exists=True,
|
|
317
|
+
)
|
|
318
|
+
return True
|
|
319
|
+
|
|
320
|
+
def delete_sync(self, path: "str | Path", *, recursive: bool = False, **kwargs: Any) -> None:
|
|
321
|
+
"""Delete object using obstore synchronously.
|
|
322
|
+
|
|
323
|
+
Args:
|
|
324
|
+
path: Path relative to ``base_path``.
|
|
325
|
+
recursive: Allow deleting directories of a local ``file://`` store.
|
|
326
|
+
**kwargs: Unused backend options.
|
|
327
|
+
|
|
328
|
+
Raises:
|
|
329
|
+
StorageOperationFailedError: On a local ``file://`` store, if ``path`` is the store root or a
|
|
330
|
+
directory and ``recursive`` is False.
|
|
331
|
+
"""
|
|
332
|
+
_ = kwargs
|
|
333
|
+
resolved_path = self._resolve_path(path)
|
|
334
|
+
directory = self._local_delete_directory(resolved_path, recursive=recursive)
|
|
335
|
+
execute_sync_storage_operation(
|
|
336
|
+
partial(shutil.rmtree, directory) if directory is not None else partial(self.store.delete, resolved_path),
|
|
337
|
+
backend=self.backend_type,
|
|
338
|
+
operation="delete",
|
|
339
|
+
path=resolved_path,
|
|
340
|
+
)
|
|
341
|
+
log_storage_event(
|
|
342
|
+
"storage.write",
|
|
343
|
+
backend_type=self.backend_type,
|
|
344
|
+
protocol=self.protocol,
|
|
345
|
+
operation="delete",
|
|
346
|
+
mode="sync",
|
|
347
|
+
path=resolved_path,
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
def _local_delete_directory(self, resolved_path: str, *, recursive: bool) -> "Path | None":
|
|
351
|
+
"""Validate a delete on a local ``file://`` store and return the directory to remove, if any."""
|
|
352
|
+
if not self._is_local_store:
|
|
353
|
+
return None
|
|
354
|
+
target = Path(self._local_store_root) / resolved_path
|
|
355
|
+
check_local_delete_target(target, self._local_store_root, recursive=recursive)
|
|
356
|
+
return target if target.is_dir() else None
|
|
357
|
+
|
|
358
|
+
def copy_sync(self, source: "str | Path", destination: "str | Path", **kwargs: Any) -> None:
|
|
359
|
+
"""Copy object using obstore synchronously."""
|
|
360
|
+
_ = kwargs
|
|
361
|
+
source_path = self._resolve_path(source)
|
|
362
|
+
dest_path = self._resolve_path(destination)
|
|
363
|
+
execute_sync_storage_operation(
|
|
364
|
+
partial(self.store.copy, source_path, dest_path),
|
|
365
|
+
backend=self.backend_type,
|
|
366
|
+
operation="copy",
|
|
367
|
+
path=f"{source_path}->{dest_path}",
|
|
368
|
+
)
|
|
369
|
+
log_storage_event(
|
|
370
|
+
"storage.write",
|
|
371
|
+
backend_type=self.backend_type,
|
|
372
|
+
protocol=self.protocol,
|
|
373
|
+
operation="copy",
|
|
374
|
+
mode="sync",
|
|
375
|
+
source_path=source_path,
|
|
376
|
+
destination_path=dest_path,
|
|
377
|
+
)
|
|
378
|
+
|
|
379
|
+
def move_sync(self, source: "str | Path", destination: "str | Path", **kwargs: Any) -> None:
|
|
380
|
+
"""Move object using obstore synchronously."""
|
|
381
|
+
_ = kwargs
|
|
382
|
+
source_path = self._resolve_path(source)
|
|
383
|
+
dest_path = self._resolve_path(destination)
|
|
384
|
+
execute_sync_storage_operation(
|
|
385
|
+
partial(self.store.rename, source_path, dest_path),
|
|
386
|
+
backend=self.backend_type,
|
|
387
|
+
operation="move",
|
|
388
|
+
path=f"{source_path}->{dest_path}",
|
|
389
|
+
)
|
|
390
|
+
log_storage_event(
|
|
391
|
+
"storage.write",
|
|
392
|
+
backend_type=self.backend_type,
|
|
393
|
+
protocol=self.protocol,
|
|
394
|
+
operation="move",
|
|
395
|
+
mode="sync",
|
|
396
|
+
source_path=source_path,
|
|
397
|
+
destination_path=dest_path,
|
|
398
|
+
)
|
|
399
|
+
|
|
400
|
+
def glob_sync(self, pattern: str, **kwargs: Any) -> "list[str]":
|
|
401
|
+
"""Find objects matching pattern synchronously.
|
|
402
|
+
|
|
403
|
+
Lists objects under the pattern's static directory prefix and filters
|
|
404
|
+
them client-side. ``*`` and ``?`` match
|
|
405
|
+
within one path segment and ``**`` spans zero or more segments, matching
|
|
406
|
+
the local and fsspec backends.
|
|
407
|
+
"""
|
|
408
|
+
_ = kwargs
|
|
409
|
+
if not pattern:
|
|
410
|
+
return []
|
|
411
|
+
reject_parent_traversal(pattern)
|
|
412
|
+
if getattr(self, "_is_local_store", False):
|
|
413
|
+
pattern_path = Path(pattern)
|
|
414
|
+
if pattern_path.is_absolute() and self._local_store_root:
|
|
415
|
+
try:
|
|
416
|
+
resolved_pattern = pattern_path.relative_to(Path(self._local_store_root)).as_posix()
|
|
417
|
+
except ValueError as exc:
|
|
418
|
+
raise with_cause(StoragePathTraversalError(pattern, self._local_store_root), exc) from exc
|
|
419
|
+
else:
|
|
420
|
+
resolved_pattern = pattern
|
|
421
|
+
else:
|
|
422
|
+
resolved_pattern = resolve_storage_path(pattern, self.base_path, self.protocol, strip_file_scheme=True)
|
|
423
|
+
all_objects = self._list_resolved_sync(extract_glob_static_prefix(resolved_pattern), recursive=True)
|
|
424
|
+
matcher = glob_to_regex(resolved_pattern)
|
|
425
|
+
results = [obj for obj in all_objects if matcher.match(obj)]
|
|
426
|
+
log_storage_event(
|
|
427
|
+
"storage.list",
|
|
428
|
+
backend_type=self.backend_type,
|
|
429
|
+
protocol=self.protocol,
|
|
430
|
+
operation="glob",
|
|
431
|
+
mode="sync",
|
|
432
|
+
path=resolved_pattern,
|
|
433
|
+
count=len(results),
|
|
434
|
+
)
|
|
435
|
+
return results
|
|
436
|
+
|
|
437
|
+
def get_metadata_sync(self, path: "str | Path", **kwargs: Any) -> "dict[str, object]":
|
|
438
|
+
"""Get object metadata using obstore synchronously."""
|
|
439
|
+
_ = kwargs
|
|
440
|
+
resolved_path = self._resolve_path(path)
|
|
441
|
+
|
|
442
|
+
try:
|
|
443
|
+
metadata = self.store.head(resolved_path)
|
|
444
|
+
except Exception:
|
|
445
|
+
return {"path": resolved_path, "exists": False}
|
|
446
|
+
else:
|
|
447
|
+
result = {
|
|
448
|
+
"path": resolved_path,
|
|
449
|
+
"exists": True,
|
|
450
|
+
"size": metadata.get("size"),
|
|
451
|
+
"last_modified": metadata.get("last_modified"),
|
|
452
|
+
"e_tag": metadata.get("e_tag"),
|
|
453
|
+
"version": metadata.get("version"),
|
|
454
|
+
}
|
|
455
|
+
metadata_dict = cast("dict[str, Any]", metadata)
|
|
456
|
+
if custom_metadata := metadata_dict.get("metadata"):
|
|
457
|
+
result["custom_metadata"] = custom_metadata
|
|
458
|
+
return result
|
|
459
|
+
|
|
460
|
+
def is_object_sync(self, path: "str | Path") -> bool:
|
|
461
|
+
"""Check if path is an object using obstore synchronously."""
|
|
462
|
+
resolved_path = self._resolve_path(path)
|
|
463
|
+
return self.exists_sync(path) and not str(path).endswith("/") and not resolved_path.endswith("/")
|
|
464
|
+
|
|
465
|
+
def is_path_sync(self, path: "str | Path") -> bool:
|
|
466
|
+
"""Check if path is a prefix/directory using obstore synchronously."""
|
|
467
|
+
resolved_path = self._resolve_path(path)
|
|
468
|
+
|
|
469
|
+
if str(path).endswith("/") or resolved_path.endswith("/"):
|
|
470
|
+
return True
|
|
471
|
+
|
|
472
|
+
try:
|
|
473
|
+
objects = self.list_objects_sync(prefix=str(path), recursive=True)
|
|
474
|
+
return len(objects) > 0
|
|
475
|
+
except Exception:
|
|
476
|
+
return False
|
|
477
|
+
|
|
478
|
+
def read_arrow_sync(self, path: "str | Path", **kwargs: Any) -> "ArrowTable":
|
|
479
|
+
"""Read Arrow table using obstore synchronously."""
|
|
480
|
+
pq = import_pyarrow_parquet()
|
|
481
|
+
resolved_path = self._resolve_path(path)
|
|
482
|
+
if getattr(self, "_is_local_store", False):
|
|
483
|
+
target: Callable[[], ArrowTable] = partial(
|
|
484
|
+
pq.read_table, str(Path(self._local_store_root) / resolved_path), **kwargs
|
|
485
|
+
)
|
|
486
|
+
else:
|
|
487
|
+
target = partial(_read_obstore_arrow_table, self.store, resolved_path, import_pyarrow(), pq, kwargs)
|
|
488
|
+
result = execute_sync_storage_operation(
|
|
489
|
+
target, backend=self.backend_type, operation="read_arrow", path=resolved_path
|
|
490
|
+
)
|
|
491
|
+
log_storage_event(
|
|
492
|
+
"storage.read",
|
|
493
|
+
backend_type=self.backend_type,
|
|
494
|
+
protocol=self.protocol,
|
|
495
|
+
operation="read_arrow",
|
|
496
|
+
mode="sync",
|
|
497
|
+
path=resolved_path,
|
|
498
|
+
)
|
|
499
|
+
return result
|
|
500
|
+
|
|
501
|
+
def supports_direct_arrow_write(self, file_format: "StorageFormat", *, overwrite: bool = True) -> bool:
|
|
502
|
+
"""Return whether ObStoreBackend can stream the given Arrow format directly.
|
|
503
|
+
|
|
504
|
+
Args:
|
|
505
|
+
file_format: Target Arrow serialization format.
|
|
506
|
+
overwrite: Whether replacing an existing destination object is permitted.
|
|
507
|
+
|
|
508
|
+
Returns:
|
|
509
|
+
True when file_format is parquet, arrow-ipc, or csv and either overwrite is True
|
|
510
|
+
or the store supports atomic conditional copy for staged create-only streams.
|
|
511
|
+
"""
|
|
512
|
+
return file_format in _DIRECT_ARROW_FORMATS and (bool(overwrite) or self._supports_atomic_copy_create())
|
|
513
|
+
|
|
514
|
+
def open_write_stream_sync(
|
|
515
|
+
self, path: "str | Path", *, overwrite: bool = True, **kwargs: Any
|
|
516
|
+
) -> "AbstractContextManager[WritableBytesSink]":
|
|
517
|
+
"""Open a synchronous multipart byte sink that aborts on unhandled exceptions.
|
|
518
|
+
|
|
519
|
+
Args:
|
|
520
|
+
path: Destination object path relative to the store or base path.
|
|
521
|
+
overwrite: Whether an existing destination may be overwritten.
|
|
522
|
+
**kwargs: Optional writer settings (attributes, tags, buffer_size,
|
|
523
|
+
chunk_size, max_concurrency, mode).
|
|
524
|
+
|
|
525
|
+
Returns:
|
|
526
|
+
Context manager entering a writable byte sink backed by obstore.open_writer.
|
|
527
|
+
|
|
528
|
+
Raises:
|
|
529
|
+
StoragePathTraversalError: If path escapes the store root.
|
|
530
|
+
StorageCapabilityError: If overwrite=False is unsupported on the store or options.
|
|
531
|
+
TypeError: If unsupported keyword arguments are supplied.
|
|
532
|
+
ValueError: If writer options conflict or specify non-positive buffer sizes.
|
|
533
|
+
"""
|
|
534
|
+
resolved_path = self._resolve_path(path)
|
|
535
|
+
log_fields = {"protocol": self.protocol, "operation": "write_stream", "mode": "sync"}
|
|
536
|
+
if not overwrite or kwargs.get("mode") == "create":
|
|
537
|
+
writer_options = self._prepare_create_only_stream_options(overwrite, kwargs)
|
|
538
|
+
stage = _obstore_stage_key(resolved_path)
|
|
539
|
+
return _ObstoreStagedCreateStream(
|
|
540
|
+
self.store, stage, resolved_path, writer_options, backend_type=self.backend_type, log_fields=log_fields
|
|
541
|
+
)
|
|
542
|
+
writer_options = _resolve_obstore_writer_options(overwrite, kwargs)
|
|
543
|
+
return _ObstoreWriteStream(
|
|
544
|
+
self.store, resolved_path, writer_options, backend_type=self.backend_type, log_fields=log_fields
|
|
545
|
+
)
|
|
546
|
+
|
|
547
|
+
def open_write_stream_async(
|
|
548
|
+
self, path: "str | Path", *, overwrite: bool = True, **kwargs: Any
|
|
549
|
+
) -> "AbstractAsyncContextManager[AsyncWritableBytesSink]":
|
|
550
|
+
"""Open an asynchronous multipart byte sink with shielded abort on error or cancellation.
|
|
551
|
+
|
|
552
|
+
Args:
|
|
553
|
+
path: Destination object path relative to the store or base path.
|
|
554
|
+
overwrite: Whether an existing destination may be overwritten.
|
|
555
|
+
**kwargs: Optional writer settings (attributes, tags, buffer_size,
|
|
556
|
+
chunk_size, max_concurrency, mode).
|
|
557
|
+
|
|
558
|
+
Returns:
|
|
559
|
+
Async context manager entering a byte sink backed by obstore.open_writer_async.
|
|
560
|
+
|
|
561
|
+
Raises:
|
|
562
|
+
StoragePathTraversalError: If path escapes the store root.
|
|
563
|
+
StorageCapabilityError: If overwrite=False is unsupported on the store or options.
|
|
564
|
+
TypeError: If unsupported keyword arguments are supplied.
|
|
565
|
+
ValueError: If writer options conflict or specify non-positive buffer sizes.
|
|
566
|
+
"""
|
|
567
|
+
resolved_path = self._resolve_path(path)
|
|
568
|
+
log_fields = {"protocol": self.protocol, "operation": "write_stream", "mode": "async"}
|
|
569
|
+
if not overwrite or kwargs.get("mode") == "create":
|
|
570
|
+
writer_options = self._prepare_create_only_stream_options(overwrite, kwargs)
|
|
571
|
+
stage = _obstore_stage_key(resolved_path)
|
|
572
|
+
return _AsyncObstoreStagedCreateStream(
|
|
573
|
+
self.store, stage, resolved_path, writer_options, backend_type=self.backend_type, log_fields=log_fields
|
|
574
|
+
)
|
|
575
|
+
writer_options = _resolve_obstore_writer_options(overwrite, kwargs)
|
|
576
|
+
return _AsyncObstoreWriteStream(
|
|
577
|
+
self.store, resolved_path, writer_options, backend_type=self.backend_type, log_fields=log_fields
|
|
578
|
+
)
|
|
579
|
+
|
|
580
|
+
def write_arrow_sync(
|
|
581
|
+
self, path: "str | Path", table: "ArrowTable", *, overwrite: bool = True, **kwargs: Any
|
|
582
|
+
) -> None:
|
|
583
|
+
"""Write an Arrow table via direct streaming or atomic buffered put when overwrite is False.
|
|
584
|
+
|
|
585
|
+
Args:
|
|
586
|
+
path: Destination object path relative to the store or base path.
|
|
587
|
+
table: Arrow table to serialize and write.
|
|
588
|
+
overwrite: Whether to overwrite an existing object or enforce atomic create.
|
|
589
|
+
**kwargs: Format hint, compression, PyArrow writer options, and ObStore options.
|
|
590
|
+
"""
|
|
591
|
+
import_pyarrow()
|
|
592
|
+
resolved_path = self._resolve_path(path)
|
|
593
|
+
|
|
594
|
+
format_hint: StorageFormat = kwargs.pop("format_hint", "parquet")
|
|
595
|
+
if format_hint == "parquet":
|
|
596
|
+
import_pyarrow_parquet()
|
|
597
|
+
if format_hint not in _DIRECT_ARROW_FORMATS:
|
|
598
|
+
msg = f"Arrow storage writes support only Parquet, Arrow IPC, and CSV formats, got {format_hint!r}"
|
|
599
|
+
raise StorageCapabilityError(
|
|
600
|
+
msg, capability="arrow_write", remediation="Write row payloads with the row storage APIs instead."
|
|
601
|
+
)
|
|
602
|
+
|
|
603
|
+
write_options_arg = kwargs.pop("write_options", None)
|
|
604
|
+
merged_write_options: dict[str, Any] = dict(write_options_arg) if write_options_arg else {}
|
|
605
|
+
store_kwargs: dict[str, Any] = {}
|
|
606
|
+
has_compression_in_kwargs = "compression" in kwargs
|
|
607
|
+
compression_arg = kwargs.pop("compression", None)
|
|
608
|
+
|
|
609
|
+
for key, value in list(kwargs.items()):
|
|
610
|
+
if key in _OBSTORE_ARROW_STORE_KWARGS:
|
|
611
|
+
store_kwargs[key] = value
|
|
612
|
+
else:
|
|
613
|
+
merged_write_options[key] = value
|
|
614
|
+
|
|
615
|
+
if has_compression_in_kwargs:
|
|
616
|
+
compression = compression_arg
|
|
617
|
+
elif "compression" in merged_write_options:
|
|
618
|
+
compression = merged_write_options.get("compression")
|
|
619
|
+
elif format_hint == "parquet":
|
|
620
|
+
compression = "snappy"
|
|
621
|
+
else:
|
|
622
|
+
compression = None
|
|
623
|
+
|
|
624
|
+
validate_arrow_write_options(format_hint, merged_write_options)
|
|
625
|
+
|
|
626
|
+
is_create_only = (not overwrite) or (store_kwargs.get("mode") == "create")
|
|
627
|
+
if not is_create_only:
|
|
628
|
+
store_kwargs.pop("use_multipart", None)
|
|
629
|
+
writer_options = _resolve_obstore_writer_options(overwrite, store_kwargs)
|
|
630
|
+
|
|
631
|
+
def _do_stream_write() -> None:
|
|
632
|
+
with _ObstoreWriteStream(
|
|
633
|
+
self.store, resolved_path, writer_options, backend_type=self.backend_type, log_fields=None
|
|
634
|
+
) as sink:
|
|
635
|
+
encode_arrow_to_sink(
|
|
636
|
+
table,
|
|
637
|
+
sink,
|
|
638
|
+
format_hint=format_hint,
|
|
639
|
+
compression=compression,
|
|
640
|
+
write_options=merged_write_options,
|
|
641
|
+
)
|
|
642
|
+
|
|
643
|
+
execute_sync_storage_operation(
|
|
644
|
+
_do_stream_write, backend=self.backend_type, operation="write_arrow", path=resolved_path
|
|
645
|
+
)
|
|
646
|
+
elif self._can_stream_create_only(store_kwargs):
|
|
647
|
+
explicit_mode = store_kwargs.get("mode")
|
|
648
|
+
if not overwrite and explicit_mode is not None and explicit_mode != "create":
|
|
649
|
+
msg = f"Conflicting write options: overwrite=False requires mode='create', got mode={explicit_mode!r}"
|
|
650
|
+
raise ValueError(msg)
|
|
651
|
+
stage_store_kwargs = {k: v for k, v in store_kwargs.items() if k not in {"mode", "use_multipart"}}
|
|
652
|
+
writer_options = _resolve_obstore_writer_options(True, stage_store_kwargs)
|
|
653
|
+
stage = _obstore_stage_key(resolved_path)
|
|
654
|
+
|
|
655
|
+
def _do_staged_stream_write() -> None:
|
|
656
|
+
with _ObstoreStagedCreateStream(
|
|
657
|
+
self.store, stage, resolved_path, writer_options, backend_type=self.backend_type, log_fields=None
|
|
658
|
+
) as sink:
|
|
659
|
+
encode_arrow_to_sink(
|
|
660
|
+
table,
|
|
661
|
+
sink,
|
|
662
|
+
format_hint=format_hint,
|
|
663
|
+
compression=compression,
|
|
664
|
+
write_options=merged_write_options,
|
|
665
|
+
)
|
|
666
|
+
|
|
667
|
+
execute_sync_storage_operation(
|
|
668
|
+
_do_staged_stream_write, backend=self.backend_type, operation="write_arrow", path=resolved_path
|
|
669
|
+
)
|
|
670
|
+
else:
|
|
671
|
+
buffer_size = store_kwargs.pop("buffer_size", None)
|
|
672
|
+
chunk_size = store_kwargs.get("chunk_size")
|
|
673
|
+
if buffer_size is not None and chunk_size is not None and buffer_size != chunk_size:
|
|
674
|
+
msg = f"Conflicting buffer sizes: buffer_size={buffer_size} and chunk_size={chunk_size}"
|
|
675
|
+
raise ValueError(msg)
|
|
676
|
+
if buffer_size is not None and buffer_size <= 0:
|
|
677
|
+
msg = f"buffer_size must be positive, got {buffer_size}"
|
|
678
|
+
raise ValueError(msg)
|
|
679
|
+
if chunk_size is not None and chunk_size <= 0:
|
|
680
|
+
msg = f"chunk_size must be positive, got {chunk_size}"
|
|
681
|
+
raise ValueError(msg)
|
|
682
|
+
if buffer_size is not None and chunk_size is None:
|
|
683
|
+
store_kwargs["chunk_size"] = buffer_size
|
|
684
|
+
|
|
685
|
+
put_options = _resolve_obstore_put_options(overwrite, store_kwargs)
|
|
686
|
+
|
|
687
|
+
def _do_buffered_write() -> None:
|
|
688
|
+
payload = encode_arrow_payload(
|
|
689
|
+
table, format_hint, compression=compression, write_options=merged_write_options
|
|
690
|
+
)
|
|
691
|
+
self.store.put(resolved_path, payload, **put_options)
|
|
692
|
+
|
|
693
|
+
execute_sync_storage_operation(
|
|
694
|
+
_do_buffered_write, backend=self.backend_type, operation="write_arrow", path=resolved_path
|
|
695
|
+
)
|
|
696
|
+
|
|
697
|
+
log_storage_event(
|
|
698
|
+
"storage.write",
|
|
699
|
+
backend_type=self.backend_type,
|
|
700
|
+
protocol=self.protocol,
|
|
701
|
+
operation="write_arrow",
|
|
702
|
+
mode="sync",
|
|
703
|
+
path=resolved_path,
|
|
704
|
+
)
|
|
705
|
+
|
|
706
|
+
def stream_read_sync(self, path: "str | Path", chunk_size: "int | None" = None, **kwargs: Any) -> Iterator[bytes]:
|
|
707
|
+
"""Stream bytes using obstore's native streaming synchronously.
|
|
708
|
+
|
|
709
|
+
Uses obstore's sync streaming iterator which yields chunks without
|
|
710
|
+
loading the entire file into memory, for both local and remote backends.
|
|
711
|
+
|
|
712
|
+
Yields:
|
|
713
|
+
Chunks of bytes from the file, with size determined by chunk_size (default: 65536 bytes).
|
|
714
|
+
"""
|
|
715
|
+
_ = kwargs
|
|
716
|
+
resolved_path = self._resolve_path(path)
|
|
717
|
+
chunk_size = chunk_size or 65536
|
|
718
|
+
|
|
719
|
+
result = execute_sync_storage_operation(
|
|
720
|
+
partial(self.store.get, resolved_path),
|
|
721
|
+
backend=self.backend_type,
|
|
722
|
+
operation="stream_read",
|
|
723
|
+
path=resolved_path,
|
|
724
|
+
)
|
|
725
|
+
|
|
726
|
+
for chunk in result.stream(min_chunk_size=chunk_size):
|
|
727
|
+
yield bytes(chunk)
|
|
728
|
+
|
|
729
|
+
def stream_arrow_sync(
|
|
730
|
+
self, pattern: str, *, file_format: Literal["parquet"] = "parquet", batch_size: int = 65_536, **kwargs: Any
|
|
731
|
+
) -> "Iterator[ArrowRecordBatch]":
|
|
732
|
+
"""Stream Arrow record batches using obstore's native streaming synchronously.
|
|
733
|
+
|
|
734
|
+
For each matching file, PyArrow reads through obstore's seekable reader.
|
|
735
|
+
|
|
736
|
+
Yields:
|
|
737
|
+
Arrow record batches in file and row-group order.
|
|
738
|
+
"""
|
|
739
|
+
obs = import_obstore()
|
|
740
|
+
|
|
741
|
+
validate_parquet_stream_options(pattern, file_format, batch_size)
|
|
742
|
+
pq = import_pyarrow_parquet()
|
|
743
|
+
read_buffer_bytes = kwargs.pop("read_buffer_bytes", 16_777_216)
|
|
744
|
+
arrow_schema = kwargs.pop("arrow_schema", None)
|
|
745
|
+
for obj_path in self.glob_sync(pattern):
|
|
746
|
+
if getattr(self, "_is_local_store", False) and self._local_store_root:
|
|
747
|
+
ensure_path_within_root(Path(self._local_store_root) / obj_path, self._local_store_root)
|
|
748
|
+
reader = execute_sync_storage_operation(
|
|
749
|
+
partial(_open_obstore_reader, obs, self.store, obj_path, read_buffer_bytes),
|
|
750
|
+
backend=self.backend_type,
|
|
751
|
+
operation="stream_open",
|
|
752
|
+
path=obj_path,
|
|
753
|
+
)
|
|
754
|
+
with _ObStoreFileProxy(reader) as stream:
|
|
755
|
+
parquet_file = execute_sync_storage_operation(
|
|
756
|
+
partial(pq.ParquetFile, stream), backend=self.backend_type, operation="stream_arrow", path=obj_path
|
|
757
|
+
)
|
|
758
|
+
yield from iter_parquet_row_groups(
|
|
759
|
+
parquet_file, batch_size=batch_size, arrow_schema=arrow_schema, **kwargs
|
|
760
|
+
)
|
|
761
|
+
|
|
762
|
+
@overload
|
|
763
|
+
def sign_sync(self, paths: str, expires_in: int = 3600, for_upload: bool = False) -> str: ...
|
|
764
|
+
@overload
|
|
765
|
+
def sign_sync(self, paths: "list[str]", expires_in: int = 3600, for_upload: bool = False) -> "list[str]": ...
|
|
766
|
+
def sign_sync(
|
|
767
|
+
self, paths: "str | list[str]", expires_in: int = 3600, for_upload: bool = False
|
|
768
|
+
) -> "str | list[str]":
|
|
769
|
+
"""Generate signed URL(s) for the object(s).
|
|
770
|
+
|
|
771
|
+
Args:
|
|
772
|
+
paths: Single object path or list of paths to sign.
|
|
773
|
+
expires_in: URL expiration time in seconds (default: 3600, max: 604800 = 7 days).
|
|
774
|
+
for_upload: Whether the URL is for upload (PUT) vs download (GET).
|
|
775
|
+
|
|
776
|
+
Returns:
|
|
777
|
+
Single signed URL string if paths is a string, or list of signed URLs
|
|
778
|
+
if paths is a list. Preserves input type for convenience.
|
|
779
|
+
"""
|
|
780
|
+
obs = import_obstore()
|
|
781
|
+
|
|
782
|
+
method, expires_delta, resolved_paths, is_single = self._prepare_sign_request(paths, expires_in, for_upload)
|
|
783
|
+
|
|
784
|
+
try:
|
|
785
|
+
signed_urls: list[str] = obs.sign(self.store, method, resolved_paths, expires_delta)
|
|
786
|
+
return signed_urls[0] if is_single else signed_urls
|
|
787
|
+
except Exception as exc:
|
|
788
|
+
msg = f"Failed to generate signed URL(s) for {resolved_paths}"
|
|
789
|
+
raise with_cause(StorageOperationFailedError(msg), exc) from exc
|
|
790
|
+
|
|
791
|
+
async def read_bytes_async(self, path: "str | Path", **kwargs: Any) -> bytes:
|
|
792
|
+
"""Read bytes from storage asynchronously."""
|
|
793
|
+
_ = kwargs
|
|
794
|
+
resolved_path = self._resolve_path(path)
|
|
795
|
+
return await self._read_bytes_resolved_async(resolved_path)
|
|
796
|
+
|
|
797
|
+
async def write_bytes_async(
|
|
798
|
+
self, path: "str | Path", data: bytes, *, overwrite: bool = True, **kwargs: Any
|
|
799
|
+
) -> None:
|
|
800
|
+
"""Write bytes to storage asynchronously."""
|
|
801
|
+
options = _resolve_obstore_put_options(overwrite, kwargs)
|
|
802
|
+
resolved_path = self._resolve_path(path)
|
|
803
|
+
await self._write_bytes_resolved_async(resolved_path, data, options)
|
|
804
|
+
|
|
805
|
+
async def stream_read_async(
|
|
806
|
+
self, path: "str | Path", chunk_size: "int | None" = None, **kwargs: Any
|
|
807
|
+
) -> AsyncIterator[bytes]:
|
|
808
|
+
"""Stream bytes from storage asynchronously.
|
|
809
|
+
|
|
810
|
+
Uses obstore's native async streaming to yield chunks of bytes
|
|
811
|
+
without buffering the entire file into memory.
|
|
812
|
+
"""
|
|
813
|
+
_ = kwargs
|
|
814
|
+
resolved_path = self._resolve_path(path)
|
|
815
|
+
effective_chunk_size = chunk_size or 65536
|
|
816
|
+
|
|
817
|
+
result = await execute_async_storage_operation(
|
|
818
|
+
partial(self.store.get_async, resolved_path),
|
|
819
|
+
backend=self.backend_type,
|
|
820
|
+
operation="stream_read",
|
|
821
|
+
path=resolved_path,
|
|
822
|
+
)
|
|
823
|
+
try:
|
|
824
|
+
stream = result.stream(min_chunk_size=effective_chunk_size)
|
|
825
|
+
except TypeError:
|
|
826
|
+
stream = result.stream()
|
|
827
|
+
return AsyncObStoreStreamIterator(stream, effective_chunk_size)
|
|
828
|
+
|
|
829
|
+
async def list_objects_async(self, prefix: str = "", recursive: bool = True, **kwargs: Any) -> "list[str]":
|
|
830
|
+
"""List objects in storage asynchronously."""
|
|
831
|
+
_ = kwargs
|
|
832
|
+
resolved_prefix = self._resolve_list_prefix(prefix)
|
|
833
|
+
|
|
834
|
+
results = await execute_async_storage_operation(
|
|
835
|
+
partial(self._list_resolved_async, resolved_prefix, recursive),
|
|
836
|
+
backend=self.backend_type,
|
|
837
|
+
operation="list_objects",
|
|
838
|
+
path=resolved_prefix,
|
|
839
|
+
)
|
|
840
|
+
log_storage_event(
|
|
841
|
+
"storage.list",
|
|
842
|
+
backend_type=self.backend_type,
|
|
843
|
+
protocol=self.protocol,
|
|
844
|
+
operation="list_objects",
|
|
845
|
+
mode="async",
|
|
846
|
+
path=resolved_prefix,
|
|
847
|
+
count=len(results),
|
|
848
|
+
)
|
|
849
|
+
return results
|
|
850
|
+
|
|
851
|
+
async def read_text_async(self, path: "str | Path", encoding: str = "utf-8", **kwargs: Any) -> str:
|
|
852
|
+
"""Read text from storage asynchronously."""
|
|
853
|
+
data = await self.read_bytes_async(path, **kwargs)
|
|
854
|
+
return data.decode(encoding)
|
|
855
|
+
|
|
856
|
+
async def write_text_async(
|
|
857
|
+
self, path: "str | Path", data: str, encoding: str = "utf-8", *, overwrite: bool = True, **kwargs: Any
|
|
858
|
+
) -> None:
|
|
859
|
+
"""Write text to storage asynchronously."""
|
|
860
|
+
encoded_data = data.encode(encoding)
|
|
861
|
+
await self.write_bytes_async(path, encoded_data, overwrite=overwrite, **kwargs)
|
|
862
|
+
|
|
863
|
+
async def exists_async(self, path: "str | Path", **kwargs: Any) -> bool:
|
|
864
|
+
"""Check if object exists in storage asynchronously."""
|
|
865
|
+
_ = kwargs
|
|
866
|
+
resolved_path = self._resolve_path(path)
|
|
867
|
+
|
|
868
|
+
try:
|
|
869
|
+
await self.store.head_async(resolved_path)
|
|
870
|
+
except Exception:
|
|
871
|
+
log_storage_event(
|
|
872
|
+
"storage.read",
|
|
873
|
+
backend_type=self.backend_type,
|
|
874
|
+
protocol=self.protocol,
|
|
875
|
+
operation="exists",
|
|
876
|
+
mode="async",
|
|
877
|
+
path=str(path),
|
|
878
|
+
exists=False,
|
|
879
|
+
)
|
|
880
|
+
return False
|
|
881
|
+
log_storage_event(
|
|
882
|
+
"storage.read",
|
|
883
|
+
backend_type=self.backend_type,
|
|
884
|
+
protocol=self.protocol,
|
|
885
|
+
operation="exists",
|
|
886
|
+
mode="async",
|
|
887
|
+
path=resolved_path,
|
|
888
|
+
exists=True,
|
|
889
|
+
)
|
|
890
|
+
return True
|
|
891
|
+
|
|
892
|
+
async def delete_async(self, path: "str | Path", *, recursive: bool = False, **kwargs: Any) -> None:
|
|
893
|
+
"""Delete object from storage asynchronously."""
|
|
894
|
+
_ = kwargs
|
|
895
|
+
resolved_path = self._resolve_path(path)
|
|
896
|
+
directory = self._local_delete_directory(resolved_path, recursive=recursive)
|
|
897
|
+
operation = (
|
|
898
|
+
async_(partial(shutil.rmtree, directory))
|
|
899
|
+
if directory is not None
|
|
900
|
+
else partial(self.store.delete_async, resolved_path)
|
|
901
|
+
)
|
|
902
|
+
await execute_async_storage_operation(
|
|
903
|
+
operation, backend=self.backend_type, operation="delete", path=resolved_path
|
|
904
|
+
)
|
|
905
|
+
log_storage_event(
|
|
906
|
+
"storage.write",
|
|
907
|
+
backend_type=self.backend_type,
|
|
908
|
+
protocol=self.protocol,
|
|
909
|
+
operation="delete",
|
|
910
|
+
mode="async",
|
|
911
|
+
path=resolved_path,
|
|
912
|
+
)
|
|
913
|
+
|
|
914
|
+
async def copy_async(self, source: "str | Path", destination: "str | Path", **kwargs: Any) -> None:
|
|
915
|
+
"""Copy object in storage asynchronously."""
|
|
916
|
+
_ = kwargs
|
|
917
|
+
source_path = self._resolve_path(source)
|
|
918
|
+
dest_path = self._resolve_path(destination)
|
|
919
|
+
|
|
920
|
+
await execute_async_storage_operation(
|
|
921
|
+
partial(self.store.copy_async, source_path, dest_path),
|
|
922
|
+
backend=self.backend_type,
|
|
923
|
+
operation="copy",
|
|
924
|
+
path=f"{source_path}->{dest_path}",
|
|
925
|
+
)
|
|
926
|
+
log_storage_event(
|
|
927
|
+
"storage.write",
|
|
928
|
+
backend_type=self.backend_type,
|
|
929
|
+
protocol=self.protocol,
|
|
930
|
+
operation="copy",
|
|
931
|
+
mode="async",
|
|
932
|
+
source_path=source_path,
|
|
933
|
+
destination_path=dest_path,
|
|
934
|
+
)
|
|
935
|
+
|
|
936
|
+
async def move_async(self, source: "str | Path", destination: "str | Path", **kwargs: Any) -> None:
|
|
937
|
+
"""Move object in storage asynchronously."""
|
|
938
|
+
_ = kwargs
|
|
939
|
+
source_path = self._resolve_path(source)
|
|
940
|
+
dest_path = self._resolve_path(destination)
|
|
941
|
+
|
|
942
|
+
await execute_async_storage_operation(
|
|
943
|
+
partial(self.store.rename_async, source_path, dest_path),
|
|
944
|
+
backend=self.backend_type,
|
|
945
|
+
operation="move",
|
|
946
|
+
path=f"{source_path}->{dest_path}",
|
|
947
|
+
)
|
|
948
|
+
log_storage_event(
|
|
949
|
+
"storage.write",
|
|
950
|
+
backend_type=self.backend_type,
|
|
951
|
+
protocol=self.protocol,
|
|
952
|
+
operation="move",
|
|
953
|
+
mode="async",
|
|
954
|
+
source_path=source_path,
|
|
955
|
+
destination_path=dest_path,
|
|
956
|
+
)
|
|
957
|
+
|
|
958
|
+
async def get_metadata_async(self, path: "str | Path", **kwargs: Any) -> "dict[str, object]":
|
|
959
|
+
"""Get object metadata from storage asynchronously."""
|
|
960
|
+
_ = kwargs
|
|
961
|
+
resolved_path = self._resolve_path(path)
|
|
962
|
+
|
|
963
|
+
result: dict[str, object] = {}
|
|
964
|
+
try:
|
|
965
|
+
metadata = await self.store.head_async(resolved_path)
|
|
966
|
+
result.update({
|
|
967
|
+
"path": resolved_path,
|
|
968
|
+
"exists": True,
|
|
969
|
+
"size": metadata.get("size"),
|
|
970
|
+
"last_modified": metadata.get("last_modified"),
|
|
971
|
+
"e_tag": metadata.get("e_tag"),
|
|
972
|
+
"version": metadata.get("version"),
|
|
973
|
+
})
|
|
974
|
+
metadata_dict = cast("dict[str, Any]", metadata)
|
|
975
|
+
if custom_metadata := metadata_dict.get("metadata"):
|
|
976
|
+
result["custom_metadata"] = custom_metadata
|
|
977
|
+
|
|
978
|
+
except Exception:
|
|
979
|
+
return {"path": resolved_path, "exists": False}
|
|
980
|
+
else:
|
|
981
|
+
return result
|
|
982
|
+
|
|
983
|
+
async def read_arrow_async(self, path: "str | Path", **kwargs: Any) -> "ArrowTable":
|
|
984
|
+
"""Read Arrow table from storage asynchronously.
|
|
985
|
+
|
|
986
|
+
Uses async_() with storage limiter to offload blocking PyArrow I/O to thread pool.
|
|
987
|
+
"""
|
|
988
|
+
pq = import_pyarrow_parquet()
|
|
989
|
+
resolved_path = self._resolve_path(path)
|
|
990
|
+
if getattr(self, "_is_local_store", False):
|
|
991
|
+
source: Any = str(Path(self._local_store_root) / resolved_path)
|
|
992
|
+
else:
|
|
993
|
+
source = await execute_async_storage_operation(
|
|
994
|
+
partial(_read_obstore_arrow_source_async, self.store, resolved_path, import_pyarrow()),
|
|
995
|
+
backend=self.backend_type,
|
|
996
|
+
operation="read_arrow",
|
|
997
|
+
path=resolved_path,
|
|
998
|
+
)
|
|
999
|
+
|
|
1000
|
+
result = await execute_async_storage_operation(
|
|
1001
|
+
partial(async_(pq.read_table), source, **kwargs),
|
|
1002
|
+
backend=self.backend_type,
|
|
1003
|
+
operation="read_arrow",
|
|
1004
|
+
path=resolved_path,
|
|
1005
|
+
)
|
|
1006
|
+
|
|
1007
|
+
log_storage_event(
|
|
1008
|
+
"storage.read",
|
|
1009
|
+
backend_type=self.backend_type,
|
|
1010
|
+
protocol=self.protocol,
|
|
1011
|
+
operation="read_arrow",
|
|
1012
|
+
mode="async",
|
|
1013
|
+
path=resolved_path,
|
|
1014
|
+
)
|
|
1015
|
+
return cast("ArrowTable", result)
|
|
1016
|
+
|
|
1017
|
+
async def write_arrow_async(
|
|
1018
|
+
self, path: "str | Path", table: "ArrowTable", *, overwrite: bool = True, **kwargs: Any
|
|
1019
|
+
) -> None:
|
|
1020
|
+
"""Write an Arrow table asynchronously via direct streaming or atomic buffered put_async.
|
|
1021
|
+
|
|
1022
|
+
Args:
|
|
1023
|
+
path: Destination object path relative to the store or base path.
|
|
1024
|
+
table: Arrow table to serialize and write.
|
|
1025
|
+
overwrite: Whether to overwrite an existing object or enforce atomic create.
|
|
1026
|
+
**kwargs: Format hint, compression, PyArrow writer options, and ObStore options.
|
|
1027
|
+
"""
|
|
1028
|
+
import_pyarrow()
|
|
1029
|
+
resolved_path = self._resolve_path(path)
|
|
1030
|
+
|
|
1031
|
+
format_hint: StorageFormat = kwargs.pop("format_hint", "parquet")
|
|
1032
|
+
if format_hint == "parquet":
|
|
1033
|
+
import_pyarrow_parquet()
|
|
1034
|
+
if format_hint not in _DIRECT_ARROW_FORMATS:
|
|
1035
|
+
msg = f"Arrow storage writes support only Parquet, Arrow IPC, and CSV formats, got {format_hint!r}"
|
|
1036
|
+
raise StorageCapabilityError(
|
|
1037
|
+
msg, capability="arrow_write", remediation="Write row payloads with the row storage APIs instead."
|
|
1038
|
+
)
|
|
1039
|
+
|
|
1040
|
+
write_options_arg = kwargs.pop("write_options", None)
|
|
1041
|
+
merged_write_options: dict[str, Any] = dict(write_options_arg) if write_options_arg else {}
|
|
1042
|
+
store_kwargs: dict[str, Any] = {}
|
|
1043
|
+
has_compression_in_kwargs = "compression" in kwargs
|
|
1044
|
+
compression_arg = kwargs.pop("compression", None)
|
|
1045
|
+
|
|
1046
|
+
for key, value in list(kwargs.items()):
|
|
1047
|
+
if key in _OBSTORE_ARROW_STORE_KWARGS:
|
|
1048
|
+
store_kwargs[key] = value
|
|
1049
|
+
else:
|
|
1050
|
+
merged_write_options[key] = value
|
|
1051
|
+
|
|
1052
|
+
if has_compression_in_kwargs:
|
|
1053
|
+
compression = compression_arg
|
|
1054
|
+
elif "compression" in merged_write_options:
|
|
1055
|
+
compression = merged_write_options.get("compression")
|
|
1056
|
+
elif format_hint == "parquet":
|
|
1057
|
+
compression = "snappy"
|
|
1058
|
+
else:
|
|
1059
|
+
compression = None
|
|
1060
|
+
|
|
1061
|
+
validate_arrow_write_options(format_hint, merged_write_options)
|
|
1062
|
+
|
|
1063
|
+
is_create_only = (not overwrite) or (store_kwargs.get("mode") == "create")
|
|
1064
|
+
if not is_create_only:
|
|
1065
|
+
store_kwargs.pop("use_multipart", None)
|
|
1066
|
+
writer_options = _resolve_obstore_writer_options(overwrite, store_kwargs)
|
|
1067
|
+
|
|
1068
|
+
async def _do_stream_write_async() -> None:
|
|
1069
|
+
stream_context = _AsyncObstoreWriteStream(
|
|
1070
|
+
self.store, resolved_path, writer_options, backend_type=self.backend_type, log_fields=None
|
|
1071
|
+
)
|
|
1072
|
+
sink = await stream_context.__aenter__()
|
|
1073
|
+
stream_error: BaseException | None = None
|
|
1074
|
+
try:
|
|
1075
|
+
chunk_size = writer_options.get("buffer_size", 1048576)
|
|
1076
|
+
await encode_arrow_to_async_sink(
|
|
1077
|
+
table,
|
|
1078
|
+
sink,
|
|
1079
|
+
format_hint=format_hint,
|
|
1080
|
+
compression=compression,
|
|
1081
|
+
write_options=merged_write_options,
|
|
1082
|
+
chunk_size=chunk_size,
|
|
1083
|
+
)
|
|
1084
|
+
except BaseException as caught:
|
|
1085
|
+
stream_error = caught
|
|
1086
|
+
await exit_async_context(stream_context, stream_error)
|
|
1087
|
+
|
|
1088
|
+
await execute_async_storage_operation(
|
|
1089
|
+
_do_stream_write_async, backend=self.backend_type, operation="write_arrow", path=resolved_path
|
|
1090
|
+
)
|
|
1091
|
+
elif self._can_stream_create_only(store_kwargs):
|
|
1092
|
+
explicit_mode = store_kwargs.get("mode")
|
|
1093
|
+
if not overwrite and explicit_mode is not None and explicit_mode != "create":
|
|
1094
|
+
msg = f"Conflicting write options: overwrite=False requires mode='create', got mode={explicit_mode!r}"
|
|
1095
|
+
raise ValueError(msg)
|
|
1096
|
+
stage_store_kwargs = {k: v for k, v in store_kwargs.items() if k not in {"mode", "use_multipart"}}
|
|
1097
|
+
writer_options = _resolve_obstore_writer_options(True, stage_store_kwargs)
|
|
1098
|
+
stage = _obstore_stage_key(resolved_path)
|
|
1099
|
+
|
|
1100
|
+
async def _do_staged_stream_write_async() -> None:
|
|
1101
|
+
stream_context = _AsyncObstoreStagedCreateStream(
|
|
1102
|
+
self.store, stage, resolved_path, writer_options, backend_type=self.backend_type, log_fields=None
|
|
1103
|
+
)
|
|
1104
|
+
sink = await stream_context.__aenter__()
|
|
1105
|
+
stream_error: BaseException | None = None
|
|
1106
|
+
try:
|
|
1107
|
+
chunk_size = writer_options.get("buffer_size", 1048576)
|
|
1108
|
+
await encode_arrow_to_async_sink(
|
|
1109
|
+
table,
|
|
1110
|
+
sink,
|
|
1111
|
+
format_hint=format_hint,
|
|
1112
|
+
compression=compression,
|
|
1113
|
+
write_options=merged_write_options,
|
|
1114
|
+
chunk_size=chunk_size,
|
|
1115
|
+
)
|
|
1116
|
+
except BaseException as caught:
|
|
1117
|
+
stream_error = caught
|
|
1118
|
+
await exit_async_context(stream_context, stream_error)
|
|
1119
|
+
|
|
1120
|
+
await execute_async_storage_operation(
|
|
1121
|
+
_do_staged_stream_write_async, backend=self.backend_type, operation="write_arrow", path=resolved_path
|
|
1122
|
+
)
|
|
1123
|
+
else:
|
|
1124
|
+
buffer_size = store_kwargs.pop("buffer_size", None)
|
|
1125
|
+
chunk_size = store_kwargs.get("chunk_size")
|
|
1126
|
+
if buffer_size is not None and chunk_size is not None and buffer_size != chunk_size:
|
|
1127
|
+
msg = f"Conflicting buffer sizes: buffer_size={buffer_size} and chunk_size={chunk_size}"
|
|
1128
|
+
raise ValueError(msg)
|
|
1129
|
+
if buffer_size is not None and buffer_size <= 0:
|
|
1130
|
+
msg = f"buffer_size must be positive, got {buffer_size}"
|
|
1131
|
+
raise ValueError(msg)
|
|
1132
|
+
if chunk_size is not None and chunk_size <= 0:
|
|
1133
|
+
msg = f"chunk_size must be positive, got {chunk_size}"
|
|
1134
|
+
raise ValueError(msg)
|
|
1135
|
+
if buffer_size is not None and chunk_size is None:
|
|
1136
|
+
store_kwargs["chunk_size"] = buffer_size
|
|
1137
|
+
|
|
1138
|
+
put_options = _resolve_obstore_put_options(overwrite, store_kwargs)
|
|
1139
|
+
|
|
1140
|
+
async def _do_buffered_write_async() -> None:
|
|
1141
|
+
payload = await async_(encode_arrow_payload)(
|
|
1142
|
+
table, format_hint, compression=compression, write_options=merged_write_options
|
|
1143
|
+
)
|
|
1144
|
+
await self.store.put_async(resolved_path, payload, **put_options)
|
|
1145
|
+
|
|
1146
|
+
await execute_async_storage_operation(
|
|
1147
|
+
_do_buffered_write_async, backend=self.backend_type, operation="write_arrow", path=resolved_path
|
|
1148
|
+
)
|
|
1149
|
+
|
|
1150
|
+
log_storage_event(
|
|
1151
|
+
"storage.write",
|
|
1152
|
+
backend_type=self.backend_type,
|
|
1153
|
+
protocol=self.protocol,
|
|
1154
|
+
operation="write_arrow",
|
|
1155
|
+
mode="async",
|
|
1156
|
+
path=resolved_path,
|
|
1157
|
+
)
|
|
1158
|
+
|
|
1159
|
+
def stream_arrow_async(
|
|
1160
|
+
self, pattern: str, *, file_format: Literal["parquet"] = "parquet", batch_size: int = 65_536, **kwargs: Any
|
|
1161
|
+
) -> AsyncIterator["ArrowRecordBatch"]:
|
|
1162
|
+
"""Stream Arrow record batches from storage asynchronously.
|
|
1163
|
+
|
|
1164
|
+
Args:
|
|
1165
|
+
pattern: Glob pattern to match files.
|
|
1166
|
+
file_format: Storage format. Only Parquet supports bounded batch streaming.
|
|
1167
|
+
batch_size: Maximum number of rows in each yielded record batch.
|
|
1168
|
+
**kwargs: Additional arguments passed to stream_arrow_sync().
|
|
1169
|
+
|
|
1170
|
+
Returns:
|
|
1171
|
+
AsyncIterator yielding Arrow record batches.
|
|
1172
|
+
"""
|
|
1173
|
+
return AsyncArrowBatchIterator(
|
|
1174
|
+
self.stream_arrow_sync(pattern, file_format=file_format, batch_size=batch_size, **kwargs)
|
|
1175
|
+
)
|
|
1176
|
+
|
|
1177
|
+
@overload
|
|
1178
|
+
async def sign_async(self, paths: str, expires_in: int = 3600, for_upload: bool = False) -> str: ...
|
|
1179
|
+
@overload
|
|
1180
|
+
async def sign_async(self, paths: "list[str]", expires_in: int = 3600, for_upload: bool = False) -> "list[str]": ...
|
|
1181
|
+
async def sign_async(
|
|
1182
|
+
self, paths: "str | list[str]", expires_in: int = 3600, for_upload: bool = False
|
|
1183
|
+
) -> "str | list[str]":
|
|
1184
|
+
"""Generate signed URL(s) asynchronously.
|
|
1185
|
+
|
|
1186
|
+
Args:
|
|
1187
|
+
paths: Single object path or list of paths to sign.
|
|
1188
|
+
expires_in: URL expiration time in seconds (default: 3600, max: 604800 = 7 days).
|
|
1189
|
+
for_upload: Whether the URL is for upload (PUT) vs download (GET).
|
|
1190
|
+
|
|
1191
|
+
Returns:
|
|
1192
|
+
Single signed URL string if paths is a string, or list of signed URLs
|
|
1193
|
+
if paths is a list. Preserves input type for convenience.
|
|
1194
|
+
"""
|
|
1195
|
+
obs = import_obstore()
|
|
1196
|
+
|
|
1197
|
+
method, expires_delta, resolved_paths, is_single = self._prepare_sign_request(paths, expires_in, for_upload)
|
|
1198
|
+
|
|
1199
|
+
try:
|
|
1200
|
+
signed_urls: list[str] = await obs.sign_async(self.store, method, resolved_paths, expires_delta)
|
|
1201
|
+
return signed_urls[0] if is_single else signed_urls
|
|
1202
|
+
except Exception as exc:
|
|
1203
|
+
msg = f"Failed to generate signed URL(s) for {resolved_paths}"
|
|
1204
|
+
raise with_cause(StorageOperationFailedError(msg), exc) from exc
|
|
1205
|
+
|
|
1206
|
+
def _supports_atomic_copy_create(self) -> bool:
|
|
1207
|
+
"""Return whether the underlying store supports atomic conditional copy (overwrite=False)."""
|
|
1208
|
+
if self.protocol in _ATOMIC_COPY_CREATE_PROTOCOLS:
|
|
1209
|
+
return True
|
|
1210
|
+
if self.protocol in _S3_PROTOCOLS:
|
|
1211
|
+
store_config = getattr(self.store, "config", None)
|
|
1212
|
+
has_store_setting = (
|
|
1213
|
+
bool(store_config.get("copy_if_not_exists")) if isinstance(store_config, dict) else False
|
|
1214
|
+
)
|
|
1215
|
+
return has_store_setting or bool(os.environ.get("AWS_COPY_IF_NOT_EXISTS"))
|
|
1216
|
+
return False
|
|
1217
|
+
|
|
1218
|
+
def _can_stream_create_only(self, kwargs: "dict[str, Any]") -> bool:
|
|
1219
|
+
"""Return whether create-only streaming can preserve the requested options on this store."""
|
|
1220
|
+
if not self._supports_atomic_copy_create():
|
|
1221
|
+
return False
|
|
1222
|
+
return not (
|
|
1223
|
+
self.protocol in _S3_PROTOCOLS and (kwargs.get("attributes") is not None or kwargs.get("tags") is not None)
|
|
1224
|
+
)
|
|
1225
|
+
|
|
1226
|
+
def _prepare_create_only_stream_options(self, overwrite: bool, kwargs: "dict[str, Any]") -> "dict[str, Any]":
|
|
1227
|
+
"""Validate create-only stream options and resolve options for the staged inner writer."""
|
|
1228
|
+
if kwargs:
|
|
1229
|
+
unsupported = sorted(k for k in kwargs if k not in _SUPPORTED_WRITER_KWARGS)
|
|
1230
|
+
if unsupported:
|
|
1231
|
+
names = ", ".join(unsupported)
|
|
1232
|
+
msg = f"Unsupported write stream keyword argument(s) for ObStoreBackend: {names}"
|
|
1233
|
+
raise TypeError(msg)
|
|
1234
|
+
mode = kwargs.get("mode")
|
|
1235
|
+
if not overwrite and mode is not None and mode != "create":
|
|
1236
|
+
msg = f"Conflicting write options: overwrite=False requires mode='create', got mode={mode!r}"
|
|
1237
|
+
raise ValueError(msg)
|
|
1238
|
+
if not self._supports_atomic_copy_create():
|
|
1239
|
+
msg = "Direct write streams do not support overwrite=False for this store"
|
|
1240
|
+
raise StorageCapabilityError(msg, capability="overwrite_false_stream")
|
|
1241
|
+
if self.protocol in _S3_PROTOCOLS and (kwargs.get("attributes") is not None or kwargs.get("tags") is not None):
|
|
1242
|
+
msg = "Direct create-only write streams on S3 do not preserve attributes or tags"
|
|
1243
|
+
raise StorageCapabilityError(msg, capability="overwrite_false_stream")
|
|
1244
|
+
stage_kwargs = {k: v for k, v in kwargs.items() if k != "mode"}
|
|
1245
|
+
return _resolve_obstore_writer_options(True, stage_kwargs)
|
|
1246
|
+
|
|
1247
|
+
def _resolve_path(self, path: "str | Path") -> str:
|
|
1248
|
+
if getattr(self, "_is_local_store", False):
|
|
1249
|
+
return self._local_store_path(path)
|
|
1250
|
+
return resolve_storage_path(path, self.base_path, self.protocol, strip_file_scheme=True)
|
|
1251
|
+
|
|
1252
|
+
def _resolve_list_prefix(self, prefix: str) -> str:
|
|
1253
|
+
"""Resolve a caller-supplied listing prefix to a store-relative one.
|
|
1254
|
+
|
|
1255
|
+
A local store's root already contains ``base_path``, so resolving the
|
|
1256
|
+
prefix against ``base_path`` again would look for that segment twice and
|
|
1257
|
+
match nothing.
|
|
1258
|
+
|
|
1259
|
+
Args:
|
|
1260
|
+
prefix: Caller-supplied listing prefix, possibly empty.
|
|
1261
|
+
|
|
1262
|
+
Returns:
|
|
1263
|
+
The prefix as the store expects it, or ``""`` to list everything.
|
|
1264
|
+
"""
|
|
1265
|
+
is_local = getattr(self, "_is_local_store", False)
|
|
1266
|
+
if not prefix:
|
|
1267
|
+
return "" if is_local else (self.base_path or "")
|
|
1268
|
+
if is_local:
|
|
1269
|
+
return self._local_store_path(prefix)
|
|
1270
|
+
return resolve_storage_path(prefix, self.base_path, self.protocol, strip_file_scheme=True)
|
|
1271
|
+
|
|
1272
|
+
def _local_store_path(self, path: "str | Path") -> str:
|
|
1273
|
+
"""Resolve path for LocalStore, which expects relative paths from its root.
|
|
1274
|
+
|
|
1275
|
+
Args:
|
|
1276
|
+
path: Caller-supplied storage path.
|
|
1277
|
+
|
|
1278
|
+
Returns:
|
|
1279
|
+
The path relative to the store root.
|
|
1280
|
+
|
|
1281
|
+
Raises:
|
|
1282
|
+
StoragePathTraversalError: If the path resolves outside the store root.
|
|
1283
|
+
"""
|
|
1284
|
+
target: str | Path = path
|
|
1285
|
+
target_str = str(path)
|
|
1286
|
+
if target_str.startswith("file://"):
|
|
1287
|
+
target = parse_file_uri_path(target_str)
|
|
1288
|
+
root = getattr(self, "_local_store_root", "") or str(Path.cwd().resolve())
|
|
1289
|
+
return ensure_path_within_root(target, root)
|
|
1290
|
+
|
|
1291
|
+
def _read_bytes_resolved_sync(self, resolved_path: str) -> bytes:
|
|
1292
|
+
if getattr(self, "_is_local_store", False):
|
|
1293
|
+
target: Callable[[], bytes] = (Path(self._local_store_root) / resolved_path).read_bytes
|
|
1294
|
+
else:
|
|
1295
|
+
target = partial(_read_obstore_bytes, self.store, resolved_path)
|
|
1296
|
+
result = execute_sync_storage_operation(
|
|
1297
|
+
target, backend=self.backend_type, operation="read_bytes", path=resolved_path
|
|
1298
|
+
)
|
|
1299
|
+
log_storage_event(
|
|
1300
|
+
"storage.read",
|
|
1301
|
+
backend_type=self.backend_type,
|
|
1302
|
+
protocol=self.protocol,
|
|
1303
|
+
operation="read_bytes",
|
|
1304
|
+
mode="sync",
|
|
1305
|
+
path=resolved_path,
|
|
1306
|
+
)
|
|
1307
|
+
return result
|
|
1308
|
+
|
|
1309
|
+
def _write_bytes_resolved_sync(self, resolved_path: str, data: bytes, options: "dict[str, Any]") -> None:
|
|
1310
|
+
execute_sync_storage_operation(
|
|
1311
|
+
partial(self.store.put, resolved_path, data, **options),
|
|
1312
|
+
backend=self.backend_type,
|
|
1313
|
+
operation="write_bytes",
|
|
1314
|
+
path=resolved_path,
|
|
1315
|
+
)
|
|
1316
|
+
log_storage_event(
|
|
1317
|
+
"storage.write",
|
|
1318
|
+
backend_type=self.backend_type,
|
|
1319
|
+
protocol=self.protocol,
|
|
1320
|
+
operation="write_bytes",
|
|
1321
|
+
mode="sync",
|
|
1322
|
+
path=resolved_path,
|
|
1323
|
+
)
|
|
1324
|
+
|
|
1325
|
+
def _list_resolved_sync(self, resolved_prefix: str, recursive: bool) -> "list[str]":
|
|
1326
|
+
"""List object keys under a prefix that is already store-relative.
|
|
1327
|
+
|
|
1328
|
+
Args:
|
|
1329
|
+
resolved_prefix: Prefix as the store expects it; ``""`` lists everything.
|
|
1330
|
+
recursive: Whether to descend into nested prefixes.
|
|
1331
|
+
|
|
1332
|
+
Returns:
|
|
1333
|
+
Sorted object keys.
|
|
1334
|
+
"""
|
|
1335
|
+
if not recursive:
|
|
1336
|
+
result = execute_sync_storage_operation(
|
|
1337
|
+
partial(self.store.list_with_delimiter, resolved_prefix),
|
|
1338
|
+
backend=self.backend_type,
|
|
1339
|
+
operation="list_objects",
|
|
1340
|
+
path=resolved_prefix,
|
|
1341
|
+
)
|
|
1342
|
+
objects = [item["path"] for item in result["objects"]]
|
|
1343
|
+
else:
|
|
1344
|
+
batches = execute_sync_storage_operation(
|
|
1345
|
+
partial(self.store.list, resolved_prefix),
|
|
1346
|
+
backend=self.backend_type,
|
|
1347
|
+
operation="list_objects",
|
|
1348
|
+
path=resolved_prefix,
|
|
1349
|
+
)
|
|
1350
|
+
objects = [item["path"] for batch in batches for item in batch]
|
|
1351
|
+
if getattr(self, "_is_local_store", False) and self._local_store_root:
|
|
1352
|
+
objects = _filter_local_obstore_keys(objects, self._local_store_root)
|
|
1353
|
+
return sorted(objects)
|
|
1354
|
+
|
|
1355
|
+
async def _list_resolved_async(self, resolved_prefix: str, recursive: bool) -> "list[str]":
|
|
1356
|
+
if not recursive and hasattr(self.store, "list_with_delimiter_async"):
|
|
1357
|
+
result = await self.store.list_with_delimiter_async(resolved_prefix)
|
|
1358
|
+
objects = [item["path"] for item in result["objects"]]
|
|
1359
|
+
else:
|
|
1360
|
+
objects = []
|
|
1361
|
+
async for batch in self.store.list_async(resolved_prefix): # pyright: ignore[reportAttributeAccessIssue]
|
|
1362
|
+
objects.extend(item["path"] for item in batch)
|
|
1363
|
+
if not recursive:
|
|
1364
|
+
base_depth = resolved_prefix.rstrip("/").count("/") + (1 if resolved_prefix.strip("/") else 0)
|
|
1365
|
+
objects = [obj for obj in objects if obj.count("/") < base_depth]
|
|
1366
|
+
if getattr(self, "_is_local_store", False) and self._local_store_root:
|
|
1367
|
+
objects = _filter_local_obstore_keys(objects, self._local_store_root)
|
|
1368
|
+
return sorted(objects)
|
|
1369
|
+
|
|
1370
|
+
def _prepare_sign_request(
|
|
1371
|
+
self, paths: "str | list[str]", expires_in: int, for_upload: bool
|
|
1372
|
+
) -> "tuple[str, timedelta, list[str], bool]":
|
|
1373
|
+
if self.protocol not in _SIGNABLE_PROTOCOLS:
|
|
1374
|
+
msg = (
|
|
1375
|
+
f"URL signing is not supported for protocol '{self.protocol}'. "
|
|
1376
|
+
f"Only S3, GCS, and Azure backends support pre-signed URLs."
|
|
1377
|
+
)
|
|
1378
|
+
raise NotImplementedError(msg)
|
|
1379
|
+
|
|
1380
|
+
if expires_in > _MAX_SIGN_EXPIRES_SECONDS:
|
|
1381
|
+
msg = f"expires_in cannot exceed {_MAX_SIGN_EXPIRES_SECONDS} seconds (7 days), got {expires_in}"
|
|
1382
|
+
raise ValueError(msg)
|
|
1383
|
+
|
|
1384
|
+
method = "PUT" if for_upload else "GET"
|
|
1385
|
+
expires_delta = timedelta(seconds=expires_in)
|
|
1386
|
+
if isinstance(paths, str):
|
|
1387
|
+
path_list = [paths]
|
|
1388
|
+
is_single = True
|
|
1389
|
+
else:
|
|
1390
|
+
path_list = list(paths)
|
|
1391
|
+
is_single = False
|
|
1392
|
+
|
|
1393
|
+
resolved_paths = [self._resolve_path(path) for path in path_list]
|
|
1394
|
+
return method, expires_delta, resolved_paths, is_single
|
|
1395
|
+
|
|
1396
|
+
async def _read_bytes_resolved_async(self, resolved_path: str) -> bytes:
|
|
1397
|
+
if getattr(self, "_is_local_store", False):
|
|
1398
|
+
target: Callable[[], Awaitable[bytes]] = async_((Path(self._local_store_root) / resolved_path).read_bytes)
|
|
1399
|
+
else:
|
|
1400
|
+
target = partial(_read_obstore_bytes_async, self.store, resolved_path)
|
|
1401
|
+
data = await execute_async_storage_operation(
|
|
1402
|
+
target, backend=self.backend_type, operation="read_bytes", path=resolved_path
|
|
1403
|
+
)
|
|
1404
|
+
log_storage_event(
|
|
1405
|
+
"storage.read",
|
|
1406
|
+
backend_type=self.backend_type,
|
|
1407
|
+
protocol=self.protocol,
|
|
1408
|
+
operation="read_bytes",
|
|
1409
|
+
mode="async",
|
|
1410
|
+
path=resolved_path,
|
|
1411
|
+
)
|
|
1412
|
+
return data
|
|
1413
|
+
|
|
1414
|
+
async def _write_bytes_resolved_async(self, resolved_path: str, data: bytes, options: "dict[str, Any]") -> None:
|
|
1415
|
+
await execute_async_storage_operation(
|
|
1416
|
+
partial(self.store.put_async, resolved_path, data, **options),
|
|
1417
|
+
backend=self.backend_type,
|
|
1418
|
+
operation="write_bytes",
|
|
1419
|
+
path=resolved_path,
|
|
1420
|
+
)
|
|
1421
|
+
log_storage_event(
|
|
1422
|
+
"storage.write",
|
|
1423
|
+
backend_type=self.backend_type,
|
|
1424
|
+
protocol=self.protocol,
|
|
1425
|
+
operation="write_bytes",
|
|
1426
|
+
mode="async",
|
|
1427
|
+
path=resolved_path,
|
|
1428
|
+
)
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
def _resolve_obstore_put_options(overwrite: bool, kwargs: "dict[str, Any]") -> "dict[str, Any]":
|
|
1432
|
+
"""Validate and resolve obstore put options for byte writes.
|
|
1433
|
+
|
|
1434
|
+
Args:
|
|
1435
|
+
overwrite: Whether an existing object may be replaced.
|
|
1436
|
+
kwargs: Caller-supplied ``obstore.put`` options.
|
|
1437
|
+
|
|
1438
|
+
Returns:
|
|
1439
|
+
The options to pass to ``put``, with ``mode="create"`` when overwriting is disabled.
|
|
1440
|
+
|
|
1441
|
+
Raises:
|
|
1442
|
+
TypeError: If an option is not an ``obstore.put`` option.
|
|
1443
|
+
ValueError: If ``overwrite=False`` is combined with a mode other than ``"create"``.
|
|
1444
|
+
"""
|
|
1445
|
+
if kwargs:
|
|
1446
|
+
unsupported = [name for name in kwargs if name not in _SUPPORTED_WRITE_KWARGS]
|
|
1447
|
+
if unsupported:
|
|
1448
|
+
names = ", ".join(sorted(unsupported))
|
|
1449
|
+
msg = f"Unsupported write keyword argument(s) for ObStoreBackend: {names}"
|
|
1450
|
+
raise TypeError(msg)
|
|
1451
|
+
if overwrite:
|
|
1452
|
+
return kwargs
|
|
1453
|
+
explicit_mode = kwargs.get("mode")
|
|
1454
|
+
if explicit_mode is not None and explicit_mode != "create":
|
|
1455
|
+
msg = f"Conflicting write options: overwrite=False requires mode='create', got mode={explicit_mode!r}"
|
|
1456
|
+
raise ValueError(msg)
|
|
1457
|
+
return {**kwargs, "mode": "create"}
|
|
1458
|
+
|
|
1459
|
+
|
|
1460
|
+
async def _read_obstore_bytes_async(store: Any, resolved_path: str) -> bytes:
|
|
1461
|
+
"""Read bytes via obstore asynchronously."""
|
|
1462
|
+
result = await store.get_async(resolved_path)
|
|
1463
|
+
bytes_obj = await result.bytes_async()
|
|
1464
|
+
return cast("bytes", bytes_obj.to_bytes())
|
|
1465
|
+
|
|
1466
|
+
|
|
1467
|
+
def _read_obstore_arrow_table(
|
|
1468
|
+
store: Any, resolved_path: str, pa: Any, pq: Any, options: "dict[str, Any]"
|
|
1469
|
+
) -> "ArrowTable":
|
|
1470
|
+
"""Read an Arrow table via obstore using a zero-copy buffer reader."""
|
|
1471
|
+
result = store.get(resolved_path)
|
|
1472
|
+
return cast("ArrowTable", pq.read_table(pa.BufferReader(result.bytes()), **options))
|
|
1473
|
+
|
|
1474
|
+
|
|
1475
|
+
async def _read_obstore_arrow_source_async(store: Any, resolved_path: str, pa: Any) -> Any:
|
|
1476
|
+
"""Read an obstore object into a zero-copy Arrow buffer reader asynchronously."""
|
|
1477
|
+
result = await store.get_async(resolved_path)
|
|
1478
|
+
return pa.BufferReader(await result.bytes_async())
|
|
1479
|
+
|
|
1480
|
+
|
|
1481
|
+
def _open_obstore_reader(obs: Any, store: Any, obj_path: str, read_buffer_bytes: int | None) -> Any:
|
|
1482
|
+
if read_buffer_bytes is not None:
|
|
1483
|
+
try:
|
|
1484
|
+
return obs.open_reader(store, obj_path, buffer_size=int(read_buffer_bytes))
|
|
1485
|
+
except TypeError:
|
|
1486
|
+
pass
|
|
1487
|
+
return obs.open_reader(store, obj_path)
|
|
1488
|
+
|
|
1489
|
+
|
|
1490
|
+
def _read_obstore_bytes(store: Any, resolved_path: str) -> bytes:
|
|
1491
|
+
"""Read bytes via obstore."""
|
|
1492
|
+
result = store.get(resolved_path)
|
|
1493
|
+
return cast("bytes", result.bytes().to_bytes())
|
|
1494
|
+
|
|
1495
|
+
|
|
1496
|
+
class _ObStoreFileProxy:
|
|
1497
|
+
"""Complete obstore's seekable reader interface for PyArrow."""
|
|
1498
|
+
|
|
1499
|
+
__slots__ = ("_closed", "_reader")
|
|
1500
|
+
|
|
1501
|
+
def __init__(self, reader: Any) -> None:
|
|
1502
|
+
self._reader = reader
|
|
1503
|
+
self._closed = False
|
|
1504
|
+
|
|
1505
|
+
def __enter__(self) -> Self:
|
|
1506
|
+
return self
|
|
1507
|
+
|
|
1508
|
+
def __exit__(self, *_: Any) -> None:
|
|
1509
|
+
self.close()
|
|
1510
|
+
|
|
1511
|
+
@property
|
|
1512
|
+
def closed(self) -> bool:
|
|
1513
|
+
return self._closed
|
|
1514
|
+
|
|
1515
|
+
def readable(self) -> bool:
|
|
1516
|
+
return not self._closed
|
|
1517
|
+
|
|
1518
|
+
def seekable(self) -> bool:
|
|
1519
|
+
return not self._closed and bool(self._reader.seekable())
|
|
1520
|
+
|
|
1521
|
+
def writable(self) -> bool:
|
|
1522
|
+
return False
|
|
1523
|
+
|
|
1524
|
+
def read(self, size: int = -1) -> "Bytes":
|
|
1525
|
+
"""Read from the object without copying obstore's buffer.
|
|
1526
|
+
|
|
1527
|
+
Args:
|
|
1528
|
+
size: Maximum number of bytes to read, or a negative value to read to the end.
|
|
1529
|
+
|
|
1530
|
+
Returns:
|
|
1531
|
+
An ``obstore.Bytes`` buffer, which PyArrow reads through the buffer protocol.
|
|
1532
|
+
"""
|
|
1533
|
+
if size < 0:
|
|
1534
|
+
return cast("Bytes", self._reader.readall())
|
|
1535
|
+
return cast("Bytes", self._reader.read(size))
|
|
1536
|
+
|
|
1537
|
+
def readinto(self, buffer: Any) -> int:
|
|
1538
|
+
data = self.read(len(buffer))
|
|
1539
|
+
buffer[: len(data)] = data
|
|
1540
|
+
return len(data)
|
|
1541
|
+
|
|
1542
|
+
def seek(self, offset: int, whence: int = 0) -> int:
|
|
1543
|
+
return cast("int", self._reader.seek(offset, whence))
|
|
1544
|
+
|
|
1545
|
+
def tell(self) -> int:
|
|
1546
|
+
return cast("int", self._reader.tell())
|
|
1547
|
+
|
|
1548
|
+
def close(self) -> None:
|
|
1549
|
+
if not self._closed:
|
|
1550
|
+
self._closed = True
|
|
1551
|
+
self._reader.close()
|
|
1552
|
+
|
|
1553
|
+
|
|
1554
|
+
def _resolve_obstore_writer_options(overwrite: bool, kwargs: "dict[str, Any]") -> "dict[str, Any]":
|
|
1555
|
+
"""Validate and normalize keyword arguments for obstore.open_writer and open_writer_async.
|
|
1556
|
+
|
|
1557
|
+
Args:
|
|
1558
|
+
overwrite: Whether overwriting existing destinations is allowed.
|
|
1559
|
+
kwargs: Raw keyword arguments supplied to open_write_stream_*.
|
|
1560
|
+
|
|
1561
|
+
Returns:
|
|
1562
|
+
Validated options dictionary suitable for open_writer and open_writer_async.
|
|
1563
|
+
|
|
1564
|
+
Raises:
|
|
1565
|
+
TypeError: If unsupported keyword arguments are present.
|
|
1566
|
+
ValueError: If mode conflicts with overwrite=False or buffer sizes conflict or are non-positive.
|
|
1567
|
+
StorageCapabilityError: If overwrite is False or mode is 'create'.
|
|
1568
|
+
"""
|
|
1569
|
+
if kwargs:
|
|
1570
|
+
unsupported = sorted(k for k in kwargs if k not in _SUPPORTED_WRITER_KWARGS)
|
|
1571
|
+
if unsupported:
|
|
1572
|
+
names = ", ".join(unsupported)
|
|
1573
|
+
msg = f"Unsupported write stream keyword argument(s) for ObStoreBackend: {names}"
|
|
1574
|
+
raise TypeError(msg)
|
|
1575
|
+
|
|
1576
|
+
mode = kwargs.get("mode")
|
|
1577
|
+
if not overwrite:
|
|
1578
|
+
if mode is not None and mode != "create":
|
|
1579
|
+
msg = f"Conflicting write options: overwrite=False requires mode='create', got mode={mode!r}"
|
|
1580
|
+
raise ValueError(msg)
|
|
1581
|
+
msg = "Direct write streams do not support overwrite=False"
|
|
1582
|
+
raise StorageCapabilityError(msg, capability="overwrite_false_stream")
|
|
1583
|
+
|
|
1584
|
+
if mode == "create":
|
|
1585
|
+
msg = "Direct write streams do not support mode='create'"
|
|
1586
|
+
raise StorageCapabilityError(msg, capability="overwrite_false_stream")
|
|
1587
|
+
|
|
1588
|
+
buffer_size = kwargs.get("buffer_size")
|
|
1589
|
+
chunk_size = kwargs.get("chunk_size")
|
|
1590
|
+
if buffer_size is not None and chunk_size is not None and buffer_size != chunk_size:
|
|
1591
|
+
msg = f"Conflicting buffer sizes: buffer_size={buffer_size} and chunk_size={chunk_size}"
|
|
1592
|
+
raise ValueError(msg)
|
|
1593
|
+
if buffer_size is not None and buffer_size <= 0:
|
|
1594
|
+
msg = f"buffer_size must be positive, got {buffer_size}"
|
|
1595
|
+
raise ValueError(msg)
|
|
1596
|
+
if chunk_size is not None and chunk_size <= 0:
|
|
1597
|
+
msg = f"chunk_size must be positive, got {chunk_size}"
|
|
1598
|
+
raise ValueError(msg)
|
|
1599
|
+
|
|
1600
|
+
opts = dict(kwargs)
|
|
1601
|
+
opts.pop("mode", None)
|
|
1602
|
+
if chunk_size is not None and buffer_size is None:
|
|
1603
|
+
opts["buffer_size"] = chunk_size
|
|
1604
|
+
opts.pop("chunk_size", None)
|
|
1605
|
+
return opts
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
1609
|
+
class _ObstoreWriteStream:
|
|
1610
|
+
"""Commit or abort one obstore multipart writer around a caller's write block."""
|
|
1611
|
+
|
|
1612
|
+
__slots__ = ("_backend_type", "_entered", "_log_fields", "_resolved_path", "_sink", "_store", "_writer_options")
|
|
1613
|
+
|
|
1614
|
+
def __init__(
|
|
1615
|
+
self,
|
|
1616
|
+
store: Any,
|
|
1617
|
+
resolved_path: str,
|
|
1618
|
+
writer_options: "dict[str, Any]",
|
|
1619
|
+
*,
|
|
1620
|
+
backend_type: str,
|
|
1621
|
+
log_fields: "dict[str, Any] | None",
|
|
1622
|
+
) -> None:
|
|
1623
|
+
self._store = store
|
|
1624
|
+
self._resolved_path = resolved_path
|
|
1625
|
+
self._writer_options = writer_options
|
|
1626
|
+
self._backend_type = backend_type
|
|
1627
|
+
self._log_fields = log_fields
|
|
1628
|
+
self._entered: Any = None
|
|
1629
|
+
self._sink: _ObstoreSink | None = None
|
|
1630
|
+
|
|
1631
|
+
def __enter__(self) -> "_ObstoreSink":
|
|
1632
|
+
obs = import_obstore()
|
|
1633
|
+
raw_writer = execute_sync_storage_operation(
|
|
1634
|
+
partial(obs.open_writer, self._store, self._resolved_path, **self._writer_options),
|
|
1635
|
+
backend=self._backend_type,
|
|
1636
|
+
operation="open_write_stream",
|
|
1637
|
+
path=self._resolved_path,
|
|
1638
|
+
)
|
|
1639
|
+
entered_writer = execute_sync_storage_operation(
|
|
1640
|
+
raw_writer.__enter__, backend=self._backend_type, operation="open_write_stream", path=self._resolved_path
|
|
1641
|
+
)
|
|
1642
|
+
self._entered = entered_writer
|
|
1643
|
+
sink = _ObstoreSink(entered_writer, backend=self._backend_type, path=self._resolved_path)
|
|
1644
|
+
self._sink = sink
|
|
1645
|
+
return sink
|
|
1646
|
+
|
|
1647
|
+
def __exit__(self, exc_type: Any, exc: Any, traceback: Any) -> None:
|
|
1648
|
+
entered_writer = self._entered
|
|
1649
|
+
sink = self._sink
|
|
1650
|
+
if sink is not None:
|
|
1651
|
+
sink._closed = True
|
|
1652
|
+
if entered_writer is None:
|
|
1653
|
+
return
|
|
1654
|
+
if exc_type is None:
|
|
1655
|
+
execute_sync_storage_operation(
|
|
1656
|
+
partial(entered_writer.__exit__, None, None, None),
|
|
1657
|
+
backend=self._backend_type,
|
|
1658
|
+
operation="write_stream_close",
|
|
1659
|
+
path=self._resolved_path,
|
|
1660
|
+
)
|
|
1661
|
+
if self._log_fields is not None:
|
|
1662
|
+
log_storage_event(
|
|
1663
|
+
"storage.write", backend_type=self._backend_type, path=self._resolved_path, **self._log_fields
|
|
1664
|
+
)
|
|
1665
|
+
else:
|
|
1666
|
+
with contextlib.suppress(Exception):
|
|
1667
|
+
entered_writer.__exit__(exc_type, exc, traceback)
|
|
1668
|
+
|
|
1669
|
+
|
|
1670
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
1671
|
+
class _AsyncObstoreWriteStream:
|
|
1672
|
+
"""Commit or abort one obstore async writer with shielded completion."""
|
|
1673
|
+
|
|
1674
|
+
__slots__ = ("_backend_type", "_entered", "_log_fields", "_resolved_path", "_sink", "_store", "_writer_options")
|
|
1675
|
+
|
|
1676
|
+
def __init__(
|
|
1677
|
+
self,
|
|
1678
|
+
store: Any,
|
|
1679
|
+
resolved_path: str,
|
|
1680
|
+
writer_options: "dict[str, Any]",
|
|
1681
|
+
*,
|
|
1682
|
+
backend_type: str,
|
|
1683
|
+
log_fields: "dict[str, Any] | None",
|
|
1684
|
+
) -> None:
|
|
1685
|
+
self._store = store
|
|
1686
|
+
self._resolved_path = resolved_path
|
|
1687
|
+
self._writer_options = writer_options
|
|
1688
|
+
self._backend_type = backend_type
|
|
1689
|
+
self._log_fields = log_fields
|
|
1690
|
+
self._entered: Any = None
|
|
1691
|
+
self._sink: _AsyncObstoreSink | None = None
|
|
1692
|
+
|
|
1693
|
+
async def __aenter__(self) -> "_AsyncObstoreSink":
|
|
1694
|
+
obs = import_obstore()
|
|
1695
|
+
raw_writer = execute_sync_storage_operation(
|
|
1696
|
+
partial(obs.open_writer_async, self._store, self._resolved_path, **self._writer_options),
|
|
1697
|
+
backend=self._backend_type,
|
|
1698
|
+
operation="open_write_stream",
|
|
1699
|
+
path=self._resolved_path,
|
|
1700
|
+
)
|
|
1701
|
+
entered_writer = await execute_async_storage_operation(
|
|
1702
|
+
raw_writer.__aenter__, backend=self._backend_type, operation="open_write_stream", path=self._resolved_path
|
|
1703
|
+
)
|
|
1704
|
+
self._entered = entered_writer
|
|
1705
|
+
sink = _AsyncObstoreSink(entered_writer, backend=self._backend_type, path=self._resolved_path)
|
|
1706
|
+
self._sink = sink
|
|
1707
|
+
return sink
|
|
1708
|
+
|
|
1709
|
+
async def __aexit__(self, exc_type: Any, exc: Any, traceback: Any) -> None:
|
|
1710
|
+
entered_writer = self._entered
|
|
1711
|
+
sink = self._sink
|
|
1712
|
+
if sink is not None:
|
|
1713
|
+
sink._closed = True
|
|
1714
|
+
if entered_writer is None:
|
|
1715
|
+
return
|
|
1716
|
+
if exc_type is None:
|
|
1717
|
+
exit_fut = entered_writer.__aexit__(None, None, None)
|
|
1718
|
+
if inspect.isawaitable(exit_fut):
|
|
1719
|
+
await execute_async_storage_operation(
|
|
1720
|
+
partial(join_shielded, asyncio.ensure_future(exit_fut)),
|
|
1721
|
+
backend=self._backend_type,
|
|
1722
|
+
operation="write_stream_close",
|
|
1723
|
+
path=self._resolved_path,
|
|
1724
|
+
)
|
|
1725
|
+
if self._log_fields is not None:
|
|
1726
|
+
log_storage_event(
|
|
1727
|
+
"storage.write", backend_type=self._backend_type, path=self._resolved_path, **self._log_fields
|
|
1728
|
+
)
|
|
1729
|
+
else:
|
|
1730
|
+
try:
|
|
1731
|
+
exit_fut = entered_writer.__aexit__(exc_type, exc, traceback)
|
|
1732
|
+
if inspect.isawaitable(exit_fut):
|
|
1733
|
+
await join_shielded(asyncio.ensure_future(exit_fut), suppress_result=True)
|
|
1734
|
+
except Exception:
|
|
1735
|
+
return
|
|
1736
|
+
|
|
1737
|
+
|
|
1738
|
+
def _obstore_stage_key(destination: str) -> str:
|
|
1739
|
+
"""Construct a hidden stage key in the destination's parent prefix."""
|
|
1740
|
+
if "/" in destination:
|
|
1741
|
+
parent, _ = destination.rsplit("/", 1)
|
|
1742
|
+
return f"{parent}/{_STAGE_PREFIX}{uuid4().hex}" if parent else f"{_STAGE_PREFIX}{uuid4().hex}"
|
|
1743
|
+
return f"{_STAGE_PREFIX}{uuid4().hex}"
|
|
1744
|
+
|
|
1745
|
+
|
|
1746
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
1747
|
+
class _ObstoreStagedCreateStream:
|
|
1748
|
+
"""Stage a create-only obstore stream to a temporary key and publish via conditional copy."""
|
|
1749
|
+
|
|
1750
|
+
__slots__ = ("_backend_type", "_destination", "_inner", "_log_fields", "_stage", "_store")
|
|
1751
|
+
|
|
1752
|
+
def __init__(
|
|
1753
|
+
self,
|
|
1754
|
+
store: Any,
|
|
1755
|
+
stage: str,
|
|
1756
|
+
destination: str,
|
|
1757
|
+
writer_options: "dict[str, Any]",
|
|
1758
|
+
*,
|
|
1759
|
+
backend_type: str,
|
|
1760
|
+
log_fields: "dict[str, Any] | None",
|
|
1761
|
+
) -> None:
|
|
1762
|
+
self._store = store
|
|
1763
|
+
self._stage = stage
|
|
1764
|
+
self._destination = destination
|
|
1765
|
+
self._backend_type = backend_type
|
|
1766
|
+
self._log_fields = log_fields
|
|
1767
|
+
self._inner = _ObstoreWriteStream(store, stage, writer_options, backend_type=backend_type, log_fields=None)
|
|
1768
|
+
|
|
1769
|
+
def __enter__(self) -> "_ObstoreSink":
|
|
1770
|
+
return self._inner.__enter__()
|
|
1771
|
+
|
|
1772
|
+
def __exit__(self, exc_type: Any, exc: Any, traceback: Any) -> None:
|
|
1773
|
+
if exc_type is not None:
|
|
1774
|
+
self._inner.__exit__(exc_type, exc, traceback)
|
|
1775
|
+
return
|
|
1776
|
+
self._inner.__exit__(None, None, None)
|
|
1777
|
+
obs = import_obstore()
|
|
1778
|
+
try:
|
|
1779
|
+
execute_sync_storage_operation(
|
|
1780
|
+
partial(obs.copy, self._store, self._stage, self._destination, overwrite=False),
|
|
1781
|
+
backend=self._backend_type,
|
|
1782
|
+
operation="write_stream_close",
|
|
1783
|
+
path=self._destination,
|
|
1784
|
+
)
|
|
1785
|
+
finally:
|
|
1786
|
+
with contextlib.suppress(Exception):
|
|
1787
|
+
obs.delete(self._store, self._stage)
|
|
1788
|
+
if self._log_fields is not None:
|
|
1789
|
+
log_storage_event(
|
|
1790
|
+
"storage.write", backend_type=self._backend_type, path=self._destination, **self._log_fields
|
|
1791
|
+
)
|
|
1792
|
+
|
|
1793
|
+
|
|
1794
|
+
async def _delete_obstore_stage_async(store: Any, stage: str) -> None:
|
|
1795
|
+
"""Delete a temporary staged obstore object while suppressing cleanup errors."""
|
|
1796
|
+
obs = import_obstore()
|
|
1797
|
+
try:
|
|
1798
|
+
del_coro = obs.delete_async(store, stage)
|
|
1799
|
+
await join_shielded(asyncio.ensure_future(del_coro), suppress_result=True)
|
|
1800
|
+
except Exception:
|
|
1801
|
+
return
|
|
1802
|
+
|
|
1803
|
+
|
|
1804
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
1805
|
+
class _AsyncObstoreStagedCreateStream:
|
|
1806
|
+
"""Asynchronously stage a create-only obstore stream and publish via shielded conditional copy."""
|
|
1807
|
+
|
|
1808
|
+
__slots__ = ("_backend_type", "_destination", "_inner", "_log_fields", "_stage", "_store")
|
|
1809
|
+
|
|
1810
|
+
def __init__(
|
|
1811
|
+
self,
|
|
1812
|
+
store: Any,
|
|
1813
|
+
stage: str,
|
|
1814
|
+
destination: str,
|
|
1815
|
+
writer_options: "dict[str, Any]",
|
|
1816
|
+
*,
|
|
1817
|
+
backend_type: str,
|
|
1818
|
+
log_fields: "dict[str, Any] | None",
|
|
1819
|
+
) -> None:
|
|
1820
|
+
self._store = store
|
|
1821
|
+
self._stage = stage
|
|
1822
|
+
self._destination = destination
|
|
1823
|
+
self._backend_type = backend_type
|
|
1824
|
+
self._log_fields = log_fields
|
|
1825
|
+
self._inner = _AsyncObstoreWriteStream(store, stage, writer_options, backend_type=backend_type, log_fields=None)
|
|
1826
|
+
|
|
1827
|
+
async def __aenter__(self) -> "_AsyncObstoreSink":
|
|
1828
|
+
return await self._inner.__aenter__()
|
|
1829
|
+
|
|
1830
|
+
async def __aexit__(self, exc_type: Any, exc: Any, traceback: Any) -> None:
|
|
1831
|
+
if exc_type is not None:
|
|
1832
|
+
await self._inner.__aexit__(exc_type, exc, traceback)
|
|
1833
|
+
return
|
|
1834
|
+
obs = import_obstore()
|
|
1835
|
+
cancel_exc: asyncio.CancelledError | None = None
|
|
1836
|
+
try:
|
|
1837
|
+
await self._inner.__aexit__(None, None, None)
|
|
1838
|
+
except asyncio.CancelledError as caught_cancel:
|
|
1839
|
+
cancel_exc = caught_cancel
|
|
1840
|
+
if cancel_exc is not None:
|
|
1841
|
+
await _delete_obstore_stage_async(self._store, self._stage)
|
|
1842
|
+
raise cancel_exc
|
|
1843
|
+
pending_exc: BaseException | None = None
|
|
1844
|
+
try:
|
|
1845
|
+
copy_coro = obs.copy_async(self._store, self._stage, self._destination, overwrite=False)
|
|
1846
|
+
await execute_async_storage_operation(
|
|
1847
|
+
partial(join_shielded, asyncio.ensure_future(copy_coro)),
|
|
1848
|
+
backend=self._backend_type,
|
|
1849
|
+
operation="write_stream_close",
|
|
1850
|
+
path=self._destination,
|
|
1851
|
+
)
|
|
1852
|
+
except BaseException as publish_exc:
|
|
1853
|
+
pending_exc = publish_exc
|
|
1854
|
+
await _delete_obstore_stage_async(self._store, self._stage)
|
|
1855
|
+
if pending_exc is not None:
|
|
1856
|
+
raise pending_exc
|
|
1857
|
+
if self._log_fields is not None:
|
|
1858
|
+
log_storage_event(
|
|
1859
|
+
"storage.write", backend_type=self._backend_type, path=self._destination, **self._log_fields
|
|
1860
|
+
)
|
|
1861
|
+
|
|
1862
|
+
|
|
1863
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
1864
|
+
class _ObstoreSink:
|
|
1865
|
+
"""Adapt an obstore WritableFile to WritableBytesSink and pyarrow.PythonFile."""
|
|
1866
|
+
|
|
1867
|
+
__slots__ = ("_backend", "_closed", "_path", "_writer")
|
|
1868
|
+
|
|
1869
|
+
def __init__(self, writer: Any, *, backend: str = "obstore", path: str | None = None) -> None:
|
|
1870
|
+
self._writer = writer
|
|
1871
|
+
self._backend = backend
|
|
1872
|
+
self._path = path
|
|
1873
|
+
self._closed = False
|
|
1874
|
+
|
|
1875
|
+
@property
|
|
1876
|
+
def closed(self) -> bool:
|
|
1877
|
+
if self._closed:
|
|
1878
|
+
return True
|
|
1879
|
+
writer_closed = getattr(self._writer, "closed", None)
|
|
1880
|
+
if callable(writer_closed):
|
|
1881
|
+
return bool(writer_closed())
|
|
1882
|
+
if writer_closed is not None:
|
|
1883
|
+
return bool(writer_closed)
|
|
1884
|
+
return False
|
|
1885
|
+
|
|
1886
|
+
def write(self, data: Any, /) -> int:
|
|
1887
|
+
if self._closed:
|
|
1888
|
+
return 0
|
|
1889
|
+
payload = bytes(data) if isinstance(data, (bytearray, memoryview)) else data
|
|
1890
|
+
if not payload:
|
|
1891
|
+
return 0
|
|
1892
|
+
return int(
|
|
1893
|
+
execute_sync_storage_operation(
|
|
1894
|
+
partial(self._writer.write, payload),
|
|
1895
|
+
backend=self._backend,
|
|
1896
|
+
operation="write_stream_write",
|
|
1897
|
+
path=self._path,
|
|
1898
|
+
)
|
|
1899
|
+
)
|
|
1900
|
+
|
|
1901
|
+
def flush(self) -> None:
|
|
1902
|
+
if self._closed:
|
|
1903
|
+
return
|
|
1904
|
+
flush_fn = getattr(self._writer, "flush", None)
|
|
1905
|
+
if callable(flush_fn):
|
|
1906
|
+
execute_sync_storage_operation(
|
|
1907
|
+
flush_fn, backend=self._backend, operation="write_stream_flush", path=self._path
|
|
1908
|
+
)
|
|
1909
|
+
|
|
1910
|
+
def close(self) -> None:
|
|
1911
|
+
self._closed = True
|
|
1912
|
+
|
|
1913
|
+
|
|
1914
|
+
@mypyc_attr(allow_interpreted_subclasses=False)
|
|
1915
|
+
class _AsyncObstoreSink:
|
|
1916
|
+
"""Adapt an obstore AsyncWritableFile to AsyncWritableBytesSink with storage error translation."""
|
|
1917
|
+
|
|
1918
|
+
__slots__ = ("_backend", "_closed", "_path", "_writer")
|
|
1919
|
+
|
|
1920
|
+
def __init__(self, writer: Any, *, backend: str = "obstore", path: str | None = None) -> None:
|
|
1921
|
+
self._writer = writer
|
|
1922
|
+
self._backend = backend
|
|
1923
|
+
self._path = path
|
|
1924
|
+
self._closed = False
|
|
1925
|
+
|
|
1926
|
+
@property
|
|
1927
|
+
def closed(self) -> bool:
|
|
1928
|
+
return self._closed
|
|
1929
|
+
|
|
1930
|
+
async def write(self, data: Any, /) -> int:
|
|
1931
|
+
if self._closed:
|
|
1932
|
+
return 0
|
|
1933
|
+
payload = bytes(data) if isinstance(data, (bytearray, memoryview)) else data
|
|
1934
|
+
if not payload:
|
|
1935
|
+
return 0
|
|
1936
|
+
try:
|
|
1937
|
+
result = self._writer.write(payload)
|
|
1938
|
+
if inspect.isawaitable(result):
|
|
1939
|
+
result = await result
|
|
1940
|
+
return int(result)
|
|
1941
|
+
except Exception as error:
|
|
1942
|
+
raise_storage_error(error, backend=self._backend, operation="write_stream_write", path=self._path)
|
|
1943
|
+
|
|
1944
|
+
async def flush(self) -> None:
|
|
1945
|
+
if self._closed:
|
|
1946
|
+
return
|
|
1947
|
+
flush_fn = getattr(self._writer, "flush", None)
|
|
1948
|
+
if callable(flush_fn):
|
|
1949
|
+
try:
|
|
1950
|
+
result = flush_fn()
|
|
1951
|
+
if inspect.isawaitable(result):
|
|
1952
|
+
await result
|
|
1953
|
+
except Exception as error:
|
|
1954
|
+
raise_storage_error(error, backend=self._backend, operation="write_stream_flush", path=self._path)
|
|
1955
|
+
|
|
1956
|
+
async def close(self) -> None:
|
|
1957
|
+
self._closed = True
|
|
1958
|
+
|
|
1959
|
+
|
|
1960
|
+
def _filter_local_obstore_keys(objects: "list[str]", root: str) -> "list[str]":
|
|
1961
|
+
"""Filter listed local obstore keys so symlinks escaping ``root`` are omitted."""
|
|
1962
|
+
try:
|
|
1963
|
+
root_obj = Path(root).resolve()
|
|
1964
|
+
except OSError:
|
|
1965
|
+
return []
|
|
1966
|
+
confined: list[str] = []
|
|
1967
|
+
for item_path in objects:
|
|
1968
|
+
try:
|
|
1969
|
+
resolved = (root_obj / item_path).resolve()
|
|
1970
|
+
except OSError:
|
|
1971
|
+
continue
|
|
1972
|
+
if resolved == root_obj or root_obj in resolved.parents:
|
|
1973
|
+
confined.append(item_path)
|
|
1974
|
+
return confined
|