singlestoredb 1.0.4__tar.gz → 1.2.0__tar.gz

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.

Potentially problematic release.


This version of singlestoredb might be problematic. Click here for more details.

Files changed (131) hide show
  1. {singlestoredb-1.0.4/singlestoredb.egg-info → singlestoredb-1.2.0}/PKG-INFO +1 -1
  2. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/accel.c +315 -32
  3. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/setup.cfg +3 -2
  4. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/__init__.py +1 -1
  5. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/config.py +131 -0
  6. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/connection.py +3 -0
  7. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/converters.py +390 -0
  8. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/functions/dtypes.py +5 -198
  9. singlestoredb-1.2.0/singlestoredb/functions/ext/__init__.py +1 -0
  10. singlestoredb-1.2.0/singlestoredb/functions/ext/asgi.py +1179 -0
  11. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/functions/ext/json.py +2 -2
  12. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/functions/ext/mmap.py +174 -67
  13. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/functions/ext/rowdat_1.py +2 -2
  14. singlestoredb-1.2.0/singlestoredb/functions/ext/utils.py +169 -0
  15. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/fusion/handler.py +115 -9
  16. singlestoredb-1.2.0/singlestoredb/fusion/handlers/stage.py +490 -0
  17. singlestoredb-1.2.0/singlestoredb/fusion/handlers/workspace.py +815 -0
  18. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/fusion/registry.py +86 -1
  19. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/http/connection.py +40 -2
  20. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/management/__init__.py +1 -0
  21. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/management/organization.py +4 -0
  22. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/management/utils.py +2 -2
  23. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/management/workspace.py +79 -6
  24. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/connection.py +81 -0
  25. singlestoredb-1.2.0/singlestoredb/mysql/constants/EXTENDED_TYPE.py +3 -0
  26. singlestoredb-1.2.0/singlestoredb/mysql/constants/FIELD_TYPE.py +48 -0
  27. singlestoredb-1.2.0/singlestoredb/mysql/constants/VECTOR_TYPE.py +6 -0
  28. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/cursors.py +177 -4
  29. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/protocol.py +50 -1
  30. singlestoredb-1.2.0/singlestoredb/notebook/__init__.py +15 -0
  31. singlestoredb-1.2.0/singlestoredb/notebook/_objects.py +212 -0
  32. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test.sql +259 -0
  33. singlestoredb-1.2.0/singlestoredb/tests/test_connection.py +3056 -0
  34. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test_ext_func.py +2 -2
  35. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test_ext_func_data.py +1 -1
  36. singlestoredb-1.2.0/singlestoredb/utils/dtypes.py +205 -0
  37. singlestoredb-1.2.0/singlestoredb/utils/results.py +581 -0
  38. {singlestoredb-1.0.4 → singlestoredb-1.2.0/singlestoredb.egg-info}/PKG-INFO +1 -1
  39. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb.egg-info/SOURCES.txt +6 -0
  40. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb.egg-info/requires.txt +3 -0
  41. singlestoredb-1.0.4/singlestoredb/functions/ext/__init__.py +0 -2
  42. singlestoredb-1.0.4/singlestoredb/functions/ext/asgi.py +0 -661
  43. singlestoredb-1.0.4/singlestoredb/fusion/handlers/stage.py +0 -257
  44. singlestoredb-1.0.4/singlestoredb/fusion/handlers/workspace.py +0 -412
  45. singlestoredb-1.0.4/singlestoredb/mysql/constants/FIELD_TYPE.py +0 -32
  46. singlestoredb-1.0.4/singlestoredb/tests/test_connection.py +0 -1474
  47. singlestoredb-1.0.4/singlestoredb/utils/results.py +0 -228
  48. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/LICENSE +0 -0
  49. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/README.md +0 -0
  50. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/setup.py +0 -0
  51. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/alchemy/__init__.py +0 -0
  52. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/auth.py +0 -0
  53. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/exceptions.py +0 -0
  54. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/functions/__init__.py +0 -0
  55. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/functions/decorator.py +0 -0
  56. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/functions/ext/arrow.py +0 -0
  57. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/functions/signature.py +0 -0
  58. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/fusion/__init__.py +0 -0
  59. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/fusion/graphql.py +0 -0
  60. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/fusion/handlers/__init__.py +0 -0
  61. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/fusion/handlers/utils.py +0 -0
  62. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/fusion/result.py +0 -0
  63. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/http/__init__.py +0 -0
  64. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/management/billing_usage.py +0 -0
  65. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/management/cluster.py +0 -0
  66. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/management/manager.py +0 -0
  67. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/management/region.py +0 -0
  68. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/__init__.py +0 -0
  69. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/_auth.py +0 -0
  70. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/charset.py +0 -0
  71. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/constants/CLIENT.py +0 -0
  72. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/constants/COMMAND.py +0 -0
  73. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/constants/CR.py +0 -0
  74. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/constants/ER.py +0 -0
  75. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/constants/FLAG.py +0 -0
  76. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/constants/SERVER_STATUS.py +0 -0
  77. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/constants/__init__.py +0 -0
  78. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/converters.py +0 -0
  79. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/err.py +0 -0
  80. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/optionfile.py +0 -0
  81. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/__init__.py +0 -0
  82. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/base.py +0 -0
  83. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/conftest.py +0 -0
  84. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/test_DictCursor.py +0 -0
  85. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/test_SSCursor.py +0 -0
  86. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/test_basic.py +0 -0
  87. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/test_connection.py +0 -0
  88. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/test_converters.py +0 -0
  89. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/test_cursor.py +0 -0
  90. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/test_err.py +0 -0
  91. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/test_issues.py +0 -0
  92. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/test_load_local.py +0 -0
  93. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/test_nextset.py +0 -0
  94. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/test_optionfile.py +0 -0
  95. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/thirdparty/__init__.py +0 -0
  96. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/__init__.py +0 -0
  97. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/capabilities.py +0 -0
  98. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/dbapi20.py +0 -0
  99. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_capabilities.py +0 -0
  100. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_dbapi20.py +0 -0
  101. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_nonstandard.py +0 -0
  102. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/mysql/times.py +0 -0
  103. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/pytest.py +0 -0
  104. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/__init__.py +0 -0
  105. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/empty.sql +0 -0
  106. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/ext_funcs/__init__.py +0 -0
  107. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/local_infile.csv +0 -0
  108. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test2.sql +0 -0
  109. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test_basics.py +0 -0
  110. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test_config.py +0 -0
  111. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test_dbapi.py +0 -0
  112. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test_exceptions.py +0 -0
  113. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test_fusion.py +0 -0
  114. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test_http.py +0 -0
  115. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test_management.py +0 -0
  116. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test_plugin.py +0 -0
  117. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test_results.py +0 -0
  118. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test_types.py +0 -0
  119. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test_udf.py +0 -0
  120. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/test_xdict.py +0 -0
  121. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/tests/utils.py +0 -0
  122. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/types.py +0 -0
  123. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/utils/__init__.py +0 -0
  124. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/utils/config.py +0 -0
  125. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/utils/convert_rows.py +0 -0
  126. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/utils/debug.py +0 -0
  127. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/utils/mogrify.py +0 -0
  128. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb/utils/xdict.py +0 -0
  129. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb.egg-info/dependency_links.txt +0 -0
  130. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb.egg-info/entry_points.txt +0 -0
  131. {singlestoredb-1.0.4 → singlestoredb-1.2.0}/singlestoredb.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: singlestoredb
