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
|
Binary file
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"""Temporal query expressions.
|
|
2
|
+
|
|
3
|
+
Overrides sqlglot's built-in version_sql generators to produce dialect-specific
|
|
4
|
+
time-travel query syntax. Uses sqlglot's exp.Version and Table.version slot.
|
|
5
|
+
|
|
6
|
+
Supported syntax by dialect:
|
|
7
|
+
- BigQuery: table FOR SYSTEM_TIME AS OF timestamp (built-in)
|
|
8
|
+
- Oracle: table AS OF TIMESTAMP timestamp / AS OF SCN scn
|
|
9
|
+
- Snowflake: table AT (TIMESTAMP => timestamp) / BEFORE (...)
|
|
10
|
+
- DuckDB: table AT (TIMESTAMP => timestamp)
|
|
11
|
+
- CockroachDB (Postgres): table AS OF SYSTEM TIME timestamp
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from sqlglot import exp
|
|
15
|
+
from sqlglot.dialects.duckdb import DuckDB
|
|
16
|
+
from sqlglot.dialects.oracle import Oracle
|
|
17
|
+
from sqlglot.dialects.postgres import Postgres
|
|
18
|
+
from sqlglot.dialects.snowflake import Snowflake
|
|
19
|
+
from sqlglot.generator import Generator
|
|
20
|
+
|
|
21
|
+
__all__ = ("create_temporal_table", "register_version_generators")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _oracle_version_sql(self: "Oracle.Generator", expression: exp.Version) -> str:
|
|
25
|
+
"""Oracle: AS OF TIMESTAMP timestamp or AS OF SCN scn."""
|
|
26
|
+
expr = self.sql(expression, "expression")
|
|
27
|
+
this = expression.name or "TIMESTAMP"
|
|
28
|
+
return f"AS OF {this} {expr}"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _snowflake_version_sql(self: "Snowflake.Generator", expression: exp.Version) -> str:
|
|
32
|
+
"""Snowflake: AT (TIMESTAMP => timestamp) or BEFORE (TIMESTAMP => ...).
|
|
33
|
+
|
|
34
|
+
AS OF is mapped to AT, and BEFORE is supported for point-before queries.
|
|
35
|
+
"""
|
|
36
|
+
kind = expression.text("kind")
|
|
37
|
+
expr = self.sql(expression, "expression")
|
|
38
|
+
this = expression.name or "TIMESTAMP"
|
|
39
|
+
if kind and "BEFORE" in kind.upper():
|
|
40
|
+
return f"BEFORE ({this} => {expr})"
|
|
41
|
+
return f"AT ({this} => {expr})"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _duckdb_version_sql(self: "DuckDB.Generator", expression: exp.Version) -> str:
|
|
45
|
+
"""DuckDB: AT (TIMESTAMP => timestamp)."""
|
|
46
|
+
expr = self.sql(expression, "expression")
|
|
47
|
+
return f"AT (TIMESTAMP => {expr})"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _cockroachdb_version_sql(self: "Postgres.Generator", expression: exp.Version) -> str:
|
|
51
|
+
"""CockroachDB (via Postgres dialect): AS OF SYSTEM TIME timestamp."""
|
|
52
|
+
expr = self.sql(expression, "expression")
|
|
53
|
+
return f"AS OF SYSTEM TIME {expr}"
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _default_version_sql(self: "Generator", expression: exp.Version) -> str:
|
|
57
|
+
"""Default: AS OF SYSTEM TIME timestamp (CockroachDB style).
|
|
58
|
+
|
|
59
|
+
When no dialect is specified, we default to CockroachDB/Postgres style
|
|
60
|
+
which is commonly expected for time-travel queries.
|
|
61
|
+
"""
|
|
62
|
+
expr = self.sql(expression, "expression")
|
|
63
|
+
return f"AS OF SYSTEM TIME {expr}"
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def create_temporal_table(
|
|
67
|
+
table: "str | exp.Table | exp.Expression", as_of: "exp.Expression | str", kind: "str | None" = None
|
|
68
|
+
) -> exp.Table:
|
|
69
|
+
"""Create a table expression with temporal (time-travel) version clause.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
table: Table name or expression.
|
|
73
|
+
as_of: Timestamp or SCN expression for the point-in-time.
|
|
74
|
+
kind: Optional version kind (e.g., "TIMESTAMP", "SCN", "SYSTEM TIME").
|
|
75
|
+
Defaults to dialect-appropriate value.
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
Table expression with version clause that generates dialect-specific SQL.
|
|
79
|
+
|
|
80
|
+
Notes:
|
|
81
|
+
Inputs are normalized before building the ``exp.Version`` clause so both string table names and literal timestamps
|
|
82
|
+
work consistently.
|
|
83
|
+
|
|
84
|
+
Example:
|
|
85
|
+
>>> from sqlspec.builder import create_temporal_table
|
|
86
|
+
>>> from sqlglot import exp
|
|
87
|
+
>>> t = create_temporal_table(
|
|
88
|
+
... "orders", exp.Literal.string("2024-01-01")
|
|
89
|
+
... )
|
|
90
|
+
>>> t.sql(dialect="oracle")
|
|
91
|
+
"orders AS OF TIMESTAMP '2024-01-01'"
|
|
92
|
+
>>> t.sql(dialect="bigquery")
|
|
93
|
+
"orders FOR SYSTEM_TIME AS OF '2024-01-01'"
|
|
94
|
+
"""
|
|
95
|
+
if isinstance(table, str):
|
|
96
|
+
table_expr = exp.to_table(table)
|
|
97
|
+
elif isinstance(table, exp.Table):
|
|
98
|
+
table_expr = table.copy()
|
|
99
|
+
else:
|
|
100
|
+
table_expr = exp.to_table(str(table))
|
|
101
|
+
|
|
102
|
+
as_of_expr = exp.Literal.string(as_of) if isinstance(as_of, str) else as_of
|
|
103
|
+
|
|
104
|
+
version = exp.Version(this=kind or "TIMESTAMP", kind="AS OF", expression=as_of_expr)
|
|
105
|
+
|
|
106
|
+
table_expr.set("version", version)
|
|
107
|
+
return table_expr
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
_VERSION_GENERATORS_REGISTERED = False
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def register_version_generators() -> None:
|
|
114
|
+
"""Register dialect-specific version_sql generators.
|
|
115
|
+
|
|
116
|
+
This function is idempotent - calling it multiple times has no effect
|
|
117
|
+
after the first call. It is called automatically when the builder
|
|
118
|
+
module is imported.
|
|
119
|
+
|
|
120
|
+
Registers custom SQL generators for temporal (time-travel) queries:
|
|
121
|
+
- Default (no dialect): AS OF SYSTEM TIME (CockroachDB style)
|
|
122
|
+
- Oracle: AS OF TIMESTAMP / AS OF SCN
|
|
123
|
+
- Snowflake: AT (TIMESTAMP => ...) / BEFORE (...)
|
|
124
|
+
- DuckDB: AT (TIMESTAMP => ...)
|
|
125
|
+
- Postgres/CockroachDB: AS OF SYSTEM TIME
|
|
126
|
+
- BigQuery: Uses built-in FOR SYSTEM_TIME AS OF
|
|
127
|
+
"""
|
|
128
|
+
global _VERSION_GENERATORS_REGISTERED
|
|
129
|
+
if _VERSION_GENERATORS_REGISTERED:
|
|
130
|
+
return
|
|
131
|
+
|
|
132
|
+
Generator.TRANSFORMS[exp.Version] = _default_version_sql
|
|
133
|
+
|
|
134
|
+
Oracle.Generator.TRANSFORMS[exp.Version] = _oracle_version_sql
|
|
135
|
+
Snowflake.Generator.TRANSFORMS[exp.Version] = _snowflake_version_sql
|
|
136
|
+
DuckDB.Generator.TRANSFORMS[exp.Version] = _duckdb_version_sql
|
|
137
|
+
Postgres.Generator.TRANSFORMS[exp.Version] = _cockroachdb_version_sql
|
|
138
|
+
|
|
139
|
+
_VERSION_GENERATORS_REGISTERED = True
|
|
Binary file
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"""UPDATE statement builder.
|
|
2
|
+
|
|
3
|
+
Provides a fluent interface for building SQL UPDATE queries with
|
|
4
|
+
parameter binding and validation.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import TYPE_CHECKING, Any, cast
|
|
8
|
+
|
|
9
|
+
from sqlglot import exp
|
|
10
|
+
from typing_extensions import Self
|
|
11
|
+
|
|
12
|
+
from sqlspec.builder._base import BuiltQuery, QueryBuilder
|
|
13
|
+
from sqlspec.builder._dml import UpdateFromClauseMixin, UpdateSetClauseMixin, UpdateTableClauseMixin
|
|
14
|
+
from sqlspec.builder._explain import ExplainMixin
|
|
15
|
+
from sqlspec.builder._join import build_join_clause
|
|
16
|
+
from sqlspec.builder._select import ReturningClauseMixin, WhereClauseMixin
|
|
17
|
+
from sqlspec.core import SQLResult
|
|
18
|
+
from sqlspec.exceptions import SQLBuilderError
|
|
19
|
+
|
|
20
|
+
if TYPE_CHECKING:
|
|
21
|
+
from sqlglot.dialects.dialect import DialectType
|
|
22
|
+
|
|
23
|
+
from sqlspec.builder._select import Select
|
|
24
|
+
from sqlspec.protocols import SQLBuilderProtocol
|
|
25
|
+
|
|
26
|
+
__all__ = ("Update",)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Update(
|
|
30
|
+
QueryBuilder,
|
|
31
|
+
WhereClauseMixin,
|
|
32
|
+
ReturningClauseMixin,
|
|
33
|
+
UpdateSetClauseMixin,
|
|
34
|
+
UpdateFromClauseMixin,
|
|
35
|
+
UpdateTableClauseMixin,
|
|
36
|
+
ExplainMixin,
|
|
37
|
+
):
|
|
38
|
+
"""Builder for UPDATE statements.
|
|
39
|
+
|
|
40
|
+
Constructs SQL UPDATE statements with parameter binding and validation.
|
|
41
|
+
|
|
42
|
+
Example:
|
|
43
|
+
```python
|
|
44
|
+
update_query = (
|
|
45
|
+
Update()
|
|
46
|
+
.table("users")
|
|
47
|
+
.set_(name="John Doe")
|
|
48
|
+
.set_(email="john@example.com")
|
|
49
|
+
.where("id = 1")
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
update_query = (
|
|
53
|
+
Update("users").set_(name="John Doe").where("id = 1")
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
update_query = (
|
|
57
|
+
Update()
|
|
58
|
+
.table("users")
|
|
59
|
+
.set_(status="active")
|
|
60
|
+
.where_eq("id", 123)
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
update_query = (
|
|
64
|
+
Update()
|
|
65
|
+
.table("users", "u")
|
|
66
|
+
.set_(name="Updated Name")
|
|
67
|
+
.from_("profiles", "p")
|
|
68
|
+
.where("u.id = p.user_id AND p.is_verified = true")
|
|
69
|
+
)
|
|
70
|
+
```
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
__slots__ = ()
|
|
74
|
+
_expression: exp.Expression | None
|
|
75
|
+
|
|
76
|
+
def __init__(self, table: str | None = None, **kwargs: Any) -> None:
|
|
77
|
+
"""Initialize UPDATE with optional table.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
table: Target table name
|
|
81
|
+
**kwargs: Additional QueryBuilder arguments
|
|
82
|
+
"""
|
|
83
|
+
(dialect, schema, enable_optimization, optimize_joins, optimize_predicates, simplify_expressions) = (
|
|
84
|
+
self._parse_query_builder_kwargs(kwargs)
|
|
85
|
+
)
|
|
86
|
+
super().__init__(
|
|
87
|
+
dialect=dialect,
|
|
88
|
+
schema=schema,
|
|
89
|
+
enable_optimization=enable_optimization,
|
|
90
|
+
optimize_joins=optimize_joins,
|
|
91
|
+
optimize_predicates=optimize_predicates,
|
|
92
|
+
simplify_expressions=simplify_expressions,
|
|
93
|
+
)
|
|
94
|
+
self._initialize_expression()
|
|
95
|
+
|
|
96
|
+
if table:
|
|
97
|
+
self.table(table)
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
def _expected_result_type(self) -> "type[SQLResult]":
|
|
101
|
+
"""Return the expected result type for this builder."""
|
|
102
|
+
return SQLResult
|
|
103
|
+
|
|
104
|
+
def _create_base_expression(self) -> exp.Update:
|
|
105
|
+
"""Create a base UPDATE expression.
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
A new sqlglot Update expression with empty clauses.
|
|
109
|
+
"""
|
|
110
|
+
return exp.Update(this=None, expressions=[], joins=[])
|
|
111
|
+
|
|
112
|
+
def join(
|
|
113
|
+
self,
|
|
114
|
+
table: "str | exp.Expression | Select",
|
|
115
|
+
on: "str | exp.Expression",
|
|
116
|
+
alias: "str | None" = None,
|
|
117
|
+
join_type: str = "INNER",
|
|
118
|
+
) -> "Self":
|
|
119
|
+
"""Add JOIN clause to the UPDATE statement.
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
table: The table name, expression, or subquery to join.
|
|
123
|
+
on: The JOIN condition.
|
|
124
|
+
alias: Optional alias for the joined table.
|
|
125
|
+
join_type: Type of join (INNER, LEFT, RIGHT, FULL).
|
|
126
|
+
|
|
127
|
+
Returns:
|
|
128
|
+
The current builder instance for method chaining.
|
|
129
|
+
|
|
130
|
+
Raises:
|
|
131
|
+
SQLBuilderError: If the current expression is not an UPDATE statement.
|
|
132
|
+
"""
|
|
133
|
+
if self._expression is None or not isinstance(self._expression, exp.Update):
|
|
134
|
+
msg = "Cannot add JOIN clause to non-UPDATE expression."
|
|
135
|
+
raise SQLBuilderError(msg)
|
|
136
|
+
|
|
137
|
+
join_expr = build_join_clause(cast("SQLBuilderProtocol", self), table, on, alias, join_type)
|
|
138
|
+
|
|
139
|
+
if not self._expression.args.get("joins"):
|
|
140
|
+
self._expression.set("joins", [])
|
|
141
|
+
self._expression.args["joins"].append(join_expr)
|
|
142
|
+
|
|
143
|
+
return self
|
|
144
|
+
|
|
145
|
+
def build(self, dialect: "DialectType" = None) -> "BuiltQuery":
|
|
146
|
+
"""Build the UPDATE query with validation.
|
|
147
|
+
|
|
148
|
+
Args:
|
|
149
|
+
dialect: Optional dialect override for SQL generation.
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
BuiltQuery: The built query with SQL and parameters.
|
|
153
|
+
|
|
154
|
+
Raises:
|
|
155
|
+
SQLBuilderError: If no table is set or expression is not an UPDATE.
|
|
156
|
+
"""
|
|
157
|
+
if self._expression is None:
|
|
158
|
+
msg = "UPDATE expression not initialized."
|
|
159
|
+
raise SQLBuilderError(msg)
|
|
160
|
+
|
|
161
|
+
if not isinstance(self._expression, exp.Update):
|
|
162
|
+
msg = "No UPDATE expression to build or expression is of the wrong type."
|
|
163
|
+
raise SQLBuilderError(msg)
|
|
164
|
+
|
|
165
|
+
if self._expression.this is None:
|
|
166
|
+
msg = "No table specified for UPDATE statement."
|
|
167
|
+
raise SQLBuilderError(msg)
|
|
168
|
+
|
|
169
|
+
if not self._expression.args.get("expressions"):
|
|
170
|
+
msg = "At least one SET clause must be specified for UPDATE statement."
|
|
171
|
+
raise SQLBuilderError(msg)
|
|
172
|
+
|
|
173
|
+
return super().build(dialect=dialect)
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"""Custom SQLGlot expressions for vector distance operations.
|
|
2
|
+
|
|
3
|
+
Provides dialect-specific SQL generation for vector similarity search
|
|
4
|
+
across PostgreSQL (pgvector), MySQL 9+, Oracle 23ai+, BigQuery, and Spanner.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from contextlib import suppress
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from sqlglot import exp
|
|
11
|
+
from sqlglot.dialects.bigquery import BigQuery
|
|
12
|
+
from sqlglot.dialects.duckdb import DuckDB
|
|
13
|
+
from sqlglot.dialects.mysql import MySQL
|
|
14
|
+
from sqlglot.dialects.oracle import Oracle
|
|
15
|
+
from sqlglot.dialects.postgres import Postgres
|
|
16
|
+
from sqlglot.generator import Generator
|
|
17
|
+
|
|
18
|
+
__all__ = ("VectorDistance",)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class VectorDistance(exp.Expression):
|
|
22
|
+
"""Vector distance expression with dialect-specific generation.
|
|
23
|
+
|
|
24
|
+
Generates database-specific SQL for vector distance calculations:
|
|
25
|
+
- PostgreSQL (pgvector): Operators <->, <=>, <#>
|
|
26
|
+
- MySQL 9+: DISTANCE(col, vec, 'METRIC') function
|
|
27
|
+
- Oracle 23ai+: VECTOR_DISTANCE(col, vec, METRIC) function
|
|
28
|
+
- Generic: VECTOR_DISTANCE(col, vec, 'METRIC') function
|
|
29
|
+
|
|
30
|
+
The metric is stored as a raw string attribute (not parametrized) and drives
|
|
31
|
+
dialect-specific generation at SQL build time.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
arg_types = {"this": True, "expression": True, "metric": False}
|
|
35
|
+
|
|
36
|
+
def __init__(self, **args: Any) -> None:
|
|
37
|
+
"""Initialize VectorDistance with metric stored in args."""
|
|
38
|
+
metric_value = args.get("metric", "euclidean")
|
|
39
|
+
if isinstance(metric_value, exp.Literal):
|
|
40
|
+
metric_value = str(metric_value.this).lower()
|
|
41
|
+
elif isinstance(metric_value, exp.Identifier):
|
|
42
|
+
metric_value = metric_value.this.lower()
|
|
43
|
+
elif isinstance(metric_value, str):
|
|
44
|
+
metric_value = metric_value.lower()
|
|
45
|
+
else:
|
|
46
|
+
metric_value = "euclidean"
|
|
47
|
+
|
|
48
|
+
args["metric"] = exp.Identifier(this=metric_value)
|
|
49
|
+
super().__init__(**args)
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def left(self) -> "exp.Expression":
|
|
53
|
+
"""Get the left operand (column)."""
|
|
54
|
+
result: exp.Expression = self.this
|
|
55
|
+
return result
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def right(self) -> "exp.Expression":
|
|
59
|
+
"""Get the right operand (vector value)."""
|
|
60
|
+
result: exp.Expression = self.expression
|
|
61
|
+
return result
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def metric(self) -> str:
|
|
65
|
+
"""Get the distance metric as raw string (not parametrized)."""
|
|
66
|
+
metric_expr = self.args.get("metric")
|
|
67
|
+
if isinstance(metric_expr, exp.Identifier):
|
|
68
|
+
metric_name: str = metric_expr.this
|
|
69
|
+
return metric_name.lower()
|
|
70
|
+
return "euclidean"
|
|
71
|
+
|
|
72
|
+
def sql(self, dialect: "Any | None" = None, **opts: Any) -> str:
|
|
73
|
+
"""Generate dialect-specific SQL.
|
|
74
|
+
|
|
75
|
+
This overrides the default sql() method to provide custom
|
|
76
|
+
dialect-specific generation for vector distance operations.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
dialect: Target SQL dialect (postgres, mysql, oracle, bigquery, duckdb, etc.)
|
|
80
|
+
**opts: Additional SQL generation options
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
Dialect-specific SQL string
|
|
84
|
+
"""
|
|
85
|
+
dialect_name = str(dialect).lower() if dialect else "generic"
|
|
86
|
+
|
|
87
|
+
left_sql = self.left.sql(dialect=dialect, **opts)
|
|
88
|
+
right_sql = self.right.sql(dialect=dialect, **opts)
|
|
89
|
+
metric = self.metric
|
|
90
|
+
|
|
91
|
+
if dialect_name in {"postgres", "postgresql"}:
|
|
92
|
+
return self._sql_postgres(left_sql, right_sql, metric)
|
|
93
|
+
|
|
94
|
+
if dialect_name == "mysql":
|
|
95
|
+
return self._sql_mysql(left_sql, right_sql, metric)
|
|
96
|
+
|
|
97
|
+
if dialect_name == "oracle":
|
|
98
|
+
return self._sql_oracle(left_sql, right_sql, metric)
|
|
99
|
+
|
|
100
|
+
if dialect_name == "bigquery":
|
|
101
|
+
return self._sql_bigquery(left_sql, right_sql, metric)
|
|
102
|
+
|
|
103
|
+
if dialect_name == "duckdb":
|
|
104
|
+
return self._sql_duckdb(left_sql, right_sql, metric)
|
|
105
|
+
|
|
106
|
+
return self._sql_generic(left_sql, right_sql, metric)
|
|
107
|
+
|
|
108
|
+
def _sql_postgres(self, left: str, right: str, metric: str) -> str:
|
|
109
|
+
"""Generate PostgreSQL pgvector operator syntax."""
|
|
110
|
+
operator_map = {"euclidean": "<->", "cosine": "<=>", "inner_product": "<#>"}
|
|
111
|
+
|
|
112
|
+
operator = operator_map.get(metric)
|
|
113
|
+
if operator:
|
|
114
|
+
return f"{left} {operator} {right}"
|
|
115
|
+
|
|
116
|
+
return self._sql_generic(left, right, metric)
|
|
117
|
+
|
|
118
|
+
def _sql_mysql(self, left: str, right: str, metric: str) -> str:
|
|
119
|
+
"""Generate MySQL DISTANCE function syntax."""
|
|
120
|
+
metric_map = {"euclidean": "EUCLIDEAN", "cosine": "COSINE", "inner_product": "DOT"}
|
|
121
|
+
|
|
122
|
+
mysql_metric = metric_map.get(metric, "EUCLIDEAN")
|
|
123
|
+
|
|
124
|
+
if ("ARRAY" in right or "[" in right) and "STRING_TO_VECTOR" not in right:
|
|
125
|
+
right = f"STRING_TO_VECTOR({right})"
|
|
126
|
+
|
|
127
|
+
return f"DISTANCE({left}, {right}, '{mysql_metric}')"
|
|
128
|
+
|
|
129
|
+
def _sql_oracle(self, left: str, right: str, metric: str) -> str:
|
|
130
|
+
"""Generate Oracle VECTOR_DISTANCE function syntax."""
|
|
131
|
+
metric_map = {
|
|
132
|
+
"euclidean": "EUCLIDEAN",
|
|
133
|
+
"cosine": "COSINE",
|
|
134
|
+
"inner_product": "DOT",
|
|
135
|
+
"euclidean_squared": "EUCLIDEAN_SQUARED",
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
oracle_metric = metric_map.get(metric, "EUCLIDEAN")
|
|
139
|
+
|
|
140
|
+
if isinstance(self.expression, exp.Array):
|
|
141
|
+
values = []
|
|
142
|
+
for expr in self.expression.expressions:
|
|
143
|
+
if isinstance(expr, exp.Literal):
|
|
144
|
+
values.append(str(expr.this))
|
|
145
|
+
else: # pragma: no cover - defensive
|
|
146
|
+
values.append(expr.sql(dialect="oracle"))
|
|
147
|
+
right = f"TO_VECTOR('[{', '.join(values)}]')"
|
|
148
|
+
elif ("ARRAY" in right or "[" in right) and "TO_VECTOR" not in right:
|
|
149
|
+
right = f"TO_VECTOR({right})"
|
|
150
|
+
|
|
151
|
+
return f"VECTOR_DISTANCE({left}, {right}, {oracle_metric})"
|
|
152
|
+
|
|
153
|
+
def _sql_bigquery(self, left: str, right: str, metric: str) -> str:
|
|
154
|
+
"""Generate BigQuery vector distance function syntax."""
|
|
155
|
+
function_map = {"euclidean": "EUCLIDEAN_DISTANCE", "cosine": "COSINE_DISTANCE", "inner_product": "DOT_PRODUCT"}
|
|
156
|
+
|
|
157
|
+
function_name = function_map.get(metric)
|
|
158
|
+
if function_name:
|
|
159
|
+
return f"{function_name}({left}, {right})"
|
|
160
|
+
|
|
161
|
+
return self._sql_generic(left, right, metric)
|
|
162
|
+
|
|
163
|
+
def _sql_duckdb(self, left: str, right: str, metric: str) -> str:
|
|
164
|
+
"""Generate DuckDB VSS extension function syntax.
|
|
165
|
+
|
|
166
|
+
DuckDB's VSS extension provides:
|
|
167
|
+
- array_distance(): L2 squared distance (euclidean)
|
|
168
|
+
- array_cosine_distance(): Cosine distance (1 - cosine_similarity)
|
|
169
|
+
- array_negative_inner_product(): Negative inner product
|
|
170
|
+
|
|
171
|
+
Note: Array literals must be cast to DOUBLE[] since DuckDB infers
|
|
172
|
+
decimal literals as DECIMAL type, but VSS functions require DOUBLE[].
|
|
173
|
+
"""
|
|
174
|
+
function_map = {
|
|
175
|
+
"euclidean": "array_distance",
|
|
176
|
+
"cosine": "array_cosine_distance",
|
|
177
|
+
"inner_product": "array_negative_inner_product",
|
|
178
|
+
}
|
|
179
|
+
target_type = "DOUBLE[]"
|
|
180
|
+
if isinstance(self.expression, exp.Array) and self.expression.expressions:
|
|
181
|
+
target_type = f"DOUBLE[{len(self.expression.expressions)}]"
|
|
182
|
+
|
|
183
|
+
function_name = function_map.get(metric)
|
|
184
|
+
if function_name:
|
|
185
|
+
right_cast = f"CAST({right} AS {target_type})"
|
|
186
|
+
return f"{function_name}({left}, {right_cast})"
|
|
187
|
+
|
|
188
|
+
return self._sql_generic(left, right, metric)
|
|
189
|
+
|
|
190
|
+
def _sql_generic(self, left: str, right: str, metric: str) -> str:
|
|
191
|
+
"""Generate generic VECTOR_DISTANCE function syntax."""
|
|
192
|
+
return f"VECTOR_DISTANCE({left}, {right}, '{metric.upper()}')"
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def _vector_distance_sql_base(generator: "Generator", expression: "VectorDistance") -> str:
|
|
196
|
+
"""Base generator for VectorDistance expressions."""
|
|
197
|
+
return expression._sql_generic( # pyright: ignore[reportPrivateUsage]
|
|
198
|
+
generator.sql(expression.left), generator.sql(expression.right), expression.metric
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def _vector_distance_sql_postgres(generator: "Generator", expression: "VectorDistance") -> str:
|
|
203
|
+
"""PostgreSQL generator for VectorDistance expressions."""
|
|
204
|
+
return expression._sql_postgres( # pyright: ignore[reportPrivateUsage]
|
|
205
|
+
generator.sql(expression.left), generator.sql(expression.right), expression.metric
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def _vector_distance_sql_mysql(generator: "Generator", expression: "VectorDistance") -> str:
|
|
210
|
+
"""MySQL generator for VectorDistance expressions."""
|
|
211
|
+
return expression._sql_mysql( # pyright: ignore[reportPrivateUsage]
|
|
212
|
+
generator.sql(expression.left), generator.sql(expression.right), expression.metric
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def _vector_distance_sql_oracle(generator: "Generator", expression: "VectorDistance") -> str:
|
|
217
|
+
"""Oracle generator for VectorDistance expressions."""
|
|
218
|
+
return expression._sql_oracle( # pyright: ignore[reportPrivateUsage]
|
|
219
|
+
generator.sql(expression.left), generator.sql(expression.right), expression.metric
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def _vector_distance_sql_bigquery(generator: "Generator", expression: "VectorDistance") -> str:
|
|
224
|
+
"""BigQuery generator for VectorDistance expressions."""
|
|
225
|
+
return expression._sql_bigquery( # pyright: ignore[reportPrivateUsage]
|
|
226
|
+
generator.sql(expression.left), generator.sql(expression.right), expression.metric
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def _vector_distance_sql_spanner(generator: "Generator", expression: "VectorDistance") -> str:
|
|
231
|
+
"""Spanner generator for VectorDistance expressions (same as BigQuery)."""
|
|
232
|
+
return expression._sql_bigquery( # pyright: ignore[reportPrivateUsage]
|
|
233
|
+
generator.sql(expression.left), generator.sql(expression.right), expression.metric
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def _vector_distance_sql_duckdb(generator: "Generator", expression: "VectorDistance") -> str:
|
|
238
|
+
"""DuckDB generator for VectorDistance expressions."""
|
|
239
|
+
return expression._sql_duckdb( # pyright: ignore[reportPrivateUsage]
|
|
240
|
+
generator.sql(expression.left), generator.sql(expression.right), expression.metric
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def _register_with_sqlglot() -> None:
|
|
245
|
+
"""Register VectorDistance with SQLGlot's generator dispatch system."""
|
|
246
|
+
spanner_dialect: type | None = None
|
|
247
|
+
spangres_dialect: type | None = None
|
|
248
|
+
with suppress(ImportError):
|
|
249
|
+
from sqlspec.adapters.spanner.dialect import Spangres, Spanner
|
|
250
|
+
|
|
251
|
+
spanner_dialect = Spanner
|
|
252
|
+
spangres_dialect = Spangres
|
|
253
|
+
|
|
254
|
+
Generator.TRANSFORMS[VectorDistance] = _vector_distance_sql_base
|
|
255
|
+
|
|
256
|
+
Postgres.Generator.TRANSFORMS[VectorDistance] = _vector_distance_sql_postgres
|
|
257
|
+
MySQL.Generator.TRANSFORMS[VectorDistance] = _vector_distance_sql_mysql
|
|
258
|
+
Oracle.Generator.TRANSFORMS[VectorDistance] = _vector_distance_sql_oracle
|
|
259
|
+
BigQuery.Generator.TRANSFORMS[VectorDistance] = _vector_distance_sql_bigquery
|
|
260
|
+
DuckDB.Generator.TRANSFORMS[VectorDistance] = _vector_distance_sql_duckdb
|
|
261
|
+
if spanner_dialect is not None:
|
|
262
|
+
spanner_dialect.Generator.TRANSFORMS[VectorDistance] = _vector_distance_sql_spanner # type: ignore[attr-defined]
|
|
263
|
+
if spangres_dialect is not None:
|
|
264
|
+
spangres_dialect.Generator.TRANSFORMS[VectorDistance] = _vector_distance_sql_postgres # type: ignore[attr-defined]
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
_register_with_sqlglot()
|