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.
Files changed (531) hide show
  1. ac8f31065839703b4e70__mypyc.cpython-310-aarch64-linux-gnu.so +0 -0
  2. sqlspec/__init__.py +140 -0
  3. sqlspec/__main__.py +12 -0
  4. sqlspec/__metadata__.py +14 -0
  5. sqlspec/_serialization.py +315 -0
  6. sqlspec/_typing.py +700 -0
  7. sqlspec/adapters/__init__.py +0 -0
  8. sqlspec/adapters/adbc/__init__.py +5 -0
  9. sqlspec/adapters/adbc/_typing.py +82 -0
  10. sqlspec/adapters/adbc/adk/__init__.py +5 -0
  11. sqlspec/adapters/adbc/adk/store.py +1273 -0
  12. sqlspec/adapters/adbc/config.py +295 -0
  13. sqlspec/adapters/adbc/core.cpython-310-aarch64-linux-gnu.so +0 -0
  14. sqlspec/adapters/adbc/core.py +735 -0
  15. sqlspec/adapters/adbc/data_dictionary.py +334 -0
  16. sqlspec/adapters/adbc/driver.py +529 -0
  17. sqlspec/adapters/adbc/events/__init__.py +5 -0
  18. sqlspec/adapters/adbc/events/store.py +285 -0
  19. sqlspec/adapters/adbc/litestar/__init__.py +5 -0
  20. sqlspec/adapters/adbc/litestar/store.py +502 -0
  21. sqlspec/adapters/adbc/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
  22. sqlspec/adapters/adbc/type_converter.py +140 -0
  23. sqlspec/adapters/aiosqlite/__init__.py +25 -0
  24. sqlspec/adapters/aiosqlite/_typing.py +82 -0
  25. sqlspec/adapters/aiosqlite/adk/__init__.py +5 -0
  26. sqlspec/adapters/aiosqlite/adk/store.py +818 -0
  27. sqlspec/adapters/aiosqlite/config.py +334 -0
  28. sqlspec/adapters/aiosqlite/core.cpython-310-aarch64-linux-gnu.so +0 -0
  29. sqlspec/adapters/aiosqlite/core.py +315 -0
  30. sqlspec/adapters/aiosqlite/data_dictionary.py +208 -0
  31. sqlspec/adapters/aiosqlite/driver.py +313 -0
  32. sqlspec/adapters/aiosqlite/events/__init__.py +5 -0
  33. sqlspec/adapters/aiosqlite/events/store.py +20 -0
  34. sqlspec/adapters/aiosqlite/litestar/__init__.py +5 -0
  35. sqlspec/adapters/aiosqlite/litestar/store.py +279 -0
  36. sqlspec/adapters/aiosqlite/pool.py +533 -0
  37. sqlspec/adapters/asyncmy/__init__.py +21 -0
  38. sqlspec/adapters/asyncmy/_typing.py +87 -0
  39. sqlspec/adapters/asyncmy/adk/__init__.py +5 -0
  40. sqlspec/adapters/asyncmy/adk/store.py +703 -0
  41. sqlspec/adapters/asyncmy/config.py +302 -0
  42. sqlspec/adapters/asyncmy/core.cpython-310-aarch64-linux-gnu.so +0 -0
  43. sqlspec/adapters/asyncmy/core.py +360 -0
  44. sqlspec/adapters/asyncmy/data_dictionary.py +124 -0
  45. sqlspec/adapters/asyncmy/driver.py +383 -0
  46. sqlspec/adapters/asyncmy/events/__init__.py +5 -0
  47. sqlspec/adapters/asyncmy/events/store.py +104 -0
  48. sqlspec/adapters/asyncmy/litestar/__init__.py +5 -0
  49. sqlspec/adapters/asyncmy/litestar/store.py +296 -0
  50. sqlspec/adapters/asyncpg/__init__.py +19 -0
  51. sqlspec/adapters/asyncpg/_typing.py +88 -0
  52. sqlspec/adapters/asyncpg/adk/__init__.py +5 -0
  53. sqlspec/adapters/asyncpg/adk/store.py +748 -0
  54. sqlspec/adapters/asyncpg/config.py +569 -0
  55. sqlspec/adapters/asyncpg/core.cpython-310-aarch64-linux-gnu.so +0 -0
  56. sqlspec/adapters/asyncpg/core.py +367 -0
  57. sqlspec/adapters/asyncpg/data_dictionary.py +162 -0
  58. sqlspec/adapters/asyncpg/driver.py +487 -0
  59. sqlspec/adapters/asyncpg/events/__init__.py +6 -0
  60. sqlspec/adapters/asyncpg/events/backend.py +286 -0
  61. sqlspec/adapters/asyncpg/events/store.py +40 -0
  62. sqlspec/adapters/asyncpg/litestar/__init__.py +5 -0
  63. sqlspec/adapters/asyncpg/litestar/store.py +251 -0
  64. sqlspec/adapters/bigquery/__init__.py +14 -0
  65. sqlspec/adapters/bigquery/_typing.py +86 -0
  66. sqlspec/adapters/bigquery/adk/__init__.py +5 -0
  67. sqlspec/adapters/bigquery/adk/store.py +827 -0
  68. sqlspec/adapters/bigquery/config.py +353 -0
  69. sqlspec/adapters/bigquery/core.cpython-310-aarch64-linux-gnu.so +0 -0
  70. sqlspec/adapters/bigquery/core.py +715 -0
  71. sqlspec/adapters/bigquery/data_dictionary.py +128 -0
  72. sqlspec/adapters/bigquery/driver.py +548 -0
  73. sqlspec/adapters/bigquery/events/__init__.py +5 -0
  74. sqlspec/adapters/bigquery/events/store.py +139 -0
  75. sqlspec/adapters/bigquery/litestar/__init__.py +5 -0
  76. sqlspec/adapters/bigquery/litestar/store.py +325 -0
  77. sqlspec/adapters/bigquery/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
  78. sqlspec/adapters/bigquery/type_converter.py +107 -0
  79. sqlspec/adapters/cockroach_asyncpg/__init__.py +24 -0
  80. sqlspec/adapters/cockroach_asyncpg/_typing.py +72 -0
  81. sqlspec/adapters/cockroach_asyncpg/adk/__init__.py +3 -0
  82. sqlspec/adapters/cockroach_asyncpg/adk/store.py +410 -0
  83. sqlspec/adapters/cockroach_asyncpg/config.py +238 -0
  84. sqlspec/adapters/cockroach_asyncpg/core.cpython-310-aarch64-linux-gnu.so +0 -0
  85. sqlspec/adapters/cockroach_asyncpg/core.py +55 -0
  86. sqlspec/adapters/cockroach_asyncpg/data_dictionary.py +107 -0
  87. sqlspec/adapters/cockroach_asyncpg/driver.py +144 -0
  88. sqlspec/adapters/cockroach_asyncpg/events/__init__.py +3 -0
  89. sqlspec/adapters/cockroach_asyncpg/events/store.py +20 -0
  90. sqlspec/adapters/cockroach_asyncpg/litestar/__init__.py +3 -0
  91. sqlspec/adapters/cockroach_asyncpg/litestar/store.py +142 -0
  92. sqlspec/adapters/cockroach_psycopg/__init__.py +38 -0
  93. sqlspec/adapters/cockroach_psycopg/_typing.py +129 -0
  94. sqlspec/adapters/cockroach_psycopg/adk/__init__.py +13 -0
  95. sqlspec/adapters/cockroach_psycopg/adk/store.py +868 -0
  96. sqlspec/adapters/cockroach_psycopg/config.py +484 -0
  97. sqlspec/adapters/cockroach_psycopg/core.cpython-310-aarch64-linux-gnu.so +0 -0
  98. sqlspec/adapters/cockroach_psycopg/core.py +63 -0
  99. sqlspec/adapters/cockroach_psycopg/data_dictionary.py +215 -0
  100. sqlspec/adapters/cockroach_psycopg/driver.py +284 -0
  101. sqlspec/adapters/cockroach_psycopg/events/__init__.py +6 -0
  102. sqlspec/adapters/cockroach_psycopg/events/store.py +34 -0
  103. sqlspec/adapters/cockroach_psycopg/litestar/__init__.py +3 -0
  104. sqlspec/adapters/cockroach_psycopg/litestar/store.py +325 -0
  105. sqlspec/adapters/duckdb/__init__.py +25 -0
  106. sqlspec/adapters/duckdb/_typing.py +81 -0
  107. sqlspec/adapters/duckdb/adk/__init__.py +14 -0
  108. sqlspec/adapters/duckdb/adk/store.py +850 -0
  109. sqlspec/adapters/duckdb/config.py +463 -0
  110. sqlspec/adapters/duckdb/core.cpython-310-aarch64-linux-gnu.so +0 -0
  111. sqlspec/adapters/duckdb/core.py +257 -0
  112. sqlspec/adapters/duckdb/data_dictionary.py +140 -0
  113. sqlspec/adapters/duckdb/driver.py +430 -0
  114. sqlspec/adapters/duckdb/events/__init__.py +5 -0
  115. sqlspec/adapters/duckdb/events/store.py +57 -0
  116. sqlspec/adapters/duckdb/litestar/__init__.py +5 -0
  117. sqlspec/adapters/duckdb/litestar/store.py +330 -0
  118. sqlspec/adapters/duckdb/pool.py +293 -0
  119. sqlspec/adapters/duckdb/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
  120. sqlspec/adapters/duckdb/type_converter.py +118 -0
  121. sqlspec/adapters/mock/__init__.py +72 -0
  122. sqlspec/adapters/mock/_typing.py +147 -0
  123. sqlspec/adapters/mock/config.py +483 -0
  124. sqlspec/adapters/mock/core.py +319 -0
  125. sqlspec/adapters/mock/data_dictionary.py +366 -0
  126. sqlspec/adapters/mock/driver.py +721 -0
  127. sqlspec/adapters/mysqlconnector/__init__.py +36 -0
  128. sqlspec/adapters/mysqlconnector/_typing.py +141 -0
  129. sqlspec/adapters/mysqlconnector/adk/__init__.py +15 -0
  130. sqlspec/adapters/mysqlconnector/adk/store.py +1060 -0
  131. sqlspec/adapters/mysqlconnector/config.py +394 -0
  132. sqlspec/adapters/mysqlconnector/core.cpython-310-aarch64-linux-gnu.so +0 -0
  133. sqlspec/adapters/mysqlconnector/core.py +303 -0
  134. sqlspec/adapters/mysqlconnector/data_dictionary.py +235 -0
  135. sqlspec/adapters/mysqlconnector/driver.py +483 -0
  136. sqlspec/adapters/mysqlconnector/events/__init__.py +8 -0
  137. sqlspec/adapters/mysqlconnector/events/store.py +98 -0
  138. sqlspec/adapters/mysqlconnector/litestar/__init__.py +5 -0
  139. sqlspec/adapters/mysqlconnector/litestar/store.py +426 -0
  140. sqlspec/adapters/oracledb/__init__.py +60 -0
  141. sqlspec/adapters/oracledb/_numpy_handlers.py +141 -0
  142. sqlspec/adapters/oracledb/_typing.py +182 -0
  143. sqlspec/adapters/oracledb/_uuid_handlers.py +166 -0
  144. sqlspec/adapters/oracledb/adk/__init__.py +10 -0
  145. sqlspec/adapters/oracledb/adk/store.py +2369 -0
  146. sqlspec/adapters/oracledb/config.py +550 -0
  147. sqlspec/adapters/oracledb/core.cpython-310-aarch64-linux-gnu.so +0 -0
  148. sqlspec/adapters/oracledb/core.py +543 -0
  149. sqlspec/adapters/oracledb/data_dictionary.py +536 -0
  150. sqlspec/adapters/oracledb/driver.py +1229 -0
  151. sqlspec/adapters/oracledb/events/__init__.py +16 -0
  152. sqlspec/adapters/oracledb/events/backend.py +347 -0
  153. sqlspec/adapters/oracledb/events/store.py +420 -0
  154. sqlspec/adapters/oracledb/litestar/__init__.py +5 -0
  155. sqlspec/adapters/oracledb/litestar/store.py +781 -0
  156. sqlspec/adapters/oracledb/migrations.py +535 -0
  157. sqlspec/adapters/oracledb/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
  158. sqlspec/adapters/oracledb/type_converter.py +211 -0
  159. sqlspec/adapters/psqlpy/__init__.py +17 -0
  160. sqlspec/adapters/psqlpy/_typing.py +79 -0
  161. sqlspec/adapters/psqlpy/adk/__init__.py +5 -0
  162. sqlspec/adapters/psqlpy/adk/store.py +766 -0
  163. sqlspec/adapters/psqlpy/config.py +304 -0
  164. sqlspec/adapters/psqlpy/core.cpython-310-aarch64-linux-gnu.so +0 -0
  165. sqlspec/adapters/psqlpy/core.py +480 -0
  166. sqlspec/adapters/psqlpy/data_dictionary.py +126 -0
  167. sqlspec/adapters/psqlpy/driver.py +438 -0
  168. sqlspec/adapters/psqlpy/events/__init__.py +6 -0
  169. sqlspec/adapters/psqlpy/events/backend.py +310 -0
  170. sqlspec/adapters/psqlpy/events/store.py +20 -0
  171. sqlspec/adapters/psqlpy/litestar/__init__.py +5 -0
  172. sqlspec/adapters/psqlpy/litestar/store.py +270 -0
  173. sqlspec/adapters/psqlpy/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
  174. sqlspec/adapters/psqlpy/type_converter.py +113 -0
  175. sqlspec/adapters/psycopg/__init__.py +32 -0
  176. sqlspec/adapters/psycopg/_typing.py +164 -0
  177. sqlspec/adapters/psycopg/adk/__init__.py +10 -0
  178. sqlspec/adapters/psycopg/adk/store.py +1387 -0
  179. sqlspec/adapters/psycopg/config.py +576 -0
  180. sqlspec/adapters/psycopg/core.cpython-310-aarch64-linux-gnu.so +0 -0
  181. sqlspec/adapters/psycopg/core.py +450 -0
  182. sqlspec/adapters/psycopg/data_dictionary.py +289 -0
  183. sqlspec/adapters/psycopg/driver.py +975 -0
  184. sqlspec/adapters/psycopg/events/__init__.py +20 -0
  185. sqlspec/adapters/psycopg/events/backend.py +458 -0
  186. sqlspec/adapters/psycopg/events/store.py +42 -0
  187. sqlspec/adapters/psycopg/litestar/__init__.py +5 -0
  188. sqlspec/adapters/psycopg/litestar/store.py +552 -0
  189. sqlspec/adapters/psycopg/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
  190. sqlspec/adapters/psycopg/type_converter.py +93 -0
  191. sqlspec/adapters/pymysql/__init__.py +21 -0
  192. sqlspec/adapters/pymysql/_typing.py +71 -0
  193. sqlspec/adapters/pymysql/adk/__init__.py +5 -0
  194. sqlspec/adapters/pymysql/adk/store.py +540 -0
  195. sqlspec/adapters/pymysql/config.py +195 -0
  196. sqlspec/adapters/pymysql/core.cpython-310-aarch64-linux-gnu.so +0 -0
  197. sqlspec/adapters/pymysql/core.py +299 -0
  198. sqlspec/adapters/pymysql/data_dictionary.py +122 -0
  199. sqlspec/adapters/pymysql/driver.py +259 -0
  200. sqlspec/adapters/pymysql/events/__init__.py +5 -0
  201. sqlspec/adapters/pymysql/events/store.py +50 -0
  202. sqlspec/adapters/pymysql/litestar/__init__.py +5 -0
  203. sqlspec/adapters/pymysql/litestar/store.py +232 -0
  204. sqlspec/adapters/pymysql/pool.py +137 -0
  205. sqlspec/adapters/spanner/__init__.py +40 -0
  206. sqlspec/adapters/spanner/_typing.py +86 -0
  207. sqlspec/adapters/spanner/adk/__init__.py +5 -0
  208. sqlspec/adapters/spanner/adk/store.py +732 -0
  209. sqlspec/adapters/spanner/config.py +352 -0
  210. sqlspec/adapters/spanner/core.cpython-310-aarch64-linux-gnu.so +0 -0
  211. sqlspec/adapters/spanner/core.py +188 -0
  212. sqlspec/adapters/spanner/data_dictionary.py +120 -0
  213. sqlspec/adapters/spanner/dialect/__init__.py +6 -0
  214. sqlspec/adapters/spanner/dialect/_spangres.py +57 -0
  215. sqlspec/adapters/spanner/dialect/_spanner.py +130 -0
  216. sqlspec/adapters/spanner/driver.py +373 -0
  217. sqlspec/adapters/spanner/events/__init__.py +5 -0
  218. sqlspec/adapters/spanner/events/store.py +187 -0
  219. sqlspec/adapters/spanner/litestar/__init__.py +5 -0
  220. sqlspec/adapters/spanner/litestar/store.py +291 -0
  221. sqlspec/adapters/spanner/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
  222. sqlspec/adapters/spanner/type_converter.py +331 -0
  223. sqlspec/adapters/sqlite/__init__.py +19 -0
  224. sqlspec/adapters/sqlite/_typing.py +80 -0
  225. sqlspec/adapters/sqlite/adk/__init__.py +5 -0
  226. sqlspec/adapters/sqlite/adk/store.py +958 -0
  227. sqlspec/adapters/sqlite/config.py +280 -0
  228. sqlspec/adapters/sqlite/core.cpython-310-aarch64-linux-gnu.so +0 -0
  229. sqlspec/adapters/sqlite/core.py +312 -0
  230. sqlspec/adapters/sqlite/data_dictionary.py +202 -0
  231. sqlspec/adapters/sqlite/driver.py +359 -0
  232. sqlspec/adapters/sqlite/events/__init__.py +5 -0
  233. sqlspec/adapters/sqlite/events/store.py +20 -0
  234. sqlspec/adapters/sqlite/litestar/__init__.py +5 -0
  235. sqlspec/adapters/sqlite/litestar/store.py +316 -0
  236. sqlspec/adapters/sqlite/pool.py +198 -0
  237. sqlspec/adapters/sqlite/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
  238. sqlspec/adapters/sqlite/type_converter.py +114 -0
  239. sqlspec/base.py +747 -0
  240. sqlspec/builder/__init__.py +179 -0
  241. sqlspec/builder/_base.cpython-310-aarch64-linux-gnu.so +0 -0
  242. sqlspec/builder/_base.py +1022 -0
  243. sqlspec/builder/_column.cpython-310-aarch64-linux-gnu.so +0 -0
  244. sqlspec/builder/_column.py +521 -0
  245. sqlspec/builder/_ddl.cpython-310-aarch64-linux-gnu.so +0 -0
  246. sqlspec/builder/_ddl.py +1642 -0
  247. sqlspec/builder/_delete.cpython-310-aarch64-linux-gnu.so +0 -0
  248. sqlspec/builder/_delete.py +95 -0
  249. sqlspec/builder/_dml.cpython-310-aarch64-linux-gnu.so +0 -0
  250. sqlspec/builder/_dml.py +365 -0
  251. sqlspec/builder/_explain.cpython-310-aarch64-linux-gnu.so +0 -0
  252. sqlspec/builder/_explain.py +579 -0
  253. sqlspec/builder/_expression_wrappers.cpython-310-aarch64-linux-gnu.so +0 -0
  254. sqlspec/builder/_expression_wrappers.py +46 -0
  255. sqlspec/builder/_factory.cpython-310-aarch64-linux-gnu.so +0 -0
  256. sqlspec/builder/_factory.py +1697 -0
  257. sqlspec/builder/_insert.cpython-310-aarch64-linux-gnu.so +0 -0
  258. sqlspec/builder/_insert.py +328 -0
  259. sqlspec/builder/_join.cpython-310-aarch64-linux-gnu.so +0 -0
  260. sqlspec/builder/_join.py +499 -0
  261. sqlspec/builder/_merge.cpython-310-aarch64-linux-gnu.so +0 -0
  262. sqlspec/builder/_merge.py +821 -0
  263. sqlspec/builder/_parsing_utils.cpython-310-aarch64-linux-gnu.so +0 -0
  264. sqlspec/builder/_parsing_utils.py +297 -0
  265. sqlspec/builder/_select.cpython-310-aarch64-linux-gnu.so +0 -0
  266. sqlspec/builder/_select.py +1660 -0
  267. sqlspec/builder/_temporal.cpython-310-aarch64-linux-gnu.so +0 -0
  268. sqlspec/builder/_temporal.py +139 -0
  269. sqlspec/builder/_update.cpython-310-aarch64-linux-gnu.so +0 -0
  270. sqlspec/builder/_update.py +173 -0
  271. sqlspec/builder/_vector_expressions.py +267 -0
  272. sqlspec/cli.py +911 -0
  273. sqlspec/config.py +1755 -0
  274. sqlspec/core/__init__.py +374 -0
  275. sqlspec/core/_correlation.cpython-310-aarch64-linux-gnu.so +0 -0
  276. sqlspec/core/_correlation.py +176 -0
  277. sqlspec/core/cache.cpython-310-aarch64-linux-gnu.so +0 -0
  278. sqlspec/core/cache.py +1069 -0
  279. sqlspec/core/compiler.cpython-310-aarch64-linux-gnu.so +0 -0
  280. sqlspec/core/compiler.py +954 -0
  281. sqlspec/core/explain.cpython-310-aarch64-linux-gnu.so +0 -0
  282. sqlspec/core/explain.py +275 -0
  283. sqlspec/core/filters.cpython-310-aarch64-linux-gnu.so +0 -0
  284. sqlspec/core/filters.py +952 -0
  285. sqlspec/core/hashing.cpython-310-aarch64-linux-gnu.so +0 -0
  286. sqlspec/core/hashing.py +262 -0
  287. sqlspec/core/metrics.cpython-310-aarch64-linux-gnu.so +0 -0
  288. sqlspec/core/metrics.py +83 -0
  289. sqlspec/core/parameters/__init__.py +71 -0
  290. sqlspec/core/parameters/_alignment.cpython-310-aarch64-linux-gnu.so +0 -0
  291. sqlspec/core/parameters/_alignment.py +270 -0
  292. sqlspec/core/parameters/_converter.cpython-310-aarch64-linux-gnu.so +0 -0
  293. sqlspec/core/parameters/_converter.py +543 -0
  294. sqlspec/core/parameters/_processor.cpython-310-aarch64-linux-gnu.so +0 -0
  295. sqlspec/core/parameters/_processor.py +505 -0
  296. sqlspec/core/parameters/_registry.cpython-310-aarch64-linux-gnu.so +0 -0
  297. sqlspec/core/parameters/_registry.py +206 -0
  298. sqlspec/core/parameters/_transformers.cpython-310-aarch64-linux-gnu.so +0 -0
  299. sqlspec/core/parameters/_transformers.py +292 -0
  300. sqlspec/core/parameters/_types.cpython-310-aarch64-linux-gnu.so +0 -0
  301. sqlspec/core/parameters/_types.py +499 -0
  302. sqlspec/core/parameters/_validator.cpython-310-aarch64-linux-gnu.so +0 -0
  303. sqlspec/core/parameters/_validator.py +180 -0
  304. sqlspec/core/pipeline.cpython-310-aarch64-linux-gnu.so +0 -0
  305. sqlspec/core/pipeline.py +319 -0
  306. sqlspec/core/query_modifiers.cpython-310-aarch64-linux-gnu.so +0 -0
  307. sqlspec/core/query_modifiers.py +437 -0
  308. sqlspec/core/result/__init__.py +23 -0
  309. sqlspec/core/result/_base.cpython-310-aarch64-linux-gnu.so +0 -0
  310. sqlspec/core/result/_base.py +1121 -0
  311. sqlspec/core/result/_io.cpython-310-aarch64-linux-gnu.so +0 -0
  312. sqlspec/core/result/_io.py +28 -0
  313. sqlspec/core/splitter.cpython-310-aarch64-linux-gnu.so +0 -0
  314. sqlspec/core/splitter.py +966 -0
  315. sqlspec/core/stack.cpython-310-aarch64-linux-gnu.so +0 -0
  316. sqlspec/core/stack.py +163 -0
  317. sqlspec/core/statement.cpython-310-aarch64-linux-gnu.so +0 -0
  318. sqlspec/core/statement.py +1503 -0
  319. sqlspec/core/type_converter.cpython-310-aarch64-linux-gnu.so +0 -0
  320. sqlspec/core/type_converter.py +339 -0
  321. sqlspec/data_dictionary/__init__.py +22 -0
  322. sqlspec/data_dictionary/_loader.py +123 -0
  323. sqlspec/data_dictionary/_registry.cpython-310-aarch64-linux-gnu.so +0 -0
  324. sqlspec/data_dictionary/_registry.py +74 -0
  325. sqlspec/data_dictionary/_types.cpython-310-aarch64-linux-gnu.so +0 -0
  326. sqlspec/data_dictionary/_types.py +121 -0
  327. sqlspec/data_dictionary/dialects/__init__.py +21 -0
  328. sqlspec/data_dictionary/dialects/bigquery.cpython-310-aarch64-linux-gnu.so +0 -0
  329. sqlspec/data_dictionary/dialects/bigquery.py +49 -0
  330. sqlspec/data_dictionary/dialects/cockroachdb.cpython-310-aarch64-linux-gnu.so +0 -0
  331. sqlspec/data_dictionary/dialects/cockroachdb.py +43 -0
  332. sqlspec/data_dictionary/dialects/duckdb.cpython-310-aarch64-linux-gnu.so +0 -0
  333. sqlspec/data_dictionary/dialects/duckdb.py +47 -0
  334. sqlspec/data_dictionary/dialects/mysql.cpython-310-aarch64-linux-gnu.so +0 -0
  335. sqlspec/data_dictionary/dialects/mysql.py +42 -0
  336. sqlspec/data_dictionary/dialects/oracle.cpython-310-aarch64-linux-gnu.so +0 -0
  337. sqlspec/data_dictionary/dialects/oracle.py +34 -0
  338. sqlspec/data_dictionary/dialects/postgres.cpython-310-aarch64-linux-gnu.so +0 -0
  339. sqlspec/data_dictionary/dialects/postgres.py +46 -0
  340. sqlspec/data_dictionary/dialects/spanner.cpython-310-aarch64-linux-gnu.so +0 -0
  341. sqlspec/data_dictionary/dialects/spanner.py +37 -0
  342. sqlspec/data_dictionary/dialects/sqlite.cpython-310-aarch64-linux-gnu.so +0 -0
  343. sqlspec/data_dictionary/dialects/sqlite.py +42 -0
  344. sqlspec/data_dictionary/sql/.gitkeep +0 -0
  345. sqlspec/data_dictionary/sql/bigquery/columns.sql +23 -0
  346. sqlspec/data_dictionary/sql/bigquery/foreign_keys.sql +34 -0
  347. sqlspec/data_dictionary/sql/bigquery/indexes.sql +19 -0
  348. sqlspec/data_dictionary/sql/bigquery/tables.sql +33 -0
  349. sqlspec/data_dictionary/sql/bigquery/version.sql +3 -0
  350. sqlspec/data_dictionary/sql/cockroachdb/columns.sql +34 -0
  351. sqlspec/data_dictionary/sql/cockroachdb/foreign_keys.sql +40 -0
  352. sqlspec/data_dictionary/sql/cockroachdb/indexes.sql +32 -0
  353. sqlspec/data_dictionary/sql/cockroachdb/tables.sql +44 -0
  354. sqlspec/data_dictionary/sql/cockroachdb/version.sql +3 -0
  355. sqlspec/data_dictionary/sql/duckdb/columns.sql +23 -0
  356. sqlspec/data_dictionary/sql/duckdb/foreign_keys.sql +36 -0
  357. sqlspec/data_dictionary/sql/duckdb/indexes.sql +19 -0
  358. sqlspec/data_dictionary/sql/duckdb/tables.sql +38 -0
  359. sqlspec/data_dictionary/sql/duckdb/version.sql +3 -0
  360. sqlspec/data_dictionary/sql/mysql/columns.sql +23 -0
  361. sqlspec/data_dictionary/sql/mysql/foreign_keys.sql +28 -0
  362. sqlspec/data_dictionary/sql/mysql/indexes.sql +26 -0
  363. sqlspec/data_dictionary/sql/mysql/tables.sql +33 -0
  364. sqlspec/data_dictionary/sql/mysql/version.sql +3 -0
  365. sqlspec/data_dictionary/sql/oracle/columns.sql +23 -0
  366. sqlspec/data_dictionary/sql/oracle/foreign_keys.sql +48 -0
  367. sqlspec/data_dictionary/sql/oracle/indexes.sql +44 -0
  368. sqlspec/data_dictionary/sql/oracle/tables.sql +25 -0
  369. sqlspec/data_dictionary/sql/oracle/version.sql +20 -0
  370. sqlspec/data_dictionary/sql/postgres/columns.sql +34 -0
  371. sqlspec/data_dictionary/sql/postgres/foreign_keys.sql +40 -0
  372. sqlspec/data_dictionary/sql/postgres/indexes.sql +56 -0
  373. sqlspec/data_dictionary/sql/postgres/tables.sql +44 -0
  374. sqlspec/data_dictionary/sql/postgres/version.sql +3 -0
  375. sqlspec/data_dictionary/sql/spanner/columns.sql +23 -0
  376. sqlspec/data_dictionary/sql/spanner/foreign_keys.sql +70 -0
  377. sqlspec/data_dictionary/sql/spanner/indexes.sql +30 -0
  378. sqlspec/data_dictionary/sql/spanner/tables.sql +9 -0
  379. sqlspec/data_dictionary/sql/spanner/version.sql +3 -0
  380. sqlspec/data_dictionary/sql/sqlite/columns.sql +23 -0
  381. sqlspec/data_dictionary/sql/sqlite/foreign_keys.sql +22 -0
  382. sqlspec/data_dictionary/sql/sqlite/indexes.sql +7 -0
  383. sqlspec/data_dictionary/sql/sqlite/tables.sql +28 -0
  384. sqlspec/data_dictionary/sql/sqlite/version.sql +3 -0
  385. sqlspec/driver/__init__.py +32 -0
  386. sqlspec/driver/_async.cpython-310-aarch64-linux-gnu.so +0 -0
  387. sqlspec/driver/_async.py +1737 -0
  388. sqlspec/driver/_common.cpython-310-aarch64-linux-gnu.so +0 -0
  389. sqlspec/driver/_common.py +1478 -0
  390. sqlspec/driver/_sql_helpers.cpython-310-aarch64-linux-gnu.so +0 -0
  391. sqlspec/driver/_sql_helpers.py +148 -0
  392. sqlspec/driver/_storage_helpers.cpython-310-aarch64-linux-gnu.so +0 -0
  393. sqlspec/driver/_storage_helpers.py +144 -0
  394. sqlspec/driver/_sync.cpython-310-aarch64-linux-gnu.so +0 -0
  395. sqlspec/driver/_sync.py +1710 -0
  396. sqlspec/exceptions.py +338 -0
  397. sqlspec/extensions/__init__.py +0 -0
  398. sqlspec/extensions/adk/__init__.py +70 -0
  399. sqlspec/extensions/adk/_types.py +51 -0
  400. sqlspec/extensions/adk/converters.py +172 -0
  401. sqlspec/extensions/adk/memory/__init__.py +69 -0
  402. sqlspec/extensions/adk/memory/_types.py +30 -0
  403. sqlspec/extensions/adk/memory/converters.py +149 -0
  404. sqlspec/extensions/adk/memory/service.py +217 -0
  405. sqlspec/extensions/adk/memory/store.py +569 -0
  406. sqlspec/extensions/adk/migrations/0001_create_adk_tables.py +246 -0
  407. sqlspec/extensions/adk/migrations/__init__.py +0 -0
  408. sqlspec/extensions/adk/service.py +225 -0
  409. sqlspec/extensions/adk/store.py +567 -0
  410. sqlspec/extensions/events/__init__.py +51 -0
  411. sqlspec/extensions/events/_channel.py +703 -0
  412. sqlspec/extensions/events/_hints.py +45 -0
  413. sqlspec/extensions/events/_models.py +23 -0
  414. sqlspec/extensions/events/_payload.py +69 -0
  415. sqlspec/extensions/events/_protocols.py +134 -0
  416. sqlspec/extensions/events/_queue.py +461 -0
  417. sqlspec/extensions/events/_store.py +209 -0
  418. sqlspec/extensions/events/migrations/0001_create_event_queue.py +59 -0
  419. sqlspec/extensions/events/migrations/__init__.py +3 -0
  420. sqlspec/extensions/fastapi/__init__.py +19 -0
  421. sqlspec/extensions/fastapi/extension.py +351 -0
  422. sqlspec/extensions/fastapi/providers.py +607 -0
  423. sqlspec/extensions/flask/__init__.py +37 -0
  424. sqlspec/extensions/flask/_state.py +76 -0
  425. sqlspec/extensions/flask/_utils.py +71 -0
  426. sqlspec/extensions/flask/extension.py +519 -0
  427. sqlspec/extensions/litestar/__init__.py +28 -0
  428. sqlspec/extensions/litestar/_utils.py +52 -0
  429. sqlspec/extensions/litestar/channels.py +165 -0
  430. sqlspec/extensions/litestar/cli.py +102 -0
  431. sqlspec/extensions/litestar/config.py +90 -0
  432. sqlspec/extensions/litestar/handlers.py +316 -0
  433. sqlspec/extensions/litestar/migrations/0001_create_session_table.py +137 -0
  434. sqlspec/extensions/litestar/migrations/__init__.py +3 -0
  435. sqlspec/extensions/litestar/plugin.py +671 -0
  436. sqlspec/extensions/litestar/providers.py +526 -0
  437. sqlspec/extensions/litestar/store.py +296 -0
  438. sqlspec/extensions/otel/__init__.py +58 -0
  439. sqlspec/extensions/prometheus/__init__.py +113 -0
  440. sqlspec/extensions/starlette/__init__.py +19 -0
  441. sqlspec/extensions/starlette/_state.py +30 -0
  442. sqlspec/extensions/starlette/_utils.py +96 -0
  443. sqlspec/extensions/starlette/extension.py +346 -0
  444. sqlspec/extensions/starlette/middleware.py +235 -0
  445. sqlspec/loader.cpython-310-aarch64-linux-gnu.so +0 -0
  446. sqlspec/loader.py +702 -0
  447. sqlspec/migrations/__init__.py +36 -0
  448. sqlspec/migrations/base.py +731 -0
  449. sqlspec/migrations/commands.py +1232 -0
  450. sqlspec/migrations/context.py +157 -0
  451. sqlspec/migrations/fix.py +204 -0
  452. sqlspec/migrations/loaders.py +443 -0
  453. sqlspec/migrations/runner.py +1172 -0
  454. sqlspec/migrations/templates.py +234 -0
  455. sqlspec/migrations/tracker.py +611 -0
  456. sqlspec/migrations/utils.py +256 -0
  457. sqlspec/migrations/validation.py +207 -0
  458. sqlspec/migrations/version.py +446 -0
  459. sqlspec/observability/__init__.py +55 -0
  460. sqlspec/observability/_common.cpython-310-aarch64-linux-gnu.so +0 -0
  461. sqlspec/observability/_common.py +77 -0
  462. sqlspec/observability/_config.cpython-310-aarch64-linux-gnu.so +0 -0
  463. sqlspec/observability/_config.py +348 -0
  464. sqlspec/observability/_diagnostics.cpython-310-aarch64-linux-gnu.so +0 -0
  465. sqlspec/observability/_diagnostics.py +74 -0
  466. sqlspec/observability/_dispatcher.cpython-310-aarch64-linux-gnu.so +0 -0
  467. sqlspec/observability/_dispatcher.py +152 -0
  468. sqlspec/observability/_formatters/__init__.py +13 -0
  469. sqlspec/observability/_formatters/_aws.cpython-310-aarch64-linux-gnu.so +0 -0
  470. sqlspec/observability/_formatters/_aws.py +102 -0
  471. sqlspec/observability/_formatters/_azure.cpython-310-aarch64-linux-gnu.so +0 -0
  472. sqlspec/observability/_formatters/_azure.py +96 -0
  473. sqlspec/observability/_formatters/_base.cpython-310-aarch64-linux-gnu.so +0 -0
  474. sqlspec/observability/_formatters/_base.py +57 -0
  475. sqlspec/observability/_formatters/_gcp.cpython-310-aarch64-linux-gnu.so +0 -0
  476. sqlspec/observability/_formatters/_gcp.py +131 -0
  477. sqlspec/observability/_formatting.py +58 -0
  478. sqlspec/observability/_observer.cpython-310-aarch64-linux-gnu.so +0 -0
  479. sqlspec/observability/_observer.py +357 -0
  480. sqlspec/observability/_runtime.cpython-310-aarch64-linux-gnu.so +0 -0
  481. sqlspec/observability/_runtime.py +420 -0
  482. sqlspec/observability/_sampling.cpython-310-aarch64-linux-gnu.so +0 -0
  483. sqlspec/observability/_sampling.py +188 -0
  484. sqlspec/observability/_spans.cpython-310-aarch64-linux-gnu.so +0 -0
  485. sqlspec/observability/_spans.py +161 -0
  486. sqlspec/protocols.py +916 -0
  487. sqlspec/py.typed +0 -0
  488. sqlspec/storage/__init__.py +48 -0
  489. sqlspec/storage/_utils.py +104 -0
  490. sqlspec/storage/backends/__init__.py +1 -0
  491. sqlspec/storage/backends/base.py +253 -0
  492. sqlspec/storage/backends/fsspec.py +529 -0
  493. sqlspec/storage/backends/local.py +441 -0
  494. sqlspec/storage/backends/obstore.py +916 -0
  495. sqlspec/storage/errors.py +104 -0
  496. sqlspec/storage/pipeline.py +582 -0
  497. sqlspec/storage/registry.py +301 -0
  498. sqlspec/typing.py +395 -0
  499. sqlspec/utils/__init__.py +7 -0
  500. sqlspec/utils/arrow_helpers.py +318 -0
  501. sqlspec/utils/config_tools.py +332 -0
  502. sqlspec/utils/correlation.cpython-310-aarch64-linux-gnu.so +0 -0
  503. sqlspec/utils/correlation.py +134 -0
  504. sqlspec/utils/deprecation.py +190 -0
  505. sqlspec/utils/fixtures.cpython-310-aarch64-linux-gnu.so +0 -0
  506. sqlspec/utils/fixtures.py +258 -0
  507. sqlspec/utils/logging.py +222 -0
  508. sqlspec/utils/module_loader.py +306 -0
  509. sqlspec/utils/portal.cpython-310-aarch64-linux-gnu.so +0 -0
  510. sqlspec/utils/portal.py +375 -0
  511. sqlspec/utils/schema.cpython-310-aarch64-linux-gnu.so +0 -0
  512. sqlspec/utils/schema.py +485 -0
  513. sqlspec/utils/serializers.cpython-310-aarch64-linux-gnu.so +0 -0
  514. sqlspec/utils/serializers.py +408 -0
  515. sqlspec/utils/singleton.cpython-310-aarch64-linux-gnu.so +0 -0
  516. sqlspec/utils/singleton.py +41 -0
  517. sqlspec/utils/sync_tools.cpython-310-aarch64-linux-gnu.so +0 -0
  518. sqlspec/utils/sync_tools.py +311 -0
  519. sqlspec/utils/text.cpython-310-aarch64-linux-gnu.so +0 -0
  520. sqlspec/utils/text.py +108 -0
  521. sqlspec/utils/type_converters.cpython-310-aarch64-linux-gnu.so +0 -0
  522. sqlspec/utils/type_converters.py +128 -0
  523. sqlspec/utils/type_guards.cpython-310-aarch64-linux-gnu.so +0 -0
  524. sqlspec/utils/type_guards.py +1360 -0
  525. sqlspec/utils/uuids.cpython-310-aarch64-linux-gnu.so +0 -0
  526. sqlspec/utils/uuids.py +225 -0
  527. sqlspec-0.36.0.dist-info/METADATA +205 -0
  528. sqlspec-0.36.0.dist-info/RECORD +531 -0
  529. sqlspec-0.36.0.dist-info/WHEEL +7 -0
  530. sqlspec-0.36.0.dist-info/entry_points.txt +2 -0
  531. sqlspec-0.36.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,139 @@