3
- Version: 1.0.4
3
+ Version: 1.2.0
4
4
  Summary: Interface to the SingleStoreDB database and workspace management APIs
5
5
  Home-page: https://github.com/singlestore-labs/singlestoredb-python
6
6
  Author: SingleStore
@@ -16,6 +16,10 @@
16
16
  #define ACCEL_OUT_STRUCTSEQUENCES 1
17
17
  #define ACCEL_OUT_DICTS 2
18
18
  #define ACCEL_OUT_NAMEDTUPLES 3
19
+ #define ACCEL_OUT_NUMPY 4
20
+ #define ACCEL_OUT_PANDAS 5
21
+ #define ACCEL_OUT_POLARS 6
22
+ #define ACCEL_OUT_ARROW 7
19
23
 
20
24
  #define NUMPY_BOOL 1
21
25
  #define NUMPY_INT8 2
@@ -77,6 +81,21 @@
77
81
  #define MYSQL_TYPE_STRING 254
78
82
  #define MYSQL_TYPE_GEOMETRY 255
79
83
 
84
+ // SingleStoreDB extended types
85
+ #define MYSQL_TYPE_BSON 1001
86
+ #define MYSQL_TYPE_FLOAT32_VECTOR_JSON 2001
87
+ #define MYSQL_TYPE_FLOAT64_VECTOR_JSON 2002
88
+ #define MYSQL_TYPE_INT8_VECTOR_JSON 2003
89
+ #define MYSQL_TYPE_INT16_VECTOR_JSON 2004
90
+ #define MYSQL_TYPE_INT32_VECTOR_JSON 2005
91
+ #define MYSQL_TYPE_INT64_VECTOR_JSON 2006
92
+ #define MYSQL_TYPE_FLOAT32_VECTOR 3001
93
+ #define MYSQL_TYPE_FLOAT64_VECTOR 3002
94
+ #define MYSQL_TYPE_INT8_VECTOR 3003
95
+ #define MYSQL_TYPE_INT16_VECTOR 3004
96
+ #define MYSQL_TYPE_INT32_VECTOR 3005
97
+ #define MYSQL_TYPE_INT64_VECTOR 3006
98
+
80
99
  #define MYSQL_TYPE_CHAR MYSQL_TYPE_TINY
