singlestoredb 1.1.0__tar.gz → 1.3.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 (126) hide show
  1. {singlestoredb-1.1.0/singlestoredb.egg-info → singlestoredb-1.3.0}/PKG-INFO +1 -1
  2. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/accel.c +190 -5
  3. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/setup.cfg +1 -1
  4. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/__init__.py +1 -1
  5. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/config.py +6 -0
  6. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/connection.py +23 -1
  7. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/converters.py +390 -0
  8. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/functions/ext/asgi.py +7 -1
  9. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/fusion/handler.py +14 -8
  10. singlestoredb-1.3.0/singlestoredb/fusion/handlers/stage.py +490 -0
  11. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/fusion/handlers/workspace.py +250 -108
  12. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/fusion/registry.py +27 -10
  13. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/http/connection.py +18 -1
  14. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/management/__init__.py +1 -0
  15. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/management/organization.py +4 -0
  16. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/management/utils.py +2 -2
  17. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/management/workspace.py +79 -6
  18. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/connection.py +92 -16
  19. singlestoredb-1.3.0/singlestoredb/mysql/constants/EXTENDED_TYPE.py +3 -0
  20. singlestoredb-1.3.0/singlestoredb/mysql/constants/FIELD_TYPE.py +48 -0
  21. singlestoredb-1.3.0/singlestoredb/mysql/constants/VECTOR_TYPE.py +6 -0
  22. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/cursors.py +13 -10
  23. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/protocol.py +50 -1
  24. singlestoredb-1.3.0/singlestoredb/notebook/__init__.py +15 -0
  25. singlestoredb-1.3.0/singlestoredb/notebook/_objects.py +212 -0
  26. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test.sql +49 -0
  27. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test_connection.py +174 -0
  28. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/utils/results.py +5 -1
  29. {singlestoredb-1.1.0 → singlestoredb-1.3.0/singlestoredb.egg-info}/PKG-INFO +1 -1
  30. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb.egg-info/SOURCES.txt +4 -0
  31. singlestoredb-1.1.0/singlestoredb/fusion/handlers/stage.py +0 -407
  32. singlestoredb-1.1.0/singlestoredb/mysql/constants/FIELD_TYPE.py +0 -32
  33. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/LICENSE +0 -0
  34. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/README.md +0 -0
  35. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/setup.py +0 -0
  36. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/alchemy/__init__.py +0 -0
  37. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/auth.py +0 -0
  38. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/exceptions.py +0 -0
  39. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/functions/__init__.py +0 -0
  40. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/functions/decorator.py +0 -0
  41. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/functions/dtypes.py +0 -0
  42. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/functions/ext/__init__.py +0 -0
  43. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/functions/ext/arrow.py +0 -0
  44. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/functions/ext/json.py +0 -0
  45. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/functions/ext/mmap.py +0 -0
  46. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/functions/ext/rowdat_1.py +0 -0
  47. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/functions/ext/utils.py +0 -0
  48. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/functions/signature.py +0 -0
  49. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/fusion/__init__.py +0 -0
  50. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/fusion/graphql.py +0 -0
  51. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/fusion/handlers/__init__.py +0 -0
  52. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/fusion/handlers/utils.py +0 -0
  53. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/fusion/result.py +0 -0
  54. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/http/__init__.py +0 -0
  55. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/management/billing_usage.py +0 -0
  56. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/management/cluster.py +0 -0
  57. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/management/manager.py +0 -0
  58. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/management/region.py +0 -0
  59. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/__init__.py +0 -0
  60. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/_auth.py +0 -0
  61. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/charset.py +0 -0
  62. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/constants/CLIENT.py +0 -0
  63. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/constants/COMMAND.py +0 -0
  64. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/constants/CR.py +0 -0
  65. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/constants/ER.py +0 -0
  66. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/constants/FLAG.py +0 -0
  67. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/constants/SERVER_STATUS.py +0 -0
  68. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/constants/__init__.py +0 -0
  69. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/converters.py +0 -0
  70. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/err.py +0 -0
  71. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/optionfile.py +0 -0
  72. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/__init__.py +0 -0
  73. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/base.py +0 -0
  74. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/conftest.py +0 -0
  75. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/test_DictCursor.py +0 -0
  76. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/test_SSCursor.py +0 -0
  77. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/test_basic.py +0 -0
  78. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/test_connection.py +0 -0
  79. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/test_converters.py +0 -0
  80. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/test_cursor.py +0 -0
  81. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/test_err.py +0 -0
  82. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/test_issues.py +0 -0
  83. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/test_load_local.py +0 -0
  84. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/test_nextset.py +0 -0
  85. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/test_optionfile.py +0 -0
  86. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/thirdparty/__init__.py +0 -0
  87. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/__init__.py +0 -0
  88. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/capabilities.py +0 -0
  89. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/dbapi20.py +0 -0
  90. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_capabilities.py +0 -0
  91. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_dbapi20.py +0 -0
  92. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_nonstandard.py +0 -0
  93. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/mysql/times.py +0 -0
  94. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/pytest.py +0 -0
  95. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/__init__.py +0 -0
  96. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/empty.sql +0 -0
  97. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/ext_funcs/__init__.py +0 -0
  98. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/local_infile.csv +0 -0
  99. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test2.sql +0 -0
  100. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test_basics.py +0 -0
  101. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test_config.py +0 -0
  102. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test_dbapi.py +0 -0
  103. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test_exceptions.py +0 -0
  104. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test_ext_func.py +0 -0
  105. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test_ext_func_data.py +0 -0
  106. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test_fusion.py +0 -0
  107. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test_http.py +0 -0
  108. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test_management.py +0 -0
  109. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test_plugin.py +0 -0
  110. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test_results.py +0 -0
  111. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test_types.py +0 -0
  112. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test_udf.py +0 -0
  113. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/test_xdict.py +0 -0
  114. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/tests/utils.py +0 -0
  115. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/types.py +0 -0
  116. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/utils/__init__.py +0 -0
  117. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/utils/config.py +0 -0
  118. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/utils/convert_rows.py +0 -0
  119. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/utils/debug.py +0 -0
  120. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/utils/dtypes.py +0 -0
  121. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/utils/mogrify.py +0 -0
  122. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb/utils/xdict.py +0 -0
  123. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb.egg-info/dependency_links.txt +0 -0
  124. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb.egg-info/entry_points.txt +0 -0
  125. {singlestoredb-1.1.0 → singlestoredb-1.3.0}/singlestoredb.egg-info/requires.txt +0 -0
  126. {singlestoredb-1.1.0 → singlestoredb-1.3.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.1.0
3
+ Version: 1.3.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
@@ -81,6 +81,21 @@
81
81
  #define MYSQL_TYPE_STRING 254
82
82
  #define MYSQL_TYPE_GEOMETRY 255
83
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
+
84
99
  #define MYSQL_TYPE_CHAR MYSQL_TYPE_TINY
85
100
  #define MYSQL_TYPE_INTERVAL MYSQL_TYPE_ENUM
86
101
 
@@ -333,6 +348,8 @@ typedef struct {
333
348
  inline int IMAX(int a, int b) { return((a) > (b) ? a : b); }
334
349
  inline int IMIN(int a, int b) { return((a) < (b) ? a : b); }
335
350
 
351
+ static PyObject *create_numpy_array(PyObject *py_memview, char *data_format, int data_type, PyObject *py_objs);
352
+
336
353
  char *_PyUnicode_AsUTF8(PyObject *unicode) {
337
354
  PyObject *bytes = PyUnicode_AsEncodedString(unicode, "utf-8", "strict");
338
355
  if (!bytes) return NULL;
@@ -396,6 +413,14 @@ typedef struct {
396
413
  PyObject *DataFrame;
397
414
  PyObject *Table;
398
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;
399
424
  } PyStrings;
400
425
 
401
426
  static PyStrings PyStr = {0};
@@ -417,6 +442,8 @@ typedef struct {
417
442
  PyObject *polars_DataFrame;
418
443
  PyObject *pyarrow_Table;
419
444
  PyObject *pyarrow_Table_from_pylist;
445
+ PyObject *struct_unpack;
446
+ PyObject *bson_decode;
420
447
  } PyFunctions;
421
448
 
422
449
  static PyFunctions PyFunc = {0};
@@ -428,6 +455,9 @@ typedef struct {
428
455
  PyObject *namedtuple_kwargs;
429
456
  PyObject *create_numpy_array_args;
430
457
  PyObject *create_numpy_array_kwargs;
458
+ PyObject *create_numpy_array_kwargs_vector[7];
459
+ PyObject *struct_unpack_args;
460
+ PyObject *bson_decode_args;
431
461
  } PyObjects;
432
462
 
433
463
  static PyObjects PyObj = {0};
@@ -498,6 +528,7 @@ exit:
498
528
  return 0;
499
529
 
500
530
  error:
531
+ PyErr_Clear();
501
532
  return -1;
502
533
  }
503
534
 
@@ -516,6 +547,7 @@ exit:
516
547
  return 0;
517
548
 
518
549
  error:
550
+ PyErr_Clear();
519
551
  return -1;
520
552
  }
521
553
 
@@ -534,6 +566,7 @@ exit:
534
566
  return 0;
535
567
 
536
568
  error:
569
+ PyErr_Clear();
537
570
  return -1;
538
571
  }
