pyswordfish 3.0.4.0__cp312-cp312-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (644) hide show
  1. pyswordfish-3.0.4.0.dist-info/METADATA +53 -0
  2. pyswordfish-3.0.4.0.dist-info/RECORD +644 -0
  3. pyswordfish-3.0.4.0.dist-info/WHEEL +5 -0
  4. pyswordfish-3.0.4.0.dist-info/top_level.txt +1 -0
  5. swordfish/__init__.py +102 -0
  6. swordfish/_config.py +901 -0
  7. swordfish/_connection.py +1418 -0
  8. swordfish/_core.py +17 -0
  9. swordfish/_engine.py +1456 -0
  10. swordfish/_enums.py +142 -0
  11. swordfish/_function_bindings.py +23594 -0
  12. swordfish/_function_tools.py +124 -0
  13. swordfish/_helper.py +57 -0
  14. swordfish/_runtime.py +158 -0
  15. swordfish/_sqlbuilder.py +549 -0
  16. swordfish/_streaming.py +333 -0
  17. swordfish/_swordfishcpp.cp312-win_amd64.pyd +0 -0
  18. swordfish/_swordfishcpp.pyi +4784 -0
  19. swordfish/_translator.py +580 -0
  20. swordfish/asset/dolphindb.dos +71 -0
  21. swordfish/asset/tzdb/Africa/Abidjan +0 -0
  22. swordfish/asset/tzdb/Africa/Accra +0 -0
  23. swordfish/asset/tzdb/Africa/Addis_Ababa +0 -0
  24. swordfish/asset/tzdb/Africa/Algiers +0 -0
  25. swordfish/asset/tzdb/Africa/Asmara +0 -0
  26. swordfish/asset/tzdb/Africa/Asmera +0 -0
  27. swordfish/asset/tzdb/Africa/Bamako +0 -0
  28. swordfish/asset/tzdb/Africa/Bangui +0 -0
  29. swordfish/asset/tzdb/Africa/Banjul +0 -0
  30. swordfish/asset/tzdb/Africa/Bissau +0 -0
  31. swordfish/asset/tzdb/Africa/Blantyre +0 -0
  32. swordfish/asset/tzdb/Africa/Brazzaville +0 -0
  33. swordfish/asset/tzdb/Africa/Bujumbura +0 -0
  34. swordfish/asset/tzdb/Africa/Cairo +0 -0
  35. swordfish/asset/tzdb/Africa/Casablanca +0 -0
  36. swordfish/asset/tzdb/Africa/Ceuta +0 -0
  37. swordfish/asset/tzdb/Africa/Conakry +0 -0
  38. swordfish/asset/tzdb/Africa/Dakar +0 -0
  39. swordfish/asset/tzdb/Africa/Dar_es_Salaam +0 -0
  40. swordfish/asset/tzdb/Africa/Djibouti +0 -0
  41. swordfish/asset/tzdb/Africa/Douala +0 -0
  42. swordfish/asset/tzdb/Africa/El_Aaiun +0 -0
  43. swordfish/asset/tzdb/Africa/Freetown +0 -0
  44. swordfish/asset/tzdb/Africa/Gaborone +0 -0
  45. swordfish/asset/tzdb/Africa/Harare +0 -0
  46. swordfish/asset/tzdb/Africa/Johannesburg +0 -0
  47. swordfish/asset/tzdb/Africa/Juba +0 -0
  48. swordfish/asset/tzdb/Africa/Kampala +0 -0
  49. swordfish/asset/tzdb/Africa/Khartoum +0 -0
  50. swordfish/asset/tzdb/Africa/Kigali +0 -0
  51. swordfish/asset/tzdb/Africa/Kinshasa +0 -0
  52. swordfish/asset/tzdb/Africa/Lagos +0 -0
  53. swordfish/asset/tzdb/Africa/Libreville +0 -0
  54. swordfish/asset/tzdb/Africa/Lome +0 -0
  55. swordfish/asset/tzdb/Africa/Luanda +0 -0
  56. swordfish/asset/tzdb/Africa/Lubumbashi +0 -0
  57. swordfish/asset/tzdb/Africa/Lusaka +0 -0
  58. swordfish/asset/tzdb/Africa/Malabo +0 -0
  59. swordfish/asset/tzdb/Africa/Maputo +0 -0
  60. swordfish/asset/tzdb/Africa/Maseru +0 -0
  61. swordfish/asset/tzdb/Africa/Mbabane +0 -0
  62. swordfish/asset/tzdb/Africa/Mogadishu +0 -0
  63. swordfish/asset/tzdb/Africa/Monrovia +0 -0
  64. swordfish/asset/tzdb/Africa/Nairobi +0 -0
  65. swordfish/asset/tzdb/Africa/Ndjamena +0 -0
  66. swordfish/asset/tzdb/Africa/Niamey +0 -0
  67. swordfish/asset/tzdb/Africa/Nouakchott +0 -0
  68. swordfish/asset/tzdb/Africa/Ouagadougou +0 -0
  69. swordfish/asset/tzdb/Africa/Porto-Novo +0 -0
  70. swordfish/asset/tzdb/Africa/Sao_Tome +0 -0
  71. swordfish/asset/tzdb/Africa/Timbuktu +0 -0
  72. swordfish/asset/tzdb/Africa/Tripoli +0 -0
  73. swordfish/asset/tzdb/Africa/Tunis +0 -0
  74. swordfish/asset/tzdb/Africa/Windhoek +0 -0
  75. swordfish/asset/tzdb/America/Adak +0 -0
  76. swordfish/asset/tzdb/America/Anchorage +0 -0
  77. swordfish/asset/tzdb/America/Anguilla +0 -0
  78. swordfish/asset/tzdb/America/Antigua +0 -0
  79. swordfish/asset/tzdb/America/Araguaina +0 -0
  80. swordfish/asset/tzdb/America/Argentina/Buenos_Aires +0 -0
  81. swordfish/asset/tzdb/America/Argentina/Catamarca +0 -0
  82. swordfish/asset/tzdb/America/Argentina/ComodRivadavia +0 -0
  83. swordfish/asset/tzdb/America/Argentina/Cordoba +0 -0
  84. swordfish/asset/tzdb/America/Argentina/Jujuy +0 -0
  85. swordfish/asset/tzdb/America/Argentina/La_Rioja +0 -0
  86. swordfish/asset/tzdb/America/Argentina/Mendoza +0 -0
  87. swordfish/asset/tzdb/America/Argentina/Rio_Gallegos +0 -0
  88. swordfish/asset/tzdb/America/Argentina/Salta +0 -0
  89. swordfish/asset/tzdb/America/Argentina/San_Juan +0 -0
  90. swordfish/asset/tzdb/America/Argentina/San_Luis +0 -0
  91. swordfish/asset/tzdb/America/Argentina/Tucuman +0 -0
  92. swordfish/asset/tzdb/America/Argentina/Ushuaia +0 -0
  93. swordfish/asset/tzdb/America/Aruba +0 -0
  94. swordfish/asset/tzdb/America/Asuncion +0 -0
  95. swordfish/asset/tzdb/America/Atikokan +0 -0
  96. swordfish/asset/tzdb/America/Atka +0 -0
  97. swordfish/asset/tzdb/America/Bahia +0 -0
  98. swordfish/asset/tzdb/America/Bahia_Banderas +0 -0
  99. swordfish/asset/tzdb/America/Barbados +0 -0
  100. swordfish/asset/tzdb/America/Belem +0 -0
  101. swordfish/asset/tzdb/America/Belize +0 -0
  102. swordfish/asset/tzdb/America/Blanc-Sablon +0 -0
  103. swordfish/asset/tzdb/America/Boa_Vista +0 -0
  104. swordfish/asset/tzdb/America/Bogota +0 -0
  105. swordfish/asset/tzdb/America/Boise +0 -0
  106. swordfish/asset/tzdb/America/Buenos_Aires +0 -0
  107. swordfish/asset/tzdb/America/Cambridge_Bay +0 -0
  108. swordfish/asset/tzdb/America/Campo_Grande +0 -0
  109. swordfish/asset/tzdb/America/Cancun +0 -0
  110. swordfish/asset/tzdb/America/Caracas +0 -0
  111. swordfish/asset/tzdb/America/Catamarca +0 -0
  112. swordfish/asset/tzdb/America/Cayenne +0 -0
  113. swordfish/asset/tzdb/America/Cayman +0 -0
  114. swordfish/asset/tzdb/America/Chicago +0 -0
  115. swordfish/asset/tzdb/America/Chihuahua +0 -0
  116. swordfish/asset/tzdb/America/Coral_Harbour +0 -0
  117. swordfish/asset/tzdb/America/Cordoba +0 -0
  118. swordfish/asset/tzdb/America/Costa_Rica +0 -0
  119. swordfish/asset/tzdb/America/Creston +0 -0
  120. swordfish/asset/tzdb/America/Cuiaba +0 -0
  121. swordfish/asset/tzdb/America/Curacao +0 -0
  122. swordfish/asset/tzdb/America/Danmarkshavn +0 -0
  123. swordfish/asset/tzdb/America/Dawson +0 -0
  124. swordfish/asset/tzdb/America/Dawson_Creek +0 -0
  125. swordfish/asset/tzdb/America/Denver +0 -0
  126. swordfish/asset/tzdb/America/Detroit +0 -0
  127. swordfish/asset/tzdb/America/Dominica +0 -0
  128. swordfish/asset/tzdb/America/Edmonton +0 -0
  129. swordfish/asset/tzdb/America/Eirunepe +0 -0
  130. swordfish/asset/tzdb/America/El_Salvador +0 -0
  131. swordfish/asset/tzdb/America/Ensenada +0 -0
  132. swordfish/asset/tzdb/America/Fort_Nelson +0 -0
  133. swordfish/asset/tzdb/America/Fort_Wayne +0 -0
  134. swordfish/asset/tzdb/America/Fortaleza +0 -0
  135. swordfish/asset/tzdb/America/Glace_Bay +0 -0
  136. swordfish/asset/tzdb/America/Godthab +0 -0
  137. swordfish/asset/tzdb/America/Goose_Bay +0 -0
  138. swordfish/asset/tzdb/America/Grand_Turk +0 -0
  139. swordfish/asset/tzdb/America/Grenada +0 -0
  140. swordfish/asset/tzdb/America/Guadeloupe +0 -0
  141. swordfish/asset/tzdb/America/Guatemala +0 -0
  142. swordfish/asset/tzdb/America/Guayaquil +0 -0
  143. swordfish/asset/tzdb/America/Guyana +0 -0
  144. swordfish/asset/tzdb/America/Halifax +0 -0
  145. swordfish/asset/tzdb/America/Havana +0 -0
  146. swordfish/asset/tzdb/America/Hermosillo +0 -0
  147. swordfish/asset/tzdb/America/Indiana/Indianapolis +0 -0
  148. swordfish/asset/tzdb/America/Indiana/Knox +0 -0
  149. swordfish/asset/tzdb/America/Indiana/Marengo +0 -0
  150. swordfish/asset/tzdb/America/Indiana/Petersburg +0 -0
  151. swordfish/asset/tzdb/America/Indiana/Tell_City +0 -0
  152. swordfish/asset/tzdb/America/Indiana/Vevay +0 -0
  153. swordfish/asset/tzdb/America/Indiana/Vincennes +0 -0
  154. swordfish/asset/tzdb/America/Indiana/Winamac +0 -0
  155. swordfish/asset/tzdb/America/Indianapolis +0 -0
  156. swordfish/asset/tzdb/America/Inuvik +0 -0
  157. swordfish/asset/tzdb/America/Iqaluit +0 -0
  158. swordfish/asset/tzdb/America/Jamaica +0 -0
  159. swordfish/asset/tzdb/America/Jujuy +0 -0
  160. swordfish/asset/tzdb/America/Juneau +0 -0
  161. swordfish/asset/tzdb/America/Kentucky/Louisville +0 -0
  162. swordfish/asset/tzdb/America/Kentucky/Monticello +0 -0
  163. swordfish/asset/tzdb/America/Knox_IN +0 -0
  164. swordfish/asset/tzdb/America/Kralendijk +0 -0
  165. swordfish/asset/tzdb/America/La_Paz +0 -0
  166. swordfish/asset/tzdb/America/Lima +0 -0
  167. swordfish/asset/tzdb/America/Los_Angeles +0 -0
  168. swordfish/asset/tzdb/America/Louisville +0 -0
  169. swordfish/asset/tzdb/America/Lower_Princes +0 -0
  170. swordfish/asset/tzdb/America/Maceio +0 -0
  171. swordfish/asset/tzdb/America/Managua +0 -0
  172. swordfish/asset/tzdb/America/Manaus +0 -0
  173. swordfish/asset/tzdb/America/Marigot +0 -0
  174. swordfish/asset/tzdb/America/Martinique +0 -0
  175. swordfish/asset/tzdb/America/Matamoros +0 -0
  176. swordfish/asset/tzdb/America/Mazatlan +0 -0
  177. swordfish/asset/tzdb/America/Mendoza +0 -0
  178. swordfish/asset/tzdb/America/Menominee +0 -0
  179. swordfish/asset/tzdb/America/Merida +0 -0
  180. swordfish/asset/tzdb/America/Metlakatla +0 -0
  181. swordfish/asset/tzdb/America/Mexico_City +0 -0
  182. swordfish/asset/tzdb/America/Miquelon +0 -0
  183. swordfish/asset/tzdb/America/Moncton +0 -0
  184. swordfish/asset/tzdb/America/Monterrey +0 -0
  185. swordfish/asset/tzdb/America/Montevideo +0 -0
  186. swordfish/asset/tzdb/America/Montreal +0 -0
  187. swordfish/asset/tzdb/America/Montserrat +0 -0
  188. swordfish/asset/tzdb/America/Nassau +0 -0
  189. swordfish/asset/tzdb/America/New_York +0 -0
  190. swordfish/asset/tzdb/America/Nipigon +0 -0
  191. swordfish/asset/tzdb/America/Nome +0 -0
  192. swordfish/asset/tzdb/America/Noronha +0 -0
  193. swordfish/asset/tzdb/America/North_Dakota/Beulah +0 -0
  194. swordfish/asset/tzdb/America/North_Dakota/Center +0 -0
  195. swordfish/asset/tzdb/America/North_Dakota/New_Salem +0 -0
  196. swordfish/asset/tzdb/America/Ojinaga +0 -0
  197. swordfish/asset/tzdb/America/Panama +0 -0
  198. swordfish/asset/tzdb/America/Pangnirtung +0 -0
  199. swordfish/asset/tzdb/America/Paramaribo +0 -0
  200. swordfish/asset/tzdb/America/Phoenix +0 -0
  201. swordfish/asset/tzdb/America/Port-au-Prince +0 -0
  202. swordfish/asset/tzdb/America/Port_of_Spain +0 -0
  203. swordfish/asset/tzdb/America/Porto_Acre +0 -0
  204. swordfish/asset/tzdb/America/Porto_Velho +0 -0
  205. swordfish/asset/tzdb/America/Puerto_Rico +0 -0
  206. swordfish/asset/tzdb/America/Punta_Arenas +0 -0
  207. swordfish/asset/tzdb/America/Rainy_River +0 -0
  208. swordfish/asset/tzdb/America/Rankin_Inlet +0 -0
  209. swordfish/asset/tzdb/America/Recife +0 -0
  210. swordfish/asset/tzdb/America/Regina +0 -0
  211. swordfish/asset/tzdb/America/Resolute +0 -0
  212. swordfish/asset/tzdb/America/Rio_Branco +0 -0
  213. swordfish/asset/tzdb/America/Rosario +0 -0
  214. swordfish/asset/tzdb/America/Santa_Isabel +0 -0
  215. swordfish/asset/tzdb/America/Santarem +0 -0
  216. swordfish/asset/tzdb/America/Santiago +0 -0
  217. swordfish/asset/tzdb/America/Santo_Domingo +0 -0
  218. swordfish/asset/tzdb/America/Sao_Paulo +0 -0
  219. swordfish/asset/tzdb/America/Scoresbysund +0 -0
  220. swordfish/asset/tzdb/America/Shiprock +0 -0
  221. swordfish/asset/tzdb/America/Sitka +0 -0
  222. swordfish/asset/tzdb/America/St_Barthelemy +0 -0
  223. swordfish/asset/tzdb/America/St_Johns +0 -0
  224. swordfish/asset/tzdb/America/St_Kitts +0 -0
  225. swordfish/asset/tzdb/America/St_Lucia +0 -0
  226. swordfish/asset/tzdb/America/St_Thomas +0 -0
  227. swordfish/asset/tzdb/America/St_Vincent +0 -0
  228. swordfish/asset/tzdb/America/Swift_Current +0 -0
  229. swordfish/asset/tzdb/America/Tegucigalpa +0 -0
  230. swordfish/asset/tzdb/America/Thule +0 -0
  231. swordfish/asset/tzdb/America/Thunder_Bay +0 -0
  232. swordfish/asset/tzdb/America/Tijuana +0 -0
  233. swordfish/asset/tzdb/America/Toronto +0 -0
  234. swordfish/asset/tzdb/America/Tortola +0 -0
  235. swordfish/asset/tzdb/America/Vancouver +0 -0
  236. swordfish/asset/tzdb/America/Virgin +0 -0
  237. swordfish/asset/tzdb/America/Whitehorse +0 -0
  238. swordfish/asset/tzdb/America/Winnipeg +0 -0
  239. swordfish/asset/tzdb/America/Yakutat +0 -0
  240. swordfish/asset/tzdb/America/Yellowknife +0 -0
  241. swordfish/asset/tzdb/Antarctica/Casey +0 -0
  242. swordfish/asset/tzdb/Antarctica/Davis +0 -0
  243. swordfish/asset/tzdb/Antarctica/DumontDUrville +0 -0
  244. swordfish/asset/tzdb/Antarctica/Macquarie +0 -0
  245. swordfish/asset/tzdb/Antarctica/Mawson +0 -0
  246. swordfish/asset/tzdb/Antarctica/McMurdo +0 -0
  247. swordfish/asset/tzdb/Antarctica/Palmer +0 -0
  248. swordfish/asset/tzdb/Antarctica/Rothera +0 -0
  249. swordfish/asset/tzdb/Antarctica/South_Pole +0 -0
  250. swordfish/asset/tzdb/Antarctica/Syowa +0 -0
  251. swordfish/asset/tzdb/Antarctica/Troll +0 -0
  252. swordfish/asset/tzdb/Antarctica/Vostok +0 -0
  253. swordfish/asset/tzdb/Arctic/Longyearbyen +0 -0
  254. swordfish/asset/tzdb/Asia/Aden +0 -0
  255. swordfish/asset/tzdb/Asia/Almaty +0 -0
  256. swordfish/asset/tzdb/Asia/Amman +0 -0
  257. swordfish/asset/tzdb/Asia/Anadyr +0 -0
  258. swordfish/asset/tzdb/Asia/Aqtau +0 -0
  259. swordfish/asset/tzdb/Asia/Aqtobe +0 -0
  260. swordfish/asset/tzdb/Asia/Ashgabat +0 -0
  261. swordfish/asset/tzdb/Asia/Ashkhabad +0 -0
  262. swordfish/asset/tzdb/Asia/Atyrau +0 -0
  263. swordfish/asset/tzdb/Asia/Baghdad +0 -0
  264. swordfish/asset/tzdb/Asia/Bahrain +0 -0
  265. swordfish/asset/tzdb/Asia/Baku +0 -0
  266. swordfish/asset/tzdb/Asia/Bangkok +0 -0
  267. swordfish/asset/tzdb/Asia/Barnaul +0 -0
  268. swordfish/asset/tzdb/Asia/Beirut +0 -0
  269. swordfish/asset/tzdb/Asia/Bishkek +0 -0
  270. swordfish/asset/tzdb/Asia/Brunei +0 -0
  271. swordfish/asset/tzdb/Asia/Calcutta +0 -0
  272. swordfish/asset/tzdb/Asia/Chita +0 -0
  273. swordfish/asset/tzdb/Asia/Choibalsan +0 -0
  274. swordfish/asset/tzdb/Asia/Chongqing +0 -0
  275. swordfish/asset/tzdb/Asia/Chungking +0 -0
  276. swordfish/asset/tzdb/Asia/Colombo +0 -0
  277. swordfish/asset/tzdb/Asia/Dacca +0 -0
  278. swordfish/asset/tzdb/Asia/Damascus +0 -0
  279. swordfish/asset/tzdb/Asia/Dhaka +0 -0
  280. swordfish/asset/tzdb/Asia/Dili +0 -0
  281. swordfish/asset/tzdb/Asia/Dubai +0 -0
  282. swordfish/asset/tzdb/Asia/Dushanbe +0 -0
  283. swordfish/asset/tzdb/Asia/Famagusta +0 -0
  284. swordfish/asset/tzdb/Asia/Gaza +0 -0
  285. swordfish/asset/tzdb/Asia/Harbin +0 -0
  286. swordfish/asset/tzdb/Asia/Hebron +0 -0
  287. swordfish/asset/tzdb/Asia/Ho_Chi_Minh +0 -0
  288. swordfish/asset/tzdb/Asia/Hong_Kong +0 -0
  289. swordfish/asset/tzdb/Asia/Hovd +0 -0
  290. swordfish/asset/tzdb/Asia/Irkutsk +0 -0
  291. swordfish/asset/tzdb/Asia/Istanbul +0 -0
  292. swordfish/asset/tzdb/Asia/Jakarta +0 -0
  293. swordfish/asset/tzdb/Asia/Jayapura +0 -0
  294. swordfish/asset/tzdb/Asia/Jerusalem +0 -0
  295. swordfish/asset/tzdb/Asia/Kabul +0 -0
  296. swordfish/asset/tzdb/Asia/Kamchatka +0 -0
  297. swordfish/asset/tzdb/Asia/Karachi +0 -0
  298. swordfish/asset/tzdb/Asia/Kashgar +0 -0
  299. swordfish/asset/tzdb/Asia/Kathmandu +0 -0
  300. swordfish/asset/tzdb/Asia/Katmandu +0 -0
  301. swordfish/asset/tzdb/Asia/Khandyga +0 -0
  302. swordfish/asset/tzdb/Asia/Kolkata +0 -0
  303. swordfish/asset/tzdb/Asia/Krasnoyarsk +0 -0
  304. swordfish/asset/tzdb/Asia/Kuala_Lumpur +0 -0
  305. swordfish/asset/tzdb/Asia/Kuching +0 -0
  306. swordfish/asset/tzdb/Asia/Kuwait +0 -0
  307. swordfish/asset/tzdb/Asia/Macao +0 -0
  308. swordfish/asset/tzdb/Asia/Macau +0 -0
  309. swordfish/asset/tzdb/Asia/Magadan +0 -0
  310. swordfish/asset/tzdb/Asia/Makassar +0 -0
  311. swordfish/asset/tzdb/Asia/Manila +0 -0
  312. swordfish/asset/tzdb/Asia/Muscat +0 -0
  313. swordfish/asset/tzdb/Asia/Nicosia +0 -0
  314. swordfish/asset/tzdb/Asia/Novokuznetsk +0 -0
  315. swordfish/asset/tzdb/Asia/Novosibirsk +0 -0
  316. swordfish/asset/tzdb/Asia/Omsk +0 -0
  317. swordfish/asset/tzdb/Asia/Oral +0 -0
  318. swordfish/asset/tzdb/Asia/Phnom_Penh +0 -0
  319. swordfish/asset/tzdb/Asia/Pontianak +0 -0
  320. swordfish/asset/tzdb/Asia/Pyongyang +0 -0
  321. swordfish/asset/tzdb/Asia/Qatar +0 -0
  322. swordfish/asset/tzdb/Asia/Qyzylorda +0 -0
  323. swordfish/asset/tzdb/Asia/Rangoon +0 -0
  324. swordfish/asset/tzdb/Asia/Riyadh +0 -0
  325. swordfish/asset/tzdb/Asia/Saigon +0 -0
  326. swordfish/asset/tzdb/Asia/Sakhalin +0 -0
  327. swordfish/asset/tzdb/Asia/Samarkand +0 -0
  328. swordfish/asset/tzdb/Asia/Seoul +0 -0
  329. swordfish/asset/tzdb/Asia/Shanghai +0 -0
  330. swordfish/asset/tzdb/Asia/Singapore +0 -0
  331. swordfish/asset/tzdb/Asia/Srednekolymsk +0 -0
  332. swordfish/asset/tzdb/Asia/Taipei +0 -0
  333. swordfish/asset/tzdb/Asia/Tashkent +0 -0
  334. swordfish/asset/tzdb/Asia/Tbilisi +0 -0
  335. swordfish/asset/tzdb/Asia/Tehran +0 -0
  336. swordfish/asset/tzdb/Asia/Tel_Aviv +0 -0
  337. swordfish/asset/tzdb/Asia/Thimbu +0 -0
  338. swordfish/asset/tzdb/Asia/Thimphu +0 -0
  339. swordfish/asset/tzdb/Asia/Tokyo +0 -0
  340. swordfish/asset/tzdb/Asia/Tomsk +0 -0
  341. swordfish/asset/tzdb/Asia/Ujung_Pandang +0 -0
  342. swordfish/asset/tzdb/Asia/Ulaanbaatar +0 -0
  343. swordfish/asset/tzdb/Asia/Ulan_Bator +0 -0
  344. swordfish/asset/tzdb/Asia/Urumqi +0 -0
  345. swordfish/asset/tzdb/Asia/Ust-Nera +0 -0
  346. swordfish/asset/tzdb/Asia/Vientiane +0 -0
  347. swordfish/asset/tzdb/Asia/Vladivostok +0 -0
  348. swordfish/asset/tzdb/Asia/Yakutsk +0 -0
  349. swordfish/asset/tzdb/Asia/Yangon +0 -0
  350. swordfish/asset/tzdb/Asia/Yekaterinburg +0 -0
  351. swordfish/asset/tzdb/Asia/Yerevan +0 -0
  352. swordfish/asset/tzdb/Atlantic/Azores +0 -0
  353. swordfish/asset/tzdb/Atlantic/Bermuda +0 -0
  354. swordfish/asset/tzdb/Atlantic/Canary +0 -0
  355. swordfish/asset/tzdb/Atlantic/Cape_Verde +0 -0
  356. swordfish/asset/tzdb/Atlantic/Faeroe +0 -0
  357. swordfish/asset/tzdb/Atlantic/Faroe +0 -0
  358. swordfish/asset/tzdb/Atlantic/Jan_Mayen +0 -0
  359. swordfish/asset/tzdb/Atlantic/Madeira +0 -0
  360. swordfish/asset/tzdb/Atlantic/Reykjavik +0 -0
  361. swordfish/asset/tzdb/Atlantic/South_Georgia +0 -0
  362. swordfish/asset/tzdb/Atlantic/St_Helena +0 -0
  363. swordfish/asset/tzdb/Atlantic/Stanley +0 -0
  364. swordfish/asset/tzdb/Australia/ACT +0 -0
  365. swordfish/asset/tzdb/Australia/Adelaide +0 -0
  366. swordfish/asset/tzdb/Australia/Brisbane +0 -0
  367. swordfish/asset/tzdb/Australia/Broken_Hill +0 -0
  368. swordfish/asset/tzdb/Australia/Canberra +0 -0
  369. swordfish/asset/tzdb/Australia/Currie +0 -0
  370. swordfish/asset/tzdb/Australia/Darwin +0 -0
  371. swordfish/asset/tzdb/Australia/Eucla +0 -0
  372. swordfish/asset/tzdb/Australia/Hobart +0 -0
  373. swordfish/asset/tzdb/Australia/LHI +0 -0
  374. swordfish/asset/tzdb/Australia/Lindeman +0 -0
  375. swordfish/asset/tzdb/Australia/Lord_Howe +0 -0
  376. swordfish/asset/tzdb/Australia/Melbourne +0 -0
  377. swordfish/asset/tzdb/Australia/NSW +0 -0
  378. swordfish/asset/tzdb/Australia/North +0 -0
  379. swordfish/asset/tzdb/Australia/Perth +0 -0
  380. swordfish/asset/tzdb/Australia/Queensland +0 -0
  381. swordfish/asset/tzdb/Australia/South +0 -0
  382. swordfish/asset/tzdb/Australia/Sydney +0 -0
  383. swordfish/asset/tzdb/Australia/Tasmania +0 -0
  384. swordfish/asset/tzdb/Australia/Victoria +0 -0
  385. swordfish/asset/tzdb/Australia/West +0 -0
  386. swordfish/asset/tzdb/Australia/Yancowinna +0 -0
  387. swordfish/asset/tzdb/Brazil/Acre +0 -0
  388. swordfish/asset/tzdb/Brazil/DeNoronha +0 -0
  389. swordfish/asset/tzdb/Brazil/East +0 -0
  390. swordfish/asset/tzdb/Brazil/West +0 -0
  391. swordfish/asset/tzdb/CET +0 -0
  392. swordfish/asset/tzdb/CST6CDT +0 -0
  393. swordfish/asset/tzdb/Canada/Atlantic +0 -0
  394. swordfish/asset/tzdb/Canada/Central +0 -0
  395. swordfish/asset/tzdb/Canada/Eastern +0 -0
  396. swordfish/asset/tzdb/Canada/Mountain +0 -0
  397. swordfish/asset/tzdb/Canada/Newfoundland +0 -0
  398. swordfish/asset/tzdb/Canada/Pacific +0 -0
  399. swordfish/asset/tzdb/Canada/Saskatchewan +0 -0
  400. swordfish/asset/tzdb/Canada/Yukon +0 -0
  401. swordfish/asset/tzdb/Chile/Continental +0 -0
  402. swordfish/asset/tzdb/Chile/EasterIsland +0 -0
  403. swordfish/asset/tzdb/Cuba +0 -0
  404. swordfish/asset/tzdb/EET +0 -0
  405. swordfish/asset/tzdb/EST +0 -0
  406. swordfish/asset/tzdb/EST5EDT +0 -0
  407. swordfish/asset/tzdb/Egypt +0 -0
  408. swordfish/asset/tzdb/Eire +0 -0
  409. swordfish/asset/tzdb/Etc/GMT +0 -0
  410. swordfish/asset/tzdb/Etc/GMT+0 +0 -0
  411. swordfish/asset/tzdb/Etc/GMT+1 +0 -0
  412. swordfish/asset/tzdb/Etc/GMT+10 +0 -0
  413. swordfish/asset/tzdb/Etc/GMT+11 +0 -0
  414. swordfish/asset/tzdb/Etc/GMT+12 +0 -0
  415. swordfish/asset/tzdb/Etc/GMT+2 +0 -0
  416. swordfish/asset/tzdb/Etc/GMT+3 +0 -0
  417. swordfish/asset/tzdb/Etc/GMT+4 +0 -0
  418. swordfish/asset/tzdb/Etc/GMT+5 +0 -0
  419. swordfish/asset/tzdb/Etc/GMT+6 +0 -0
  420. swordfish/asset/tzdb/Etc/GMT+7 +0 -0
  421. swordfish/asset/tzdb/Etc/GMT+8 +0 -0
  422. swordfish/asset/tzdb/Etc/GMT+9 +0 -0
  423. swordfish/asset/tzdb/Etc/GMT-0 +0 -0
  424. swordfish/asset/tzdb/Etc/GMT-1 +0 -0
  425. swordfish/asset/tzdb/Etc/GMT-10 +0 -0
  426. swordfish/asset/tzdb/Etc/GMT-11 +0 -0
  427. swordfish/asset/tzdb/Etc/GMT-12 +0 -0
  428. swordfish/asset/tzdb/Etc/GMT-13 +0 -0
  429. swordfish/asset/tzdb/Etc/GMT-14 +0 -0
  430. swordfish/asset/tzdb/Etc/GMT-2 +0 -0
  431. swordfish/asset/tzdb/Etc/GMT-3 +0 -0
  432. swordfish/asset/tzdb/Etc/GMT-4 +0 -0
  433. swordfish/asset/tzdb/Etc/GMT-5 +0 -0
  434. swordfish/asset/tzdb/Etc/GMT-6 +0 -0
  435. swordfish/asset/tzdb/Etc/GMT-7 +0 -0
  436. swordfish/asset/tzdb/Etc/GMT-8 +0 -0
  437. swordfish/asset/tzdb/Etc/GMT-9 +0 -0
  438. swordfish/asset/tzdb/Etc/GMT0 +0 -0
  439. swordfish/asset/tzdb/Etc/Greenwich +0 -0
  440. swordfish/asset/tzdb/Etc/UCT +0 -0
  441. swordfish/asset/tzdb/Etc/UTC +0 -0
  442. swordfish/asset/tzdb/Etc/Universal +0 -0
  443. swordfish/asset/tzdb/Etc/Zulu +0 -0
  444. swordfish/asset/tzdb/Europe/Amsterdam +0 -0
  445. swordfish/asset/tzdb/Europe/Andorra +0 -0
  446. swordfish/asset/tzdb/Europe/Astrakhan +0 -0
  447. swordfish/asset/tzdb/Europe/Athens +0 -0
  448. swordfish/asset/tzdb/Europe/Belfast +0 -0
  449. swordfish/asset/tzdb/Europe/Belgrade +0 -0
  450. swordfish/asset/tzdb/Europe/Berlin +0 -0
  451. swordfish/asset/tzdb/Europe/Bratislava +0 -0
  452. swordfish/asset/tzdb/Europe/Brussels +0 -0
  453. swordfish/asset/tzdb/Europe/Bucharest +0 -0
  454. swordfish/asset/tzdb/Europe/Budapest +0 -0
  455. swordfish/asset/tzdb/Europe/Busingen +0 -0
  456. swordfish/asset/tzdb/Europe/Chisinau +0 -0
  457. swordfish/asset/tzdb/Europe/Copenhagen +0 -0
  458. swordfish/asset/tzdb/Europe/Dublin +0 -0
  459. swordfish/asset/tzdb/Europe/Gibraltar +0 -0
  460. swordfish/asset/tzdb/Europe/Guernsey +0 -0
  461. swordfish/asset/tzdb/Europe/Helsinki +0 -0
  462. swordfish/asset/tzdb/Europe/Isle_of_Man +0 -0
  463. swordfish/asset/tzdb/Europe/Istanbul +0 -0
  464. swordfish/asset/tzdb/Europe/Jersey +0 -0
  465. swordfish/asset/tzdb/Europe/Kaliningrad +0 -0
  466. swordfish/asset/tzdb/Europe/Kiev +0 -0
  467. swordfish/asset/tzdb/Europe/Kirov +0 -0
  468. swordfish/asset/tzdb/Europe/Lisbon +0 -0
  469. swordfish/asset/tzdb/Europe/Ljubljana +0 -0
  470. swordfish/asset/tzdb/Europe/London +0 -0
  471. swordfish/asset/tzdb/Europe/Luxembourg +0 -0
  472. swordfish/asset/tzdb/Europe/Madrid +0 -0
  473. swordfish/asset/tzdb/Europe/Malta +0 -0
  474. swordfish/asset/tzdb/Europe/Mariehamn +0 -0
  475. swordfish/asset/tzdb/Europe/Minsk +0 -0
  476. swordfish/asset/tzdb/Europe/Monaco +0 -0
  477. swordfish/asset/tzdb/Europe/Moscow +0 -0
  478. swordfish/asset/tzdb/Europe/Nicosia +0 -0
  479. swordfish/asset/tzdb/Europe/Oslo +0 -0
  480. swordfish/asset/tzdb/Europe/Paris +0 -0
  481. swordfish/asset/tzdb/Europe/Podgorica +0 -0
  482. swordfish/asset/tzdb/Europe/Prague +0 -0
  483. swordfish/asset/tzdb/Europe/Riga +0 -0
  484. swordfish/asset/tzdb/Europe/Rome +0 -0
  485. swordfish/asset/tzdb/Europe/Samara +0 -0
  486. swordfish/asset/tzdb/Europe/San_Marino +0 -0
  487. swordfish/asset/tzdb/Europe/Sarajevo +0 -0
  488. swordfish/asset/tzdb/Europe/Saratov +0 -0
  489. swordfish/asset/tzdb/Europe/Simferopol +0 -0
  490. swordfish/asset/tzdb/Europe/Skopje +0 -0
  491. swordfish/asset/tzdb/Europe/Sofia +0 -0
  492. swordfish/asset/tzdb/Europe/Stockholm +0 -0
  493. swordfish/asset/tzdb/Europe/Tallinn +0 -0
  494. swordfish/asset/tzdb/Europe/Tirane +0 -0
  495. swordfish/asset/tzdb/Europe/Tiraspol +0 -0
  496. swordfish/asset/tzdb/Europe/Ulyanovsk +0 -0
  497. swordfish/asset/tzdb/Europe/Uzhgorod +0 -0
  498. swordfish/asset/tzdb/Europe/Vaduz +0 -0
  499. swordfish/asset/tzdb/Europe/Vatican +0 -0
  500. swordfish/asset/tzdb/Europe/Vienna +0 -0
  501. swordfish/asset/tzdb/Europe/Vilnius +0 -0
  502. swordfish/asset/tzdb/Europe/Volgograd +0 -0
  503. swordfish/asset/tzdb/Europe/Warsaw +0 -0
  504. swordfish/asset/tzdb/Europe/Zagreb +0 -0
  505. swordfish/asset/tzdb/Europe/Zaporozhye +0 -0
  506. swordfish/asset/tzdb/Europe/Zurich +0 -0
  507. swordfish/asset/tzdb/Factory +0 -0
  508. swordfish/asset/tzdb/GB +0 -0
  509. swordfish/asset/tzdb/GB-Eire +0 -0
  510. swordfish/asset/tzdb/GMT +0 -0
  511. swordfish/asset/tzdb/GMT+0 +0 -0
  512. swordfish/asset/tzdb/GMT-0 +0 -0
  513. swordfish/asset/tzdb/GMT0 +0 -0
  514. swordfish/asset/tzdb/Greenwich +0 -0
  515. swordfish/asset/tzdb/HST +0 -0
  516. swordfish/asset/tzdb/Hongkong +0 -0
  517. swordfish/asset/tzdb/Iceland +0 -0
  518. swordfish/asset/tzdb/Indian/Antananarivo +0 -0
  519. swordfish/asset/tzdb/Indian/Chagos +0 -0
  520. swordfish/asset/tzdb/Indian/Christmas +0 -0
  521. swordfish/asset/tzdb/Indian/Cocos +0 -0
  522. swordfish/asset/tzdb/Indian/Comoro +0 -0
  523. swordfish/asset/tzdb/Indian/Kerguelen +0 -0
  524. swordfish/asset/tzdb/Indian/Mahe +0 -0
  525. swordfish/asset/tzdb/Indian/Maldives +0 -0
  526. swordfish/asset/tzdb/Indian/Mauritius +0 -0
  527. swordfish/asset/tzdb/Indian/Mayotte +0 -0
  528. swordfish/asset/tzdb/Indian/Reunion +0 -0
  529. swordfish/asset/tzdb/Iran +0 -0
  530. swordfish/asset/tzdb/Israel +0 -0
  531. swordfish/asset/tzdb/Jamaica +0 -0
  532. swordfish/asset/tzdb/Japan +0 -0
  533. swordfish/asset/tzdb/Kwajalein +0 -0
  534. swordfish/asset/tzdb/Libya +0 -0
  535. swordfish/asset/tzdb/MET +0 -0
  536. swordfish/asset/tzdb/MST +0 -0
  537. swordfish/asset/tzdb/MST7MDT +0 -0
  538. swordfish/asset/tzdb/Mexico/BajaNorte +0 -0
  539. swordfish/asset/tzdb/Mexico/BajaSur +0 -0
  540. swordfish/asset/tzdb/Mexico/General +0 -0
  541. swordfish/asset/tzdb/NZ +0 -0
  542. swordfish/asset/tzdb/NZ-CHAT +0 -0
  543. swordfish/asset/tzdb/Navajo +0 -0
  544. swordfish/asset/tzdb/PRC +0 -0
  545. swordfish/asset/tzdb/PST8PDT +0 -0
  546. swordfish/asset/tzdb/Pacific/Apia +0 -0
  547. swordfish/asset/tzdb/Pacific/Auckland +0 -0
  548. swordfish/asset/tzdb/Pacific/Bougainville +0 -0
  549. swordfish/asset/tzdb/Pacific/Chatham +0 -0
  550. swordfish/asset/tzdb/Pacific/Chuuk +0 -0
  551. swordfish/asset/tzdb/Pacific/Easter +0 -0
  552. swordfish/asset/tzdb/Pacific/Efate +0 -0
  553. swordfish/asset/tzdb/Pacific/Enderbury +0 -0
  554. swordfish/asset/tzdb/Pacific/Fakaofo +0 -0
  555. swordfish/asset/tzdb/Pacific/Fiji +0 -0
  556. swordfish/asset/tzdb/Pacific/Funafuti +0 -0
  557. swordfish/asset/tzdb/Pacific/Galapagos +0 -0
  558. swordfish/asset/tzdb/Pacific/Gambier +0 -0
  559. swordfish/asset/tzdb/Pacific/Guadalcanal +0 -0
  560. swordfish/asset/tzdb/Pacific/Guam +0 -0
  561. swordfish/asset/tzdb/Pacific/Honolulu +0 -0
  562. swordfish/asset/tzdb/Pacific/Johnston +0 -0
  563. swordfish/asset/tzdb/Pacific/Kiritimati +0 -0
  564. swordfish/asset/tzdb/Pacific/Kosrae +0 -0
  565. swordfish/asset/tzdb/Pacific/Kwajalein +0 -0
  566. swordfish/asset/tzdb/Pacific/Majuro +0 -0
  567. swordfish/asset/tzdb/Pacific/Marquesas +0 -0
  568. swordfish/asset/tzdb/Pacific/Midway +0 -0
  569. swordfish/asset/tzdb/Pacific/Nauru +0 -0
  570. swordfish/asset/tzdb/Pacific/Niue +0 -0
  571. swordfish/asset/tzdb/Pacific/Norfolk +0 -0
  572. swordfish/asset/tzdb/Pacific/Noumea +0 -0
  573. swordfish/asset/tzdb/Pacific/Pago_Pago +0 -0
  574. swordfish/asset/tzdb/Pacific/Palau +0 -0
  575. swordfish/asset/tzdb/Pacific/Pitcairn +0 -0
  576. swordfish/asset/tzdb/Pacific/Pohnpei +0 -0
  577. swordfish/asset/tzdb/Pacific/Ponape +0 -0
  578. swordfish/asset/tzdb/Pacific/Port_Moresby +0 -0
  579. swordfish/asset/tzdb/Pacific/Rarotonga +0 -0
  580. swordfish/asset/tzdb/Pacific/Saipan +0 -0
  581. swordfish/asset/tzdb/Pacific/Samoa +0 -0
  582. swordfish/asset/tzdb/Pacific/Tahiti +0 -0
  583. swordfish/asset/tzdb/Pacific/Tarawa +0 -0
  584. swordfish/asset/tzdb/Pacific/Tongatapu +0 -0
  585. swordfish/asset/tzdb/Pacific/Truk +0 -0
  586. swordfish/asset/tzdb/Pacific/Wake +0 -0
  587. swordfish/asset/tzdb/Pacific/Wallis +0 -0
  588. swordfish/asset/tzdb/Pacific/Yap +0 -0
  589. swordfish/asset/tzdb/Poland +0 -0
  590. swordfish/asset/tzdb/Portugal +0 -0
  591. swordfish/asset/tzdb/ROC +0 -0
  592. swordfish/asset/tzdb/ROK +0 -0
  593. swordfish/asset/tzdb/Singapore +0 -0
  594. swordfish/asset/tzdb/Turkey +0 -0
  595. swordfish/asset/tzdb/UCT +0 -0
  596. swordfish/asset/tzdb/US/Alaska +0 -0
  597. swordfish/asset/tzdb/US/Aleutian +0 -0
  598. swordfish/asset/tzdb/US/Arizona +0 -0
  599. swordfish/asset/tzdb/US/Central +0 -0
  600. swordfish/asset/tzdb/US/East-Indiana +0 -0
  601. swordfish/asset/tzdb/US/Eastern +0 -0
  602. swordfish/asset/tzdb/US/Hawaii +0 -0
  603. swordfish/asset/tzdb/US/Indiana-Starke +0 -0
  604. swordfish/asset/tzdb/US/Michigan +0 -0
  605. swordfish/asset/tzdb/US/Mountain +0 -0
  606. swordfish/asset/tzdb/US/Pacific +0 -0
  607. swordfish/asset/tzdb/US/Samoa +0 -0
  608. swordfish/asset/tzdb/UTC +0 -0
  609. swordfish/asset/tzdb/Universal +0 -0
  610. swordfish/asset/tzdb/W-SU +0 -0
  611. swordfish/asset/tzdb/WET +0 -0
  612. swordfish/asset/tzdb/Zulu +0 -0
  613. swordfish/asset/tzdb/iso3166.tab +274 -0
  614. swordfish/asset/tzdb/leapseconds +61 -0
  615. swordfish/asset/tzdb/posixrules +0 -0
  616. swordfish/asset/tzdb/tzdata.zi +4150 -0
  617. swordfish/asset/tzdb/tzmap_gen.py +27 -0
  618. swordfish/asset/tzdb/tzmapping +501 -0
  619. swordfish/asset/tzdb/windowsZones.xml +781 -0
  620. swordfish/asset/tzdb/zone.tab +448 -0
  621. swordfish/asset/tzdb/zone1970.tab +382 -0
  622. swordfish/connection.py +33 -0
  623. swordfish/data.py +806 -0
  624. swordfish/engine.py +28 -0
  625. swordfish/enums.py +32 -0
  626. swordfish/function.py +3 -0
  627. swordfish/infos.py +53 -0
  628. swordfish/io.py +11 -0
  629. swordfish/libSwordfish.dll +0 -0
  630. swordfish/libclucene-contribs-lib.dll +0 -0
  631. swordfish/libclucene-core.dll +0 -0
  632. swordfish/libclucene-shared.dll +0 -0
  633. swordfish/libgcc_s_seh-1.dll +0 -0
  634. swordfish/libstdc++-6.dll +0 -0
  635. swordfish/libwinpthread-1.dll +0 -0
  636. swordfish/module.py +57 -0
  637. swordfish/plugins/__init__.py +17 -0
  638. swordfish/plugins/backtest/__init__.py +38 -0
  639. swordfish/plugins/backtest/backtest.py +4228 -0
  640. swordfish/plugins/backtest/translator.py +820 -0
  641. swordfish/plugins/matching_engine_simulator.py +247 -0
  642. swordfish/streaming.py +19 -0
  643. swordfish/tools.py +71 -0
  644. swordfish/types.py +30 -0