1
+ """BigQuery event queue store with clustering optimization.
2
+
3
+ BigQuery uses clustered tables instead of indexes for query optimization.
4
+ The event queue table is clustered by (channel, status, available_at) to
5
+ optimize polling queries that filter by channel and status.
6
+
7
+ Configuration:
8
+ extension_config={
9
+ "events": {
10
+ "queue_table": "my_events" # Default: "sqlspec_event_queue"
11
+ }
12
+ }
13
+ """
14
+
15
+ from sqlspec.adapters.bigquery.config import BigQueryConfig
16
+ from sqlspec.extensions.events import BaseEventQueueStore
17
+
18
+ __all__ = ("BigQueryEventQueueStore",)
19
+
20
+
21
+ class BigQueryEventQueueStore(BaseEventQueueStore[BigQueryConfig]):
22
+ """BigQuery-specific event queue store with clustering optimization.
23
+
24
+ Generates DDL optimized for BigQuery. BigQuery does not support traditional
25
+ indexes, so the table uses CLUSTER BY for query optimization instead.
26
+
27
+ Args:
28
+ config: BigQueryConfig with extension_config["events"] settings.
29
+
30
+ Notes:
31
+ Configuration is read from config.extension_config["events"]:
32
+ - queue_table: Table name (default: "sqlspec_event_queue")
33
+
34
+ BigQuery-specific optimizations:
35
+ - Uses STRING instead of VARCHAR (BigQuery's native string type)
36
+ - Uses INT64 instead of INTEGER
37
+ - Uses CLUSTER BY instead of CREATE INDEX
38
+ - Supports IF NOT EXISTS / IF EXISTS in DDL
39
+
40
+ Example:
41
+ from sqlspec.adapters.bigquery import BigQueryConfig
42
+ from sqlspec.adapters.bigquery.events import BigQueryEventQueueStore
43
+
44
+ config = BigQueryConfig(
45
+ connection_config={"project": "my-project"},
46
+ extension_config={"events": {"queue_table": "my_events"}}
47
+ )
48
+ store = BigQueryEventQueueStore(config)
49
+ for stmt in store.create_statements():
50
+ driver.execute_script(stmt)
51
+ """
52
+
53
+ __slots__ = ()
54
+
55
+ def _column_types(self) -> "tuple[str, str, str]":
56
+ """Return BigQuery-specific column types.
57
+
58
+ Returns:
59
+ Tuple of (payload_type, metadata_type, timestamp_type).
60
+ """
61
+ return "JSON", "JSON", "TIMESTAMP"
62
+
63
+ def _string_type(self, length: int) -> str:
64
+ """Return BigQuery STRING type (length is ignored)."""
65
+ del length
66
+ return "STRING"
67
+
68
+ def _integer_type(self) -> str:
69
+ """Return BigQuery INT64 type."""
70
+ return "INT64"
71
+
72
+ def _timestamp_default(self) -> str:
73
+ """Return BigQuery timestamp default expression."""
74
+ return "CURRENT_TIMESTAMP()"
75
+
76
+ def _table_clause(self) -> str:
77
+ """Return BigQuery CLUSTER BY clause for query optimization."""
78
+ return " CLUSTER BY channel, status, available_at"
79
+
80
+ def _build_create_table_sql(self) -> str:
81
+ """Build BigQuery CREATE TABLE with CLUSTER BY optimization.
82
+
83
+ BigQuery uses CLUSTER BY for query optimization instead of indexes.
84
+ The clustering columns match the typical polling query pattern.
85
+
86
+ Note: BigQuery does not support column-level PRIMARY KEY, so we
87
+ omit it entirely. event_id uniqueness must be enforced at insert time.
88
+ """
89
+ payload_type, metadata_type, timestamp_type = self._column_types()
90
+ string_type = self._string_type(0)
91
+ integer_type = self._integer_type()
92
+ ts_default = self._timestamp_default()
93
+ table_clause = self._table_clause()
94
+
95
+ return (
96
+ f"CREATE TABLE IF NOT EXISTS {self.table_name} ("
97
+ f"event_id {string_type} NOT NULL,"
98
+ f" channel {string_type} NOT NULL,"
99
+ f" payload_json {payload_type} NOT NULL,"
100
+ f" metadata_json {metadata_type},"
101
+ f" status {string_type} NOT NULL DEFAULT 'pending',"
102
+ f" available_at {timestamp_type} NOT NULL DEFAULT {ts_default},"
103
+ f" lease_expires_at {timestamp_type},"
104
+ f" attempts {integer_type} NOT NULL DEFAULT 0,"
105
+ f" created_at {timestamp_type} NOT NULL DEFAULT {ts_default},"
106
+ f" acknowledged_at {timestamp_type}"
107
+ f"){table_clause}"
108
+ )
109
+
110
+ def _build_index_sql(self) -> str | None:
111
+ """Return None since BigQuery uses CLUSTER BY instead of indexes.
112
+
113
+ Returns:
114
+ None, as BigQuery does not support traditional indexes.
115
+ """
116
+ return None
117
+
118
+ def create_statements(self) -> "list[str]":
119
+ """Return DDL statement for table creation.
120
+
121
+ Returns:
122
+ List containing single CREATE TABLE statement.
123
+
124
+ Notes:
125
+ BigQuery uses CLUSTER BY instead of separate index creation,
126
+ so only one statement is returned.
127
+ """
128
+ return [self._build_create_table_sql()]
129
+
130
+ def drop_statements(self) -> "list[str]":
131
+ """Return DDL statement for table deletion.
132
+
133
+ Returns:
134
+ List containing single DROP TABLE statement.
135
+
136
+ Notes:
137
+ BigQuery has no index to drop, only the table.
138
+ """
139
+ return [f"DROP TABLE IF EXISTS {self.table_name}"]
@@ -0,0 +1,5 @@
1
+ """BigQuery Litestar integration."""
2
+
3
+ from sqlspec.adapters.bigquery.litestar.store import BigQueryStore
4
+
5
+ __all__ = ("BigQueryStore",)
@@ -0,0 +1,325 @@
1
+ """BigQuery session store for Litestar integration."""
2
+
3
+ from datetime import datetime, timedelta, timezone
4
+ from typing import TYPE_CHECKING
5
+
6
+ from sqlspec.extensions.litestar.store import BaseSQLSpecStore
7
+ from sqlspec.utils.sync_tools import async_
8
+
9
+ if TYPE_CHECKING:
10
+ from sqlspec.adapters.bigquery.config import BigQueryConfig
11
+
12
+
13
+ __all__ = ("BigQueryStore",)
14
+
15
+
16
+ class BigQueryStore(BaseSQLSpecStore["BigQueryConfig"]):
17
+ """BigQuery session store using synchronous BigQuery driver.
18
+
19
+ Implements server-side session storage for Litestar using Google BigQuery.
20
+ Uses Litestar's sync_to_thread utility to provide an async interface
21
+ compatible with the Store protocol.
22
+
23
+ Provides efficient session management with:
24
+ - Sync operations wrapped for async compatibility
25
+ - MERGE for UPSERT functionality
26
+ - Native TIMESTAMP type support
27
+ - Automatic expiration handling
28
+ - Efficient cleanup of expired sessions
29
+ - Table clustering on session_id for optimized lookups
30
+
31
+ Note:
32
+ BigQuery is designed for analytical (OLAP) workloads and scales to petabytes.
33
+ For typical session store workloads, clustering by session_id provides good
34
+ performance. Consider partitioning by created_at if session volume exceeds
35
+ millions of rows per day.
36
+
37
+ Args:
38
+ config: BigQueryConfig instance.
39
+
40
+ Example:
41
+ from sqlspec.adapters.bigquery import BigQueryConfig
42
+ from sqlspec.adapters.bigquery.litestar.store import BigQueryStore
43
+
44
+ config = BigQueryConfig(connection_config={"project": "my-project"})
45
+ store = BigQueryStore(config)
46
+ await store.create_table()
47
+ """
48
+
49
+ __slots__ = ()
50
+
51
+ def __init__(self, config: "BigQueryConfig") -> None:
52
+ """Initialize BigQuery session store.
53
+
54
+ Args:
55
+ config: BigQueryConfig instance.
56
+
57
+ Notes:
58
+ Table name is read from config.extension_config["litestar"]["session_table"].
59
+ """
60
+ super().__init__(config)
61
+
62
+ def _get_create_table_sql(self) -> str:
63
+ """Get BigQuery CREATE TABLE SQL with optimized schema.
64
+
65
+ Returns:
66
+ SQL statement to create the sessions table with clustering.
67
+
68
+ Notes:
69
+ - Uses TIMESTAMP for timezone-aware expiration timestamps
70
+ - BYTES for binary session data storage
71
+ - Clustered by session_id for efficient lookups
72
+ - No indexes needed - BigQuery uses columnar storage
73
+ - Table name is internally controlled, not user input
74
+ """
75
+ return f"""
76
+ CREATE TABLE IF NOT EXISTS {self._table_name} (
77
+ session_id STRING NOT NULL,
78
+ data BYTES NOT NULL,
79
+ expires_at TIMESTAMP,
80
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
81
+ )
82
+ CLUSTER BY session_id
83
+ """
84
+
85
+ def _get_drop_table_sql(self) -> "list[str]":
86
+ """Get BigQuery DROP TABLE SQL statements.
87
+
88
+ Returns:
89
+ List containing DROP TABLE statement.
90
+
91
+ Notes:
92
+ BigQuery doesn't have separate indexes to drop.
93
+ """
94
+ return [f"DROP TABLE IF EXISTS {self._table_name}"]
95
+
96
+ def _datetime_to_timestamp(self, dt: "datetime | None") -> "datetime | None":
97
+ """Convert datetime to BigQuery TIMESTAMP.
98
+
99
+ Args:
100
+ dt: Datetime to convert (must be UTC-aware).
101
+
102
+ Returns:
103
+ UTC datetime object, or None if dt is None.
104
+
105
+ Notes:
106
+ BigQuery TIMESTAMP type expects UTC datetime objects.
107
+ The BigQuery client library handles the conversion.
108
+ """
109
+ if dt is None:
110
+ return None
111
+ if dt.tzinfo is None:
112
+ return dt.replace(tzinfo=timezone.utc)
113
+ return dt
114
+
115
+ def _timestamp_to_datetime(self, ts: "datetime | None") -> "datetime | None":
116
+ """Convert TIMESTAMP back to datetime.
117
+
118
+ Args:
119
+ ts: Datetime object from BigQuery.
120
+
121
+ Returns:
122
+ UTC-aware datetime, or None if ts is None.
123
+ """
124
+ if ts is None:
125
+ return None
126
+ if ts.tzinfo is None:
127
+ return ts.replace(tzinfo=timezone.utc)
128
+ return ts
129
+
130
+ def _create_table(self) -> None:
131
+ """Synchronous implementation of create_table."""
132
+ sql = self._get_create_table_sql()
133
+ with self._config.provide_session() as driver:
134
+ driver.execute_script(sql)
135
+ self._log_table_created()
136
+
137
+ async def create_table(self) -> None:
138
+ """Create the session table if it doesn't exist."""
139
+ await async_(self._create_table)()
140
+
141
+ def _get(self, key: str, renew_for: "int | timedelta | None" = None) -> "bytes | None":
142
+ """Synchronous implementation of get."""
143
+ sql = f"""
144
+ SELECT data, expires_at FROM {self._table_name}
145
+ WHERE session_id = @session_id
146
+ AND (expires_at IS NULL OR expires_at > CURRENT_TIMESTAMP())
147
+ """
148
+
149
+ with self._config.provide_session() as driver:
150
+ result = driver.select_one(sql, {"session_id": key})
151
+
152
+ if result is None:
153
+ return None
154
+
155
+ data = result.get("data")
156
+ expires_at = result.get("expires_at")
157
+
158
+ if renew_for is not None and expires_at is not None:
159
+ new_expires_at = self._calculate_expires_at(renew_for)
160
+ new_expires_at_ts = self._datetime_to_timestamp(new_expires_at)
161
+ if new_expires_at_ts is not None:
162
+ update_sql = f"""
163
+ UPDATE {self._table_name}
164
+ SET expires_at = @expires_at
165
+ WHERE session_id = @session_id
166
+ """
167
+ driver.execute(update_sql, {"expires_at": new_expires_at_ts, "session_id": key})
168
+
169
+ return bytes(data) if data is not None else None
170
+
171
+ async def get(self, key: str, renew_for: "int | timedelta | None" = None) -> "bytes | None":
172
+ """Get a session value by key.
173
+
174
+ Args:
175
+ key: Session ID to retrieve.
176
+ renew_for: If given, renew the expiry time for this duration.
177
+
178
+ Returns:
179
+ Session data as bytes if found and not expired, None otherwise.
180
+ """
181
+ return await async_(self._get)(key, renew_for)
182
+
183
+ def _set(self, key: str, value: "str | bytes", expires_in: "int | timedelta | None" = None) -> None:
184
+ """Synchronous implementation of set.
185
+
186
+ Notes:
187
+ Uses MERGE for UPSERT functionality in BigQuery.
188
+ BigQuery requires source data to come from a table or inline VALUES.
189
+ """
190
+ data = self._value_to_bytes(value)
191
+ expires_at = self._calculate_expires_at(expires_in)
192
+ expires_at_ts = self._datetime_to_timestamp(expires_at)
193
+
194
+ sql = f"""
195
+ MERGE {self._table_name} AS target
196
+ USING (SELECT @session_id AS session_id, @data AS data, @expires_at AS expires_at) AS source
197
+ ON target.session_id = source.session_id
198
+ WHEN MATCHED THEN
199
+ UPDATE SET data = source.data, expires_at = source.expires_at
200
+ WHEN NOT MATCHED THEN
201
+ INSERT (session_id, data, expires_at, created_at)
202
+ VALUES (source.session_id, source.data, source.expires_at, CURRENT_TIMESTAMP())
203
+ """
204
+
205
+ with self._config.provide_session() as driver:
206
+ driver.execute(sql, {"session_id": key, "data": data, "expires_at": expires_at_ts})
207
+
208
+ async def set(self, key: str, value: "str | bytes", expires_in: "int | timedelta | None" = None) -> None:
209
+ """Store a session value.
210
+
211
+ Args:
212
+ key: Session ID.
213
+ value: Session data.
214
+ expires_in: Time until expiration.
215
+ """
216
+ await async_(self._set)(key, value, expires_in)
217
+
218
+ def _delete(self, key: str) -> None:
219
+ """Synchronous implementation of delete."""
220
+ sql = f"DELETE FROM {self._table_name} WHERE session_id = @session_id"
221
+
222
+ with self._config.provide_session() as driver:
223
+ driver.execute(sql, {"session_id": key})
224
+
225
+ async def delete(self, key: str) -> None:
226
+ """Delete a session by key.
227
+
228
+ Args:
229
+ key: Session ID to delete.
230
+ """
231
+ await async_(self._delete)(key)
232
+
233
+ def _delete_all(self) -> None:
234
+ """Synchronous implementation of delete_all."""
235
+ sql = f"DELETE FROM {self._table_name} WHERE TRUE"
236
+
237
+ with self._config.provide_session() as driver:
238
+ driver.execute(sql)
239
+ self._log_delete_all()
240
+
241
+ async def delete_all(self) -> None:
242
+ """Delete all sessions from the store."""
243
+ await async_(self._delete_all)()
244
+
245
+ def _exists(self, key: str) -> bool:
246
+ """Synchronous implementation of exists."""
247
+ sql = f"""
248
+ SELECT 1 FROM {self._table_name}
249
+ WHERE session_id = @session_id
250
+ AND (expires_at IS NULL OR expires_at > CURRENT_TIMESTAMP())
251
+ LIMIT 1
252
+ """
253
+
254
+ with self._config.provide_session() as driver:
255
+ result = driver.select_one(sql, {"session_id": key})
256
+ return result is not None
257
+
258
+ async def exists(self, key: str) -> bool:
259
+ """Check if a session key exists and is not expired.
260
+
261
+ Args:
262
+ key: Session ID to check.
263
+
264
+ Returns:
265
+ True if the session exists and is not expired.
266
+ """
267
+ return await async_(self._exists)(key)
268
+
269
+ def _expires_in(self, key: str) -> "int | None":
270
+ """Synchronous implementation of expires_in."""
271
+ sql = f"""
272
+ SELECT expires_at FROM {self._table_name}
273
+ WHERE session_id = @session_id
274
+ """
275
+
276
+ with self._config.provide_session() as driver:
277
+ result = driver.select_one(sql, {"session_id": key})
278
+
279
+ if result is None:
280
+ return None
281
+
282
+ expires_at = result.get("expires_at")
283
+ if expires_at is None:
284
+ return None
285
+
286
+ expires_at_dt = self._timestamp_to_datetime(expires_at)
287
+ if expires_at_dt is None:
288
+ return None
289
+
290
+ now = datetime.now(timezone.utc)
291
+ if expires_at_dt <= now:
292
+ return 0
293
+
294
+ delta = expires_at_dt - now
295
+ return int(delta.total_seconds())
296
+
297
+ async def expires_in(self, key: str) -> "int | None":
298
+ """Get the time in seconds until the session expires.
299
+
300
+ Args:
301
+ key: Session ID to check.
302
+
303
+ Returns:
304
+ Seconds until expiration, or None if no expiry or key doesn't exist.
305
+ """
306
+ return await async_(self._expires_in)(key)
307
+
308
+ def _delete_expired(self) -> int:
309
+ """Synchronous implementation of delete_expired."""
310
+ sql = f"DELETE FROM {self._table_name} WHERE expires_at <= CURRENT_TIMESTAMP()"
311
+
312
+ with self._config.provide_session() as driver:
313
+ result = driver.execute(sql)
314
+ count = result.get_affected_count()
315
+ if count > 0:
316
+ self._log_delete_expired(count)
317
+ return count
318
+
319
+ async def delete_expired(self) -> int:
320
+ """Delete all expired sessions.
321
+
322
+ Returns:
323
+ Number of sessions deleted.
324
+ """
325
+ return await async_(self._delete_expired)()
@@ -0,0 +1,107 @@
1
+ """BigQuery-specific type conversion with native UUID support.
2
+
3
+ Provides specialized type handling for BigQuery, including UUID support
4
+ for the native BigQuery driver and parameter creation.
5
+ """
6
+
7
+ from typing import Any
8
+ from uuid import UUID
9
+
10
+ from sqlspec.core.type_converter import CachedOutputConverter, convert_uuid
11
+
12
+ __all__ = ("BIGQUERY_SPECIAL_CHARS", "BQ_TYPE_MAP", "BigQueryOutputConverter")
13
+
14
+ BQ_TYPE_MAP: "dict[str, str]" = {
15
+ "str": "STRING",
16
+ "int": "INT64",
17
+ "float": "FLOAT64",
18
+ "bool": "BOOL",
19
+ "datetime": "DATETIME",
20
+ "date": "DATE",
21
+ "time": "TIME",
22
+ "UUID": "STRING",
23
+ "uuid": "STRING",
24
+ "Decimal": "NUMERIC",
25
+ "bytes": "BYTES",
26
+ "list": "ARRAY",
27
+ "dict": "STRUCT",
28
+ }
29
+
30
+ BIGQUERY_SPECIAL_CHARS: "frozenset[str]" = frozenset({"{", "[", "-", ":", "T", "."})
31
+
32
+
33
+ class BigQueryOutputConverter(CachedOutputConverter):
34
+ """BigQuery-specific output conversion with native UUID support.
35
+
36
+ Extends CachedOutputConverter with BigQuery-specific functionality
37
+ including UUID handling and parameter creation for the native BigQuery driver.
38
+ """
39
+
40
+ __slots__ = ("_enable_uuid_conversion",)
41
+
42
+ def __init__(self, cache_size: int = 5000, enable_uuid_conversion: bool = True) -> None:
43
+ """Initialize converter with BigQuery-specific options.
44
+
45
+ Args:
46
+ cache_size: Maximum number of string values to cache (default: 5000)
47
+ enable_uuid_conversion: Enable automatic UUID string conversion (default: True)
48
+ """
49
+ super().__init__(special_chars=BIGQUERY_SPECIAL_CHARS, cache_size=cache_size)
50
+ self._enable_uuid_conversion = enable_uuid_conversion
51
+
52
+ def _convert_detected(self, value: str, detected_type: str) -> Any:
53
+ """Convert value with BigQuery-specific handling.
54
+
55
+ Args:
56
+ value: String value to convert.
57
+ detected_type: Detected type name.
58
+
59
+ Returns:
60
+ Converted value, respecting UUID conversion setting.
61
+ """
62
+ try:
63
+ return self.convert_value(value, detected_type)
64
+ except Exception:
65
+ return value
66
+
67
+ def create_parameter(self, name: str, value: Any) -> "Any | None":
68
+ """Create BigQuery parameter with proper type mapping.
69
+
70
+ Args:
71
+ name: Parameter name.
72
+ value: Parameter value.
73
+
74
+ Returns:
75
+ ScalarQueryParameter for native BigQuery driver, None if not available.
76
+ """
77
+ try:
78
+ from google.cloud.bigquery import ScalarQueryParameter
79
+ except ImportError:
80
+ return None
81
+
82
+ if self._enable_uuid_conversion:
83
+ if isinstance(value, UUID):
84
+ return ScalarQueryParameter(name, "STRING", str(value))
85
+
86
+ if isinstance(value, str):
87
+ detected_type = self.detect_type(value)
88
+ if detected_type == "uuid":
89
+ uuid_obj = convert_uuid(value)
90
+ return ScalarQueryParameter(name, "STRING", str(uuid_obj))
91
+
92
+ param_type = BQ_TYPE_MAP.get(type(value).__name__, "STRING")
93
+ return ScalarQueryParameter(name, param_type, value)
94
+
95
+ def convert_bigquery_value(self, value: Any, column_type: str) -> Any:
96
+ """Convert BigQuery value based on column type.
97
+
98
+ Args:
99
+ value: Value to convert.
100
+ column_type: BigQuery column type.
101
+
102
+ Returns:
103
+ Converted value appropriate for the column type.
104
+ """
105
+ if column_type == "STRING" and isinstance(value, str):
106
+ return self.convert(value)
107
+ return value
@@ -0,0 +1,24 @@
1
+ from sqlspec.adapters.cockroach_asyncpg._typing import (
2
+ CockroachAsyncpgConnection,
3
+ CockroachAsyncpgPool,
4
+ CockroachAsyncpgSessionContext,
5
+ )
6
+ from sqlspec.adapters.cockroach_asyncpg.config import (
7
+ CockroachAsyncpgConfig,
8
+ CockroachAsyncpgConnectionConfig,
9
+ CockroachAsyncpgDriverFeatures,
10
+ CockroachAsyncpgPoolConfig,
11
+ )
12
+ from sqlspec.adapters.cockroach_asyncpg.driver import CockroachAsyncpgDriver, CockroachAsyncpgExceptionHandler
13
+
14
+ __all__ = (
15
+ "CockroachAsyncpgConfig",
16
+ "CockroachAsyncpgConnection",
17
+ "CockroachAsyncpgConnectionConfig",
18
+ "CockroachAsyncpgDriver",
19
+ "CockroachAsyncpgDriverFeatures",
20
+ "CockroachAsyncpgExceptionHandler",
21
+ "CockroachAsyncpgPool",
22
+ "CockroachAsyncpgPoolConfig",
23
+ "CockroachAsyncpgSessionContext",
24
+ )
@@ -0,0 +1,72 @@
1
+ """CockroachDB AsyncPG adapter type definitions."""
2
+
3
+ from typing import TYPE_CHECKING, Any
4
+
5
+ from asyncpg.pool import PoolConnectionProxy
6
+
7
+ if TYPE_CHECKING:
8
+ from collections.abc import Callable
9
+ from typing import TypeAlias
10
+
11
+ from asyncpg import Connection, Pool, Record
12
+
13
+ from sqlspec.adapters.cockroach_asyncpg.driver import CockroachAsyncpgDriver
14
+ from sqlspec.core import StatementConfig
15
+
16
+ CockroachAsyncpgConnection: TypeAlias = Connection[Record] | PoolConnectionProxy[Record]
17
+ CockroachAsyncpgPool: TypeAlias = Pool[Record]
18
+ else:
19
+ from asyncpg import Pool
20
+
21
+ CockroachAsyncpgConnection = PoolConnectionProxy
22
+ CockroachAsyncpgPool = Pool
23
+
24
+
25
+ class CockroachAsyncpgSessionContext:
26
+ """Async context manager for CockroachDB AsyncPG sessions."""
27
+
28
+ __slots__ = (
29
+ "_acquire_connection",
30
+ "_connection",
31
+ "_driver",
32
+ "_driver_features",
33
+ "_prepare_driver",
34
+ "_release_connection",
35
+ "_statement_config",
36
+ )
37
+
38
+ def __init__(
39
+ self,
40
+ acquire_connection: "Callable[[], Any]",
41
+ release_connection: "Callable[[Any], Any]",
42
+ statement_config: "StatementConfig",
43
+ driver_features: "dict[str, Any]",
44
+ prepare_driver: "Callable[[CockroachAsyncpgDriver], CockroachAsyncpgDriver]",
45
+ ) -> None:
46
+ self._acquire_connection = acquire_connection
47
+ self._release_connection = release_connection
48
+ self._statement_config = statement_config
49
+ self._driver_features = driver_features
50
+ self._prepare_driver = prepare_driver
51
+ self._connection: Any = None
52
+ self._driver: CockroachAsyncpgDriver | None = None
53
+
54
+ async def __aenter__(self) -> "CockroachAsyncpgDriver":
55
+ from sqlspec.adapters.cockroach_asyncpg.driver import CockroachAsyncpgDriver
56
+
57
+ self._connection = await self._acquire_connection()
58
+ self._driver = CockroachAsyncpgDriver(
59
+ connection=self._connection, statement_config=self._statement_config, driver_features=self._driver_features
60
+ )
61
+ return self._prepare_driver(self._driver)
62
+
63
+ async def __aexit__(
64
+ self, exc_type: "type[BaseException] | None", exc_val: "BaseException | None", exc_tb: Any
65
+ ) -> "bool | None":
66
+ if self._connection is not None:
67
+ await self._release_connection(self._connection)
68
+ self._connection = None
69
+ return None
70
+
71
+
72
+ __all__ = ("CockroachAsyncpgConnection", "CockroachAsyncpgPool", "CockroachAsyncpgSessionContext")
@@ -0,0 +1,3 @@
1
+ from sqlspec.adapters.cockroach_asyncpg.adk.store import CockroachAsyncpgADKMemoryStore, CockroachAsyncpgADKStore
2
+
3
+ __all__ = ("CockroachAsyncpgADKMemoryStore", "CockroachAsyncpgADKStore")