sqlspec 0.36.0__cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ac8f31065839703b4e70__mypyc.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/__init__.py +140 -0
- sqlspec/__main__.py +12 -0
- sqlspec/__metadata__.py +14 -0
- sqlspec/_serialization.py +315 -0
- sqlspec/_typing.py +700 -0
- sqlspec/adapters/__init__.py +0 -0
- sqlspec/adapters/adbc/__init__.py +5 -0
- sqlspec/adapters/adbc/_typing.py +82 -0
- sqlspec/adapters/adbc/adk/__init__.py +5 -0
- sqlspec/adapters/adbc/adk/store.py +1273 -0
- sqlspec/adapters/adbc/config.py +295 -0
- sqlspec/adapters/adbc/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/adbc/core.py +735 -0
- sqlspec/adapters/adbc/data_dictionary.py +334 -0
- sqlspec/adapters/adbc/driver.py +529 -0
- sqlspec/adapters/adbc/events/__init__.py +5 -0
- sqlspec/adapters/adbc/events/store.py +285 -0
- sqlspec/adapters/adbc/litestar/__init__.py +5 -0
- sqlspec/adapters/adbc/litestar/store.py +502 -0
- sqlspec/adapters/adbc/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/adbc/type_converter.py +140 -0
- sqlspec/adapters/aiosqlite/__init__.py +25 -0
- sqlspec/adapters/aiosqlite/_typing.py +82 -0
- sqlspec/adapters/aiosqlite/adk/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/adk/store.py +818 -0
- sqlspec/adapters/aiosqlite/config.py +334 -0
- sqlspec/adapters/aiosqlite/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/aiosqlite/core.py +315 -0
- sqlspec/adapters/aiosqlite/data_dictionary.py +208 -0
- sqlspec/adapters/aiosqlite/driver.py +313 -0
- sqlspec/adapters/aiosqlite/events/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/events/store.py +20 -0
- sqlspec/adapters/aiosqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/aiosqlite/litestar/store.py +279 -0
- sqlspec/adapters/aiosqlite/pool.py +533 -0
- sqlspec/adapters/asyncmy/__init__.py +21 -0
- sqlspec/adapters/asyncmy/_typing.py +87 -0
- sqlspec/adapters/asyncmy/adk/__init__.py +5 -0
- sqlspec/adapters/asyncmy/adk/store.py +703 -0
- sqlspec/adapters/asyncmy/config.py +302 -0
- sqlspec/adapters/asyncmy/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/asyncmy/core.py +360 -0
- sqlspec/adapters/asyncmy/data_dictionary.py +124 -0
- sqlspec/adapters/asyncmy/driver.py +383 -0
- sqlspec/adapters/asyncmy/events/__init__.py +5 -0
- sqlspec/adapters/asyncmy/events/store.py +104 -0
- sqlspec/adapters/asyncmy/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncmy/litestar/store.py +296 -0
- sqlspec/adapters/asyncpg/__init__.py +19 -0
- sqlspec/adapters/asyncpg/_typing.py +88 -0
- sqlspec/adapters/asyncpg/adk/__init__.py +5 -0
- sqlspec/adapters/asyncpg/adk/store.py +748 -0
- sqlspec/adapters/asyncpg/config.py +569 -0
- sqlspec/adapters/asyncpg/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/asyncpg/core.py +367 -0
- sqlspec/adapters/asyncpg/data_dictionary.py +162 -0
- sqlspec/adapters/asyncpg/driver.py +487 -0
- sqlspec/adapters/asyncpg/events/__init__.py +6 -0
- sqlspec/adapters/asyncpg/events/backend.py +286 -0
- sqlspec/adapters/asyncpg/events/store.py +40 -0
- sqlspec/adapters/asyncpg/litestar/__init__.py +5 -0
- sqlspec/adapters/asyncpg/litestar/store.py +251 -0
- sqlspec/adapters/bigquery/__init__.py +14 -0
- sqlspec/adapters/bigquery/_typing.py +86 -0
- sqlspec/adapters/bigquery/adk/__init__.py +5 -0
- sqlspec/adapters/bigquery/adk/store.py +827 -0
- sqlspec/adapters/bigquery/config.py +353 -0
- sqlspec/adapters/bigquery/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/bigquery/core.py +715 -0
- sqlspec/adapters/bigquery/data_dictionary.py +128 -0
- sqlspec/adapters/bigquery/driver.py +548 -0
- sqlspec/adapters/bigquery/events/__init__.py +5 -0
- sqlspec/adapters/bigquery/events/store.py +139 -0
- sqlspec/adapters/bigquery/litestar/__init__.py +5 -0
- sqlspec/adapters/bigquery/litestar/store.py +325 -0
- sqlspec/adapters/bigquery/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/bigquery/type_converter.py +107 -0
- sqlspec/adapters/cockroach_asyncpg/__init__.py +24 -0
- sqlspec/adapters/cockroach_asyncpg/_typing.py +72 -0
- sqlspec/adapters/cockroach_asyncpg/adk/__init__.py +3 -0
- sqlspec/adapters/cockroach_asyncpg/adk/store.py +410 -0
- sqlspec/adapters/cockroach_asyncpg/config.py +238 -0
- sqlspec/adapters/cockroach_asyncpg/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/cockroach_asyncpg/core.py +55 -0
- sqlspec/adapters/cockroach_asyncpg/data_dictionary.py +107 -0
- sqlspec/adapters/cockroach_asyncpg/driver.py +144 -0
- sqlspec/adapters/cockroach_asyncpg/events/__init__.py +3 -0
- sqlspec/adapters/cockroach_asyncpg/events/store.py +20 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/__init__.py +3 -0
- sqlspec/adapters/cockroach_asyncpg/litestar/store.py +142 -0
- sqlspec/adapters/cockroach_psycopg/__init__.py +38 -0
- sqlspec/adapters/cockroach_psycopg/_typing.py +129 -0
- sqlspec/adapters/cockroach_psycopg/adk/__init__.py +13 -0
- sqlspec/adapters/cockroach_psycopg/adk/store.py +868 -0
- sqlspec/adapters/cockroach_psycopg/config.py +484 -0
- sqlspec/adapters/cockroach_psycopg/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/cockroach_psycopg/core.py +63 -0
- sqlspec/adapters/cockroach_psycopg/data_dictionary.py +215 -0
- sqlspec/adapters/cockroach_psycopg/driver.py +284 -0
- sqlspec/adapters/cockroach_psycopg/events/__init__.py +6 -0
- sqlspec/adapters/cockroach_psycopg/events/store.py +34 -0
- sqlspec/adapters/cockroach_psycopg/litestar/__init__.py +3 -0
- sqlspec/adapters/cockroach_psycopg/litestar/store.py +325 -0
- sqlspec/adapters/duckdb/__init__.py +25 -0
- sqlspec/adapters/duckdb/_typing.py +81 -0
- sqlspec/adapters/duckdb/adk/__init__.py +14 -0
- sqlspec/adapters/duckdb/adk/store.py +850 -0
- sqlspec/adapters/duckdb/config.py +463 -0
- sqlspec/adapters/duckdb/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/duckdb/core.py +257 -0
- sqlspec/adapters/duckdb/data_dictionary.py +140 -0
- sqlspec/adapters/duckdb/driver.py +430 -0
- sqlspec/adapters/duckdb/events/__init__.py +5 -0
- sqlspec/adapters/duckdb/events/store.py +57 -0
- sqlspec/adapters/duckdb/litestar/__init__.py +5 -0
- sqlspec/adapters/duckdb/litestar/store.py +330 -0
- sqlspec/adapters/duckdb/pool.py +293 -0
- sqlspec/adapters/duckdb/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/duckdb/type_converter.py +118 -0
- sqlspec/adapters/mock/__init__.py +72 -0
- sqlspec/adapters/mock/_typing.py +147 -0
- sqlspec/adapters/mock/config.py +483 -0
- sqlspec/adapters/mock/core.py +319 -0
- sqlspec/adapters/mock/data_dictionary.py +366 -0
- sqlspec/adapters/mock/driver.py +721 -0
- sqlspec/adapters/mysqlconnector/__init__.py +36 -0
- sqlspec/adapters/mysqlconnector/_typing.py +141 -0
- sqlspec/adapters/mysqlconnector/adk/__init__.py +15 -0
- sqlspec/adapters/mysqlconnector/adk/store.py +1060 -0
- sqlspec/adapters/mysqlconnector/config.py +394 -0
- sqlspec/adapters/mysqlconnector/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/mysqlconnector/core.py +303 -0
- sqlspec/adapters/mysqlconnector/data_dictionary.py +235 -0
- sqlspec/adapters/mysqlconnector/driver.py +483 -0
- sqlspec/adapters/mysqlconnector/events/__init__.py +8 -0
- sqlspec/adapters/mysqlconnector/events/store.py +98 -0
- sqlspec/adapters/mysqlconnector/litestar/__init__.py +5 -0
- sqlspec/adapters/mysqlconnector/litestar/store.py +426 -0
- sqlspec/adapters/oracledb/__init__.py +60 -0
- sqlspec/adapters/oracledb/_numpy_handlers.py +141 -0
- sqlspec/adapters/oracledb/_typing.py +182 -0
- sqlspec/adapters/oracledb/_uuid_handlers.py +166 -0
- sqlspec/adapters/oracledb/adk/__init__.py +10 -0
- sqlspec/adapters/oracledb/adk/store.py +2369 -0
- sqlspec/adapters/oracledb/config.py +550 -0
- sqlspec/adapters/oracledb/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/oracledb/core.py +543 -0
- sqlspec/adapters/oracledb/data_dictionary.py +536 -0
- sqlspec/adapters/oracledb/driver.py +1229 -0
- sqlspec/adapters/oracledb/events/__init__.py +16 -0
- sqlspec/adapters/oracledb/events/backend.py +347 -0
- sqlspec/adapters/oracledb/events/store.py +420 -0
- sqlspec/adapters/oracledb/litestar/__init__.py +5 -0
- sqlspec/adapters/oracledb/litestar/store.py +781 -0
- sqlspec/adapters/oracledb/migrations.py +535 -0
- sqlspec/adapters/oracledb/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/oracledb/type_converter.py +211 -0
- sqlspec/adapters/psqlpy/__init__.py +17 -0
- sqlspec/adapters/psqlpy/_typing.py +79 -0
- sqlspec/adapters/psqlpy/adk/__init__.py +5 -0
- sqlspec/adapters/psqlpy/adk/store.py +766 -0
- sqlspec/adapters/psqlpy/config.py +304 -0
- sqlspec/adapters/psqlpy/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/psqlpy/core.py +480 -0
- sqlspec/adapters/psqlpy/data_dictionary.py +126 -0
- sqlspec/adapters/psqlpy/driver.py +438 -0
- sqlspec/adapters/psqlpy/events/__init__.py +6 -0
- sqlspec/adapters/psqlpy/events/backend.py +310 -0
- sqlspec/adapters/psqlpy/events/store.py +20 -0
- sqlspec/adapters/psqlpy/litestar/__init__.py +5 -0
- sqlspec/adapters/psqlpy/litestar/store.py +270 -0
- sqlspec/adapters/psqlpy/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/psqlpy/type_converter.py +113 -0
- sqlspec/adapters/psycopg/__init__.py +32 -0
- sqlspec/adapters/psycopg/_typing.py +164 -0
- sqlspec/adapters/psycopg/adk/__init__.py +10 -0
- sqlspec/adapters/psycopg/adk/store.py +1387 -0
- sqlspec/adapters/psycopg/config.py +576 -0
- sqlspec/adapters/psycopg/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/psycopg/core.py +450 -0
- sqlspec/adapters/psycopg/data_dictionary.py +289 -0
- sqlspec/adapters/psycopg/driver.py +975 -0
- sqlspec/adapters/psycopg/events/__init__.py +20 -0
- sqlspec/adapters/psycopg/events/backend.py +458 -0
- sqlspec/adapters/psycopg/events/store.py +42 -0
- sqlspec/adapters/psycopg/litestar/__init__.py +5 -0
- sqlspec/adapters/psycopg/litestar/store.py +552 -0
- sqlspec/adapters/psycopg/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/psycopg/type_converter.py +93 -0
- sqlspec/adapters/pymysql/__init__.py +21 -0
- sqlspec/adapters/pymysql/_typing.py +71 -0
- sqlspec/adapters/pymysql/adk/__init__.py +5 -0
- sqlspec/adapters/pymysql/adk/store.py +540 -0
- sqlspec/adapters/pymysql/config.py +195 -0
- sqlspec/adapters/pymysql/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/pymysql/core.py +299 -0
- sqlspec/adapters/pymysql/data_dictionary.py +122 -0
- sqlspec/adapters/pymysql/driver.py +259 -0
- sqlspec/adapters/pymysql/events/__init__.py +5 -0
- sqlspec/adapters/pymysql/events/store.py +50 -0
- sqlspec/adapters/pymysql/litestar/__init__.py +5 -0
- sqlspec/adapters/pymysql/litestar/store.py +232 -0
- sqlspec/adapters/pymysql/pool.py +137 -0
- sqlspec/adapters/spanner/__init__.py +40 -0
- sqlspec/adapters/spanner/_typing.py +86 -0
- sqlspec/adapters/spanner/adk/__init__.py +5 -0
- sqlspec/adapters/spanner/adk/store.py +732 -0
- sqlspec/adapters/spanner/config.py +352 -0
- sqlspec/adapters/spanner/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/spanner/core.py +188 -0
- sqlspec/adapters/spanner/data_dictionary.py +120 -0
- sqlspec/adapters/spanner/dialect/__init__.py +6 -0
- sqlspec/adapters/spanner/dialect/_spangres.py +57 -0
- sqlspec/adapters/spanner/dialect/_spanner.py +130 -0
- sqlspec/adapters/spanner/driver.py +373 -0
- sqlspec/adapters/spanner/events/__init__.py +5 -0
- sqlspec/adapters/spanner/events/store.py +187 -0
- sqlspec/adapters/spanner/litestar/__init__.py +5 -0
- sqlspec/adapters/spanner/litestar/store.py +291 -0
- sqlspec/adapters/spanner/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/spanner/type_converter.py +331 -0
- sqlspec/adapters/sqlite/__init__.py +19 -0
- sqlspec/adapters/sqlite/_typing.py +80 -0
- sqlspec/adapters/sqlite/adk/__init__.py +5 -0
- sqlspec/adapters/sqlite/adk/store.py +958 -0
- sqlspec/adapters/sqlite/config.py +280 -0
- sqlspec/adapters/sqlite/core.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/sqlite/core.py +312 -0
- sqlspec/adapters/sqlite/data_dictionary.py +202 -0
- sqlspec/adapters/sqlite/driver.py +359 -0
- sqlspec/adapters/sqlite/events/__init__.py +5 -0
- sqlspec/adapters/sqlite/events/store.py +20 -0
- sqlspec/adapters/sqlite/litestar/__init__.py +5 -0
- sqlspec/adapters/sqlite/litestar/store.py +316 -0
- sqlspec/adapters/sqlite/pool.py +198 -0
- sqlspec/adapters/sqlite/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/adapters/sqlite/type_converter.py +114 -0
- sqlspec/base.py +747 -0
- sqlspec/builder/__init__.py +179 -0
- sqlspec/builder/_base.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_base.py +1022 -0
- sqlspec/builder/_column.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_column.py +521 -0
- sqlspec/builder/_ddl.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_ddl.py +1642 -0
- sqlspec/builder/_delete.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_delete.py +95 -0
- sqlspec/builder/_dml.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_dml.py +365 -0
- sqlspec/builder/_explain.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_explain.py +579 -0
- sqlspec/builder/_expression_wrappers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_expression_wrappers.py +46 -0
- sqlspec/builder/_factory.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_factory.py +1697 -0
- sqlspec/builder/_insert.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_insert.py +328 -0
- sqlspec/builder/_join.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_join.py +499 -0
- sqlspec/builder/_merge.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_merge.py +821 -0
- sqlspec/builder/_parsing_utils.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_parsing_utils.py +297 -0
- sqlspec/builder/_select.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_select.py +1660 -0
- sqlspec/builder/_temporal.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_temporal.py +139 -0
- sqlspec/builder/_update.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/builder/_update.py +173 -0
- sqlspec/builder/_vector_expressions.py +267 -0
- sqlspec/cli.py +911 -0
- sqlspec/config.py +1755 -0
- sqlspec/core/__init__.py +374 -0
- sqlspec/core/_correlation.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/_correlation.py +176 -0
- sqlspec/core/cache.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/cache.py +1069 -0
- sqlspec/core/compiler.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/compiler.py +954 -0
- sqlspec/core/explain.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/explain.py +275 -0
- sqlspec/core/filters.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/filters.py +952 -0
- sqlspec/core/hashing.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/hashing.py +262 -0
- sqlspec/core/metrics.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/metrics.py +83 -0
- sqlspec/core/parameters/__init__.py +71 -0
- sqlspec/core/parameters/_alignment.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_alignment.py +270 -0
- sqlspec/core/parameters/_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_converter.py +543 -0
- sqlspec/core/parameters/_processor.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_processor.py +505 -0
- sqlspec/core/parameters/_registry.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_registry.py +206 -0
- sqlspec/core/parameters/_transformers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_transformers.py +292 -0
- sqlspec/core/parameters/_types.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_types.py +499 -0
- sqlspec/core/parameters/_validator.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/parameters/_validator.py +180 -0
- sqlspec/core/pipeline.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/pipeline.py +319 -0
- sqlspec/core/query_modifiers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/query_modifiers.py +437 -0
- sqlspec/core/result/__init__.py +23 -0
- sqlspec/core/result/_base.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/result/_base.py +1121 -0
- sqlspec/core/result/_io.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/result/_io.py +28 -0
- sqlspec/core/splitter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/splitter.py +966 -0
- sqlspec/core/stack.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/stack.py +163 -0
- sqlspec/core/statement.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/statement.py +1503 -0
- sqlspec/core/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/core/type_converter.py +339 -0
- sqlspec/data_dictionary/__init__.py +22 -0
- sqlspec/data_dictionary/_loader.py +123 -0
- sqlspec/data_dictionary/_registry.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/_registry.py +74 -0
- sqlspec/data_dictionary/_types.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/_types.py +121 -0
- sqlspec/data_dictionary/dialects/__init__.py +21 -0
- sqlspec/data_dictionary/dialects/bigquery.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/bigquery.py +49 -0
- sqlspec/data_dictionary/dialects/cockroachdb.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/cockroachdb.py +43 -0
- sqlspec/data_dictionary/dialects/duckdb.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/duckdb.py +47 -0
- sqlspec/data_dictionary/dialects/mysql.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/mysql.py +42 -0
- sqlspec/data_dictionary/dialects/oracle.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/oracle.py +34 -0
- sqlspec/data_dictionary/dialects/postgres.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/postgres.py +46 -0
- sqlspec/data_dictionary/dialects/spanner.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/spanner.py +37 -0
- sqlspec/data_dictionary/dialects/sqlite.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/data_dictionary/dialects/sqlite.py +42 -0
- sqlspec/data_dictionary/sql/.gitkeep +0 -0
- sqlspec/data_dictionary/sql/bigquery/columns.sql +23 -0
- sqlspec/data_dictionary/sql/bigquery/foreign_keys.sql +34 -0
- sqlspec/data_dictionary/sql/bigquery/indexes.sql +19 -0
- sqlspec/data_dictionary/sql/bigquery/tables.sql +33 -0
- sqlspec/data_dictionary/sql/bigquery/version.sql +3 -0
- sqlspec/data_dictionary/sql/cockroachdb/columns.sql +34 -0
- sqlspec/data_dictionary/sql/cockroachdb/foreign_keys.sql +40 -0
- sqlspec/data_dictionary/sql/cockroachdb/indexes.sql +32 -0
- sqlspec/data_dictionary/sql/cockroachdb/tables.sql +44 -0
- sqlspec/data_dictionary/sql/cockroachdb/version.sql +3 -0
- sqlspec/data_dictionary/sql/duckdb/columns.sql +23 -0
- sqlspec/data_dictionary/sql/duckdb/foreign_keys.sql +36 -0
- sqlspec/data_dictionary/sql/duckdb/indexes.sql +19 -0
- sqlspec/data_dictionary/sql/duckdb/tables.sql +38 -0
- sqlspec/data_dictionary/sql/duckdb/version.sql +3 -0
- sqlspec/data_dictionary/sql/mysql/columns.sql +23 -0
- sqlspec/data_dictionary/sql/mysql/foreign_keys.sql +28 -0
- sqlspec/data_dictionary/sql/mysql/indexes.sql +26 -0
- sqlspec/data_dictionary/sql/mysql/tables.sql +33 -0
- sqlspec/data_dictionary/sql/mysql/version.sql +3 -0
- sqlspec/data_dictionary/sql/oracle/columns.sql +23 -0
- sqlspec/data_dictionary/sql/oracle/foreign_keys.sql +48 -0
- sqlspec/data_dictionary/sql/oracle/indexes.sql +44 -0
- sqlspec/data_dictionary/sql/oracle/tables.sql +25 -0
- sqlspec/data_dictionary/sql/oracle/version.sql +20 -0
- sqlspec/data_dictionary/sql/postgres/columns.sql +34 -0
- sqlspec/data_dictionary/sql/postgres/foreign_keys.sql +40 -0
- sqlspec/data_dictionary/sql/postgres/indexes.sql +56 -0
- sqlspec/data_dictionary/sql/postgres/tables.sql +44 -0
- sqlspec/data_dictionary/sql/postgres/version.sql +3 -0
- sqlspec/data_dictionary/sql/spanner/columns.sql +23 -0
- sqlspec/data_dictionary/sql/spanner/foreign_keys.sql +70 -0
- sqlspec/data_dictionary/sql/spanner/indexes.sql +30 -0
- sqlspec/data_dictionary/sql/spanner/tables.sql +9 -0
- sqlspec/data_dictionary/sql/spanner/version.sql +3 -0
- sqlspec/data_dictionary/sql/sqlite/columns.sql +23 -0
- sqlspec/data_dictionary/sql/sqlite/foreign_keys.sql +22 -0
- sqlspec/data_dictionary/sql/sqlite/indexes.sql +7 -0
- sqlspec/data_dictionary/sql/sqlite/tables.sql +28 -0
- sqlspec/data_dictionary/sql/sqlite/version.sql +3 -0
- sqlspec/driver/__init__.py +32 -0
- sqlspec/driver/_async.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/driver/_async.py +1737 -0
- sqlspec/driver/_common.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/driver/_common.py +1478 -0
- sqlspec/driver/_sql_helpers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/driver/_sql_helpers.py +148 -0
- sqlspec/driver/_storage_helpers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/driver/_storage_helpers.py +144 -0
- sqlspec/driver/_sync.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/driver/_sync.py +1710 -0
- sqlspec/exceptions.py +338 -0
- sqlspec/extensions/__init__.py +0 -0
- sqlspec/extensions/adk/__init__.py +70 -0
- sqlspec/extensions/adk/_types.py +51 -0
- sqlspec/extensions/adk/converters.py +172 -0
- sqlspec/extensions/adk/memory/__init__.py +69 -0
- sqlspec/extensions/adk/memory/_types.py +30 -0
- sqlspec/extensions/adk/memory/converters.py +149 -0
- sqlspec/extensions/adk/memory/service.py +217 -0
- sqlspec/extensions/adk/memory/store.py +569 -0
- sqlspec/extensions/adk/migrations/0001_create_adk_tables.py +246 -0
- sqlspec/extensions/adk/migrations/__init__.py +0 -0
- sqlspec/extensions/adk/service.py +225 -0
- sqlspec/extensions/adk/store.py +567 -0
- sqlspec/extensions/events/__init__.py +51 -0
- sqlspec/extensions/events/_channel.py +703 -0
- sqlspec/extensions/events/_hints.py +45 -0
- sqlspec/extensions/events/_models.py +23 -0
- sqlspec/extensions/events/_payload.py +69 -0
- sqlspec/extensions/events/_protocols.py +134 -0
- sqlspec/extensions/events/_queue.py +461 -0
- sqlspec/extensions/events/_store.py +209 -0
- sqlspec/extensions/events/migrations/0001_create_event_queue.py +59 -0
- sqlspec/extensions/events/migrations/__init__.py +3 -0
- sqlspec/extensions/fastapi/__init__.py +19 -0
- sqlspec/extensions/fastapi/extension.py +351 -0
- sqlspec/extensions/fastapi/providers.py +607 -0
- sqlspec/extensions/flask/__init__.py +37 -0
- sqlspec/extensions/flask/_state.py +76 -0
- sqlspec/extensions/flask/_utils.py +71 -0
- sqlspec/extensions/flask/extension.py +519 -0
- sqlspec/extensions/litestar/__init__.py +28 -0
- sqlspec/extensions/litestar/_utils.py +52 -0
- sqlspec/extensions/litestar/channels.py +165 -0
- sqlspec/extensions/litestar/cli.py +102 -0
- sqlspec/extensions/litestar/config.py +90 -0
- sqlspec/extensions/litestar/handlers.py +316 -0
- sqlspec/extensions/litestar/migrations/0001_create_session_table.py +137 -0
- sqlspec/extensions/litestar/migrations/__init__.py +3 -0
- sqlspec/extensions/litestar/plugin.py +671 -0
- sqlspec/extensions/litestar/providers.py +526 -0
- sqlspec/extensions/litestar/store.py +296 -0
- sqlspec/extensions/otel/__init__.py +58 -0
- sqlspec/extensions/prometheus/__init__.py +113 -0
- sqlspec/extensions/starlette/__init__.py +19 -0
- sqlspec/extensions/starlette/_state.py +30 -0
- sqlspec/extensions/starlette/_utils.py +96 -0
- sqlspec/extensions/starlette/extension.py +346 -0
- sqlspec/extensions/starlette/middleware.py +235 -0
- sqlspec/loader.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/loader.py +702 -0
- sqlspec/migrations/__init__.py +36 -0
- sqlspec/migrations/base.py +731 -0
- sqlspec/migrations/commands.py +1232 -0
- sqlspec/migrations/context.py +157 -0
- sqlspec/migrations/fix.py +204 -0
- sqlspec/migrations/loaders.py +443 -0
- sqlspec/migrations/runner.py +1172 -0
- sqlspec/migrations/templates.py +234 -0
- sqlspec/migrations/tracker.py +611 -0
- sqlspec/migrations/utils.py +256 -0
- sqlspec/migrations/validation.py +207 -0
- sqlspec/migrations/version.py +446 -0
- sqlspec/observability/__init__.py +55 -0
- sqlspec/observability/_common.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_common.py +77 -0
- sqlspec/observability/_config.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_config.py +348 -0
- sqlspec/observability/_diagnostics.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_diagnostics.py +74 -0
- sqlspec/observability/_dispatcher.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_dispatcher.py +152 -0
- sqlspec/observability/_formatters/__init__.py +13 -0
- sqlspec/observability/_formatters/_aws.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_formatters/_aws.py +102 -0
- sqlspec/observability/_formatters/_azure.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_formatters/_azure.py +96 -0
- sqlspec/observability/_formatters/_base.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_formatters/_base.py +57 -0
- sqlspec/observability/_formatters/_gcp.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_formatters/_gcp.py +131 -0
- sqlspec/observability/_formatting.py +58 -0
- sqlspec/observability/_observer.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_observer.py +357 -0
- sqlspec/observability/_runtime.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_runtime.py +420 -0
- sqlspec/observability/_sampling.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_sampling.py +188 -0
- sqlspec/observability/_spans.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/observability/_spans.py +161 -0
- sqlspec/protocols.py +916 -0
- sqlspec/py.typed +0 -0
- sqlspec/storage/__init__.py +48 -0
- sqlspec/storage/_utils.py +104 -0
- sqlspec/storage/backends/__init__.py +1 -0
- sqlspec/storage/backends/base.py +253 -0
- sqlspec/storage/backends/fsspec.py +529 -0
- sqlspec/storage/backends/local.py +441 -0
- sqlspec/storage/backends/obstore.py +916 -0
- sqlspec/storage/errors.py +104 -0
- sqlspec/storage/pipeline.py +582 -0
- sqlspec/storage/registry.py +301 -0
- sqlspec/typing.py +395 -0
- sqlspec/utils/__init__.py +7 -0
- sqlspec/utils/arrow_helpers.py +318 -0
- sqlspec/utils/config_tools.py +332 -0
- sqlspec/utils/correlation.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/correlation.py +134 -0
- sqlspec/utils/deprecation.py +190 -0
- sqlspec/utils/fixtures.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/fixtures.py +258 -0
- sqlspec/utils/logging.py +222 -0
- sqlspec/utils/module_loader.py +306 -0
- sqlspec/utils/portal.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/portal.py +375 -0
- sqlspec/utils/schema.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/schema.py +485 -0
- sqlspec/utils/serializers.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/serializers.py +408 -0
- sqlspec/utils/singleton.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/singleton.py +41 -0
- sqlspec/utils/sync_tools.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/sync_tools.py +311 -0
- sqlspec/utils/text.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/text.py +108 -0
- sqlspec/utils/type_converters.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/type_converters.py +128 -0
- sqlspec/utils/type_guards.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/type_guards.py +1360 -0
- sqlspec/utils/uuids.cpython-310-aarch64-linux-gnu.so +0 -0
- sqlspec/utils/uuids.py +225 -0
- sqlspec-0.36.0.dist-info/METADATA +205 -0
- sqlspec-0.36.0.dist-info/RECORD +531 -0
- sqlspec-0.36.0.dist-info/WHEEL +7 -0
- sqlspec-0.36.0.dist-info/entry_points.txt +2 -0
- sqlspec-0.36.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
"""Arrow conversion helpers for dict-to-Arrow transformations.
|
|
2
|
+
|
|
3
|
+
This module provides utilities for converting Python dictionaries to Apache Arrow
|
|
4
|
+
format, handling empty results, NULL values, and type inference.
|
|
5
|
+
|
|
6
|
+
NOTE: This module is excluded from mypyc compilation to avoid segmentation faults
|
|
7
|
+
when compiled drivers touch Arrow objects.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from collections.abc import Iterable
|
|
11
|
+
from typing import TYPE_CHECKING, Any, Literal, overload
|
|
12
|
+
|
|
13
|
+
from sqlspec.utils.module_loader import ensure_pandas, ensure_polars, ensure_pyarrow
|
|
14
|
+
from sqlspec.utils.type_guards import has_arrow_table_stats, has_get_data
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from sqlspec.core.result import ArrowResult
|
|
18
|
+
from sqlspec.typing import ArrowRecordBatch, ArrowRecordBatchReader, ArrowTable, PandasDataFrame, PolarsDataFrame
|
|
19
|
+
|
|
20
|
+
__all__ = (
|
|
21
|
+
"arrow_table_column_names",
|
|
22
|
+
"arrow_table_num_columns",
|
|
23
|
+
"arrow_table_num_rows",
|
|
24
|
+
"arrow_table_to_pandas",
|
|
25
|
+
"arrow_table_to_polars",
|
|
26
|
+
"arrow_table_to_pylist",
|
|
27
|
+
"arrow_table_to_return_format",
|
|
28
|
+
"arrow_table_to_rows",
|
|
29
|
+
"build_ingest_telemetry",
|
|
30
|
+
"cast_arrow_table_schema",
|
|
31
|
+
"coerce_arrow_table",
|
|
32
|
+
"convert_dict_to_arrow",
|
|
33
|
+
"convert_dict_to_arrow_with_schema",
|
|
34
|
+
"ensure_arrow_table",
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@overload
|
|
39
|
+
def convert_dict_to_arrow(
|
|
40
|
+
data: "list[dict[str, Any]]", return_format: Literal["table"] = "table", batch_size: int | None = None
|
|
41
|
+
) -> "ArrowTable": ...
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@overload
|
|
45
|
+
def convert_dict_to_arrow(
|
|
46
|
+
data: "list[dict[str, Any]]", return_format: Literal["reader"], batch_size: int | None = None
|
|
47
|
+
) -> "ArrowRecordBatchReader": ...
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@overload
|
|
51
|
+
def convert_dict_to_arrow(
|
|
52
|
+
data: "list[dict[str, Any]]", return_format: Literal["batch"], batch_size: int | None = None
|
|
53
|
+
) -> "ArrowRecordBatch": ...
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@overload
|
|
57
|
+
def convert_dict_to_arrow(
|
|
58
|
+
data: "list[dict[str, Any]]", return_format: Literal["batches"], batch_size: int | None = None
|
|
59
|
+
) -> "list[ArrowRecordBatch]": ...
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def convert_dict_to_arrow(
|
|
63
|
+
data: "list[dict[str, Any]]",
|
|
64
|
+
return_format: Literal["table", "reader", "batch", "batches"] = "table",
|
|
65
|
+
batch_size: int | None = None,
|
|
66
|
+
) -> "ArrowTable | ArrowRecordBatch | ArrowRecordBatchReader | list[ArrowRecordBatch]":
|
|
67
|
+
"""Convert list of dictionaries to Arrow Table or RecordBatch.
|
|
68
|
+
|
|
69
|
+
Handles empty results, NULL values, and automatic type inference.
|
|
70
|
+
Used by adapters that don't have native Arrow support to convert
|
|
71
|
+
dict-based results to Arrow format.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
data: List of dictionaries (one per row).
|
|
75
|
+
return_format: Output format - "table" for Table, "batch"/"batches" for RecordBatch.
|
|
76
|
+
"reader" returns a RecordBatchReader.
|
|
77
|
+
batch_size: Chunk size for batching (used when return_format="batch"/"batches").
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
ArrowTable or ArrowRecordBatch depending on return_format.
|
|
81
|
+
|
|
82
|
+
Examples:
|
|
83
|
+
>>> data = [
|
|
84
|
+
... {"id": 1, "name": "Alice"},
|
|
85
|
+
... {"id": 2, "name": "Bob"},
|
|
86
|
+
... ]
|
|
87
|
+
>>> table = convert_dict_to_arrow(data, return_format="table")
|
|
88
|
+
>>> print(table.num_rows)
|
|
89
|
+
2
|
|
90
|
+
|
|
91
|
+
>>> batch = convert_dict_to_arrow(data, return_format="batch")
|
|
92
|
+
>>> print(batch.num_rows)
|
|
93
|
+
2
|
|
94
|
+
"""
|
|
95
|
+
ensure_pyarrow()
|
|
96
|
+
import pyarrow as pa
|
|
97
|
+
|
|
98
|
+
if not data:
|
|
99
|
+
empty_schema = pa.schema([])
|
|
100
|
+
empty_table = pa.Table.from_pydict({}, schema=empty_schema)
|
|
101
|
+
|
|
102
|
+
if return_format == "reader":
|
|
103
|
+
return pa.RecordBatchReader.from_batches(empty_table.schema, empty_table.to_batches())
|
|
104
|
+
|
|
105
|
+
if return_format in {"batch", "batches"}:
|
|
106
|
+
batches = empty_table.to_batches(max_chunksize=batch_size)
|
|
107
|
+
return batches[0] if batches else pa.RecordBatch.from_pydict({})
|
|
108
|
+
|
|
109
|
+
return empty_table
|
|
110
|
+
|
|
111
|
+
columns: dict[str, list[Any]] = {key: [row.get(key) for row in data] for key in data[0]}
|
|
112
|
+
arrow_table = pa.Table.from_pydict(columns)
|
|
113
|
+
|
|
114
|
+
if return_format == "reader":
|
|
115
|
+
batches = arrow_table.to_batches(max_chunksize=batch_size)
|
|
116
|
+
return pa.RecordBatchReader.from_batches(arrow_table.schema, batches)
|
|
117
|
+
|
|
118
|
+
if return_format == "batches":
|
|
119
|
+
return arrow_table.to_batches(max_chunksize=batch_size)
|
|
120
|
+
|
|
121
|
+
if return_format == "batch":
|
|
122
|
+
batches = arrow_table.to_batches(max_chunksize=batch_size)
|
|
123
|
+
return batches[0] if batches else pa.RecordBatch.from_pydict({})
|
|
124
|
+
|
|
125
|
+
return arrow_table
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def convert_dict_to_arrow_with_schema(
|
|
129
|
+
data: "list[dict[str, Any]]",
|
|
130
|
+
return_format: Literal["table", "reader", "batch", "batches"] = "table",
|
|
131
|
+
batch_size: int | None = None,
|
|
132
|
+
arrow_schema: Any = None,
|
|
133
|
+
) -> "ArrowTable | ArrowRecordBatch | ArrowRecordBatchReader | list[ArrowRecordBatch]":
|
|
134
|
+
"""Convert dict rows to Arrow and optionally cast to a schema."""
|
|
135
|
+
table = convert_dict_to_arrow(data, return_format="table", batch_size=batch_size)
|
|
136
|
+
if arrow_schema is not None:
|
|
137
|
+
ensure_pyarrow()
|
|
138
|
+
import pyarrow as pa
|
|
139
|
+
|
|
140
|
+
if not isinstance(arrow_schema, pa.Schema):
|
|
141
|
+
msg = f"arrow_schema must be a pyarrow.Schema, got {type(arrow_schema).__name__}"
|
|
142
|
+
raise TypeError(msg)
|
|
143
|
+
if not data:
|
|
144
|
+
table = pa.Table.from_pydict({name: [] for name in arrow_schema.names}, schema=arrow_schema)
|
|
145
|
+
else:
|
|
146
|
+
table = table.cast(arrow_schema)
|
|
147
|
+
|
|
148
|
+
if return_format == "table":
|
|
149
|
+
return table
|
|
150
|
+
|
|
151
|
+
ensure_pyarrow()
|
|
152
|
+
import pyarrow as pa
|
|
153
|
+
|
|
154
|
+
if return_format == "reader":
|
|
155
|
+
batches = table.to_batches(max_chunksize=batch_size)
|
|
156
|
+
return pa.RecordBatchReader.from_batches(table.schema, batches)
|
|
157
|
+
if return_format == "batches":
|
|
158
|
+
return table.to_batches(max_chunksize=batch_size)
|
|
159
|
+
batches = table.to_batches(max_chunksize=batch_size)
|
|
160
|
+
return batches[0] if batches else pa.RecordBatch.from_pydict({})
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def coerce_arrow_table(source: "ArrowResult | Any") -> "ArrowTable":
|
|
164
|
+
"""Coerce various sources to a PyArrow Table."""
|
|
165
|
+
ensure_pyarrow()
|
|
166
|
+
import pyarrow as pa
|
|
167
|
+
|
|
168
|
+
if has_get_data(source):
|
|
169
|
+
table = source.get_data()
|
|
170
|
+
if isinstance(table, pa.Table):
|
|
171
|
+
return table
|
|
172
|
+
msg = "ArrowResult did not return a pyarrow.Table instance"
|
|
173
|
+
raise TypeError(msg)
|
|
174
|
+
if isinstance(source, pa.Table):
|
|
175
|
+
return source
|
|
176
|
+
if isinstance(source, pa.RecordBatch):
|
|
177
|
+
return pa.Table.from_batches([source])
|
|
178
|
+
if isinstance(source, Iterable):
|
|
179
|
+
return pa.Table.from_pylist(list(source))
|
|
180
|
+
msg = f"Unsupported Arrow source type: {type(source).__name__}"
|
|
181
|
+
raise TypeError(msg)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def ensure_arrow_table(data: Any) -> "ArrowTable":
|
|
185
|
+
"""Ensure data is a PyArrow Table."""
|
|
186
|
+
ensure_pyarrow()
|
|
187
|
+
import pyarrow as pa
|
|
188
|
+
|
|
189
|
+
if isinstance(data, pa.Table):
|
|
190
|
+
return data
|
|
191
|
+
msg = f"Expected an Arrow Table, but got {type(data).__name__}"
|
|
192
|
+
raise TypeError(msg)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def cast_arrow_table_schema(table: "ArrowTable", arrow_schema: Any) -> "ArrowTable":
|
|
196
|
+
"""Cast an Arrow table to a provided schema.
|
|
197
|
+
|
|
198
|
+
Args:
|
|
199
|
+
table: Arrow table to cast.
|
|
200
|
+
arrow_schema: Optional pyarrow.Schema for casting.
|
|
201
|
+
|
|
202
|
+
Returns:
|
|
203
|
+
Arrow table with updated schema.
|
|
204
|
+
|
|
205
|
+
Raises:
|
|
206
|
+
TypeError: If arrow_schema is not a pyarrow.Schema instance.
|
|
207
|
+
"""
|
|
208
|
+
if arrow_schema is None:
|
|
209
|
+
return table
|
|
210
|
+
|
|
211
|
+
ensure_pyarrow()
|
|
212
|
+
import pyarrow as pa
|
|
213
|
+
|
|
214
|
+
if not isinstance(arrow_schema, pa.Schema):
|
|
215
|
+
msg = f"arrow_schema must be a pyarrow.Schema, got {type(arrow_schema).__name__}"
|
|
216
|
+
raise TypeError(msg)
|
|
217
|
+
return table.cast(arrow_schema)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def arrow_table_to_return_format(
|
|
221
|
+
table: "ArrowTable",
|
|
222
|
+
return_format: Literal["table", "reader", "batch", "batches"] = "table",
|
|
223
|
+
batch_size: int | None = None,
|
|
224
|
+
) -> "ArrowTable | ArrowRecordBatch | ArrowRecordBatchReader | list[ArrowRecordBatch]":
|
|
225
|
+
"""Convert an Arrow table into the requested return format.
|
|
226
|
+
|
|
227
|
+
Args:
|
|
228
|
+
table: Arrow table to convert.
|
|
229
|
+
return_format: Output format (table, reader, batch, batches).
|
|
230
|
+
batch_size: Batch size for reader/batch outputs.
|
|
231
|
+
|
|
232
|
+
Returns:
|
|
233
|
+
Converted Arrow data in the requested format.
|
|
234
|
+
"""
|
|
235
|
+
ensure_pyarrow()
|
|
236
|
+
import pyarrow as pa
|
|
237
|
+
|
|
238
|
+
if return_format == "table":
|
|
239
|
+
return table
|
|
240
|
+
|
|
241
|
+
batches = table.to_batches(max_chunksize=batch_size)
|
|
242
|
+
if return_format == "reader":
|
|
243
|
+
return pa.RecordBatchReader.from_batches(table.schema, batches)
|
|
244
|
+
if return_format == "batches":
|
|
245
|
+
return batches
|
|
246
|
+
return batches[0] if batches else pa.RecordBatch.from_pydict({})
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def arrow_table_to_rows(
|
|
250
|
+
table: "ArrowTable", columns: "list[str] | None" = None
|
|
251
|
+
) -> "tuple[list[str], list[tuple[Any, ...]]]":
|
|
252
|
+
"""Convert Arrow table to column names and row tuples."""
|
|
253
|
+
ensure_pyarrow()
|
|
254
|
+
resolved_columns = columns or list(table.column_names)
|
|
255
|
+
if not resolved_columns:
|
|
256
|
+
msg = "Arrow table has no columns to import"
|
|
257
|
+
raise ValueError(msg)
|
|
258
|
+
batches = table.to_pylist()
|
|
259
|
+
records: list[tuple[Any, ...]] = []
|
|
260
|
+
for row in batches:
|
|
261
|
+
record = tuple(row.get(col) for col in resolved_columns)
|
|
262
|
+
records.append(record)
|
|
263
|
+
return resolved_columns, records
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def arrow_table_to_pylist(table: "ArrowTable") -> "list[dict[str, Any]]":
|
|
267
|
+
"""Convert Arrow table to list of dictionaries."""
|
|
268
|
+
return table.to_pylist()
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def arrow_table_column_names(table: "ArrowTable") -> "list[str]":
|
|
272
|
+
"""Return Arrow table column names."""
|
|
273
|
+
return list(table.column_names)
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def arrow_table_num_rows(table: "ArrowTable") -> int:
|
|
277
|
+
"""Return Arrow table row count."""
|
|
278
|
+
return int(table.num_rows)
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def arrow_table_num_columns(table: "ArrowTable") -> int:
|
|
282
|
+
"""Return Arrow table column count."""
|
|
283
|
+
return int(table.num_columns)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def arrow_table_to_pandas(table: "ArrowTable") -> "PandasDataFrame":
|
|
287
|
+
"""Convert Arrow table to pandas DataFrame."""
|
|
288
|
+
ensure_pandas()
|
|
289
|
+
import pandas as pd
|
|
290
|
+
|
|
291
|
+
result = table.to_pandas()
|
|
292
|
+
if not isinstance(result, pd.DataFrame):
|
|
293
|
+
msg = f"Expected a pandas DataFrame, but got {type(result).__name__}"
|
|
294
|
+
raise TypeError(msg)
|
|
295
|
+
return result
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def arrow_table_to_polars(table: "ArrowTable") -> "PolarsDataFrame":
|
|
299
|
+
"""Convert Arrow table to Polars DataFrame."""
|
|
300
|
+
ensure_polars()
|
|
301
|
+
import polars as pl
|
|
302
|
+
|
|
303
|
+
result = pl.from_arrow(table)
|
|
304
|
+
if not isinstance(result, pl.DataFrame):
|
|
305
|
+
msg = f"Expected a Polars DataFrame, but got {type(result).__name__}"
|
|
306
|
+
raise TypeError(msg)
|
|
307
|
+
return result
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def build_ingest_telemetry(table: "ArrowTable", *, format_label: str = "arrow") -> "dict[str, int | str]":
|
|
311
|
+
"""Build telemetry dict from Arrow table statistics."""
|
|
312
|
+
if has_arrow_table_stats(table):
|
|
313
|
+
rows = int(table.num_rows)
|
|
314
|
+
bytes_processed = int(table.nbytes)
|
|
315
|
+
else:
|
|
316
|
+
rows = 0
|
|
317
|
+
bytes_processed = 0
|
|
318
|
+
return {"rows_processed": rows, "bytes_processed": bytes_processed, "format": format_label}
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
"""Configuration utilities for SQLSpec.
|
|
2
|
+
|
|
3
|
+
This module consolidates configuration-related helpers:
|
|
4
|
+
- pyproject.toml discovery for CLI convenience
|
|
5
|
+
- dotted path resolution for config objects
|
|
6
|
+
- connection config normalization for adapters
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import inspect
|
|
10
|
+
import sys
|
|
11
|
+
from collections.abc import Sequence
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import TYPE_CHECKING, Any, cast
|
|
14
|
+
|
|
15
|
+
from sqlspec.exceptions import ConfigResolverError, ImproperConfigurationError
|
|
16
|
+
from sqlspec.utils.module_loader import import_string
|
|
17
|
+
from sqlspec.utils.sync_tools import async_, await_
|
|
18
|
+
from sqlspec.utils.type_guards import (
|
|
19
|
+
has_config_attribute,
|
|
20
|
+
has_connection_config,
|
|
21
|
+
has_database_url_and_bind_key,
|
|
22
|
+
has_migration_config,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
if sys.version_info >= (3, 11):
|
|
26
|
+
import tomllib
|
|
27
|
+
else:
|
|
28
|
+
import tomli as tomllib
|
|
29
|
+
|
|
30
|
+
if TYPE_CHECKING:
|
|
31
|
+
from collections.abc import Mapping
|
|
32
|
+
|
|
33
|
+
from sqlspec.config import AsyncDatabaseConfig, SyncDatabaseConfig
|
|
34
|
+
|
|
35
|
+
__all__ = (
|
|
36
|
+
"discover_config_from_pyproject",
|
|
37
|
+
"find_pyproject_toml",
|
|
38
|
+
"normalize_connection_config",
|
|
39
|
+
"parse_pyproject_config",
|
|
40
|
+
"reject_pool_aliases",
|
|
41
|
+
"resolve_config_async",
|
|
42
|
+
"resolve_config_sync",
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# =============================================================================
|
|
47
|
+
# pyproject.toml Discovery
|
|
48
|
+
# =============================================================================
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def discover_config_from_pyproject() -> str | None:
|
|
52
|
+
"""Find and parse pyproject.toml for SQLSpec config.
|
|
53
|
+
|
|
54
|
+
Walks filesystem upward from current directory to find pyproject.toml.
|
|
55
|
+
Parses [tool.sqlspec] section for 'config' key.
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
Config path(s) as string (comma-separated if list), or None if not found.
|
|
59
|
+
"""
|
|
60
|
+
pyproject_path = find_pyproject_toml()
|
|
61
|
+
if pyproject_path is None:
|
|
62
|
+
return None
|
|
63
|
+
|
|
64
|
+
return parse_pyproject_config(pyproject_path)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def find_pyproject_toml() -> "Path | None":
|
|
68
|
+
"""Walk filesystem upward to find pyproject.toml.
|
|
69
|
+
|
|
70
|
+
Starts from current working directory and walks up to filesystem root.
|
|
71
|
+
Stops at .git directory boundary (repository root) if found.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
Path to pyproject.toml, or None if not found.
|
|
75
|
+
"""
|
|
76
|
+
current = Path.cwd()
|
|
77
|
+
|
|
78
|
+
while True:
|
|
79
|
+
pyproject = current / "pyproject.toml"
|
|
80
|
+
if pyproject.exists():
|
|
81
|
+
return pyproject
|
|
82
|
+
|
|
83
|
+
# Stop at .git boundary (repository root)
|
|
84
|
+
if (current / ".git").exists():
|
|
85
|
+
return None
|
|
86
|
+
|
|
87
|
+
# Stop at filesystem root
|
|
88
|
+
if current == current.parent:
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
current = current.parent
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def parse_pyproject_config(pyproject_path: "Path") -> str | None:
|
|
95
|
+
"""Parse pyproject.toml for [tool.sqlspec] config.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
pyproject_path: Path to pyproject.toml file.
|
|
99
|
+
|
|
100
|
+
Returns:
|
|
101
|
+
Config path(s) as string (converts list to comma-separated), or None if not found.
|
|
102
|
+
|
|
103
|
+
Raises:
|
|
104
|
+
ValueError: If [tool.sqlspec].config has invalid type (not str or list[str]).
|
|
105
|
+
"""
|
|
106
|
+
try:
|
|
107
|
+
with pyproject_path.open("rb") as f:
|
|
108
|
+
data = tomllib.load(f)
|
|
109
|
+
except Exception as e:
|
|
110
|
+
msg = f"Failed to parse {pyproject_path}: {e}"
|
|
111
|
+
raise ValueError(msg) from e
|
|
112
|
+
|
|
113
|
+
# Navigate to [tool.sqlspec] section
|
|
114
|
+
tool_section = data.get("tool", {})
|
|
115
|
+
if not isinstance(tool_section, dict):
|
|
116
|
+
return None
|
|
117
|
+
|
|
118
|
+
sqlspec_section = tool_section.get("sqlspec", {})
|
|
119
|
+
if not isinstance(sqlspec_section, dict):
|
|
120
|
+
return None
|
|
121
|
+
|
|
122
|
+
# Extract config value
|
|
123
|
+
config = sqlspec_section.get("config")
|
|
124
|
+
if config is None:
|
|
125
|
+
return None
|
|
126
|
+
|
|
127
|
+
# Handle string config
|
|
128
|
+
if isinstance(config, str):
|
|
129
|
+
return config
|
|
130
|
+
|
|
131
|
+
# Handle list config (convert to comma-separated)
|
|
132
|
+
if isinstance(config, list):
|
|
133
|
+
if not all(isinstance(item, str) for item in config):
|
|
134
|
+
msg = f"Invalid [tool.sqlspec].config in {pyproject_path}: list items must be strings"
|
|
135
|
+
raise ValueError(msg)
|
|
136
|
+
return ",".join(config)
|
|
137
|
+
|
|
138
|
+
# Invalid type
|
|
139
|
+
msg = f"Invalid [tool.sqlspec].config in {pyproject_path}: must be string or list of strings, got {type(config).__name__}"
|
|
140
|
+
raise ValueError(msg)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
# =============================================================================
|
|
144
|
+
# Config Resolution
|
|
145
|
+
# =============================================================================
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
async def resolve_config_async(
|
|
149
|
+
config_path: str,
|
|
150
|
+
) -> "list[AsyncDatabaseConfig[Any, Any, Any] | SyncDatabaseConfig[Any, Any, Any]] | AsyncDatabaseConfig[Any, Any, Any] | SyncDatabaseConfig[Any, Any, Any]":
|
|
151
|
+
"""Resolve config from dotted path, handling callables and direct instances.
|
|
152
|
+
|
|
153
|
+
This is the async-first version that handles both sync and async callables efficiently.
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
config_path: Dotted path to config object or callable function.
|
|
157
|
+
|
|
158
|
+
Returns:
|
|
159
|
+
Resolved config instance or list of config instances.
|
|
160
|
+
|
|
161
|
+
Raises:
|
|
162
|
+
ConfigResolverError: If config resolution fails.
|
|
163
|
+
"""
|
|
164
|
+
try:
|
|
165
|
+
config_obj = import_string(config_path)
|
|
166
|
+
except ImportError as e:
|
|
167
|
+
msg = f"Failed to import config from path '{config_path}': {e}"
|
|
168
|
+
raise ConfigResolverError(msg) from e
|
|
169
|
+
|
|
170
|
+
if not callable(config_obj):
|
|
171
|
+
return _validate_config_result(config_obj, config_path)
|
|
172
|
+
|
|
173
|
+
try:
|
|
174
|
+
if inspect.iscoroutinefunction(config_obj):
|
|
175
|
+
result = await config_obj()
|
|
176
|
+
else:
|
|
177
|
+
result = await async_(config_obj)()
|
|
178
|
+
except Exception as e:
|
|
179
|
+
msg = f"Failed to execute callable config '{config_path}': {e}"
|
|
180
|
+
raise ConfigResolverError(msg) from e
|
|
181
|
+
|
|
182
|
+
return _validate_config_result(result, config_path)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def resolve_config_sync(
|
|
186
|
+
config_path: str,
|
|
187
|
+
) -> "list[AsyncDatabaseConfig[Any, Any, Any] | SyncDatabaseConfig[Any, Any, Any]] | AsyncDatabaseConfig[Any, Any, Any] | SyncDatabaseConfig[Any, Any, Any]":
|
|
188
|
+
"""Synchronous wrapper for resolve_config.
|
|
189
|
+
|
|
190
|
+
Args:
|
|
191
|
+
config_path: Dotted path to config object or callable function.
|
|
192
|
+
|
|
193
|
+
Returns:
|
|
194
|
+
Resolved config instance or list of config instances.
|
|
195
|
+
"""
|
|
196
|
+
try:
|
|
197
|
+
config_obj = import_string(config_path)
|
|
198
|
+
except ImportError as e:
|
|
199
|
+
msg = f"Failed to import config from path '{config_path}': {e}"
|
|
200
|
+
raise ConfigResolverError(msg) from e
|
|
201
|
+
|
|
202
|
+
if not callable(config_obj):
|
|
203
|
+
return _validate_config_result(config_obj, config_path)
|
|
204
|
+
|
|
205
|
+
try:
|
|
206
|
+
if inspect.iscoroutinefunction(config_obj):
|
|
207
|
+
result = await_(config_obj, raise_sync_error=False)()
|
|
208
|
+
else:
|
|
209
|
+
result = config_obj()
|
|
210
|
+
except Exception as e:
|
|
211
|
+
msg = f"Failed to execute callable config '{config_path}': {e}"
|
|
212
|
+
raise ConfigResolverError(msg) from e
|
|
213
|
+
|
|
214
|
+
return _validate_config_result(result, config_path)
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def _validate_config_result(
|
|
218
|
+
config_result: Any, config_path: str
|
|
219
|
+
) -> "list[AsyncDatabaseConfig[Any, Any, Any] | SyncDatabaseConfig[Any, Any, Any]] | AsyncDatabaseConfig[Any, Any, Any] | SyncDatabaseConfig[Any, Any, Any]":
|
|
220
|
+
"""Validate that the config result is a valid config or list of configs.
|
|
221
|
+
|
|
222
|
+
Args:
|
|
223
|
+
config_result: The result from config resolution.
|
|
224
|
+
config_path: Original config path for error messages.
|
|
225
|
+
|
|
226
|
+
Returns:
|
|
227
|
+
Validated config result.
|
|
228
|
+
|
|
229
|
+
Raises:
|
|
230
|
+
ConfigResolverError: If config result is invalid.
|
|
231
|
+
"""
|
|
232
|
+
if config_result is None:
|
|
233
|
+
msg = f"Config '{config_path}' resolved to None. Expected config instance or list of configs."
|
|
234
|
+
raise ConfigResolverError(msg)
|
|
235
|
+
|
|
236
|
+
if isinstance(config_result, Sequence) and not isinstance(config_result, str):
|
|
237
|
+
if not config_result:
|
|
238
|
+
msg = f"Config '{config_path}' resolved to empty list. Expected at least one config."
|
|
239
|
+
raise ConfigResolverError(msg)
|
|
240
|
+
|
|
241
|
+
for i, config in enumerate(config_result): # pyright: ignore
|
|
242
|
+
if not _is_valid_config(config):
|
|
243
|
+
msg = f"Config '{config_path}' returned invalid config at index {i}. Expected database config instance."
|
|
244
|
+
raise ConfigResolverError(msg)
|
|
245
|
+
|
|
246
|
+
return cast("list[AsyncDatabaseConfig[Any, Any, Any] | SyncDatabaseConfig[Any, Any, Any]]", list(config_result)) # pyright: ignore
|
|
247
|
+
|
|
248
|
+
if not _is_valid_config(config_result):
|
|
249
|
+
msg = f"Config '{config_path}' returned invalid type '{type(config_result).__name__}'. Expected database config instance or list."
|
|
250
|
+
raise ConfigResolverError(msg)
|
|
251
|
+
|
|
252
|
+
return cast("AsyncDatabaseConfig[Any, Any, Any] | SyncDatabaseConfig[Any, Any, Any]", config_result)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def _is_valid_config(config: Any) -> bool:
|
|
256
|
+
"""Check if an object is a valid SQLSpec database config.
|
|
257
|
+
|
|
258
|
+
Args:
|
|
259
|
+
config: Object to validate.
|
|
260
|
+
|
|
261
|
+
Returns:
|
|
262
|
+
True if object is a valid config instance (not a class).
|
|
263
|
+
"""
|
|
264
|
+
# Reject config classes - must be instances
|
|
265
|
+
if isinstance(config, type):
|
|
266
|
+
return False
|
|
267
|
+
|
|
268
|
+
if has_config_attribute(config):
|
|
269
|
+
nested_config = config.config
|
|
270
|
+
if has_migration_config(nested_config):
|
|
271
|
+
return True
|
|
272
|
+
|
|
273
|
+
if has_migration_config(config) and config.migration_config is not None:
|
|
274
|
+
if has_connection_config(config):
|
|
275
|
+
return True
|
|
276
|
+
if has_database_url_and_bind_key(config):
|
|
277
|
+
return True
|
|
278
|
+
|
|
279
|
+
return False
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
# =============================================================================
|
|
283
|
+
# Connection Config Normalization
|
|
284
|
+
# =============================================================================
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
def reject_pool_aliases(kwargs: "dict[str, Any]") -> None:
|
|
288
|
+
"""Reject legacy pool_config/pool_instance aliases.
|
|
289
|
+
|
|
290
|
+
Args:
|
|
291
|
+
kwargs: Keyword arguments passed to the adapter config constructor.
|
|
292
|
+
|
|
293
|
+
Raises:
|
|
294
|
+
ImproperConfigurationError: If deprecated pool aliases are supplied.
|
|
295
|
+
"""
|
|
296
|
+
if "pool_config" in kwargs or "pool_instance" in kwargs:
|
|
297
|
+
msg = (
|
|
298
|
+
"pool_config and pool_instance are no longer supported. "
|
|
299
|
+
"Use connection_config and connection_instance instead."
|
|
300
|
+
)
|
|
301
|
+
raise ImproperConfigurationError(msg)
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
def normalize_connection_config(
|
|
305
|
+
connection_config: "Mapping[str, Any] | None", *, extra_key: str = "extra"
|
|
306
|
+
) -> "dict[str, Any]":
|
|
307
|
+
"""Normalize an adapter connection_config dictionary.
|
|
308
|
+
|
|
309
|
+
This function:
|
|
310
|
+
- Copies the provided mapping into a new dict.
|
|
311
|
+
- Merges any nested dict stored under ``extra_key`` into the top-level config.
|
|
312
|
+
- Ensures the extra mapping is a dictionary (or None).
|
|
313
|
+
|
|
314
|
+
Args:
|
|
315
|
+
connection_config: Raw connection configuration mapping.
|
|
316
|
+
extra_key: Key holding additional keyword arguments to merge.
|
|
317
|
+
|
|
318
|
+
Returns:
|
|
319
|
+
Normalized connection configuration.
|
|
320
|
+
|
|
321
|
+
Raises:
|
|
322
|
+
ImproperConfigurationError: If ``extra_key`` exists but is not a dictionary.
|
|
323
|
+
"""
|
|
324
|
+
normalized: dict[str, Any] = dict(connection_config) if connection_config else {}
|
|
325
|
+
extras = normalized.pop(extra_key, {})
|
|
326
|
+
if extras is None:
|
|
327
|
+
return normalized
|
|
328
|
+
if not isinstance(extras, dict):
|
|
329
|
+
msg = f"The '{extra_key}' field in connection_config must be a dictionary."
|
|
330
|
+
raise ImproperConfigurationError(msg)
|
|
331
|
+
normalized.update(extras)
|
|
332
|
+
return normalized
|
|
Binary file
|