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,579 @@
|
|
|
1
|
+
"""EXPLAIN statement builder.
|
|
2
|
+
|
|
3
|
+
Provides a fluent interface for building EXPLAIN statements with
|
|
4
|
+
dialect-aware SQL generation.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import TYPE_CHECKING, Any, ClassVar
|
|
8
|
+
|
|
9
|
+
from mypy_extensions import trait
|
|
10
|
+
from typing_extensions import Self
|
|
11
|
+
|
|
12
|
+
from sqlspec.core import SQL, StatementConfig
|
|
13
|
+
from sqlspec.core.explain import ExplainFormat, ExplainOptions
|
|
14
|
+
from sqlspec.exceptions import SQLBuilderError
|
|
15
|
+
from sqlspec.utils.type_guards import has_expression_and_sql, has_parameter_builder, is_expression
|
|
16
|
+
|
|
17
|
+
if TYPE_CHECKING:
|
|
18
|
+
from sqlglot import exp
|
|
19
|
+
from sqlglot.dialects.dialect import DialectType
|
|
20
|
+
|
|
21
|
+
from sqlspec.protocols import SQLBuilderProtocol
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
__all__ = (
|
|
25
|
+
"Explain",
|
|
26
|
+
"ExplainMixin",
|
|
27
|
+
"build_bigquery_explain",
|
|
28
|
+
"build_duckdb_explain",
|
|
29
|
+
"build_explain_sql",
|
|
30
|
+
"build_generic_explain",
|
|
31
|
+
"build_mysql_explain",
|
|
32
|
+
"build_oracle_explain",
|
|
33
|
+
"build_postgres_explain",
|
|
34
|
+
"build_sqlite_explain",
|
|
35
|
+
"normalize_dialect_name",
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
POSTGRES_DIALECTS = frozenset({"postgres", "postgresql", "redshift"})
|
|
40
|
+
MYSQL_DIALECTS = frozenset({"mysql", "mariadb"})
|
|
41
|
+
SQLITE_DIALECTS = frozenset({"sqlite"})
|
|
42
|
+
DUCKDB_DIALECTS = frozenset({"duckdb"})
|
|
43
|
+
ORACLE_DIALECTS = frozenset({"oracle"})
|
|
44
|
+
BIGQUERY_DIALECTS = frozenset({"bigquery"})
|
|
45
|
+
SPANNER_DIALECTS = frozenset({"spanner"})
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def normalize_dialect_name(dialect: "DialectType | None") -> str | None:
|
|
49
|
+
"""Normalize dialect to lowercase string.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
dialect: Dialect type, string, or None
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
Lowercase string representation of dialect or None
|
|
56
|
+
"""
|
|
57
|
+
if dialect is None:
|
|
58
|
+
return None
|
|
59
|
+
if isinstance(dialect, str):
|
|
60
|
+
return dialect.lower()
|
|
61
|
+
return dialect.__class__.__name__.lower()
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def build_postgres_explain(statement_sql: str, options: "ExplainOptions") -> str:
|
|
65
|
+
"""Build PostgreSQL EXPLAIN statement.
|
|
66
|
+
|
|
67
|
+
PostgreSQL uses the syntax: EXPLAIN (OPTIONS) statement
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
statement_sql: The SQL statement to explain
|
|
71
|
+
options: ExplainOptions configuration
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
Complete EXPLAIN SQL string
|
|
75
|
+
"""
|
|
76
|
+
option_parts: list[str] = []
|
|
77
|
+
|
|
78
|
+
if options.analyze:
|
|
79
|
+
option_parts.append("ANALYZE")
|
|
80
|
+
if options.verbose:
|
|
81
|
+
option_parts.append("VERBOSE")
|
|
82
|
+
if options.costs is not None:
|
|
83
|
+
option_parts.append(f"COSTS {'TRUE' if options.costs else 'FALSE'}")
|
|
84
|
+
if options.buffers is not None:
|
|
85
|
+
option_parts.append(f"BUFFERS {'TRUE' if options.buffers else 'FALSE'}")
|
|
86
|
+
if options.timing is not None:
|
|
87
|
+
option_parts.append(f"TIMING {'TRUE' if options.timing else 'FALSE'}")
|
|
88
|
+
if options.summary is not None:
|
|
89
|
+
option_parts.append(f"SUMMARY {'TRUE' if options.summary else 'FALSE'}")
|
|
90
|
+
if options.memory is not None:
|
|
91
|
+
option_parts.append(f"MEMORY {'TRUE' if options.memory else 'FALSE'}")
|
|
92
|
+
if options.settings is not None:
|
|
93
|
+
option_parts.append(f"SETTINGS {'TRUE' if options.settings else 'FALSE'}")
|
|
94
|
+
if options.wal is not None:
|
|
95
|
+
option_parts.append(f"WAL {'TRUE' if options.wal else 'FALSE'}")
|
|
96
|
+
if options.generic_plan is not None:
|
|
97
|
+
option_parts.append(f"GENERIC_PLAN {'TRUE' if options.generic_plan else 'FALSE'}")
|
|
98
|
+
if options.format is not None:
|
|
99
|
+
option_parts.append(f"FORMAT {options.format.value.upper()}")
|
|
100
|
+
|
|
101
|
+
if option_parts:
|
|
102
|
+
options_str = ", ".join(option_parts)
|
|
103
|
+
return f"EXPLAIN ({options_str}) {statement_sql}"
|
|
104
|
+
return f"EXPLAIN {statement_sql}"
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def build_mysql_explain(statement_sql: str, options: "ExplainOptions") -> str:
|
|
108
|
+
"""Build MySQL EXPLAIN statement.
|
|
109
|
+
|
|
110
|
+
MySQL uses:
|
|
111
|
+
- EXPLAIN [FORMAT = TRADITIONAL|JSON|TREE] statement
|
|
112
|
+
- EXPLAIN ANALYZE statement (always TREE format)
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
statement_sql: The SQL statement to explain
|
|
116
|
+
options: ExplainOptions configuration
|
|
117
|
+
|
|
118
|
+
Returns:
|
|
119
|
+
Complete EXPLAIN SQL string
|
|
120
|
+
"""
|
|
121
|
+
if options.analyze:
|
|
122
|
+
return f"EXPLAIN ANALYZE {statement_sql}"
|
|
123
|
+
|
|
124
|
+
if options.format is not None:
|
|
125
|
+
format_map = {
|
|
126
|
+
ExplainFormat.JSON: "JSON",
|
|
127
|
+
ExplainFormat.TREE: "TREE",
|
|
128
|
+
ExplainFormat.TRADITIONAL: "TRADITIONAL",
|
|
129
|
+
ExplainFormat.TEXT: "TRADITIONAL",
|
|
130
|
+
}
|
|
131
|
+
fmt = format_map.get(options.format, "TRADITIONAL")
|
|
132
|
+
return f"EXPLAIN FORMAT = {fmt} {statement_sql}"
|
|
133
|
+
|
|
134
|
+
return f"EXPLAIN {statement_sql}"
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def build_sqlite_explain(statement_sql: str, options: "ExplainOptions") -> str:
|
|
138
|
+
"""Build SQLite EXPLAIN statement.
|
|
139
|
+
|
|
140
|
+
SQLite only supports EXPLAIN QUERY PLAN (no additional options).
|
|
141
|
+
Raw EXPLAIN returns virtual machine opcodes which is rarely useful.
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
statement_sql: The SQL statement to explain
|
|
145
|
+
options: ExplainOptions configuration (mostly ignored for SQLite)
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
Complete EXPLAIN SQL string
|
|
149
|
+
"""
|
|
150
|
+
return f"EXPLAIN QUERY PLAN {statement_sql}"
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def build_duckdb_explain(statement_sql: str, options: "ExplainOptions") -> str:
|
|
154
|
+
"""Build DuckDB EXPLAIN statement.
|
|
155
|
+
|
|
156
|
+
DuckDB supports:
|
|
157
|
+
- EXPLAIN statement
|
|
158
|
+
- EXPLAIN ANALYZE statement
|
|
159
|
+
- EXPLAIN (FORMAT JSON) statement
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
statement_sql: The SQL statement to explain
|
|
163
|
+
options: ExplainOptions configuration
|
|
164
|
+
|
|
165
|
+
Returns:
|
|
166
|
+
Complete EXPLAIN SQL string
|
|
167
|
+
"""
|
|
168
|
+
if options.analyze:
|
|
169
|
+
return f"EXPLAIN ANALYZE {statement_sql}"
|
|
170
|
+
|
|
171
|
+
if options.format is not None and options.format == ExplainFormat.JSON:
|
|
172
|
+
return f"EXPLAIN (FORMAT JSON) {statement_sql}"
|
|
173
|
+
|
|
174
|
+
return f"EXPLAIN {statement_sql}"
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def build_oracle_explain(statement_sql: str, options: "ExplainOptions") -> str:
|
|
178
|
+
"""Build Oracle EXPLAIN statement.
|
|
179
|
+
|
|
180
|
+
Oracle requires a two-step process:
|
|
181
|
+
1. EXPLAIN PLAN FOR statement
|
|
182
|
+
2. SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY())
|
|
183
|
+
|
|
184
|
+
This function returns only the first step. The driver must handle
|
|
185
|
+
executing both statements.
|
|
186
|
+
|
|
187
|
+
Args:
|
|
188
|
+
statement_sql: The SQL statement to explain
|
|
189
|
+
options: ExplainOptions configuration (mostly ignored for Oracle)
|
|
190
|
+
|
|
191
|
+
Returns:
|
|
192
|
+
EXPLAIN PLAN FOR SQL string
|
|
193
|
+
"""
|
|
194
|
+
return f"EXPLAIN PLAN FOR {statement_sql}"
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def build_bigquery_explain(statement_sql: str, options: "ExplainOptions") -> str:
|
|
198
|
+
"""Build BigQuery EXPLAIN statement.
|
|
199
|
+
|
|
200
|
+
BigQuery supports:
|
|
201
|
+
- EXPLAIN statement
|
|
202
|
+
- EXPLAIN ANALYZE statement (incurs query execution costs!)
|
|
203
|
+
|
|
204
|
+
Args:
|
|
205
|
+
statement_sql: The SQL statement to explain
|
|
206
|
+
options: ExplainOptions configuration
|
|
207
|
+
|
|
208
|
+
Returns:
|
|
209
|
+
Complete EXPLAIN SQL string
|
|
210
|
+
"""
|
|
211
|
+
if options.analyze:
|
|
212
|
+
return f"EXPLAIN ANALYZE {statement_sql}"
|
|
213
|
+
return f"EXPLAIN {statement_sql}"
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def build_generic_explain(statement_sql: str, options: "ExplainOptions") -> str:
|
|
217
|
+
"""Build generic EXPLAIN statement for unknown dialects.
|
|
218
|
+
|
|
219
|
+
Args:
|
|
220
|
+
statement_sql: The SQL statement to explain
|
|
221
|
+
options: ExplainOptions configuration
|
|
222
|
+
|
|
223
|
+
Returns:
|
|
224
|
+
Complete EXPLAIN SQL string
|
|
225
|
+
"""
|
|
226
|
+
if options.analyze:
|
|
227
|
+
return f"EXPLAIN ANALYZE {statement_sql}"
|
|
228
|
+
return f"EXPLAIN {statement_sql}"
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def build_explain_sql(statement_sql: str, options: "ExplainOptions", dialect: "DialectType | None" = None) -> str:
|
|
232
|
+
"""Build dialect-specific EXPLAIN SQL.
|
|
233
|
+
|
|
234
|
+
Args:
|
|
235
|
+
statement_sql: The SQL statement to explain
|
|
236
|
+
options: ExplainOptions configuration
|
|
237
|
+
dialect: Target SQL dialect
|
|
238
|
+
|
|
239
|
+
Returns:
|
|
240
|
+
Complete EXPLAIN SQL string for the target dialect
|
|
241
|
+
"""
|
|
242
|
+
dialect_name = normalize_dialect_name(dialect)
|
|
243
|
+
|
|
244
|
+
if dialect_name in POSTGRES_DIALECTS:
|
|
245
|
+
return build_postgres_explain(statement_sql, options)
|
|
246
|
+
if dialect_name in MYSQL_DIALECTS:
|
|
247
|
+
return build_mysql_explain(statement_sql, options)
|
|
248
|
+
if dialect_name in SQLITE_DIALECTS:
|
|
249
|
+
return build_sqlite_explain(statement_sql, options)
|
|
250
|
+
if dialect_name in DUCKDB_DIALECTS:
|
|
251
|
+
return build_duckdb_explain(statement_sql, options)
|
|
252
|
+
if dialect_name in ORACLE_DIALECTS:
|
|
253
|
+
return build_oracle_explain(statement_sql, options)
|
|
254
|
+
if dialect_name in BIGQUERY_DIALECTS:
|
|
255
|
+
return build_bigquery_explain(statement_sql, options)
|
|
256
|
+
|
|
257
|
+
return build_generic_explain(statement_sql, options)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
class Explain:
|
|
261
|
+
"""Builder for EXPLAIN statements with dialect-aware rendering.
|
|
262
|
+
|
|
263
|
+
Provides a fluent API for constructing EXPLAIN statements with
|
|
264
|
+
various options that are translated to dialect-specific syntax.
|
|
265
|
+
|
|
266
|
+
Examples:
|
|
267
|
+
Basic usage:
|
|
268
|
+
explain = Explain("SELECT * FROM users").build()
|
|
269
|
+
|
|
270
|
+
With options:
|
|
271
|
+
explain = (
|
|
272
|
+
Explain("SELECT * FROM users", dialect="postgres")
|
|
273
|
+
.analyze()
|
|
274
|
+
.format("json")
|
|
275
|
+
.buffers()
|
|
276
|
+
.build()
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
From QueryBuilder:
|
|
280
|
+
explain = (
|
|
281
|
+
Explain(select_builder, dialect="postgres")
|
|
282
|
+
.analyze()
|
|
283
|
+
.verbose()
|
|
284
|
+
.build()
|
|
285
|
+
)
|
|
286
|
+
"""
|
|
287
|
+
|
|
288
|
+
__slots__: ClassVar[tuple[str, ...]] = ("_dialect", "_options", "_parameters", "_statement", "_statement_sql")
|
|
289
|
+
|
|
290
|
+
def __init__(
|
|
291
|
+
self,
|
|
292
|
+
statement: "str | exp.Expression | SQL | SQLBuilderProtocol",
|
|
293
|
+
dialect: "DialectType | None" = None,
|
|
294
|
+
options: "ExplainOptions | None" = None,
|
|
295
|
+
) -> None:
|
|
296
|
+
"""Initialize ExplainBuilder.
|
|
297
|
+
|
|
298
|
+
Args:
|
|
299
|
+
statement: SQL statement to explain (string, expression, SQL object, or builder)
|
|
300
|
+
dialect: Target SQL dialect
|
|
301
|
+
options: Initial ExplainOptions (or None for defaults)
|
|
302
|
+
"""
|
|
303
|
+
self._dialect = dialect
|
|
304
|
+
self._options = options if options is not None else ExplainOptions()
|
|
305
|
+
self._statement = statement
|
|
306
|
+
self._parameters: dict[str, Any] = {}
|
|
307
|
+
|
|
308
|
+
self._statement_sql = self._resolve_statement_sql(statement)
|
|
309
|
+
|
|
310
|
+
def _resolve_statement_sql(self, statement: "str | exp.Expression | SQL | SQLBuilderProtocol") -> str:
|
|
311
|
+
"""Resolve statement to SQL string.
|
|
312
|
+
|
|
313
|
+
Args:
|
|
314
|
+
statement: The statement to resolve
|
|
315
|
+
|
|
316
|
+
Returns:
|
|
317
|
+
SQL string representation of the statement
|
|
318
|
+
"""
|
|
319
|
+
if isinstance(statement, str):
|
|
320
|
+
return statement
|
|
321
|
+
|
|
322
|
+
if isinstance(statement, SQL):
|
|
323
|
+
self._parameters.update(statement.named_parameters)
|
|
324
|
+
return statement.raw_sql
|
|
325
|
+
|
|
326
|
+
if is_expression(statement):
|
|
327
|
+
dialect_str = normalize_dialect_name(self._dialect)
|
|
328
|
+
return statement.sql(dialect=dialect_str)
|
|
329
|
+
|
|
330
|
+
if has_parameter_builder(statement):
|
|
331
|
+
safe_query = statement.build(dialect=self._dialect)
|
|
332
|
+
if safe_query.parameters:
|
|
333
|
+
self._parameters.update(safe_query.parameters)
|
|
334
|
+
return str(safe_query.sql)
|
|
335
|
+
|
|
336
|
+
if has_expression_and_sql(statement):
|
|
337
|
+
return statement.sql
|
|
338
|
+
|
|
339
|
+
msg = f"Cannot resolve statement to SQL: {type(statement).__name__}"
|
|
340
|
+
raise SQLBuilderError(msg)
|
|
341
|
+
|
|
342
|
+
def analyze(self, enabled: bool = True) -> Self:
|
|
343
|
+
"""Enable ANALYZE option (execute statement for real statistics).
|
|
344
|
+
|
|
345
|
+
Args:
|
|
346
|
+
enabled: Whether to enable ANALYZE
|
|
347
|
+
|
|
348
|
+
Returns:
|
|
349
|
+
Self for method chaining
|
|
350
|
+
"""
|
|
351
|
+
self._options = self._options.copy(analyze=enabled)
|
|
352
|
+
return self
|
|
353
|
+
|
|
354
|
+
def verbose(self, enabled: bool = True) -> Self:
|
|
355
|
+
"""Enable VERBOSE option (show additional information).
|
|
356
|
+
|
|
357
|
+
Args:
|
|
358
|
+
enabled: Whether to enable VERBOSE
|
|
359
|
+
|
|
360
|
+
Returns:
|
|
361
|
+
Self for method chaining
|
|
362
|
+
"""
|
|
363
|
+
self._options = self._options.copy(verbose=enabled)
|
|
364
|
+
return self
|
|
365
|
+
|
|
366
|
+
def format(self, fmt: "ExplainFormat | str") -> Self:
|
|
367
|
+
"""Set output format.
|
|
368
|
+
|
|
369
|
+
Args:
|
|
370
|
+
fmt: Output format (TEXT, JSON, XML, YAML, TREE, TRADITIONAL)
|
|
371
|
+
|
|
372
|
+
Returns:
|
|
373
|
+
Self for method chaining
|
|
374
|
+
"""
|
|
375
|
+
if isinstance(fmt, str):
|
|
376
|
+
fmt = ExplainFormat(fmt.lower())
|
|
377
|
+
self._options = self._options.copy(format=fmt)
|
|
378
|
+
return self
|
|
379
|
+
|
|
380
|
+
def costs(self, enabled: bool = True) -> Self:
|
|
381
|
+
"""Enable COSTS option (show estimated costs).
|
|
382
|
+
|
|
383
|
+
Args:
|
|
384
|
+
enabled: Whether to show costs
|
|
385
|
+
|
|
386
|
+
Returns:
|
|
387
|
+
Self for method chaining
|
|
388
|
+
"""
|
|
389
|
+
self._options = self._options.copy(costs=enabled)
|
|
390
|
+
return self
|
|
391
|
+
|
|
392
|
+
def buffers(self, enabled: bool = True) -> Self:
|
|
393
|
+
"""Enable BUFFERS option (show buffer usage).
|
|
394
|
+
|
|
395
|
+
Args:
|
|
396
|
+
enabled: Whether to show buffer usage
|
|
397
|
+
|
|
398
|
+
Returns:
|
|
399
|
+
Self for method chaining
|
|
400
|
+
"""
|
|
401
|
+
self._options = self._options.copy(buffers=enabled)
|
|
402
|
+
return self
|
|
403
|
+
|
|
404
|
+
def timing(self, enabled: bool = True) -> Self:
|
|
405
|
+
"""Enable TIMING option (show actual timing).
|
|
406
|
+
|
|
407
|
+
Args:
|
|
408
|
+
enabled: Whether to show timing
|
|
409
|
+
|
|
410
|
+
Returns:
|
|
411
|
+
Self for method chaining
|
|
412
|
+
"""
|
|
413
|
+
self._options = self._options.copy(timing=enabled)
|
|
414
|
+
return self
|
|
415
|
+
|
|
416
|
+
def summary(self, enabled: bool = True) -> Self:
|
|
417
|
+
"""Enable SUMMARY option (show summary information).
|
|
418
|
+
|
|
419
|
+
Args:
|
|
420
|
+
enabled: Whether to show summary
|
|
421
|
+
|
|
422
|
+
Returns:
|
|
423
|
+
Self for method chaining
|
|
424
|
+
"""
|
|
425
|
+
self._options = self._options.copy(summary=enabled)
|
|
426
|
+
return self
|
|
427
|
+
|
|
428
|
+
def memory(self, enabled: bool = True) -> Self:
|
|
429
|
+
"""Enable MEMORY option (show memory usage, PostgreSQL 17+).
|
|
430
|
+
|
|
431
|
+
Args:
|
|
432
|
+
enabled: Whether to show memory usage
|
|
433
|
+
|
|
434
|
+
Returns:
|
|
435
|
+
Self for method chaining
|
|
436
|
+
"""
|
|
437
|
+
self._options = self._options.copy(memory=enabled)
|
|
438
|
+
return self
|
|
439
|
+
|
|
440
|
+
def settings(self, enabled: bool = True) -> Self:
|
|
441
|
+
"""Enable SETTINGS option (show configuration parameters, PostgreSQL 12+).
|
|
442
|
+
|
|
443
|
+
Args:
|
|
444
|
+
enabled: Whether to show settings
|
|
445
|
+
|
|
446
|
+
Returns:
|
|
447
|
+
Self for method chaining
|
|
448
|
+
"""
|
|
449
|
+
self._options = self._options.copy(settings=enabled)
|
|
450
|
+
return self
|
|
451
|
+
|
|
452
|
+
def wal(self, enabled: bool = True) -> Self:
|
|
453
|
+
"""Enable WAL option (show WAL usage, PostgreSQL 13+).
|
|
454
|
+
|
|
455
|
+
Args:
|
|
456
|
+
enabled: Whether to show WAL usage
|
|
457
|
+
|
|
458
|
+
Returns:
|
|
459
|
+
Self for method chaining
|
|
460
|
+
"""
|
|
461
|
+
self._options = self._options.copy(wal=enabled)
|
|
462
|
+
return self
|
|
463
|
+
|
|
464
|
+
def generic_plan(self, enabled: bool = True) -> Self:
|
|
465
|
+
"""Enable GENERIC_PLAN option (ignore parameter values, PostgreSQL 16+).
|
|
466
|
+
|
|
467
|
+
Args:
|
|
468
|
+
enabled: Whether to use generic plan
|
|
469
|
+
|
|
470
|
+
Returns:
|
|
471
|
+
Self for method chaining
|
|
472
|
+
"""
|
|
473
|
+
self._options = self._options.copy(generic_plan=enabled)
|
|
474
|
+
return self
|
|
475
|
+
|
|
476
|
+
def with_options(self, options: "ExplainOptions") -> Self:
|
|
477
|
+
"""Replace all options with the provided ExplainOptions.
|
|
478
|
+
|
|
479
|
+
Args:
|
|
480
|
+
options: New options to use
|
|
481
|
+
|
|
482
|
+
Returns:
|
|
483
|
+
Self for method chaining
|
|
484
|
+
"""
|
|
485
|
+
self._options = options
|
|
486
|
+
return self
|
|
487
|
+
|
|
488
|
+
@property
|
|
489
|
+
def options(self) -> "ExplainOptions":
|
|
490
|
+
"""Get current ExplainOptions."""
|
|
491
|
+
return self._options
|
|
492
|
+
|
|
493
|
+
@property
|
|
494
|
+
def dialect(self) -> "DialectType | None":
|
|
495
|
+
"""Get current dialect."""
|
|
496
|
+
return self._dialect
|
|
497
|
+
|
|
498
|
+
@property
|
|
499
|
+
def parameters(self) -> dict[str, Any]:
|
|
500
|
+
"""Get parameters from the underlying statement."""
|
|
501
|
+
return self._parameters.copy()
|
|
502
|
+
|
|
503
|
+
def build(self, dialect: "DialectType | None" = None) -> "SQL":
|
|
504
|
+
"""Build the EXPLAIN statement as a SQL object.
|
|
505
|
+
|
|
506
|
+
Args:
|
|
507
|
+
dialect: Optional dialect override
|
|
508
|
+
|
|
509
|
+
Returns:
|
|
510
|
+
SQL object containing the EXPLAIN statement
|
|
511
|
+
"""
|
|
512
|
+
target_dialect = dialect or self._dialect
|
|
513
|
+
explain_sql = build_explain_sql(self._statement_sql, self._options, target_dialect)
|
|
514
|
+
statement_config = StatementConfig(dialect=target_dialect) if target_dialect is not None else None
|
|
515
|
+
|
|
516
|
+
if self._parameters:
|
|
517
|
+
if statement_config is None:
|
|
518
|
+
return SQL(explain_sql, self._parameters)
|
|
519
|
+
return SQL(explain_sql, self._parameters, statement_config=statement_config)
|
|
520
|
+
if statement_config is None:
|
|
521
|
+
return SQL(explain_sql)
|
|
522
|
+
return SQL(explain_sql, statement_config=statement_config)
|
|
523
|
+
|
|
524
|
+
def to_sql(self, dialect: "DialectType | None" = None) -> str:
|
|
525
|
+
"""Build and return just the SQL string.
|
|
526
|
+
|
|
527
|
+
Args:
|
|
528
|
+
dialect: Optional dialect override
|
|
529
|
+
|
|
530
|
+
Returns:
|
|
531
|
+
EXPLAIN SQL string
|
|
532
|
+
"""
|
|
533
|
+
target_dialect = dialect or self._dialect
|
|
534
|
+
return build_explain_sql(self._statement_sql, self._options, target_dialect)
|
|
535
|
+
|
|
536
|
+
def __repr__(self) -> str:
|
|
537
|
+
"""String representation."""
|
|
538
|
+
return f"Explain({self._statement_sql!r}, dialect={self._dialect!r}, options={self._options!r})"
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
@trait
|
|
542
|
+
class ExplainMixin:
|
|
543
|
+
"""Mixin to add .explain() method to QueryBuilder subclasses.
|
|
544
|
+
|
|
545
|
+
This mixin can be added to any QueryBuilder subclass to provide
|
|
546
|
+
EXPLAIN plan functionality.
|
|
547
|
+
|
|
548
|
+
Examples:
|
|
549
|
+
class Select(QueryBuilder, ExplainMixin):
|
|
550
|
+
pass
|
|
551
|
+
|
|
552
|
+
query = Select().select("*").from_("users")
|
|
553
|
+
explain = query.explain().analyze().format("json").build()
|
|
554
|
+
"""
|
|
555
|
+
|
|
556
|
+
__slots__ = ()
|
|
557
|
+
|
|
558
|
+
dialect: "DialectType | None"
|
|
559
|
+
|
|
560
|
+
def explain(
|
|
561
|
+
self, analyze: bool = False, verbose: bool = False, format: "ExplainFormat | str | None" = None
|
|
562
|
+
) -> "Explain":
|
|
563
|
+
"""Create an EXPLAIN builder for this query.
|
|
564
|
+
|
|
565
|
+
Args:
|
|
566
|
+
analyze: Execute the statement for real statistics
|
|
567
|
+
verbose: Show additional information
|
|
568
|
+
format: Output format (TEXT, JSON, XML, YAML, TREE)
|
|
569
|
+
|
|
570
|
+
Returns:
|
|
571
|
+
Explain builder for further configuration
|
|
572
|
+
"""
|
|
573
|
+
fmt = None
|
|
574
|
+
if format is not None:
|
|
575
|
+
fmt = ExplainFormat(format.lower()) if isinstance(format, str) else format
|
|
576
|
+
|
|
577
|
+
options = ExplainOptions(analyze=analyze, verbose=verbose, format=fmt)
|
|
578
|
+
|
|
579
|
+
return Explain(self, dialect=self.dialect, options=options) # type: ignore[arg-type]
|
|
Binary file
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Expression wrapper classes for proper type annotations."""
|
|
2
|
+
|
|
3
|
+
from typing import cast
|
|
4
|
+
|
|
5
|
+
from sqlglot import exp
|
|
6
|
+
|
|
7
|
+
__all__ = ("AggregateExpression", "ConversionExpression", "FunctionExpression", "MathExpression", "StringExpression")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ExpressionWrapper:
|
|
11
|
+
"""Base wrapper for SQLGlot expressions."""
|
|
12
|
+
|
|
13
|
+
def __init__(self, expression: exp.Expression) -> None:
|
|
14
|
+
self._expression = expression
|
|
15
|
+
|
|
16
|
+
def as_(self, alias: str) -> exp.Alias:
|
|
17
|
+
"""Create an aliased expression."""
|
|
18
|
+
return cast("exp.Alias", exp.alias_(self._expression, alias))
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def expression(self) -> exp.Expression:
|
|
22
|
+
"""Get the underlying SQLGlot expression."""
|
|
23
|
+
return self._expression
|
|
24
|
+
|
|
25
|
+
def __str__(self) -> str:
|
|
26
|
+
return str(self._expression)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class AggregateExpression(ExpressionWrapper):
|
|
30
|
+
"""Aggregate functions like COUNT, SUM, AVG."""
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class FunctionExpression(ExpressionWrapper):
|
|
34
|
+
"""General SQL functions."""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class MathExpression(ExpressionWrapper):
|
|
38
|
+
"""Mathematical functions like ROUND."""
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class StringExpression(ExpressionWrapper):
|
|
42
|
+
"""String functions like UPPER, LOWER, LENGTH."""
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class ConversionExpression(ExpressionWrapper):
|
|
46
|
+
"""Conversion functions like CAST, COALESCE."""
|
|
Binary file
|