81
100
  #define MYSQL_TYPE_INTERVAL MYSQL_TYPE_ENUM
82
101
 
@@ -329,6 +348,8 @@ typedef struct {
329
348
  inline int IMAX(int a, int b) { return((a) > (b) ? a : b); }
330
349
  inline int IMIN(int a, int b) { return((a) < (b) ? a : b); }
331
350
 
351
+ static PyObject *create_numpy_array(PyObject *py_memview, char *data_format, int data_type, PyObject *py_objs);
352
+
332
353
  char *_PyUnicode_AsUTF8(PyObject *unicode) {
333
354
  PyObject *bytes = PyUnicode_AsEncodedString(unicode, "utf-8", "strict");
334
355
  if (!bytes) return NULL;
@@ -389,6 +410,17 @@ typedef struct {
389
410
  PyObject *Series;
390
411
  PyObject *array;
391
412
  PyObject *vectorize;
413
+ PyObject *DataFrame;
414
+ PyObject *Table;
415
+ PyObject *from_pylist;
416
+ PyObject *int8;
417
+ PyObject *int16;
418
+ PyObject *int32;
419
+ PyObject *int64;
420
+ PyObject *float32;
421
+ PyObject *float64;
422
+ PyObject *unpack;
423
+ PyObject *decode;
392
424
  } PyStrings;
393
425
 
394
426
  static PyStrings PyStr = {0};
@@ -406,6 +438,12 @@ typedef struct {
406
438
  PyObject *collections_namedtuple;
407
439
  PyObject *numpy_array;
408
440
  PyObject *numpy_vectorize;
441
+ PyObject *pandas_DataFrame;
442
+ PyObject *polars_DataFrame;
443
+ PyObject *pyarrow_Table;
444
+ PyObject *pyarrow_Table_from_pylist;
445
+ PyObject *struct_unpack;
446
+ PyObject *bson_decode;
409
447
  } PyFunctions;
410
448
 
411
449
  static PyFunctions PyFunc = {0};
@@ -417,6 +455,9 @@ typedef struct {
417
455
  PyObject *namedtuple_kwargs;
418
456
  PyObject *create_numpy_array_args;
419
457
  PyObject *create_numpy_array_kwargs;
458
+ PyObject *create_numpy_array_kwargs_vector[7];
459
+ PyObject *struct_unpack_args;
460
+ PyObject *bson_decode_args;
420
461
  } PyObjects;
421
462
 
422
463
  static PyObjects PyObj = {0};
@@ -466,10 +507,111 @@ typedef struct {
466
507
  char *encoding_errors;
467
508
  } StateObject;
468
509
 
469
- static void read_options(MySQLAccelOptions *options, PyObject *dict);
510
+ static int read_options(MySQLAccelOptions *options, PyObject *dict);
470
511
 
471
512
  #define DESTROY(x) do { if (x) { free((void*)x); (x) = NULL; } } while (0)
472
513
 
514
+ int ensure_numpy() {
515
+ if (PyFunc.numpy_array && PyFunc.numpy_vectorize) goto exit;
516
+
517
+ // Import numpy if it exists
518
+ PyObject *numpy_mod = PyImport_ImportModule("numpy");
519
+ if (!numpy_mod) goto error;
520
+
521
+ PyFunc.numpy_array = PyObject_GetAttr(numpy_mod, PyStr.array);
522
+ if (!PyFunc.numpy_array) goto error;
523
+
524
+ PyFunc.numpy_vectorize = PyObject_GetAttr(numpy_mod, PyStr.vectorize);
525
+ if (!PyFunc.numpy_vectorize) goto error;
526
+
527
+ exit:
528
+ return 0;
529
+
530
+ error:
531
+ PyErr_Clear();
532
+ return -1;
533
+ }
534
+
535
+
536
+ int ensure_pandas() {
537
+ if (PyFunc.pandas_DataFrame) goto exit;
538
+
539
+ // Import pandas if it exists
540
+ PyObject *pandas_mod = PyImport_ImportModule("pandas");
541
+ if (!pandas_mod) goto error;
542
+
543
+ PyFunc.pandas_DataFrame = PyObject_GetAttr(pandas_mod, PyStr.DataFrame);
544
+ if (!PyFunc.pandas_DataFrame) goto error;
545
+
546
+ exit:
547
+ return 0;
548
+
549
+ error:
550
+ PyErr_Clear();
551
+ return -1;
552
+ }
553
+
554
+
555
+ int ensure_polars() {
556
+ if (PyFunc.polars_DataFrame) goto exit;
557
+
558
+ // Import polars if it exists
559
+ PyObject *polars_mod = PyImport_ImportModule("polars");
560
+ if (!polars_mod) goto error;
561
+
562
+ PyFunc.polars_DataFrame = PyObject_GetAttr(polars_mod, PyStr.DataFrame);
563
+ if (!PyFunc.polars_DataFrame) goto error;
564
+
565
+ exit:
566
+ return 0;
567
+
568
+ error:
569
+ PyErr_Clear();
570
+ return -1;
571
+ }
572
+
573
+
574
+ int ensure_pyarrow() {
575
+ if (PyFunc.pyarrow_Table_from_pylist) goto exit;
576
+
577
+ // Import pyarrow if it exists
578
+ PyObject *pyarrow_mod = PyImport_ImportModule("pyarrow");
579
+ if (!pyarrow_mod) goto error;
580
+
581
+ PyFunc.pyarrow_Table = PyObject_GetAttr(pyarrow_mod, PyStr.Table);
582
+ if (!PyFunc.pyarrow_Table) goto error;
583
+
584
+ PyFunc.pyarrow_Table_from_pylist = PyObject_GetAttr(PyFunc.pyarrow_Table, PyStr.from_pylist);
585
+ if (!PyFunc.pyarrow_Table_from_pylist) goto error;
586
+
587
+ exit:
588
+ return 0;
589
+
590
+ error:
591
+ PyErr_Clear();
592
+ return -1;
593
+ }
594
+
595
+
596
+ int ensure_bson() {
597
+ if (PyFunc.bson_decode) goto exit;
598
+
599
+ // Import bson if it exists
600
+ PyObject *bson_mod = PyImport_ImportModule("bson");
601
+ if (!bson_mod) goto error;
602
+
603
+ PyFunc.bson_decode = PyObject_GetAttr(bson_mod, PyStr.decode);
604
+ if (!PyFunc.bson_decode) goto error;
605
+
606
+ exit:
607
+ return 0;
608
+
609
+ error:
610
+ PyErr_Clear();
611
+ return -1;
612
+ }
613
+
614
+
473
615
  static void State_clear_fields(StateObject *self) {
474
616
  if (!self) return;
475
617
  DESTROY(self->offsets);
@@ -679,9 +821,10 @@ static int State_init(StateObject *self, PyObject *args, PyObject *kwds) {
679
821
  NULL : py_converter;
680
822
  Py_XINCREF(self->py_invalid_values[i]);
681
823
 
682
- self->py_converters[i] = (!py_converter
683
- || py_converter == Py_None
684
- || py_converter == py_default_converter) ?
824
+ self->py_converters[i] = ((!py_converter || py_converter == py_default_converter)
825
+ // TODO: Need C accelerated converters for extended types
826
+ // && self->type_codes[i] < 256
827
+ ) ?
685
828
  NULL : py_converter;
686
829
  Py_XINCREF(self->py_converters[i]);
687
830
  }
@@ -709,7 +852,8 @@ static int State_init(StateObject *self, PyObject *args, PyObject *kwds) {
709
852
  Py_XDECREF(py_next_seq_id);
710
853
 
711
854
  if (py_options && PyDict_Check(py_options)) {
712
- read_options(&self->options, py_options);
855
+ rc = read_options(&self->options, py_options);
856
+ if (rc) goto error;
713
857
  }
714
858
 
715
859
  switch (self->options.results_type) {
@@ -825,12 +969,13 @@ static PyType_Spec StateType_spec = {
825
969
  // End State
826
970
  //
827
971
 
828
- static void read_options(MySQLAccelOptions *options, PyObject *dict) {
829
- if (!options || !dict) return;
972
+ static int read_options(MySQLAccelOptions *options, PyObject *dict) {
973
+ if (!options || !dict) return 0;
830
974
 
831
975
  PyObject *key = NULL;
832
976
  PyObject *value = NULL;
833
977
  Py_ssize_t pos = 0;
978
+ int rc = 0;
834
979
 
835
980
  while (PyDict_Next(dict, &pos, &key, &value)) {
836
981
  if (PyUnicode_CompareWithASCIIString(key, "results_type") == 0) {
@@ -846,6 +991,23 @@ static void read_options(MySQLAccelOptions *options, PyObject *dict) {
846
991
  PyUnicode_CompareWithASCIIString(value, "structsequences") == 0) {
847
992
  options->results_type = ACCEL_OUT_STRUCTSEQUENCES;
848
993
  }
994
+ else if (PyUnicode_CompareWithASCIIString(value, "numpy") == 0) {
995
+ options->results_type = ACCEL_OUT_NUMPY;
996
+ rc = ensure_numpy();
997
+ }
998
+ else if (PyUnicode_CompareWithASCIIString(value, "pandas") == 0) {
999
+ options->results_type = ACCEL_OUT_PANDAS;
1000
+ rc = ensure_pandas();
1001
+ }
1002
+ else if (PyUnicode_CompareWithASCIIString(value, "polars") == 0) {
1003
+ options->results_type = ACCEL_OUT_POLARS;
1004
+ rc = ensure_polars();
1005
+ }
1006
+ else if (PyUnicode_CompareWithASCIIString(value, "arrow") == 0 ||
1007
+ PyUnicode_CompareWithASCIIString(value, "pyarrow") == 0) {
1008
+ options->results_type = ACCEL_OUT_ARROW;
1009
+ rc = ensure_pyarrow();
1010
+ }
849
1011
  else {
850
1012
  options->results_type = ACCEL_OUT_TUPLES;
851
1013
  }
@@ -857,6 +1019,8 @@ static void read_options(MySQLAccelOptions *options, PyObject *dict) {
857
1019
  }
858
1020
  }
859
1021
  }
1022
+
1023
+ return rc;
860
1024
  }
861
1025
 
862
1026
  static void raise_exception(
@@ -1310,7 +1474,10 @@ static PyObject *read_row_from_packet(
1310
1474
  PyObject *py_result = NULL;
1311
1475
  PyObject *py_item = NULL;
1312
1476
  PyObject *py_str = NULL;
1477
+ PyObject *py_memview = NULL;
1313
1478
  char end = '\0';
1479
+ char *cast_type_codes[] = {"", "f", "d", "b", "h", "l", "q"};
1480
+ int item_type_lengths[] = {0, 4, 8, 1, 2, 4, 8};
1314
1481
 
1315
1482
  int sign = 1;
1316
1483
  int year = 0;
@@ -1323,9 +1490,10 @@ static PyObject *read_row_from_packet(
1323
1490
 
1324
1491
  switch (py_state->options.results_type) {
1325
1492
  case ACCEL_OUT_DICTS:
1493
+ case ACCEL_OUT_ARROW:
1326
1494
  py_result = PyDict_New();
1327
1495
  break;
1328
- case ACCEL_OUT_STRUCTSEQUENCES: {
1496
+ case ACCEL_OUT_STRUCTSEQUENCES: {
1329
1497
  if (!py_state->structsequence) goto error;
1330
1498
  py_result = PyStructSequence_New(py_state->structsequence);
1331
1499
  break;
@@ -1362,8 +1530,12 @@ static PyObject *read_row_from_packet(
1362
1530
  py_str = PyUnicode_Decode(out, out_l, py_state->encodings[i], py_state->encoding_errors);
1363
1531
  if (!py_str) goto error;
1364
1532
  }
1365
- py_item = PyObject_CallFunctionObjArgs(py_state->py_converters[i], py_str, NULL);
1366
- Py_CLEAR(py_str);
1533
+ if (py_state->py_converters[i] == Py_None) {
1534
+ py_item = py_str;
1535
+ } else {
1536
+ py_item = PyObject_CallFunctionObjArgs(py_state->py_converters[i], py_str, NULL);
1537
+ Py_CLEAR(py_str);
1538
+ }
1367
1539
  if (!py_item) goto error;
1368
1540
  }
1369
1541
 
@@ -1550,6 +1722,12 @@ static PyObject *read_row_from_packet(
1550
1722
  case MYSQL_TYPE_VARCHAR:
1551
1723
  case MYSQL_TYPE_VAR_STRING:
1552
1724
  case MYSQL_TYPE_STRING:
1725
+ case MYSQL_TYPE_FLOAT32_VECTOR_JSON:
1726
+ case MYSQL_TYPE_FLOAT64_VECTOR_JSON:
1727
+ case MYSQL_TYPE_INT8_VECTOR_JSON:
1728
+ case MYSQL_TYPE_INT16_VECTOR_JSON:
1729
+ case MYSQL_TYPE_INT32_VECTOR_JSON:
1730
+ case MYSQL_TYPE_INT64_VECTOR_JSON:
1553
1731
  if (!py_state->encodings[i]) {
1554
1732
  py_item = PyBytes_FromStringAndSize(out, out_l);
1555
1733
  if (!py_item) goto error;
@@ -1560,13 +1738,86 @@ static PyObject *read_row_from_packet(
1560
1738
  if (!py_item) goto error;
1561
1739
 
1562
1740
  // Parse JSON string.
1563
- if (py_state->type_codes[i] == MYSQL_TYPE_JSON && py_state->options.parse_json) {
1741
+ if ((py_state->type_codes[i] == MYSQL_TYPE_JSON && py_state->options.parse_json)
1742
+ || (py_state->type_codes[i] >= MYSQL_TYPE_FLOAT32_VECTOR_JSON
1743
+ && py_state->type_codes[i] <= MYSQL_TYPE_INT64_VECTOR_JSON)) {
1564
1744
  py_str = py_item;
1565
1745
  py_item = PyObject_CallFunctionObjArgs(PyFunc.json_loads, py_str, NULL);
1566
1746
  Py_CLEAR(py_str);
1567
1747
  if (!py_item) goto error;
1568
1748
  }
1569
1749
 
1750
+ if (ensure_numpy() == 0) {
1751
+ switch (py_state->type_codes[i]) {
1752
+ case MYSQL_TYPE_FLOAT32_VECTOR_JSON:
1753
+ case MYSQL_TYPE_FLOAT64_VECTOR_JSON:
1754
+ case MYSQL_TYPE_INT8_VECTOR_JSON:
1755
+ case MYSQL_TYPE_INT16_VECTOR_JSON:
1756
+ case MYSQL_TYPE_INT32_VECTOR_JSON:
1757
+ case MYSQL_TYPE_INT64_VECTOR_JSON:
1758
+ CHECKRC(PyTuple_SetItem(PyObj.create_numpy_array_args, 0, py_item));
1759
+ py_item = PyObject_Call(
1760
+ PyFunc.numpy_array,
1761
+ PyObj.create_numpy_array_args,
1762
+ PyObj.create_numpy_array_kwargs_vector[py_state->type_codes[i] % 1000]
1763
+ );
1764
+ if (!py_item) goto error;
1765
+ }
1766
+ }
1767
+
1768
+ break;
1769
+
1770
+ case MYSQL_TYPE_FLOAT32_VECTOR:
1771
+ case MYSQL_TYPE_FLOAT64_VECTOR:
1772
+ case MYSQL_TYPE_INT8_VECTOR:
1773
+ case MYSQL_TYPE_INT16_VECTOR:
1774
+ case MYSQL_TYPE_INT32_VECTOR:
1775
+ case MYSQL_TYPE_INT64_VECTOR:
1776
+ if (ensure_numpy() == 0) {
1777
+ py_memview = PyMemoryView_FromMemory(out, out_l, PyBUF_WRITE);
1778
+ if (!py_memview) goto error;
1779
+
1780
+ py_item = create_numpy_array(
1781
+ py_memview,
1782
+ cast_type_codes[py_state->type_codes[i] % 1000],
1783
+ py_state->type_codes[i],
1784
+ NULL
1785
+ );
1786
+ Py_CLEAR(py_memview);
1787
+ if (!py_item) goto error;
1788
+
1789
+ } else {
1790
+ py_memview = PyBytes_FromStringAndSize(out, out_l);
1791
+ if (!py_memview) goto error;
1792
+
1793
+ CHECKRC(PyTuple_SetItem(PyObj.struct_unpack_args, 0,
1794
+ PyUnicode_FromFormat("<%l%s", out_l / item_type_lengths[i], cast_type_codes[i])));
1795
+ CHECKRC(PyTuple_SetItem(PyObj.struct_unpack_args, 1, py_memview));
1796
+
1797
+ py_item = PyObject_Call(
1798
+ PyFunc.struct_unpack,
1799
+ PyObj.struct_unpack_args,
1800
+ NULL
1801
+ );
1802
+ if (!py_item) goto error;
1803
+ }
1804
+
1805
+ break;
1806
+
1807
+ case MYSQL_TYPE_BSON:
1808
+ py_item = PyBytes_FromStringAndSize(out, out_l);
1809
+ if (!py_item) goto error;
1810
+
1811
+ if (ensure_bson() == 0) {
1812
+ CHECKRC(PyTuple_SetItem(PyObj.bson_decode_args, 0, py_item));
1813
+ py_item = PyObject_Call(
1814
+ PyFunc.bson_decode,
1815
+ PyObj.bson_decode_args,
1816
+ NULL
1817
+ );
1818
+ if (!py_item) goto error;
1819
+ }
1820
+
1570
1821
  break;
1571
1822
 
1572
1823
  default:
@@ -1586,6 +1837,7 @@ static PyObject *read_row_from_packet(
1586
1837
  PyStructSequence_SetItem(py_result, i, py_item);
1587
1838
  break;
1588
1839
  case ACCEL_OUT_DICTS:
1840
+ case ACCEL_OUT_ARROW:
1589
1841
  PyDict_SetItem(py_result, py_state->py_names[i], py_item);
1590
1842
  Py_INCREF(py_state->py_names[i]);
1591
1843
  Py_DECREF(py_item);
@@ -1847,27 +2099,6 @@ error:
1847
2099
  }
1848
2100
 
1849
2101
 
1850
- int ensure_numpy() {
1851
- if (PyFunc.numpy_array && PyFunc.numpy_vectorize) goto exit;
1852
-
1853
- // Import numpy if it exists
1854
- PyObject *numpy_mod = PyImport_ImportModule("numpy");
1855
- if (!numpy_mod) goto error;
1856
-
1857
- PyFunc.numpy_array = PyObject_GetAttr(numpy_mod, PyStr.array);
1858
- if (!PyFunc.numpy_array) goto error;
1859
-
1860
- PyFunc.numpy_vectorize = PyObject_GetAttr(numpy_mod, PyStr.vectorize);
1861
- if (!PyFunc.numpy_vectorize) goto error;
1862
-
1863
- exit:
1864
- return 0;
1865
-
1866
- error:
1867
- return -1;
1868
- }
1869
-
1870
-
1871
2102
  static PyObject *load_rowdat_1_numpy(PyObject *self, PyObject *args, PyObject *kwargs) {
1872
2103
  PyObject *py_data = NULL;
1873
2104
  PyObject *py_out = NULL;
@@ -4372,6 +4603,17 @@ PyMODINIT_FUNC PyInit__singlestoredb_accel(void) {
4372
4603
  PyStr.Series = PyUnicode_FromString("Series");
4373
4604
  PyStr.array = PyUnicode_FromString("array");
4374
4605
  PyStr.vectorize = PyUnicode_FromString("vectorize");
4606
+ PyStr.DataFrame = PyUnicode_FromString("DataFrame");
4607
+ PyStr.Table = PyUnicode_FromString("Table");
4608
+ PyStr.from_pylist = PyUnicode_FromString("from_pylist");
4609
+ PyStr.int8 = PyUnicode_FromString("int8");
4610
+ PyStr.int16 = PyUnicode_FromString("int16");
4611
+ PyStr.int32 = PyUnicode_FromString("int32");
4612
+ PyStr.int64 = PyUnicode_FromString("int64");
4613
+ PyStr.float32 = PyUnicode_FromString("float32");
4614
+ PyStr.float64 = PyUnicode_FromString("float64");
4615
+ PyStr.unpack = PyUnicode_FromString("unpack");
4616
+ PyStr.decode = PyUnicode_FromString("decode");
4375
4617
 
4376
4618
  PyObject *decimal_mod = PyImport_ImportModule("decimal");
4377
4619
  if (!decimal_mod) goto error;
@@ -4381,6 +4623,8 @@ PyMODINIT_FUNC PyInit__singlestoredb_accel(void) {
4381
4623
  if (!json_mod) goto error;
4382
4624
  PyObject *collections_mod = PyImport_ImportModule("collections");
4383
4625
  if (!collections_mod) goto error;
4626
+ PyObject *struct_mod = PyImport_ImportModule("struct");
4627
+ if (!struct_mod) goto error;
4384
4628
 
4385
4629
  PyFunc.decimal_Decimal = PyObject_GetAttr(decimal_mod, PyStr.Decimal);
4386
4630
  if (!PyFunc.decimal_Decimal) goto error;
@@ -4396,6 +4640,8 @@ PyMODINIT_FUNC PyInit__singlestoredb_accel(void) {
4396
4640
  if (!PyFunc.json_loads) goto error;
4397
4641
  PyFunc.collections_namedtuple = PyObject_GetAttr(collections_mod, PyStr.namedtuple);
4398
4642
  if (!PyFunc.collections_namedtuple) goto error;
4643
+ PyFunc.struct_unpack = PyObject_GetAttr(struct_mod, PyStr.unpack);
4644
+ if (!PyFunc.struct_unpack) goto error;
4399
4645
 
4400
4646
  PyObj.namedtuple_kwargs = PyDict_New();
4401
4647
  if (!PyObj.namedtuple_kwargs) goto error;
@@ -4412,6 +4658,43 @@ PyMODINIT_FUNC PyInit__singlestoredb_accel(void) {
4412
4658
  goto error;
4413
4659
  }
4414
4660
 
4661
+ PyObj.create_numpy_array_kwargs_vector[1] = PyDict_New();
4662
+ if (!PyObj.create_numpy_array_kwargs_vector[1]) goto error;
4663
+ if (PyDict_SetItemString(PyObj.create_numpy_array_kwargs_vector[1], "dtype", PyStr.float32)) {
4664
+ goto error;
4665
+ }
4666
+ PyObj.create_numpy_array_kwargs_vector[2] = PyDict_New();
4667
+ if (!PyObj.create_numpy_array_kwargs_vector[2]) goto error;
4668
+ if (PyDict_SetItemString(PyObj.create_numpy_array_kwargs_vector[2], "dtype", PyStr.float64)) {
4669
+ goto error;
4670
+ }
4671
+ PyObj.create_numpy_array_kwargs_vector[3] = PyDict_New();
4672
+ if (!PyObj.create_numpy_array_kwargs_vector[3]) goto error;
4673
+ if (PyDict_SetItemString(PyObj.create_numpy_array_kwargs_vector[3], "dtype", PyStr.int8)) {
4674
+ goto error;
4675
+ }
4676
+ PyObj.create_numpy_array_kwargs_vector[4] = PyDict_New();
4677
+ if (!PyObj.create_numpy_array_kwargs_vector[4]) goto error;
4678
+ if (PyDict_SetItemString(PyObj.create_numpy_array_kwargs_vector[4], "dtype", PyStr.int16)) {
4679
+ goto error;
4680
+ }
4681
+ PyObj.create_numpy_array_kwargs_vector[5] = PyDict_New();
4682
+ if (!PyObj.create_numpy_array_kwargs_vector[5]) goto error;
4683
+ if (PyDict_SetItemString(PyObj.create_numpy_array_kwargs_vector[5], "dtype", PyStr.int32)) {
4684
+ goto error;
4685
+ }
4686
+ PyObj.create_numpy_array_kwargs_vector[6] = PyDict_New();
4687
+ if (!PyObj.create_numpy_array_kwargs_vector[6]) goto error;
4688
+ if (PyDict_SetItemString(PyObj.create_numpy_array_kwargs_vector[6], "dtype", PyStr.int64)) {
4689
+ goto error;
4690
+ }
4691
+
4692
+ PyObj.struct_unpack_args = PyTuple_New(2);
4693
+ if (!PyObj.struct_unpack_args) goto error;
4694
+
4695
+ PyObj.bson_decode_args = PyTuple_New(1);
4696
+ if (!PyObj.bson_decode_args) goto error;
4697
+
4415
4698
  return PyModule_Create(&_singlestoredb_accelmodule);
4416
4699
 
4417
4700
  error:
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = singlestoredb
3
- version = 1.0.4
3
+ version = 1.2.0
4
4
  description = Interface to the SingleStoreDB database and workspace management APIs
5
5
  long_description = file: README.md
6
6
  long_description_content_type = text/markdown
@@ -26,6 +26,7 @@ install_requires =
26
26
  setuptools
27
27
  sqlparams
28
28
  wheel
29
+ tomli>=1.1.0;python_version < '3.11'
29
30
  python_requires = >=3.8
30
31
  tests_require =
31
32
  coverage
@@ -77,7 +78,7 @@ exclude =
77
78
  docs/*
78
79
  resources/*
79
80
  licenses/*
80
- max-complexity = 30
81
+ max-complexity = 35
81
82
  max-line-length = 90
82
83
  per-file-ignores =
83
84
  singlestoredb/__init__.py:F401
@@ -13,7 +13,7 @@ Examples
13
13
 
14
14
  """
15
15
 
16
- __version__ = '1.0.4'
16
+ __version__ = '1.2.0'
17
17
 
18
18
  from typing import Any
19
19