539
572
 
@@ -555,6 +588,26 @@ exit:
555
588
  return 0;
556
589
 
557
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();
558
611
  return -1;
559
612
  }
560
613
 
@@ -768,9 +821,10 @@ static int State_init(StateObject *self, PyObject *args, PyObject *kwds) {
768
821
  NULL : py_converter;
769
822
  Py_XINCREF(self->py_invalid_values[i]);
770
823
 
771
- self->py_converters[i] = (!py_converter
772
- // || py_converter == Py_None
773
- || 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
+ ) ?
774
828
  NULL : py_converter;
775
829
  Py_XINCREF(self->py_converters[i]);
776
830
  }
@@ -1420,7 +1474,10 @@ static PyObject *read_row_from_packet(
1420
1474
  PyObject *py_result = NULL;
1421
1475
  PyObject *py_item = NULL;
1422
1476
  PyObject *py_str = NULL;
1477
+ PyObject *py_memview = NULL;
1423
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};
1424
1481
 
1425
1482
  int sign = 1;
1426
1483
  int year = 0;
@@ -1436,7 +1493,7 @@ static PyObject *read_row_from_packet(
1436
1493
  case ACCEL_OUT_ARROW:
1437
1494
  py_result = PyDict_New();
1438
1495
  break;
1439
- case ACCEL_OUT_STRUCTSEQUENCES: {
1496
+ case ACCEL_OUT_STRUCTSEQUENCES: {
1440
1497
  if (!py_state->structsequence) goto error;
1441
1498
  py_result = PyStructSequence_New(py_state->structsequence);
1442
1499
  break;
@@ -1665,6 +1722,12 @@ static PyObject *read_row_from_packet(
1665
1722
  case MYSQL_TYPE_VARCHAR:
1666
1723
  case MYSQL_TYPE_VAR_STRING:
1667
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:
1668
1731
  if (!py_state->encodings[i]) {
1669
1732
  py_item = PyBytes_FromStringAndSize(out, out_l);
1670
1733
  if (!py_item) goto error;
@@ -1675,13 +1738,86 @@ static PyObject *read_row_from_packet(
1675
1738
  if (!py_item) goto error;
1676
1739
 
1677
1740
  // Parse JSON string.
1678
- 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)) {
1679
1744
  py_str = py_item;
1680
1745
  py_item = PyObject_CallFunctionObjArgs(PyFunc.json_loads, py_str, NULL);
1681
1746
  Py_CLEAR(py_str);
1682
1747
  if (!py_item) goto error;
1683
1748
  }
1684
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
+
1685
1821
  break;
1686
1822
 
1687
1823
  default:
@@ -4470,6 +4606,14 @@ PyMODINIT_FUNC PyInit__singlestoredb_accel(void) {
4470
4606
  PyStr.DataFrame = PyUnicode_FromString("DataFrame");
4471
4607
  PyStr.Table = PyUnicode_FromString("Table");
4472
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");
4473
4617
 
4474
4618
  PyObject *decimal_mod = PyImport_ImportModule("decimal");
4475
4619
  if (!decimal_mod) goto error;
@@ -4479,6 +4623,8 @@ PyMODINIT_FUNC PyInit__singlestoredb_accel(void) {
4479
4623
  if (!json_mod) goto error;
4480
4624
  PyObject *collections_mod = PyImport_ImportModule("collections");
4481
4625
  if (!collections_mod) goto error;
4626
+ PyObject *struct_mod = PyImport_ImportModule("struct");
4627
+ if (!struct_mod) goto error;
4482
4628
 
4483
4629
  PyFunc.decimal_Decimal = PyObject_GetAttr(decimal_mod, PyStr.Decimal);
4484
4630
  if (!PyFunc.decimal_Decimal) goto error;
@@ -4494,6 +4640,8 @@ PyMODINIT_FUNC PyInit__singlestoredb_accel(void) {
4494
4640
  if (!PyFunc.json_loads) goto error;
4495
4641
  PyFunc.collections_namedtuple = PyObject_GetAttr(collections_mod, PyStr.namedtuple);
4496
4642
  if (!PyFunc.collections_namedtuple) goto error;
4643
+ PyFunc.struct_unpack = PyObject_GetAttr(struct_mod, PyStr.unpack);
4644
+ if (!PyFunc.struct_unpack) goto error;
4497
4645
 
4498
4646
  PyObj.namedtuple_kwargs = PyDict_New();
4499
4647
  if (!PyObj.namedtuple_kwargs) goto error;
@@ -4510,6 +4658,43 @@ PyMODINIT_FUNC PyInit__singlestoredb_accel(void) {
4510
4658
  goto error;
4511
4659
  }
4512
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
+
4513
4698
  return PyModule_Create(&_singlestoredb_accelmodule);
4514
4699
 
4515
4700
  error:
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = singlestoredb
3
- version = 1.1.0
3
+ version = 1.3.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
@@ -13,7 +13,7 @@ Examples
13
13
 
14
14
  """
15
15
 
16
- __version__ = '1.1.0'
16
+ __version__ = '1.3.0'
17
17
 
18
18
  from typing import Any
19
19
 
@@ -215,6 +215,12 @@ register_option(
215
215
  environ='SINGLESTOREDB_TRACK_ENV',
216
216
  )
217
217
 
218
+ register_option(
219
+ 'enable_extended_data_types', 'bool', check_bool, True,
220
+ 'Should extended data types (BSON, vector) be enabled?',
221
+ environ='SINGLESTOREDB_ENABLE_EXTENDED_DATA_TYPES',
222
+ )
223
+
218
224
  register_option(
219
225
  'fusion.enabled', 'bool', check_bool, False,
220
226
  'Should Fusion SQL queries be enabled?',
@@ -2,7 +2,10 @@
2
2
  """SingleStoreDB connections and cursors."""
3
3
  import abc
4
4
  import inspect
5
+ import io
6
+ import queue
5
7
  import re
8
+ import sys
6
9
  import warnings
7
10
  import weakref
8
11
  from collections.abc import Mapping
@@ -33,6 +36,11 @@ from .config import get_option
33
36
  from .utils.results import Description
34
37
  from .utils.results import Result
35
38
 
39
+ if sys.version_info < (3, 10):
40
+ InfileQueue = queue.Queue
41
+ else:
42
+ InfileQueue = queue.Queue[Union[bytes, str]]
43
+
36
44
 
37
45
  # DB-API settings
38
46
  apilevel = '2.0'
@@ -496,6 +504,14 @@ class Cursor(metaclass=abc.ABCMeta):
496
504
  def execute(
497
505
  self, query: str,
498
506
  args: Optional[Union[Sequence[Any], Dict[str, Any], Any]] = None,
507
+ infile_stream: Optional[ # type: ignore
508
+ Union[
509
+ io.RawIOBase,
510
+ io.TextIOBase,
511
+ Iterator[Union[bytes, str]],
512
+ InfileQueue,
513
+ ]
514
+ ] = None,
499
515
  ) -> int:
500
516
  """
501
517
  Execute a SQL statement.
@@ -510,6 +526,8 @@ class Cursor(metaclass=abc.ABCMeta):
510
526
  The SQL statement to execute
511
527
  args : Sequence or dict, optional
512
528
  Parameters to substitute into the SQL code
529
+ infile_stream : io.RawIOBase or io.TextIOBase or Iterator[bytes|str], optional
530
+ Data stream for ``LOCAL INFILE`` statement
513
531
 
514
532
  Examples
515
533
  --------
@@ -1285,6 +1303,7 @@ def connect(
1285
1303
  inf_as_null: Optional[bool] = None,
1286
1304
  encoding_errors: Optional[str] = None,
1287
1305
  track_env: Optional[bool] = None,
1306
+ enable_extended_data_types: Optional[bool] = None,
1288
1307
  ) -> Connection:
1289
1308
  """
1290
1309
  Return a SingleStoreDB connection.
@@ -1338,7 +1357,8 @@ def connect(
1338
1357
  autocommit : bool, optional
1339
1358
  Enable autocommits
1340
1359
  results_type : str, optional
1341
- The form of the query results: tuples, namedtuples, dicts
1360
+ The form of the query results: tuples, namedtuples, dicts,
1361
+ numpy, polars, pandas, arrow
1342
1362
  results_format : str, optional
1343
1363
  Deprecated. This option has been renamed to results_type.
1344
1364
  program_name : str, optional
@@ -1361,6 +1381,8 @@ def connect(
1361
1381
  The error handler name for value decoding errors
1362
1382
  track_env : bool, optional
1363
1383
  Should the connection track the SINGLESTOREDB_URL environment variable?
1384
+ enable_extended_data_types : bool, optional
1385
+ Should extended data types (BSON, vector) be enabled?
1364
1386
 
1365
1387
  Examples
1366
1388
  --------