@@ -0,0 +1,1418 @@
1
+ from ._swordfishcpp import ( # type: ignore
2
+ Constant, MetaCode,
3
+ DefaultSessionConnectionImpl,
4
+ MetaCodeContextImpl, EmptyContextImpl,
5
+ ConnectionImpl,
6
+ RemoteConnectionImpl,
7
+ OLTPConnectionImpl, CatalogConnectionImpl, SchemaImpl, StorageType,
8
+ SEQ, RANGE, VALUE, LIST, HASH, COMPO, INT,
9
+ ALL, LAST, FIRST,
10
+ _global_call, Table, EnumInt, FunctionDef, Handle,
11
+ ProgrammingError,
12
+ subscribe_impl_with_conn, SubscriptionHelper
13
+ )
14
+ from ._helper import Config
15
+ from .types import TypeDict
16
+ from . import data as sf_data
17
+
18
+ from typing import Dict, Any, Optional
19
+ from typing import TypeVar, Generic, Literal, List, overload, Union
20
+ from typing import final
21
+
22
+
23
+ T = TypeVar('T', bound=ConnectionImpl)
24
+
25
+
26
+ class Connection(Generic[T]):
27
+ """
28
+ A generic connection class that wraps various types of connection
29
+ implementations.
30
+ """
31
+ def __init__(self, impl: T):
32
+ self.impl = impl
33
+ self.is_closed = False
34
+ self.is_context = False
35
+
36
+ @property
37
+ @final
38
+ def __sf_connection__(self) -> Optional[T]:
39
+ if self.is_closed:
40
+ return None
41
+ return self.impl
42
+
43
+ @final
44
+ def _assert_alive(self):
45
+ if self.is_closed:
46
+ raise ProgrammingError("Connection is closed.")
47
+
48
+ @final
49
+ def __enter__(self):
50
+ """
51
+ Enters the context for the connection.
52
+
53
+ Returns
54
+ -------
55
+ ConnectionImpl
56
+ A `ConnectionImpl` instance.
57
+ """
58
+ self._assert_alive()
59
+ if self.is_context:
60
+ raise ProgrammingError("Connection cannot enter twice.")
61
+ self.is_context = True
62
+ self.impl.__enter__()
63
+ return self
64
+
65
+ @final
66
+ def __exit__(self, exc_type, exc_value, traceback):
67
+ self._assert_alive()
68
+ assert self.is_context
69
+ self.impl.__exit__(exc_type, exc_value, traceback)
70
+ self.is_context = False
71
+
72
+ @final
73
+ def sql(self, sql: str, *, vars: Optional[Dict[str, Any]] = None):
74
+ """
75
+ Executes a SQL query.
76
+
77
+ Parameters
78
+ ----------
79
+ sql : str
80
+ The SQL query string to be executed.
81
+ vars : dict, optional
82
+ A dictionary of variables to bind to the SQL query.
83
+
84
+ Returns
85
+ -------
86
+ Constant
87
+ The result of the SQL query execution.
88
+ """
89
+ self._assert_alive()
90
+ return self._sql_impl(sql, vars=vars)
91
+
92
+ def _sql_impl(self, sql: str, *, vars: Optional[Dict[str, Any]] = None):
93
+ return self.impl.sql(sql, vars=vars)
94
+
95
+ @final
96
+ def close(self):
97
+ """
98
+ Closes the connection.
99
+ """
100
+ self._assert_alive()
101
+ if self.is_context:
102
+ raise ProgrammingError("Cannot close connection in context.")
103
+ self.is_closed = True
104
+ self.impl = None
105
+
106
+ @final
107
+ def commit(self) -> None:
108
+ """
109
+ Commits the current transaction.
110
+
111
+ Raises
112
+ ------
113
+ NotImplementedError
114
+ The commit operation is not implemented.
115
+ """
116
+ self._assert_alive()
117
+ self._commit_impl()
118
+
119
+ def _commit_impl(self) -> None:
120
+ raise NotImplementedError()
121
+
122
+ @final
123
+ def in_transaction(self) -> bool:
124
+ """
125
+ Checks whether the connection is in an active transaction context.
126
+
127
+ Returns
128
+ -------
129
+ bool
130
+ True if in an active transaction context, False otherwise.
131
+
132
+ Raises
133
+ ------
134
+ NotImplementedError
135
+ The in_transaction operation is not implemented.
136
+ """
137
+ self._assert_alive()
138
+ return self._in_transaction_impl()
139
+
140
+ def _in_transaction_impl(self) -> bool:
141
+ raise NotImplementedError()
142
+
143
+ @final
144
+ def rollback(self) -> None:
145
+ """
146
+ Rolls back the current transaction.
147
+
148
+ Raises
149
+ ------
150
+ NotImplementedError
151
+ The rollback operation is not implemented.
152
+ """
153
+ self._assert_alive()
154
+ self._rollback_impl()
155
+
156
+ def _rollback_impl(self) -> None:
157
+ raise NotImplementedError()
158
+
159
+
160
+ class Partition:
161
+ """
162
+ A class for implementing data partitioning.
163
+ """
164
+ def __init__(self, partition_type, partition_scheme):
165
+ self.partition_type = partition_type
166
+ self.partition_scheme = partition_scheme
167
+
168
+ def __str__(self):
169
+ return f"Partition({self.partition_type}, {self.partition_scheme})"
170
+
171
+ def __repr__(self):
172
+ return str(self)
173
+
174
+ def build(self):
175
+ if self.partition_type != COMPO:
176
+ return self.partition_type, self.partition_scheme
177
+ return self.partition_type, sf_data.any_vector([_._build_for_compo() for _ in self.partition_scheme])
178
+
179
+ def _build_for_compo(self):
180
+ type_, scheme_ = self.build()
181
+ return _global_call("database", "", type_, scheme_)
182
+
183
+ @classmethod
184
+ def seq(cls, n):
185
+ """
186
+ Partitions data into `n` partitions using the SEQ partitioning type.
187
+
188
+ Parameters
189
+ ----------
190
+ n : Any
191
+ The number of partitions to create.
192
+
193
+ Returns
194
+ -------
195
+ Partition
196
+ A Partition object that divides the data into `n` partitions.
197
+
198
+ Examples
199
+ --------
200
+ >>> import swordfish as sf
201
+ >>> sf.Partition.seq(8)
202
+ Partition(SEQ, 8)
203
+ """
204
+ return Partition(SEQ, sf_data.scalar(n))
205
+
206
+ @classmethod
207
+ def range(cls, v):
208
+ """
209
+ Partitions data using the specified range boundaries.
210
+
211
+ Parameters
212
+ ----------
213
+ v : Any
214
+ A list of values representing the range boundaries.
215
+
216
+ Returns
217
+ -------
218
+ Partition
219
+ A Partition object that divides the data based on the specified
220
+ range boundaries.
221
+
222
+ Examples
223
+ --------
224
+ >>> import swordfish as sf
225
+ >>> sf.Partition.range([0, 5, 10])
226
+ Partition(RANGE, [0,5,10])
227
+ """
228
+ return Partition(RANGE, sf_data.vector(v))
229
+
230
+ @classmethod
231
+ def value(cls, v):
232
+ """
233
+ Partitions data based on the specified values in the partitioning column.
234
+
235
+ Parameters
236
+ ----------
237
+ v : Any
238
+ A list of values to partition the data.
239
+
240
+ Returns
241
+ -------
242
+ Partition
243
+ A Partition object that divides the data based on the provided values.
244
+
245
+ Examples
246
+ --------
247
+ >>> import swordfish as sf
248
+ >>> sf.Partition.value([1, 2, 3])
249
+ Partition(VALUE, [1,2,3])
250
+ """
251
+ return Partition(VALUE, sf_data.vector(v))
252
+
253
+ @classmethod
254
+ def list(cls, v):
255
+ """
256
+ Partitions data based on specified sets of values in the partitioning
257
+ column.
258
+
259
+ Parameters
260
+ ----------
261
+ v : Any
262
+ A list of lists representing the partition.
263
+
264
+ Returns
265
+ -------
266
+ Partition
267
+ A Partition object that divides the data based on the provided lists.
268
+
269
+ Examples
270
+ --------
271
+ >>> import swordfish as sf
272
+ >>> sf.Partition.list([[1, 2, 3], [4, 5]])
273
+ Partition(LIST, ([1,2,3],[4,5]))
274
+ """
275
+ return Partition(LIST, sf_data.any_vector(v))
276
+
277
+ @classmethod
278
+ def hash(cls, t, n):
279
+ """
280
+ Partitions data using a hash function on the partitioning column.
281
+
282
+ Parameters
283
+ ----------
284
+ t : int
285
+ The type of the partitioning column.
286
+ n : int
287
+ The number of partitions to create.
288
+
289
+ Returns
290
+ -------
291
+ Partition
292
+ A Partition object that divides data based on the given arguments.
293
+
294
+ Examples
295
+ --------
296
+ >>> import swordfish as sf
297
+ >>> sf.Partition.hash(sf.types.INT, 8)
298
+ Partition(HASH, [4,8])
299
+ """
300
+ return Partition(HASH, sf_data.vector([t, n], type=INT))
301
+
302
+ @classmethod
303
+ def compo(cls, partitions: List['Partition']):
304
+ """
305
+ Partitions data using the COMPO partitioning type, which combines two or
306
+ three dimensions.
307
+
308
+ Parameters
309
+ ----------
310
+ partitions : list of Partition
311
+ A list of Partition objects.
312
+
313
+ Returns
314
+ -------
315
+ Partition
316
+ A Partition object that combines the provided partitions.
317
+
318
+ Examples
319
+ --------
320
+ >>> import swordfish as sf
321
+ >>> sf.Partition.compo([sf.Partition.seq(2), sf.Partition.seq(5)])
322
+ Partition(COMPO, [Partition(SEQ, 2), Partition(SEQ, 5)])
323
+ """
324
+ return Partition(COMPO, partitions)
325
+
326
+
327
+ # In-Memory Connection (Default)
328
+ class DefaultSessionConnection(Connection[DefaultSessionConnectionImpl]):
329
+ pass
330
+
331
+
332
+ # OLTP Connection
333
+ class OLTPOption(Config):
334
+ """Configuration options for OLTP connections.
335
+ """
336
+ readOnly: bool = False
337
+ """
338
+ If True, the database will be opened in read-only mode, allowing only queries
339
+ but preventing any write operations (insert, delete, update) or structural
340
+ changes (create/drop tables).
341
+
342
+ A database can be opened in read-only mode multiple times simultaneously,
343
+ whether in the same process or different processes. However, if it is opened
344
+ in write mode, no other process can access it simultaneously.
345
+
346
+ Notes
347
+ -----
348
+ Avoid opening the same database multiple times in read-only mode
349
+ within the same process unless necessary. Each time the database is opened,
350
+ all data is loaded into memory, which can impact performance.
351
+ """
352
+ enableWAL: bool = True
353
+ """
354
+ - If set to false, all data is stored in memory and will be lost once the
355
+ database is closed.
356
+ - If set to true, the write-ahead logging will be turned on for persistence.
357
+
358
+ Notes
359
+ -----
360
+ Set this option to True if you want to prevent ANY data loss.
361
+ """
362
+ syncOnTxnCommit: bool = False
363
+ """
364
+ This option is relevant only when `enableWAL` is set to True.
365
+
366
+ - If True, before committing a write transaction, the database must ensure that
367
+ all write-ahead logs for the transaction are fully persisted.
368
+ - If False, the database can recover from a process crash but not from an OS crash.
369
+ This mode generally offers better performance.
370
+
371
+ Notes
372
+ -----
373
+ - Set this option to True if you want to prevent data loss even in the event of an OS crash.
374
+ - Set it to False if you prefer better performance and can tolerate data loss from an OS crash.
375
+ """
376
+ enableCheckpoint: bool = True
377
+ """
378
+ If True, the database will automatically perform a checkpoint based on
379
+ `checkpointThreshold` and `checkpointInterval`.
380
+ """
381
+ checkpointThreshold: int = 100
382
+ """
383
+ Forces a checkpoint when the size of write-ahead logs exceeds the specified
384
+ number of MiB.
385
+ """
386
+ checkpointInterval: int = 60
387
+ """
388
+ Forces a checkpoint at regular intervals, specified in seconds.
389
+ """
390
+
391
+
392
+ class OLTPConnection(Connection[OLTPConnectionImpl]):
393
+ """
394
+ Manages connections to OLTP databases.
395
+
396
+ Examples
397
+ --------
398
+ >>> import swordfish as sf
399
+ >>> conn = sf.connect(url="/path/to/file")
400
+ """
401
+ def __init__(self, impl):
402
+ super().__init__(impl)
403
+
404
+ def _sql_impl(self, sql: str, *, vars: Optional[Dict[str, Any]] = None):
405
+ if not self.impl.check_transaction():
406
+ self.impl.begin_transaction()
407
+ return self.impl.sql(sql, vars=vars)
408
+
409
+ def _commit_impl(self):
410
+ self.impl.commit()
411
+
412
+ def _in_transaction_impl(self):
413
+ return self.impl.check_transaction()
414
+
415
+ def _rollback_impl(self):
416
+ self.impl.rollback()
417
+
418
+ def create_table(self, name: str, types: TypeDict, primary, secondary=None):
419
+ """
420
+ Creates a new table in the database.
421
+
422
+ Parameters
423
+ ----------
424
+ name : str
425
+ The name of the table to create.
426
+ types : TypeDict
427
+ A dictionary specifying the column names and their data types.
428
+ primary : list of str or str
429
+ The primary key of the table.
430
+ secondary : list of tuple, optional
431
+ Secondary indexes or constraints for the table. Defaults to None.
432
+
433
+ Returns
434
+ -------
435
+ Table
436
+ A new table created based on the given parameters.
437
+
438
+ Examples
439
+ --------
440
+ >>> conn.create_table("table_name", {
441
+ ... 'a': "INT",
442
+ ... 'b': "INT",
443
+ ... 'c': "BOOL",
444
+ ... 'd': "LONG",
445
+ ... 'e': "STRING",
446
+ ... }, "a", [[True, ["b", "c", "d"]], [False, ["d"]]])
447
+ """
448
+ if secondary is None:
449
+ secondary = []
450
+ return self.impl.create_table(name, types=types, primary=primary, secondary=secondary)
451
+
452
+ def drop_table(self, name: str):
453
+ """
454
+ Drops a table from the database.
455
+
456
+ Parameters
457
+ ----------
458
+ name : str
459
+ The name of the table to drop.
460
+
461
+ Examples
462
+ --------
463
+ >>> conn.drop_table("table_name")
464
+ """
465
+ return self.impl.drop_table(name)
466
+
467
+ def list_tables(self):
468
+ """
469
+ Retrieves the names of all tables in the database.
470
+
471
+ Returns
472
+ -------
473
+ list
474
+ A list of table names in the database.
475
+
476
+ Examples
477
+ --------
478
+ >>> conn.list_tables()
479
+ """
480
+ return self.impl.list_table()
481
+
482
+ def exists_table(self, name: str) -> bool:
483
+ return self.impl.exists_table(name)
484
+
485
+ def table(self, name: str) -> Table:
486
+ """
487
+ Retrieves a specific table from the database.
488
+
489
+ Parameters
490
+ ----------
491
+ name : str
492
+ The name of the table.
493
+
494
+ Returns
495
+ -------
496
+ Table
497
+ The corresponding table object.
498
+
499
+ Examples
500
+ --------
501
+ >>> t = conn.table("table_name")
502
+ """
503
+ return self.impl.get_table(name)
504
+
505
+
506
+ class Schema:
507
+ """
508
+ Manages catalog schemas.
509
+ """
510
+ def __init__(self, impl: SchemaImpl):
511
+ self.impl = impl
512
+
513
+ @property
514
+ def handle(self) -> Handle:
515
+ """
516
+ Obtains a schema handle.
517
+
518
+ Returns
519
+ -------
520
+ Handle
521
+ The schema handle.
522
+ """
523
+ return self.impl.get_handle()
524
+
525
+ @overload
526
+ def create_table(
527
+ self,
528
+ name: str,
529
+ table_schema,
530
+ partition_cols: List[str],
531
+ *,
532
+ compress_methods: Dict[str, str] = None,
533
+ ):
534
+ pass
535
+
536
+ @overload
537
+ def create_table(
538
+ self,
539
+ name: str,
540
+ table_schema,
541
+ *,
542
+ compress_methods: Dict[str, str] = None,
543
+ ):
544
+ pass
545
+
546
+ @overload
547
+ def create_table(
548
+ self,
549
+ name: str,
550
+ table_schema,
551
+ partition_cols: List[str],
552
+ *,
553
+ compress_methods: Dict[str, str] = None,
554
+ sort_cols: List[str] = None,
555
+ keep_duplicates: Union[Literal["ALL", "LAST", "FIRST"], EnumInt] = "ALL",
556
+ sort_key_mapping_function: List[FunctionDef] = None,
557
+ soft_delete: bool = False,
558
+ indexes: List[str] = None,
559
+ ) -> Table:
560
+ pass
561
+
562
+ @overload
563
+ def create_table(
564
+ self,
565
+ name: str,
566
+ table_schema,
567
+ *,
568
+ compress_methods: Dict[str, str] = None,
569
+ sort_cols: List[str] = None,
570
+ keep_duplicates: Union[Literal["ALL", "LAST", "FIRST"], EnumInt] = "ALL",
571
+ soft_delete: bool = False,
572
+ indexes: List[str] = None,
573
+ ) -> Table:
574
+ pass
575
+
576
+ @overload
577
+ def create_table(
578
+ self,
579
+ name: str,
580
+ table_schema,
581
+ partition_cols: List[str],
582
+ *,
583
+ compress_methods: Dict[str, str] = None,
584
+ primary_key_cols: List[str] = None,
585
+ indexes: List[str] = None,
586
+ ) -> Table:
587
+ pass
588
+
589
+ @overload
590
+ def create_table(
591
+ self,
592
+ name: str,
593
+ table_schema,
594
+ *,
595
+ compress_methods: Dict[str, str] = None,
596
+ primary_key_cols: List[str] = None,
597
+ indexes: List[str] = None,
598
+ ) -> Table:
599
+ pass
600
+
601
+ def create_table(
602
+ self,
603
+ name: str,
604
+ table_schema,
605
+ partition_cols: List[str] = None,
606
+ *,
607
+ compress_methods: Dict[str, str] = None,
608
+ sort_cols: List[str] = None,
609
+ primary_key_cols: List[str] = None,
610
+ keep_duplicates: Union[Literal["ALL", "LAST", "FIRST"], EnumInt, None] = None,
611
+ sort_key_mapping_function: List[FunctionDef] = None,
612
+ soft_delete: Optional[bool] = None,
613
+ indexes: List[str] = None,
614
+ ) -> Table:
615
+ """
616
+ Creates a table using a specific storage engine with optional partitioning.
617
+
618
+ This method supports creating tables with three different storage
619
+ engines: OLAP, TSDB, PKEY. Each engine supports creating either:
620
+
621
+ - Partitioned tables: Require `partition_cols` for data partitioning
622
+ - Dimension tables: Do not use partitioning but retain other engine
623
+ capabilities
624
+
625
+ Engine Compatibility Chart:
626
+ +---------------------+-------------------+-------------------+-------------------+
627
+ | Feature | OLAP Engine | TSDB Engine | PKEY Engine |
628
+ +=====================+===================+===================+===================+
629
+ | partition_cols | ✓ (required) [1]_ | ✓ (required) [1]_ | ✓ (required) [1]_ |
630
+ +---------------------+-------------------+-------------------+-------------------+
631
+ | compress_methods | ✓ | ✓ | ✓ |
632
+ +---------------------+-------------------+-------------------+-------------------+
633
+ | sort_cols | | ✓ | |
634
+ +---------------------+-------------------+-------------------+-------------------+
635
+ | primary_key_cols | | | ✓ |
636
+ +---------------------+-------------------+-------------------+-------------------+
637
+ | keep_duplicates | | ✓ | |
638
+ +---------------------+-------------------+-------------------+-------------------+
639
+ | sort_key [2]_ | | ✓ | |
640
+ +---------------------+-------------------+-------------------+-------------------+
641
+ | soft_delete | | ✓ | |
642
+ +---------------------+-------------------+-------------------+-------------------+
643
+ | indexes | | ✓ | ✓ |
644
+ +---------------------+-------------------+-------------------+-------------------+
645
+
646
+ .. [1] Required for partitioned tables only, not for dimension tables
647
+ .. [2] `sort_key_mapping_function` is only available for TSDB
648
+ partitioned tables, not dimension tables
649
+
650
+ Parameters
651
+ ----------
652
+ name : str
653
+ The name of the table.
654
+ table_schema : Any
655
+ The schema definition of the table, a mapping of column names to
656
+ data types.
657
+ partition_cols : list of str, optional
658
+ The partitioning column(s). Defaults to None.
659
+ compress_methods : dict of str to str, optional
660
+ Compression methods for specific columns, where the key is the
661
+ column name and the value is the compression method. Defaults to
662
+ None.
663
+ sort_cols : list of str, optional
664
+ Columns used for sorting to optimize query performance, applicable
665
+ for the TSDB engine. Defaults to None.
666
+ primary_key_cols : list of str, optional
667
+ Columns that act as primary keys, applicable for the PKEY engine.
668
+ Defaults to None.
669
+ keep_duplicates : {"ALL", "LAST", "FIRST"}, EnumInt, optional
670
+ Deduplication strategy, applicable for the TSDB engine. Defaults to
671
+ None.
672
+ - "ALL": Allows all duplicate values.
673
+ - "LAST": Retains only the latest value.
674
+ - "FIRST": Retains only the earliest value.
675
+ sort_key_mapping_function : list of FunctionDef, optional
676
+ A list of functions for defining sorting key mappings, applicable
677
+ for the TSDB engine (partitioned table). Defaults to None.
678
+ soft_delete : bool, optional
679
+ Enables soft delete functionality, applicable for the TSDB engine.
680
+ Defaults to None.
681
+ indexes : list of str, optional
682
+ A list of columns to create indexes on, used for query
683
+ optimization. Applicable for the TSDB and PKEY engine. Defaults to
684
+ None.
685
+
686
+ Returns
687
+ -------
688
+ Table
689
+ The created table instance.
690
+
691
+ Examples
692
+ --------
693
+ Creating a partitioned table with the OLAP engine
694
+ >>> schema.create_table("quote", table_schema={'id': "INT",
695
+ ... 'date': "DATE", 'value': "DOUBLE"}, partition_cols=["id"],
696
+ ... compress_methods={"id": "lz4"}))
697
+
698
+ Creating a dimension table with the OLAP engine
699
+ >>> schema.create_table("quote", table_schema={'id': "INT",
700
+ ... 'date': "DATE", 'value': "DOUBLE"}, compress_methods={"id":
701
+ ... "lz4"})
702
+
703
+ Creating a partitioned table with the TSDB engine
704
+ >>> import swordfish as sf
705
+ >>> import swordfish.function as F
706
+ >>> schema.create_table(
707
+ ... name="quote",
708
+ ... table_schema={'id': "INT", 'date': "DATE", 'value':
709
+ ... "DOUBLE"},
710
+ ... partition_cols=["id"],
711
+ ... compress_methods={"id": "lz4"},
712
+ ... sort_cols=["date", "id"],
713
+ ... keep_duplicates="LAST",
714
+ ... sort_key_mapping_function=[sf.partial(F.hashBucket,
715
+ ... buckets=5)],
716
+ ... soft_delete=True,
717
+ ... indexes=["id", "date"],
718
+ ... )
719
+
720
+ Creating a dimension table with the TSDB engine
721
+ >>> schema.create_table(
722
+ ... name="quote",
723
+ ... table_schema={'id': "INT", 'date': "DATE", 'value':
724
+ ... "DOUBLE"},
725
+ ... compress_methods={"id": "lz4"},
726
+ ... sort_cols=['timestamp', 'value'],
727
+ ... keep_duplicates="LAST",
728
+ ... soft_delete=True,
729
+ ... indexes=['name', 'timestamp'],
730
+ ... )
731
+
732
+ Creating a partitioned table with the PKEY engine
733
+ >>> schema.create_table(
734
+ ... name="quote",
735
+ ... table_schema={'id': "INT", 'date': "DATE", 'value':
736
+ ... "DOUBLE"},
737
+ ... partition_cols=["id"],
738
+ ... compress_methods={"id": "lz4"},
739
+ ... primary_key_cols=["id"],
740
+ ... indexes=["timestamp"],
741
+ ... )
742
+
743
+ Creating a dimension table with the PKEY engine
744
+ >>> schema.create_table(
745
+ ... name="quote",
746
+ ... table_schema={'id': "INT", 'date': "DATE", 'value':
747
+ ... "DOUBLE"},
748
+ ... compress_methods={"value": "lz4"},
749
+ ... primary_key_cols=["id"],
750
+ ... indexes=["name"],
751
+ ... )
752
+ """
753
+ if compress_methods is None:
754
+ compress_methods = sf_data.Nothing
755
+ if sort_cols is None:
756
+ sort_cols = sf_data.Nothing
757
+ if primary_key_cols is not None:
758
+ sort_cols = primary_key_cols
759
+ if keep_duplicates is None:
760
+ keep_duplicates = sf_data.Nothing
761
+ if sort_key_mapping_function is None:
762
+ sort_key_mapping_function = sf_data.Nothing
763
+ if soft_delete is None:
764
+ soft_delete = sf_data.Nothing
765
+ if indexes is None:
766
+ indexes = sf_data.Nothing
767
+
768
+ if isinstance(table_schema, dict):
769
+ table_schema = sf_data.table(types=table_schema, size=0, capacity=1)
770
+ if isinstance(keep_duplicates, str):
771
+ map_d = {
772
+ 'ALL': ALL,
773
+ 'LAST': LAST,
774
+ 'FIRST': FIRST,
775
+ }
776
+ keep_duplicates = map_d[keep_duplicates]
777
+ if partition_cols is None:
778
+ # create dimension table
779
+ return self.impl.create_dimension_table(
780
+ table_schema,
781
+ name,
782
+ compress_methods,
783
+ sort_cols,
784
+ keep_duplicates,
785
+ soft_delete,
786
+ indexes,
787
+ )
788
+ return self.impl.create_partitioned_table(
789
+ table_schema,
790
+ name,
791
+ partition_cols,
792
+ compress_methods,
793
+ sort_cols,
794
+ keep_duplicates,
795
+ sort_key_mapping_function,
796
+ soft_delete,
797
+ indexes,
798
+ )
799
+
800
+ def list_tables(self):
801
+ """
802
+ Retrieves the names of all tables in the schema.
803
+
804
+ Returns
805
+ -------
806
+ list of str
807
+ A list of table names.
808
+
809
+ Examples
810
+ --------
811
+ >>> schema.list_tables()
812
+ """
813
+ return self.impl.list_table()
814
+
815
+ def exists_table(self, name: str) -> bool:
816
+ return self.impl.exists_table(name)
817
+
818
+ def drop_table(self, name: str):
819
+ """
820
+ Drops a table from the schema.
821
+
822
+ Parameters
823
+ ----------
824
+ name : str
825
+ The name of the table to be dropped.
826
+
827
+ Examples
828
+ --------
829
+ >>> schema.drop_table("table_name")
830
+ """
831
+ return self.impl.drop_table(name)
832
+
833
+ def truncate_table(self, name: str):
834
+ """
835
+ Truncates a table in the schema.
836
+
837
+ Parameters
838
+ ----------
839
+ name : str
840
+ The name of the table to truncate.
841
+
842
+ Examples
843
+ --------
844
+ >>> schema.truncate_table("table_name")
845
+ """
846
+ return self.impl.truncate_table(name)
847
+
848
+ def table(self, name: str):
849
+ """
850
+ Retrieves a table by name.
851
+
852
+ Parameters
853
+ ----------
854
+ name : str
855
+ The name of the table to retrieve.
856
+
857
+ Returns
858
+ -------
859
+ Table
860
+ The Table corresponding to the specified name.
861
+
862
+ Examples
863
+ --------
864
+ >>> schema.table("table_name")
865
+ """
866
+ return self.impl.get_table(name)
867
+
868
+ @property
869
+ def engine_type(self) -> StorageType:
870
+ """
871
+ Retrieves the storage engine type.
872
+
873
+ Returns
874
+ -------
875
+ StorageType
876
+ The type of storage engine.
877
+ """
878
+ return self.impl.get_engine_type()
879
+
880
+
881
+ class CatalogConnection(Connection[CatalogConnectionImpl]):
882
+ """
883
+ Manages connections to database catalogs.
884
+
885
+ Examples
886
+ --------
887
+ >>> import swordfish as sf
888
+ >>> conn = sf.connect(catalog="catalog_name")
889
+ """
890
+ def __init__(self, impl):
891
+ super().__init__(impl)
892
+
893
+ def create_schema(
894
+ self,
895
+ name,
896
+ partition: Partition,
897
+ *,
898
+ engine: Literal["OLAP", "TSDB", "PKEY"] = "OLAP",
899
+ atomic: Literal["TRANS", "CHUNK"] = "TRANS",
900
+ ) -> Schema:
901
+ """
902
+ Creates a new schema.
903
+
904
+ Parameters
905
+ ----------
906
+ name : str
907
+ The name of the schema to create.
908
+ partition : Partition
909
+ Defines the partitioning type and scheme.
910
+ engine : {"OLAP", "TSDB", "PKEY"}, optional
911
+ The storage engine type to use. Defaults to "OLAP".
912
+ atomic : {"TRANS", "CHUNK"}, optional
913
+ In cases of concurrent writes to the same partition, write conflicts
914
+ can occur. Swordfish manages these conflicts through the atomic
915
+ parameter set during schema creation, offering two modes:
916
+
917
+ - 'TRANS' (default): Write operations are terminated upon detecting a
918
+ conflict, ensuring transaction atomicity. Users themselves must
919
+ ensure that concurrent writes to the same partition are prevented.
920
+
921
+ - 'CHUNK': The system automatically handles conflicts and retries
922
+ writes, but splits a single write operation into multiple
923
+ transactions, which cannot guarantee overall atomicity.
924
+
925
+ Returns
926
+ -------
927
+ Schema
928
+ A Schema created based on the given parameters.
929
+
930
+ Examples
931
+ --------
932
+ >>> conn = sf.connect("catalog_name")
933
+ >>> conn.create_schema(name="my_schema", engine="OLAP",
934
+ ... partition=sf.Partition.range(sf.vector([0, 5, 10], type="INT")))
935
+ """
936
+ partition_type, partition_scheme = partition.build()
937
+ locations = sf_data.Nothing
938
+ impl = self.impl.create_schema(url=name, engine=engine,
939
+ partition_type=partition_type,
940
+ partition_scheme=partition_scheme,
941
+ locations=locations, atomic=atomic)
942
+ return Schema(impl)
943
+
944
+ def list_schemas(self):
945
+ """
946
+ Lists all schemas available in the catalog.
947
+
948
+ Returns
949
+ -------
950
+ list of str
951
+ A list of the names of schemas.
952
+
953
+ Examples
954
+ --------
955
+ >>> conn.list_schemas()
956
+ """
957
+ return self.impl.list_schema()
958
+
959
+ def exists_schema(self, name: str) -> bool:
960
+ return self.impl.exists_schema(name)
961
+
962
+ def drop_schema(self, name: str):
963
+ """
964
+ Drops the specified schema from the catalog.
965
+
966
+ Parameters
967
+ ----------
968
+ name : str
969
+ The name of the schema to drop.
970
+ """
971
+ return self.impl.drop_schema(name)
972
+
973
+ def schema(self, name: str) -> Schema:
974
+ """
975
+ Retrieves a schema by name.
976
+
977
+ Parameters
978
+ ----------
979
+ name : str
980
+ The name of the schema to retrieve.
981
+
982
+ Returns
983
+ -------
984
+ Schema
985
+ The schema corresponding to the given name.
986
+ """
987
+ return Schema(self.impl.get_schema(name))
988
+
989
+
990
+ class RemoteTable:
991
+ def __init__(self, conn, name: str):
992
+ self.conn = conn
993
+ self.name = name
994
+
995
+ def subscribe(
996
+ self, action_name, handler, *,
997
+ offset: int = -1, msg_as_table: bool = False, batch_size: int = 0,
998
+ throttle: float = 1, hash: int = -1, reconnect: bool = False, filter=None,
999
+ persist_offset: bool = False, time_trigger: bool = False,
1000
+ handler_need_msg_id: bool = False,
1001
+ ) -> SubscriptionHelper:
1002
+ """
1003
+ Subscribes to a remote table for receiving messages.
1004
+
1005
+ Examples
1006
+ --------
1007
+ >>> def my_handler(msg):
1008
+ ... print(msg)
1009
+ >>> t = conn.table("remote_table")
1010
+ >>> topic = t.subscribe("my_action", my_handler, offset=0, msg_as_table=True).submit()
1011
+ """
1012
+ return subscribe_impl_with_conn(
1013
+ self.conn.impl,
1014
+ self.name,
1015
+ action_name,
1016
+ handler,
1017
+ offset=offset,
1018
+ msg_as_table=msg_as_table,
1019
+ batch_size=batch_size,
1020
+ throttle=throttle,
1021
+ hash=hash,
1022
+ reconnect=reconnect,
1023
+ filter=filter,
1024
+ persist_offset=persist_offset,
1025
+ time_trigger=time_trigger,
1026
+ handler_need_msg_id=handler_need_msg_id,
1027
+ )
1028
+
1029
+
1030
+ class RemoteConnection(Connection[RemoteConnectionImpl]):
1031
+ """
1032
+ Manages connections to OLTP databases.
1033
+
1034
+ Examples
1035
+ --------
1036
+ >>> import swordfish as sf
1037
+ >>> conn = sf.connect(host="192.168.1.2", port=8848, user="admin", passwd="123456")
1038
+ """
1039
+ def __init__(self, impl):
1040
+ super().__init__(impl)
1041
+
1042
+ def table(self, name: str) -> RemoteTable:
1043
+ """
1044
+ Retrieves a specific table handle from the remote database.
1045
+
1046
+ Parameters
1047
+ ----------
1048
+ name : str
1049
+ The name of the table.
1050
+
1051
+ Returns
1052
+ -------
1053
+ Table
1054
+ The corresponding table object.
1055
+
1056
+ Examples
1057
+ --------
1058
+ >>> t = conn.table("table_name")
1059
+ """
1060
+ count = self.impl.session().exec(f"""EXEC count(*) FROM objs(true) WHERE name = "{name}" AND form = "TABLE";""")
1061
+ if count.to_python():
1062
+ return RemoteTable(self, name)
1063
+ raise ProgrammingError(f"RemoteTable '{name}' does not exist.")
1064
+
1065
+
1066
+ class CaseWhen:
1067
+ def __init__(self, ctx: "MetaCodeContext"):
1068
+ self.ctx = ctx
1069
+ self._whens = []
1070
+ self._values = []
1071
+ self._other = sf_data.NULL
1072
+
1073
+ def _process_expr(self, expr: Any):
1074
+ if hasattr(expr, "__sf_constant__"):
1075
+ expr = expr.__sf_constant__
1076
+ if isinstance(expr, MetaCode):
1077
+ return expr
1078
+ if isinstance(expr, str):
1079
+ return self.ctx.parse(str(expr))
1080
+ return self.ctx.const(expr)
1081
+
1082
+ def when(self, cond: Union[MetaCode, str], then: Union[MetaCode, str]):
1083
+ self._whens.append(self._process_expr(cond))
1084
+ self._values.append(self._process_expr(then))
1085
+ return self
1086
+
1087
+ def else_(self, then: Union[MetaCode, str]):
1088
+ self._other = self._process_expr(then)
1089
+ return self
1090
+
1091
+ @property
1092
+ def __sf_constant__(self):
1093
+ return self.ctx.impl.casewhen(self._whens, self._values, self._other)
1094
+
1095
+
1096
+ class MetaCodeContext:
1097
+ """
1098
+ Used for generating meta code.
1099
+
1100
+ Examples
1101
+ --------
1102
+ >>> with sf.meta_code() as m:
1103
+ ... code = m.var("a")
1104
+ >>> code
1105
+ MetaCode(< a >)
1106
+ """
1107
+ def __init__(self, impl: MetaCodeContextImpl) -> None:
1108
+ self.impl = impl
1109
+
1110
+ def __enter__(self):
1111
+ self.impl.__enter__()
1112
+ return self
1113
+
1114
+ def __exit__(self, exc_type, exc_value, traceback):
1115
+ self.impl.__exit__(exc_type, exc_value, traceback)
1116
+
1117
+ def var(self, name: str) -> MetaCode:
1118
+ """
1119
+ Generates meta code representing a variable by its name.
1120
+
1121
+ Parameters
1122
+ ----------
1123
+ name : str
1124
+ The name of the variable.
1125
+
1126
+ Returns
1127
+ -------
1128
+ MetaCode
1129
+ The generated meta code.
1130
+
1131
+ Examples
1132
+ --------
1133
+ >>> with sf.meta_code() as m:
1134
+ ... code = m.var("a")
1135
+ >>> code
1136
+ MetaCode(< a >)
1137
+ """
1138
+ return self.impl.var(name)
1139
+
1140
+ def const(self, obj: Constant) -> MetaCode:
1141
+ """
1142
+ Generates meta code representing a Constant.
1143
+
1144
+ Parameters
1145
+ ----------
1146
+ obj : Constant
1147
+ The constant object.
1148
+
1149
+ Returns
1150
+ -------
1151
+ MetaCode
1152
+ The generated meta code.
1153
+
1154
+ Examples
1155
+ --------
1156
+ >>> with sf.meta_code():
1157
+ ... code = x.const(2)
1158
+ >>> code
1159
+ MetaCode(< 2 >)
1160
+ """
1161
+ return self.impl.const(obj)
1162
+
1163
+ def col(self, name: str, *, qualifier: str = None) -> MetaCode:
1164
+ """
1165
+ Generates meta code for a column.
1166
+
1167
+ Parameters
1168
+ ----------
1169
+ name : str
1170
+ The name of the column.
1171
+ qualifier : str, optional
1172
+ The qualifier for the column. Defaults to None.
1173
+
1174
+ Returns
1175
+ -------
1176
+ MetaCode
1177
+ The generated meta code.
1178
+
1179
+ Examples
1180
+ --------
1181
+ >>> with sf.meta_code():
1182
+ ... code = x.col("id", qualifier="t")
1183
+ >>> code
1184
+ MetaCode(< t.id >)
1185
+ """
1186
+ return self.impl.col(name, qualifier=qualifier)
1187
+
1188
+ def col_alias(self, obj: MetaCode, name: Union[str, List[str]]) -> MetaCode:
1189
+ """
1190
+ Generates meta code for assigning an alias to a column or aliases to columns.
1191
+
1192
+ Parameters
1193
+ ----------
1194
+ obj : MetaCode
1195
+ The original meta code for the column.
1196
+ name : Union[str, List[str]]
1197
+ The alias name(s).
1198
+
1199
+ Returns
1200
+ -------
1201
+ MetaCode
1202
+ The meta code with the column alias applied.
1203
+
1204
+ Examples
1205
+ --------
1206
+ >>> with sf.meta_code():
1207
+ ... code = x.col_alias(x.col("id"), "col1")
1208
+ >>> code
1209
+ MetaCode(< id as col1 >)
1210
+ """
1211
+ return self.impl.col_alias(obj, name)
1212
+
1213
+ def parse(self, expression: str) -> MetaCode:
1214
+ """
1215
+ Parses a string expression into corresponding meta code.
1216
+
1217
+ Parameters
1218
+ ----------
1219
+ expression : str
1220
+ The expression to parse into meta code.
1221
+
1222
+ Returns
1223
+ -------
1224
+ MetaCode
1225
+ The parsed meta code corresponding to the expression.
1226
+
1227
+ Examples
1228
+ --------
1229
+ >>> with sf.meta_code():
1230
+ ... code = x.parse("a == 5")
1231
+ >>> code
1232
+ MetaCode(< a == 5 >)
1233
+ """
1234
+ return self.impl.parse(expression)
1235
+
1236
+ def call(self, func, *args) -> MetaCode:
1237
+ return self.impl.call(func, *args)
1238
+
1239
+ def make_table_joiner(self, func, *args) -> MetaCode:
1240
+ return self.impl.tablejoiner(func, *args)
1241
+
1242
+ @property
1243
+ def case_(self):
1244
+ return CaseWhen(self)
1245
+
1246
+
1247
+ class EmptyContext:
1248
+ """
1249
+ Used for generating empty context.
1250
+
1251
+ Examples
1252
+ --------
1253
+ >>> with sf.empty_context() as ctx:
1254
+ ... pass
1255
+ """
1256
+ def __init__(self, impl: EmptyContextImpl) -> None:
1257
+ self.impl = impl
1258
+
1259
+ def __enter__(self):
1260
+ self.impl.__enter__()
1261
+ return self
1262
+
1263
+ def __exit__(self, exc_type, exc_value, traceback):
1264
+ self.impl.__exit__(exc_type, exc_value, traceback)
1265
+
1266
+
1267
+ def list_catalogs():
1268
+ """Retrieves all available catalogs.
1269
+
1270
+ Returns:
1271
+ list: A list of all catalogs.
1272
+
1273
+ Examples:
1274
+ >>> sf.list_catalogs()
1275
+ Vector(["trading"], type=STRING)
1276
+ """
1277
+ return _global_call("getAllCatalogs")
1278
+
1279
+
1280
+ def exists_catalog(catalog) -> bool:
1281
+ """Checkes if a catalog exists.
1282
+
1283
+ Args:
1284
+ catalog (str): The name of the catalog to check.
1285
+
1286
+ Returns:
1287
+ bool: True if the catalog exists, False otherwise.
1288
+
1289
+ Examples:
1290
+ >>> sf.exists_catalog("trading")
1291
+ True
1292
+ """
1293
+ return bool(_global_call("existsCatalog", catalog))
1294
+
1295
+
1296
+ def create_catalog(catalog):
1297
+ """Creates a catalog.
1298
+
1299
+ Args:
1300
+ catalog (str): The name of the catalog to create.
1301
+
1302
+ Examples:
1303
+ >>> sf.create_catalog("catalog_name")
1304
+ """
1305
+ return _global_call("createCatalog", catalog)
1306
+
1307
+
1308
+ def drop_catalog(catalog):
1309
+ """Drops an existing catalog.
1310
+
1311
+ Args:
1312
+ catalog (str): The name of the catalog to drop.
1313
+
1314
+ Examples:
1315
+ >>> sf.drop_catalog("catalog_name")
1316
+ """
1317
+ return _global_call("dropCatalog", catalog)
1318
+
1319
+
1320
+ @overload
1321
+ def connect() -> DefaultSessionConnection:
1322
+ pass
1323
+
1324
+
1325
+ @overload
1326
+ def connect(catalog: str) -> CatalogConnection:
1327
+ pass
1328
+
1329
+
1330
+ @overload
1331
+ def connect(*, url: str, option: Optional[Union[OLTPOption, dict]] = None) -> OLTPConnection:
1332
+ pass
1333
+
1334
+
1335
+ @overload
1336
+ def connect(*, host: str, port: int, user: str = "", passwd: str = "") -> RemoteConnection:
1337
+ pass
1338
+
1339
+
1340
+ def connect(catalog: Optional[str] = None, *, url: Optional[str] = None, option: Optional[Union[Config, dict]] = None,
1341
+ host: str = None, port: int = None, user: str = "", passwd: str = "") -> Connection:
1342
+ """Establishes a connection to different types of databases or sessions based on the provided parameters.
1343
+
1344
+ This function supports multiple connection methods depending on the given arguments:
1345
+
1346
+ 1. If no arguments are provided, it establishes a connection to the default session.
1347
+ 2. If a `catalog` name is provided, it connects to a specific catalog.
1348
+ 3. If a `url` is provided, it establishes a connection to an OLTP database, optionally using additional connection options.
1349
+ 4. If `host` and `port` are provided, it connects to a remote database, optionally using `user` and `passwd` for authentication.
1350
+
1351
+ Args:
1352
+ catalog (Optional[str], optional): The name of the catalog to connect to. Defaults to `None`.
1353
+ url (Optional[str], optional): The URL of the OLTP database. Defaults to `None`.
1354
+ option (Config, optional): Additional options for the connection. Defaults to `None`.
1355
+ host (str, optional): The hostname of the remote database. Defaults to `None`.
1356
+ port (int, optional): The port number of the remote database. Defaults to `None`.
1357
+ user (str, optional): The username for authentication. Defaults to an empty string.
1358
+ passwd (str, optional): The password for authentication. Defaults to an empty string.
1359
+
1360
+ Returns:
1361
+ Connection: An established connection based on the provided arguments.
1362
+ - The first method returns a DefaultSessionConnection object.
1363
+ - The second method returns a CatalogConnection object.
1364
+ - The third method returns a OLTPConnection object.
1365
+ - The fourth method returns a RemoteConnection object.
1366
+
1367
+ Examples:
1368
+ Connect to the default session:
1369
+
1370
+ >>> conn = sf.connect()
1371
+
1372
+ Connect to a specific catalog:
1373
+
1374
+ >>> conn = sf.connect(catalog="catalog_name")
1375
+
1376
+ Connect to an OLTP database:
1377
+
1378
+ >>> conn = sf.connect(url="url_name", option={'readOnly': True})
1379
+
1380
+ Connect to a remote database:
1381
+
1382
+ >>> conn = sf.connect(host="192.168.1.2", port=8848, user="admin", passwd="123456")
1383
+ """
1384
+ if url is not None: # check as OLTP connection
1385
+ url = str(url)
1386
+ if option is None:
1387
+ option = OLTPOption()
1388
+ if isinstance(option, dict) and not isinstance(option, Config):
1389
+ option = OLTPOption(option)
1390
+ return OLTPConnection(OLTPConnectionImpl.connect(url, option))
1391
+ elif catalog is not None: # check as Catalog connection
1392
+ catalog = str(catalog)
1393
+ return CatalogConnection(CatalogConnectionImpl.connect(catalog))
1394
+ elif host is not None and port is not None:
1395
+ return RemoteConnection(RemoteConnectionImpl.connect(host, port, user, passwd))
1396
+ else: # connect to Default
1397
+ return DefaultSessionConnection(DefaultSessionConnectionImpl.create())
1398
+
1399
+
1400
+ def meta_code() -> MetaCodeContext:
1401
+ """Generates the MetaCode context for working with MetaCode.
1402
+
1403
+ Returns:
1404
+ MetaCodeContext: A MetaCodeContext.
1405
+
1406
+ Examples:
1407
+ >>> import swordfish as sf
1408
+ >>> import swordfish.function as F
1409
+ >>> with sf.meta_code() as m:
1410
+ ... metrics = F.add(m.col("a"), 1)
1411
+ >>> metrics
1412
+ < add(a, 1) >
1413
+ """
1414
+ return MetaCodeContext(MetaCodeContextImpl.create())
1415
+
1416
+
1417
+ def empty_context() -> EmptyContext:
1418
+ return EmptyContext(EmptyContextImpl.create())