singlestoredb 1.0.4__cp38-abi3-win_amd64.whl → 1.2.0__cp38-abi3-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.

Potentially problematic release.


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

Files changed (41) hide show
  1. _singlestoredb_accel.pyd +0 -0
  2. singlestoredb/__init__.py +1 -1
  3. singlestoredb/config.py +131 -0
  4. singlestoredb/connection.py +3 -0
  5. singlestoredb/converters.py +390 -0
  6. singlestoredb/functions/dtypes.py +5 -198
  7. singlestoredb/functions/ext/__init__.py +0 -1
  8. singlestoredb/functions/ext/asgi.py +671 -153
  9. singlestoredb/functions/ext/json.py +2 -2
  10. singlestoredb/functions/ext/mmap.py +174 -67
  11. singlestoredb/functions/ext/rowdat_1.py +2 -2
  12. singlestoredb/functions/ext/utils.py +169 -0
  13. singlestoredb/fusion/handler.py +115 -9
  14. singlestoredb/fusion/handlers/stage.py +246 -13
  15. singlestoredb/fusion/handlers/workspace.py +417 -14
  16. singlestoredb/fusion/registry.py +86 -1
  17. singlestoredb/http/connection.py +40 -2
  18. singlestoredb/management/__init__.py +1 -0
  19. singlestoredb/management/organization.py +4 -0
  20. singlestoredb/management/utils.py +2 -2
  21. singlestoredb/management/workspace.py +79 -6
  22. singlestoredb/mysql/connection.py +81 -0
  23. singlestoredb/mysql/constants/EXTENDED_TYPE.py +3 -0
  24. singlestoredb/mysql/constants/FIELD_TYPE.py +16 -0
  25. singlestoredb/mysql/constants/VECTOR_TYPE.py +6 -0
  26. singlestoredb/mysql/cursors.py +177 -4
  27. singlestoredb/mysql/protocol.py +50 -1
  28. singlestoredb/notebook/__init__.py +15 -0
  29. singlestoredb/notebook/_objects.py +212 -0
  30. singlestoredb/tests/test.sql +259 -0
  31. singlestoredb/tests/test_connection.py +1715 -133
  32. singlestoredb/tests/test_ext_func.py +2 -2
  33. singlestoredb/tests/test_ext_func_data.py +1 -1
  34. singlestoredb/utils/dtypes.py +205 -0
  35. singlestoredb/utils/results.py +367 -14
  36. {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/METADATA +2 -1
  37. {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/RECORD +41 -35
  38. {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/LICENSE +0 -0
  39. {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/WHEEL +0 -0
  40. {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/entry_points.txt +0 -0
  41. {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/top_level.txt +0 -0
@@ -13,6 +13,18 @@ from singlestoredb.tests import utils
13
13
  # import pandas as pd
14
14
  # import traceback
15
15
 
16
+ try:
17
+ import numpy as np
18
+ has_numpy = True
19
+ except ImportError:
20
+ has_numpy = False
21
+
22
+ try:
23
+ import pandas as pd
24
+ has_pandas = True
25
+ except ImportError:
26
+ has_pandas = False
27
+
16
28
 
17
29
  class TestConnection(unittest.TestCase):
18
30
 
@@ -514,212 +526,1608 @@ class TestConnection(unittest.TestCase):
514
526
  'password',
515
527
  ), out['password']
516
528
 
517
- # Query options
518
- url = 's2host.com:1000?local_infile=1&charset=utf8'
519
- out = build_params(host=url)
520
- assert out['driver'] == get_option('driver'), out['driver']
521
- assert out['host'] == 's2host.com', out['host']
522
- assert out['port'] == 1000, out['port']
523
- assert 'database' not in out
524
- assert 'user' not in out or out['user'] == get_option(
525
- 'user',
526
- ), out['user']
527
- assert 'password' not in out or out['password'] == get_option(
528
- 'password',
529
- ), out['password']
530
- assert out['local_infile'] is True, out['local_infile']
531
- assert out['charset'] == 'utf8', out['charset']
529
+ # Query options
530
+ url = 's2host.com:1000?local_infile=1&charset=utf8'
531
+ out = build_params(host=url)
532
+ assert out['driver'] == get_option('driver'), out['driver']
533
+ assert out['host'] == 's2host.com', out['host']
534
+ assert out['port'] == 1000, out['port']
535
+ assert 'database' not in out
536
+ assert 'user' not in out or out['user'] == get_option(
537
+ 'user',
538
+ ), out['user']
539
+ assert 'password' not in out or out['password'] == get_option(
540
+ 'password',
541
+ ), out['password']
542
+ assert out['local_infile'] is True, out['local_infile']
543
+ assert out['charset'] == 'utf8', out['charset']
544
+
545
+ def test_exception(self):
546
+ with self.assertRaises(s2.ProgrammingError) as cm:
547
+ self.cur.execute('garbage syntax')
548
+ exc = cm.exception
549
+ assert 'You have an error in your SQL syntax' in exc.errmsg, exc.errmsg
550
+
551
+ def test_alltypes(self):
552
+ self.cur.execute('select * from alltypes where id = 0')
553
+ names = [x[0] for x in self.cur.description]
554
+ types = [x[1] for x in self.cur.description]
555
+ out = self.cur.fetchone()
556
+ row = dict(zip(names, out))
557
+ typ = dict(zip(names, types))
558
+
559
+ bits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
560
+
561
+ def otype(x):
562
+ return x
563
+
564
+ assert row['id'] == 0, row['id']
565
+ assert typ['id'] == otype(3), typ['id']
566
+
567
+ assert row['tinyint'] == 80, row['tinyint']
568
+ assert typ['tinyint'] == otype(1), typ['tinyint']
569
+
570
+ assert row['unsigned_tinyint'] == 85, row['unsigned_tinyint']
571
+ assert typ['unsigned_tinyint'] == otype(1), typ['unsigned_tinyint']
572
+
573
+ assert row['bool'] == 0, row['bool']
574
+ assert typ['bool'] == otype(1), typ['bool']
575
+
576
+ assert row['boolean'] == 1, row['boolean']
577
+ assert typ['boolean'] == otype(1), typ['boolean']
578
+
579
+ assert row['smallint'] == -27897, row['smallint']
580
+ assert typ['smallint'] == otype(2), typ['smallint']
581
+
582
+ assert row['unsigned_smallint'] == 27897, row['unsigned_smallint']
583
+ assert typ['unsigned_smallint'] == otype(2), typ['unsigned_smallint']
584
+
585
+ assert row['mediumint'] == 104729, row['mediumint']
586
+ assert typ['mediumint'] == otype(9), typ['mediumint']
587
+
588
+ assert row['unsigned_mediumint'] == 120999, row['unsigned_mediumint']
589
+ assert typ['unsigned_mediumint'] == otype(9), typ['unsigned_mediumint']
590
+
591
+ assert row['int24'] == -200899, row['int24']
592
+ assert typ['int24'] == otype(9), typ['int24']
593
+
594
+ assert row['unsigned_int24'] == 407709, row['unsigned_int24']
595
+ assert typ['unsigned_int24'] == otype(9), typ['unsigned_int24']
596
+
597
+ assert row['int'] == -1295369311, row['int']
598
+ assert typ['int'] == otype(3), typ['int']
599
+
600
+ assert row['unsigned_int'] == 3872362332, row['unsigned_int']
601
+ assert typ['unsigned_int'] == otype(3), typ['unsigned_int']
602
+
603
+ assert row['integer'] == -1741727421, row['integer']
604
+ assert typ['integer'] == otype(3), typ['integer']
605
+
606
+ assert row['unsigned_integer'] == 3198387363, row['unsigned_integer']
607
+ assert typ['unsigned_integer'] == otype(3), typ['unsigned_integer']
608
+
609
+ assert row['bigint'] == -266883847, row['bigint']
610
+ assert typ['bigint'] == otype(8), typ['bigint']
611
+
612
+ assert row['unsigned_bigint'] == 980007287362, row['unsigned_bigint']
613
+ assert typ['unsigned_bigint'] == otype(8), typ['unsigned_bigint']
614
+
615
+ assert row['float'] == -146487000.0, row['float']
616
+ assert typ['float'] == otype(4), typ['float']
617
+
618
+ assert row['double'] == -474646154.719356, row['double']
619
+ assert typ['double'] == otype(5), typ['double']
620
+
621
+ assert row['real'] == -901409776.279346, row['real']
622
+ assert typ['real'] == otype(5), typ['real']
623
+
624
+ assert row['decimal'] == decimal.Decimal(
625
+ '28111097.610822',
626
+ ), row['decimal']
627
+ assert typ['decimal'] == otype(246), typ['decimal']
628
+
629
+ assert row['dec'] == decimal.Decimal('389451155.931428'), row['dec']
630
+ assert typ['dec'] == otype(246), typ['dec']
631
+
632
+ assert row['fixed'] == decimal.Decimal(
633
+ '-143773416.044092',
634
+ ), row['fixed']
635
+ assert typ['fixed'] == otype(246), typ['fixed']
636
+
637
+ assert row['numeric'] == decimal.Decimal(
638
+ '866689461.300046',
639
+ ), row['numeric']
640
+ assert typ['numeric'] == otype(246), typ['numeric']
641
+
642
+ assert row['date'] == datetime.date(8524, 11, 10), row['date']
643
+ assert typ['date'] == 10, typ['date']
644
+
645
+ assert row['time'] == datetime.timedelta(minutes=7), row['time']
646
+ assert typ['time'] == 11, typ['time']
647
+
648
+ assert typ['time_6'] == 11, typ['time_6']
649
+
650
+ assert row['datetime'] == datetime.datetime(
651
+ 9948, 3, 11, 15, 29, 22,
652
+ ), row['datetime']
653
+ assert typ['datetime'] == 12, typ['datetime']
654
+
655
+ assert row['datetime_6'] == datetime.datetime(
656
+ 1756, 10, 29, 2, 2, 42, 8,
657
+ ), row['datetime_6']
658
+ assert typ['datetime_6'] == 12, typ['datetime_6']
659
+
660
+ assert row['timestamp'] == datetime.datetime(
661
+ 1980, 12, 31, 1, 10, 23,
662
+ ), row['timestamp']
663
+ assert typ['timestamp'] == otype(7), typ['timestamp']
664
+
665
+ assert row['timestamp_6'] == datetime.datetime(
666
+ 1991, 1, 2, 22, 15, 10, 6,
667
+ ), row['timestamp_6']
668
+ assert typ['timestamp_6'] == otype(7), typ['timestamp_6']
669
+
670
+ assert row['year'] == 1923, row['year']
671
+ assert typ['year'] == otype(13), typ['year']
672
+
673
+ assert row['char_100'] == \
674
+ 'This is a test of a 100 character column.', row['char_100']
675
+ assert typ['char_100'] == otype(254), typ['char_100']
676
+
677
+ assert row['binary_100'] == bytearray(
678
+ bits + [0] * 84,
679
+ ), row['binary_100']
680
+ assert typ['binary_100'] == otype(254), typ['binary_100']
681
+
682
+ assert row['varchar_200'] == \
683
+ 'This is a test of a variable character column.', row['varchar_200']
684
+ assert typ['varchar_200'] == otype(
685
+ 253,
686
+ ), typ['varchar_200'] # why not 15?
687
+
688
+ assert row['varbinary_200'] == bytearray(
689
+ bits * 2,
690
+ ), row['varbinary_200']
691
+ assert typ['varbinary_200'] == otype(
692
+ 253,
693
+ ), typ['varbinary_200'] # why not 15?
694
+
695
+ assert row['longtext'] == 'This is a longtext column.', row['longtext']
696
+ assert typ['longtext'] == otype(251), typ['longtext']
697
+
698
+ assert row['mediumtext'] == 'This is a mediumtext column.', row['mediumtext']
699
+ assert typ['mediumtext'] == otype(250), typ['mediumtext']
700
+
701
+ assert row['text'] == 'This is a text column.', row['text']
702
+ assert typ['text'] == otype(252), typ['text']
703
+
704
+ assert row['tinytext'] == 'This is a tinytext column.'
705
+ assert typ['tinytext'] == otype(249), typ['tinytext']
706
+
707
+ assert row['longblob'] == bytearray(bits * 3), row['longblob']
708
+ assert typ['longblob'] == otype(251), typ['longblob']
709
+
710
+ assert row['mediumblob'] == bytearray(bits * 2), row['mediumblob']
711
+ assert typ['mediumblob'] == otype(250), typ['mediumblob']
712
+
713
+ assert row['blob'] == bytearray(bits), row['blob']
714
+ assert typ['blob'] == otype(252), typ['blob']
715
+
716
+ assert row['tinyblob'] == bytearray(
717
+ [10, 11, 12, 13, 14, 15],
718
+ ), row['tinyblob']
719
+ assert typ['tinyblob'] == otype(249), typ['tinyblob']
720
+
721
+ assert row['json'] == {
722
+ 'a': 10, 'b': 2.75,
723
+ 'c': 'hello world',
724
+ }, row['json']
725
+ assert typ['json'] == otype(245), typ['json']
726
+
727
+ assert row['enum'] == 'one', row['enum']
728
+ assert typ['enum'] == otype(253), typ['enum'] # mysql code: 247
729
+
730
+ assert row['set'] == 'two', row['set']
731
+ assert typ['set'] == otype(253), typ['set'] # mysql code: 248
732
+
733
+ assert row['bit'] == b'\x00\x00\x00\x00\x00\x00\x00\x80', row['bit']
734
+ assert typ['bit'] == otype(16), typ['bit']
735
+
736
+ def test_alltypes_numpy(self):
737
+ conn = s2.connect(database=type(self).dbname, results_type='numpy')
738
+ cur = conn.cursor()
739
+
740
+ cur.execute('select * from alltypes where id = 0')
741
+ names = [x[0] for x in cur.description]
742
+ out = cur.fetchone()
743
+ row = dict(zip(names, out[0]))
744
+
745
+ dtypes = [
746
+ ('id', '<f8'),
747
+ ('tinyint', '<f4'),
748
+ ('unsigned_tinyint', '<f4'),
749
+ ('bool', '<f4'),
750
+ ('boolean', '<f4'),
751
+ ('smallint', '<f4'),
752
+ ('unsigned_smallint', '<f4'),
753
+ ('mediumint', '<f8'),
754
+ ('unsigned_mediumint', '<f8'),
755
+ ('int24', '<f8'),
756
+ ('unsigned_int24', '<f8'),
757
+ ('int', '<f8'),
758
+ ('unsigned_int', '<f8'),
759
+ ('integer', '<f8'),
760
+ ('unsigned_integer', '<f8'),
761
+ ('bigint', '<f8'),
762
+ ('unsigned_bigint', '<f8'),
763
+ ('float', '<f4'),
764
+ ('double', '<f8'),
765
+ ('real', '<f8'),
766
+ ('decimal', 'O'),
767
+ ('dec', 'O'),
768
+ ('fixed', 'O'),
769
+ ('numeric', 'O'),
770
+ ('date', '<M8[D]'),
771
+ ('time', '<m8[us]'),
772
+ ('time_6', '<m8[us]'),
773
+ ('datetime', '<M8[us]'),
774
+ ('datetime_6', '<M8[us]'),
775
+ ('timestamp', '<M8[us]'),
776
+ ('timestamp_6', '<M8[us]'),
777
+ ('year', '<f8'),
778
+ ('char_100', 'O'),
779
+ ('binary_100', 'O'),
780
+ ('varchar_200', 'O'),
781
+ ('varbinary_200', 'O'),
782
+ ('longtext', 'O'),
783
+ ('mediumtext', 'O'),
784
+ ('text', 'O'),
785
+ ('tinytext', 'O'),
786
+ ('longblob', 'O'),
787
+ ('mediumblob', 'O'),
788
+ ('blob', 'O'),
789
+ ('tinyblob', 'O'),
790
+ ('json', 'O'),
791
+ ('enum', 'O'),
792
+ ('set', 'O'),
793
+ ('bit', 'O'),
794
+ ]
795
+
796
+ assert out.dtype == dtypes
797
+
798
+ bits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
799
+
800
+ assert row['id'] == 0, row['id']
801
+ assert row['tinyint'] == 80, row['tinyint']
802
+ assert row['unsigned_tinyint'] == 85, row['unsigned_tinyint']
803
+ assert row['bool'] == 0, row['bool']
804
+ assert row['boolean'] == 1, row['boolean']
805
+ assert row['smallint'] == -27897, row['smallint']
806
+ assert row['unsigned_smallint'] == 27897, row['unsigned_smallint']
807
+ assert row['mediumint'] == 104729, row['mediumint']
808
+ assert row['unsigned_mediumint'] == 120999, row['unsigned_mediumint']
809
+ assert row['int24'] == -200899, row['int24']
810
+ assert row['unsigned_int24'] == 407709, row['unsigned_int24']
811
+ assert row['int'] == -1295369311, row['int']
812
+ assert row['unsigned_int'] == 3872362332, row['unsigned_int']
813
+ assert row['integer'] == -1741727421, row['integer']
814
+ assert row['unsigned_integer'] == 3198387363, row['unsigned_integer']
815
+ assert row['bigint'] == -266883847, row['bigint']
816
+ assert row['unsigned_bigint'] == 980007287362, row['unsigned_bigint']
817
+ assert row['float'] - -146487000.0 < 0.00001, row['float']
818
+ assert row['double'] == -474646154.719356, row['double']
819
+ assert row['real'] == -901409776.279346, row['real']
820
+ assert row['decimal'] == decimal.Decimal(
821
+ '28111097.610822',
822
+ ), row['decimal']
823
+ assert row['dec'] == decimal.Decimal('389451155.931428'), row['dec']
824
+ assert row['fixed'] == decimal.Decimal(
825
+ '-143773416.044092',
826
+ ), row['fixed']
827
+ assert row['numeric'] == decimal.Decimal(
828
+ '866689461.300046',
829
+ ), row['numeric']
830
+ assert row['date'] == datetime.date(8524, 11, 10), row['date']
831
+ assert row['time'] == datetime.timedelta(minutes=7), row['time']
832
+ assert row['datetime'] == datetime.datetime(
833
+ 9948, 3, 11, 15, 29, 22,
834
+ ), row['datetime']
835
+ assert row['datetime_6'] == datetime.datetime(
836
+ 1756, 10, 29, 2, 2, 42, 8,
837
+ ), row['datetime_6']
838
+ assert row['timestamp'] == datetime.datetime(
839
+ 1980, 12, 31, 1, 10, 23,
840
+ ), row['timestamp']
841
+ assert row['timestamp_6'] == datetime.datetime(
842
+ 1991, 1, 2, 22, 15, 10, 6,
843
+ ), row['timestamp_6']
844
+ assert row['year'] == 1923, row['year']
845
+ assert row['char_100'] == \
846
+ 'This is a test of a 100 character column.', row['char_100']
847
+ assert row['binary_100'] == bytearray(
848
+ bits + [0] * 84,
849
+ ), row['binary_100']
850
+ assert row['varchar_200'] == \
851
+ 'This is a test of a variable character column.', row['varchar_200']
852
+ assert row['varbinary_200'] == bytearray(
853
+ bits * 2,
854
+ ), row['varbinary_200']
855
+ assert row['longtext'] == 'This is a longtext column.', row['longtext']
856
+ assert row['mediumtext'] == 'This is a mediumtext column.', row['mediumtext']
857
+ assert row['text'] == 'This is a text column.', row['text']
858
+ assert row['tinytext'] == 'This is a tinytext column.'
859
+ assert row['longblob'] == bytearray(bits * 3), row['longblob']
860
+ assert row['mediumblob'] == bytearray(bits * 2), row['mediumblob']
861
+ assert row['blob'] == bytearray(bits), row['blob']
862
+ assert row['tinyblob'] == bytearray(
863
+ [10, 11, 12, 13, 14, 15],
864
+ ), row['tinyblob']
865
+ assert row['json'] == {
866
+ 'a': 10, 'b': 2.75,
867
+ 'c': 'hello world',
868
+ }, row['json']
869
+ assert row['enum'] == 'one', row['enum']
870
+ assert row['set'] == 'two', row['set']
871
+ assert row['bit'] == b'\x00\x00\x00\x00\x00\x00\x00\x80', row['bit']
872
+
873
+ conn.close()
874
+
875
+ def test_alltypes_no_nulls_numpy(self):
876
+ if self.conn.driver in ['http', 'https']:
877
+ self.skipTest('Data API does not surface unsigned int information')
878
+
879
+ conn = s2.connect(database=type(self).dbname, results_type='numpy')
880
+ cur = conn.cursor()
881
+
882
+ cur.execute('select * from alltypes_no_nulls where id = 0')
883
+ names = [x[0] for x in cur.description]
884
+ out = cur.fetchone()
885
+ row = dict(zip(names, out[0]))
886
+
887
+ dtypes = [
888
+ ('id', '<i4'),
889
+ ('tinyint', 'i1'),
890
+ ('unsigned_tinyint', 'u1'),
891
+ ('bool', 'i1'),
892
+ ('boolean', 'i1'),
893
+ ('smallint', '<i2'),
894
+ ('unsigned_smallint', '<u2'),
895
+ ('mediumint', '<i4'),
896
+ ('unsigned_mediumint', '<u4'),
897
+ ('int24', '<i4'),
898
+ ('unsigned_int24', '<u4'),
899
+ ('int', '<i4'),
900
+ ('unsigned_int', '<u4'),
901
+ ('integer', '<i4'),
902
+ ('unsigned_integer', '<u4'),
903
+ ('bigint', '<i8'),
904
+ ('unsigned_bigint', '<u8'),
905
+ ('float', '<f4'),
906
+ ('double', '<f8'),
907
+ ('real', '<f8'),
908
+ ('decimal', 'O'),
909
+ ('dec', 'O'),
910
+ ('fixed', 'O'),
911
+ ('numeric', 'O'),
912
+ ('date', '<M8[D]'),
913
+ ('time', '<m8[us]'),
914
+ ('time_6', '<m8[us]'),
915
+ ('datetime', '<M8[us]'),
916
+ ('datetime_6', '<M8[us]'),
917
+ ('timestamp', '<M8[us]'),
918
+ ('timestamp_6', '<M8[us]'),
919
+ ('year', '<i2'),
920
+ ('char_100', 'O'),
921
+ ('binary_100', 'O'),
922
+ ('varchar_200', 'O'),
923
+ ('varbinary_200', 'O'),
924
+ ('longtext', 'O'),
925
+ ('mediumtext', 'O'),
926
+ ('text', 'O'),
927
+ ('tinytext', 'O'),
928
+ ('longblob', 'O'),
929
+ ('mediumblob', 'O'),
930
+ ('blob', 'O'),
931
+ ('tinyblob', 'O'),
932
+ ('json', 'O'),
933
+ ('enum', 'O'),
934
+ ('set', 'O'),
935
+ ('bit', 'O'),
936
+ ]
937
+
938
+ assert out.dtype == dtypes
939
+
940
+ bits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
941
+
942
+ assert row['id'] == 0, row['id']
943
+ assert row['tinyint'] == 80, row['tinyint']
944
+ assert row['unsigned_tinyint'] == 85, row['unsigned_tinyint']
945
+ assert row['bool'] == 0, row['bool']
946
+ assert row['boolean'] == 1, row['boolean']
947
+ assert row['smallint'] == -27897, row['smallint']
948
+ assert row['unsigned_smallint'] == 27897, row['unsigned_smallint']
949
+ assert row['mediumint'] == 104729, row['mediumint']
950
+ assert row['unsigned_mediumint'] == 120999, row['unsigned_mediumint']
951
+ assert row['int24'] == -200899, row['int24']
952
+ assert row['unsigned_int24'] == 407709, row['unsigned_int24']
953
+ assert row['int'] == -1295369311, row['int']
954
+ assert row['unsigned_int'] == 3872362332, row['unsigned_int']
955
+ assert row['integer'] == -1741727421, row['integer']
956
+ assert row['unsigned_integer'] == 3198387363, row['unsigned_integer']
957
+ assert row['bigint'] == -266883847, row['bigint']
958
+ assert row['unsigned_bigint'] == 980007287362, row['unsigned_bigint']
959
+ assert row['float'] - -146487000.0 < 0.00001, row['float']
960
+ assert row['double'] == -474646154.719356, row['double']
961
+ assert row['real'] == -901409776.279346, row['real']
962
+ assert row['decimal'] == decimal.Decimal(
963
+ '28111097.610822',
964
+ ), row['decimal']
965
+ assert row['dec'] == decimal.Decimal('389451155.931428'), row['dec']
966
+ assert row['fixed'] == decimal.Decimal(
967
+ '-143773416.044092',
968
+ ), row['fixed']
969
+ assert row['numeric'] == decimal.Decimal(
970
+ '866689461.300046',
971
+ ), row['numeric']
972
+ assert row['date'] == datetime.date(8524, 11, 10), row['date']
973
+ assert row['time'] == datetime.timedelta(minutes=7), row['time']
974
+ assert row['datetime'] == datetime.datetime(
975
+ 9948, 3, 11, 15, 29, 22,
976
+ ), row['datetime']
977
+ assert row['datetime_6'] == datetime.datetime(
978
+ 1756, 10, 29, 2, 2, 42, 8,
979
+ ), row['datetime_6']
980
+ assert row['timestamp'] == datetime.datetime(
981
+ 1980, 12, 31, 1, 10, 23,
982
+ ), row['timestamp']
983
+ assert row['timestamp_6'] == datetime.datetime(
984
+ 1991, 1, 2, 22, 15, 10, 6,
985
+ ), row['timestamp_6']
986
+ assert row['year'] == 1923, row['year']
987
+ assert row['char_100'] == \
988
+ 'This is a test of a 100 character column.', row['char_100']
989
+ assert row['binary_100'] == bytearray(
990
+ bits + [0] * 84,
991
+ ), row['binary_100']
992
+ assert row['varchar_200'] == \
993
+ 'This is a test of a variable character column.', row['varchar_200']
994
+ assert row['varbinary_200'] == bytearray(
995
+ bits * 2,
996
+ ), row['varbinary_200']
997
+ assert row['longtext'] == 'This is a longtext column.', row['longtext']
998
+ assert row['mediumtext'] == 'This is a mediumtext column.', row['mediumtext']
999
+ assert row['text'] == 'This is a text column.', row['text']
1000
+ assert row['tinytext'] == 'This is a tinytext column.'
1001
+ assert row['longblob'] == bytearray(bits * 3), row['longblob']
1002
+ assert row['mediumblob'] == bytearray(bits * 2), row['mediumblob']
1003
+ assert row['blob'] == bytearray(bits), row['blob']
1004
+ assert row['tinyblob'] == bytearray(
1005
+ [10, 11, 12, 13, 14, 15],
1006
+ ), row['tinyblob']
1007
+ assert row['json'] == {
1008
+ 'a': 10, 'b': 2.75,
1009
+ 'c': 'hello world',
1010
+ }, row['json']
1011
+ assert row['enum'] == 'one', row['enum']
1012
+ assert row['set'] == 'two', row['set']
1013
+ assert row['bit'] == b'\x00\x00\x00\x00\x00\x00\x00\x80', row['bit']
1014
+
1015
+ conn.close()
1016
+
1017
+ def test_alltypes_min_max_numpy(self):
1018
+ if self.conn.driver in ['http', 'https']:
1019
+ self.skipTest('Data API does not surface unsigned int information')
1020
+
1021
+ conn = s2.connect(database=type(self).dbname, results_type='numpy')
1022
+ cur = conn.cursor()
1023
+
1024
+ cur.execute('select * from alltypes_no_nulls')
1025
+ cur.fetchall()
1026
+
1027
+ cur.execute('select * from alltypes')
1028
+ cur.fetchall()
1029
+
1030
+ conn.close()
1031
+
1032
+ def test_alltypes_nulls_numpy(self):
1033
+ conn = s2.connect(database=type(self).dbname, results_type='numpy')
1034
+ cur = conn.cursor()
1035
+
1036
+ cur.execute('select * from alltypes where id = 1')
1037
+ names = [x[0] for x in cur.description]
1038
+ out = cur.fetchone()
1039
+ row = dict(zip(names, out[0]))
1040
+
1041
+ assert row['id'] == 1, row['id']
1042
+ assert np.isnan(row['tinyint']), row['tinyint']
1043
+ assert np.isnan(row['bool']), row['bool']
1044
+ assert np.isnan(row['boolean']), row['boolean']
1045
+ assert np.isnan(row['smallint']), row['smallint']
1046
+ assert np.isnan(row['mediumint']), row['mediumint']
1047
+ assert np.isnan(row['int24']), row['int24']
1048
+ assert np.isnan(row['int']), row['int']
1049
+ assert np.isnan(row['integer']), row['integer']
1050
+ assert np.isnan(row['bigint']), row['bigint']
1051
+ assert np.isnan(row['float']), row['float']
1052
+ assert np.isnan(row['double']), row['double']
1053
+ assert np.isnan(row['real']), row['real']
1054
+ assert row['decimal'] is None, row['decimal']
1055
+ assert row['dec'] is None, row['dec']
1056
+ assert row['fixed'] is None, row['fixed']
1057
+ assert row['numeric'] is None, row['numeric']
1058
+ assert np.isnat(row['date']), row['date']
1059
+ assert np.isnat(row['time']), row['time']
1060
+ assert np.isnat(row['time']), row['time']
1061
+ assert np.isnat(row['datetime']), row['datetime']
1062
+ assert np.isnat(row['datetime_6']), row['datetime_6']
1063
+ assert np.isnat(row['timestamp']), row['timestamp']
1064
+ assert np.isnat(row['timestamp_6']), row['timestamp_6']
1065
+ assert np.isnan(row['year']), row['year']
1066
+ assert row['char_100'] is None, row['char_100']
1067
+ assert row['binary_100'] is None, row['binary_100']
1068
+ assert row['varchar_200'] is None, row['varchar_200']
1069
+ assert row['varbinary_200'] is None, row['varbinary_200']
1070
+ assert row['longtext'] is None, row['longtext']
1071
+ assert row['mediumtext'] is None, row['mediumtext']
1072
+ assert row['text'] is None, row['text']
1073
+ assert row['tinytext'] is None, row['tinytext']
1074
+ assert row['longblob'] is None, row['longblob']
1075
+ assert row['mediumblob'] is None, row['mediumblob']
1076
+ assert row['blob'] is None, row['blob']
1077
+ assert row['tinyblob'] is None, row['tinyblob']
1078
+ assert row['json'] is None, row['json']
1079
+ assert row['enum'] is None, row['enum']
1080
+ assert row['set'] is None, row['set']
1081
+ assert row['bit'] is None, row['bit']
1082
+
1083
+ conn.close()
1084
+
1085
+ def test_alltypes_pandas(self):
1086
+ conn = s2.connect(database=type(self).dbname, results_type='pandas')
1087
+ cur = conn.cursor()
1088
+
1089
+ cur.execute('select * from alltypes where id = 0')
1090
+ names = [x[0] for x in cur.description]
1091
+ out = cur.fetchone()
1092
+ row = dict(zip(names, out.iloc[0]))
1093
+
1094
+ dtypes = [
1095
+ ('id', 'float64'),
1096
+ ('tinyint', 'float32'),
1097
+ ('unsigned_tinyint', 'float32'),
1098
+ ('bool', 'float32'),
1099
+ ('boolean', 'float32'),
1100
+ ('smallint', 'float32'),
1101
+ ('unsigned_smallint', 'float32'),
1102
+ ('mediumint', 'float64'),
1103
+ ('unsigned_mediumint', 'float64'),
1104
+ ('int24', 'float64'),
1105
+ ('unsigned_int24', 'float64'),
1106
+ ('int', 'float64'),
1107
+ ('unsigned_int', 'float64'),
1108
+ ('integer', 'float64'),
1109
+ ('unsigned_integer', 'float64'),
1110
+ ('bigint', 'float64'),
1111
+ ('unsigned_bigint', 'float64'),
1112
+ ('float', 'float32'),
1113
+ ('double', 'float64'),
1114
+ ('real', 'float64'),
1115
+ ('decimal', 'object'),
1116
+ ('dec', 'object'),
1117
+ ('fixed', 'object'),
1118
+ ('numeric', 'object'),
1119
+ ('date', 'datetime64[s]'),
1120
+ ('time', 'timedelta64[us]'),
1121
+ ('time_6', 'timedelta64[us]'),
1122
+ ('datetime', 'datetime64[us]'),
1123
+ ('datetime_6', 'datetime64[us]'),
1124
+ ('timestamp', 'datetime64[us]'),
1125
+ ('timestamp_6', 'datetime64[us]'),
1126
+ ('year', 'float64'),
1127
+ ('char_100', 'object'),
1128
+ ('binary_100', 'object'),
1129
+ ('varchar_200', 'object'),
1130
+ ('varbinary_200', 'object'),
1131
+ ('longtext', 'object'),
1132
+ ('mediumtext', 'object'),
1133
+ ('text', 'object'),
1134
+ ('tinytext', 'object'),
1135
+ ('longblob', 'object'),
1136
+ ('mediumblob', 'object'),
1137
+ ('blob', 'object'),
1138
+ ('tinyblob', 'object'),
1139
+ ('json', 'object'),
1140
+ ('enum', 'object'),
1141
+ ('set', 'object'),
1142
+ ('bit', 'object'),
1143
+ ]
1144
+
1145
+ assert [(x[0], str(x[1])) for x in out.dtypes.items()] == dtypes
1146
+
1147
+ bits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
1148
+
1149
+ assert row['id'] == 0, row['id']
1150
+ assert row['tinyint'] == 80, row['tinyint']
1151
+ assert row['unsigned_tinyint'] == 85, row['unsigned_tinyint']
1152
+ assert row['bool'] == 0, row['bool']
1153
+ assert row['boolean'] == 1, row['boolean']
1154
+ assert row['smallint'] == -27897, row['smallint']
1155
+ assert row['unsigned_smallint'] == 27897, row['unsigned_smallint']
1156
+ assert row['mediumint'] == 104729, row['mediumint']
1157
+ assert row['unsigned_mediumint'] == 120999, row['unsigned_mediumint']
1158
+ assert row['int24'] == -200899, row['int24']
1159
+ assert row['unsigned_int24'] == 407709, row['unsigned_int24']
1160
+ assert row['int'] == -1295369311, row['int']
1161
+ assert row['unsigned_int'] == 3872362332, row['unsigned_int']
1162
+ assert row['integer'] == -1741727421, row['integer']
1163
+ assert row['unsigned_integer'] == 3198387363, row['unsigned_integer']
1164
+ assert row['bigint'] == -266883847, row['bigint']
1165
+ assert row['unsigned_bigint'] == 980007287362, row['unsigned_bigint']
1166
+ assert row['float'] - -146487000.0 < 0.00001, row['float']
1167
+ assert row['double'] == -474646154.719356, row['double']
1168
+ assert row['real'] == -901409776.279346, row['real']
1169
+ assert row['decimal'] == decimal.Decimal(
1170
+ '28111097.610822',
1171
+ ), row['decimal']
1172
+ assert row['dec'] == decimal.Decimal('389451155.931428'), row['dec']
1173
+ assert row['fixed'] == decimal.Decimal(
1174
+ '-143773416.044092',
1175
+ ), row['fixed']
1176
+ assert row['numeric'] == decimal.Decimal(
1177
+ '866689461.300046',
1178
+ ), row['numeric']
1179
+ assert row['date'] == datetime.datetime(8524, 11, 10), row['date']
1180
+ assert row['time'] == datetime.timedelta(minutes=7), row['time']
1181
+ assert row['datetime'] == datetime.datetime(
1182
+ 9948, 3, 11, 15, 29, 22,
1183
+ ), row['datetime']
1184
+ assert row['datetime_6'] == datetime.datetime(
1185
+ 1756, 10, 29, 2, 2, 42, 8,
1186
+ ), row['datetime_6']
1187
+ assert row['timestamp'] == datetime.datetime(
1188
+ 1980, 12, 31, 1, 10, 23,
1189
+ ), row['timestamp']
1190
+ assert row['timestamp_6'] == datetime.datetime(
1191
+ 1991, 1, 2, 22, 15, 10, 6,
1192
+ ), row['timestamp_6']
1193
+ assert row['year'] == 1923, row['year']
1194
+ assert row['char_100'] == \
1195
+ 'This is a test of a 100 character column.', row['char_100']
1196
+ assert row['binary_100'] == bytearray(
1197
+ bits + [0] * 84,
1198
+ ), row['binary_100']
1199
+ assert row['varchar_200'] == \
1200
+ 'This is a test of a variable character column.', row['varchar_200']
1201
+ assert row['varbinary_200'] == bytearray(
1202
+ bits * 2,
1203
+ ), row['varbinary_200']
1204
+ assert row['longtext'] == 'This is a longtext column.', row['longtext']
1205
+ assert row['mediumtext'] == 'This is a mediumtext column.', row['mediumtext']
1206
+ assert row['text'] == 'This is a text column.', row['text']
1207
+ assert row['tinytext'] == 'This is a tinytext column.'
1208
+ assert row['longblob'] == bytearray(bits * 3), row['longblob']
1209
+ assert row['mediumblob'] == bytearray(bits * 2), row['mediumblob']
1210
+ assert row['blob'] == bytearray(bits), row['blob']
1211
+ assert row['tinyblob'] == bytearray(
1212
+ [10, 11, 12, 13, 14, 15],
1213
+ ), row['tinyblob']
1214
+ assert row['json'] == {
1215
+ 'a': 10, 'b': 2.75,
1216
+ 'c': 'hello world',
1217
+ }, row['json']
1218
+ assert row['enum'] == 'one', row['enum']
1219
+ assert row['set'] == 'two', row['set']
1220
+ assert row['bit'] == b'\x00\x00\x00\x00\x00\x00\x00\x80', row['bit']
1221
+
1222
+ conn.close()
1223
+
1224
+ def test_alltypes_no_nulls_pandas(self):
1225
+ if self.conn.driver in ['http', 'https']:
1226
+ self.skipTest('Data API does not surface unsigned int information')
1227
+
1228
+ conn = s2.connect(database=type(self).dbname, results_type='pandas')
1229
+ cur = conn.cursor()
1230
+
1231
+ cur.execute('select * from alltypes_no_nulls where id = 0')
1232
+ names = [x[0] for x in cur.description]
1233
+ out = cur.fetchone()
1234
+ row = dict(zip(names, out.iloc[0]))
1235
+
1236
+ dtypes = [
1237
+ ('id', 'int32'),
1238
+ ('tinyint', 'int8'),
1239
+ ('unsigned_tinyint', 'uint8'),
1240
+ ('bool', 'int8'),
1241
+ ('boolean', 'int8'),
1242
+ ('smallint', 'int16'),
1243
+ ('unsigned_smallint', 'uint16'),
1244
+ ('mediumint', 'int32'),
1245
+ ('unsigned_mediumint', 'uint32'),
1246
+ ('int24', 'int32'),
1247
+ ('unsigned_int24', 'uint32'),
1248
+ ('int', 'int32'),
1249
+ ('unsigned_int', 'uint32'),
1250
+ ('integer', 'int32'),
1251
+ ('unsigned_integer', 'uint32'),
1252
+ ('bigint', 'int64'),
1253
+ ('unsigned_bigint', 'uint64'),
1254
+ ('float', 'float32'),
1255
+ ('double', 'float64'),
1256
+ ('real', 'float64'),
1257
+ ('decimal', 'object'),
1258
+ ('dec', 'object'),
1259
+ ('fixed', 'object'),
1260
+ ('numeric', 'object'),
1261
+ ('date', 'datetime64[s]'),
1262
+ ('time', 'timedelta64[us]'),
1263
+ ('time_6', 'timedelta64[us]'),
1264
+ ('datetime', 'datetime64[us]'),
1265
+ ('datetime_6', 'datetime64[us]'),
1266
+ ('timestamp', 'datetime64[us]'),
1267
+ ('timestamp_6', 'datetime64[us]'),
1268
+ ('year', 'int16'),
1269
+ ('char_100', 'object'),
1270
+ ('binary_100', 'object'),
1271
+ ('varchar_200', 'object'),
1272
+ ('varbinary_200', 'object'),
1273
+ ('longtext', 'object'),
1274
+ ('mediumtext', 'object'),
1275
+ ('text', 'object'),
1276
+ ('tinytext', 'object'),
1277
+ ('longblob', 'object'),
1278
+ ('mediumblob', 'object'),
1279
+ ('blob', 'object'),
1280
+ ('tinyblob', 'object'),
1281
+ ('json', 'object'),
1282
+ ('enum', 'object'),
1283
+ ('set', 'object'),
1284
+ ('bit', 'object'),
1285
+ ]
1286
+
1287
+ assert [(x[0], str(x[1])) for x in out.dtypes.items()] == dtypes
1288
+
1289
+ bits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
1290
+
1291
+ assert row['id'] == 0, row['id']
1292
+ assert row['tinyint'] == 80, row['tinyint']
1293
+ assert row['unsigned_tinyint'] == 85, row['unsigned_tinyint']
1294
+ assert row['bool'] == 0, row['bool']
1295
+ assert row['boolean'] == 1, row['boolean']
1296
+ assert row['smallint'] == -27897, row['smallint']
1297
+ assert row['unsigned_smallint'] == 27897, row['unsigned_smallint']
1298
+ assert row['mediumint'] == 104729, row['mediumint']
1299
+ assert row['unsigned_mediumint'] == 120999, row['unsigned_mediumint']
1300
+ assert row['int24'] == -200899, row['int24']
1301
+ assert row['unsigned_int24'] == 407709, row['unsigned_int24']
1302
+ assert row['int'] == -1295369311, row['int']
1303
+ assert row['unsigned_int'] == 3872362332, row['unsigned_int']
1304
+ assert row['integer'] == -1741727421, row['integer']
1305
+ assert row['unsigned_integer'] == 3198387363, row['unsigned_integer']
1306
+ assert row['bigint'] == -266883847, row['bigint']
1307
+ assert row['unsigned_bigint'] == 980007287362, row['unsigned_bigint']
1308
+ assert row['float'] - -146487000.0 < 0.00001, row['float']
1309
+ assert row['double'] == -474646154.719356, row['double']
1310
+ assert row['real'] == -901409776.279346, row['real']
1311
+ assert row['decimal'] == decimal.Decimal(
1312
+ '28111097.610822',
1313
+ ), row['decimal']
1314
+ assert row['dec'] == decimal.Decimal('389451155.931428'), row['dec']
1315
+ assert row['fixed'] == decimal.Decimal(
1316
+ '-143773416.044092',
1317
+ ), row['fixed']
1318
+ assert row['numeric'] == decimal.Decimal(
1319
+ '866689461.300046',
1320
+ ), row['numeric']
1321
+ assert row['date'] == datetime.datetime(8524, 11, 10), row['date']
1322
+ assert row['time'] == datetime.timedelta(minutes=7), row['time']
1323
+ assert row['datetime'] == datetime.datetime(
1324
+ 9948, 3, 11, 15, 29, 22,
1325
+ ), row['datetime']
1326
+ assert row['datetime_6'] == datetime.datetime(
1327
+ 1756, 10, 29, 2, 2, 42, 8,
1328
+ ), row['datetime_6']
1329
+ assert row['timestamp'] == datetime.datetime(
1330
+ 1980, 12, 31, 1, 10, 23,
1331
+ ), row['timestamp']
1332
+ assert row['timestamp_6'] == datetime.datetime(
1333
+ 1991, 1, 2, 22, 15, 10, 6,
1334
+ ), row['timestamp_6']
1335
+ assert row['year'] == 1923, row['year']
1336
+ assert row['char_100'] == \
1337
+ 'This is a test of a 100 character column.', row['char_100']
1338
+ assert row['binary_100'] == bytearray(
1339
+ bits + [0] * 84,
1340
+ ), row['binary_100']
1341
+ assert row['varchar_200'] == \
1342
+ 'This is a test of a variable character column.', row['varchar_200']
1343
+ assert row['varbinary_200'] == bytearray(
1344
+ bits * 2,
1345
+ ), row['varbinary_200']
1346
+ assert row['longtext'] == 'This is a longtext column.', row['longtext']
1347
+ assert row['mediumtext'] == 'This is a mediumtext column.', row['mediumtext']
1348
+ assert row['text'] == 'This is a text column.', row['text']
1349
+ assert row['tinytext'] == 'This is a tinytext column.'
1350
+ assert row['longblob'] == bytearray(bits * 3), row['longblob']
1351
+ assert row['mediumblob'] == bytearray(bits * 2), row['mediumblob']
1352
+ assert row['blob'] == bytearray(bits), row['blob']
1353
+ assert row['tinyblob'] == bytearray(
1354
+ [10, 11, 12, 13, 14, 15],
1355
+ ), row['tinyblob']
1356
+ assert row['json'] == {
1357
+ 'a': 10, 'b': 2.75,
1358
+ 'c': 'hello world',
1359
+ }, row['json']
1360
+ assert row['enum'] == 'one', row['enum']
1361
+ assert row['set'] == 'two', row['set']
1362
+ assert row['bit'] == b'\x00\x00\x00\x00\x00\x00\x00\x80', row['bit']
1363
+
1364
+ conn.close()
1365
+
1366
+ def test_alltypes_min_max_pandas(self):
1367
+ if self.conn.driver in ['http', 'https']:
1368
+ self.skipTest('Data API does not surface unsigned int information')
1369
+
1370
+ conn = s2.connect(database=type(self).dbname, results_type='pandas')
1371
+ cur = conn.cursor()
1372
+
1373
+ cur.execute('select * from alltypes_no_nulls')
1374
+ cur.fetchall()
1375
+
1376
+ cur.execute('select * from alltypes')
1377
+ cur.fetchall()
1378
+
1379
+ conn.close()
1380
+
1381
+ def test_alltypes_nulls_pandas(self):
1382
+ conn = s2.connect(database=type(self).dbname, results_type='pandas')
1383
+ cur = conn.cursor()
1384
+
1385
+ cur.execute('select * from alltypes where id = 1')
1386
+ names = [x[0] for x in cur.description]
1387
+ out = cur.fetchone()
1388
+ row = dict(zip(names, out.iloc[0]))
1389
+
1390
+ assert row['id'] == 1, row['id']
1391
+ assert np.isnan(row['tinyint']), row['tinyint']
1392
+ assert np.isnan(row['bool']), row['bool']
1393
+ assert np.isnan(row['boolean']), row['boolean']
1394
+ assert np.isnan(row['smallint']), row['smallint']
1395
+ assert np.isnan(row['mediumint']), row['mediumint']
1396
+ assert np.isnan(row['int24']), row['int24']
1397
+ assert np.isnan(row['int']), row['int']
1398
+ assert np.isnan(row['integer']), row['integer']
1399
+ assert np.isnan(row['bigint']), row['bigint']
1400
+ assert np.isnan(row['float']), row['float']
1401
+ assert np.isnan(row['double']), row['double']
1402
+ assert np.isnan(row['real']), row['real']
1403
+ assert row['decimal'] is None, row['decimal']
1404
+ assert row['dec'] is None, row['dec']
1405
+ assert row['fixed'] is None, row['fixed']
1406
+ assert row['numeric'] is None, row['numeric']
1407
+ assert row['date'] is pd.NaT, row['date']
1408
+ assert row['time'] is pd.NaT, row['time']
1409
+ assert row['time'] is pd.NaT, row['time']
1410
+ assert row['datetime'] is pd.NaT, row['datetime']
1411
+ assert row['datetime_6'] is pd.NaT, row['datetime_6']
1412
+ assert row['timestamp'] is pd.NaT, row['timestamp']
1413
+ assert row['timestamp_6'] is pd.NaT, row['timestamp_6']
1414
+ assert np.isnan(row['year']), row['year']
1415
+ assert row['char_100'] is None, row['char_100']
1416
+ assert row['binary_100'] is None, row['binary_100']
1417
+ assert row['varchar_200'] is None, row['varchar_200']
1418
+ assert row['varbinary_200'] is None, row['varbinary_200']
1419
+ assert row['longtext'] is None, row['longtext']
1420
+ assert row['mediumtext'] is None, row['mediumtext']
1421
+ assert row['text'] is None, row['text']
1422
+ assert row['tinytext'] is None, row['tinytext']
1423
+ assert row['longblob'] is None, row['longblob']
1424
+ assert row['mediumblob'] is None, row['mediumblob']
1425
+ assert row['blob'] is None, row['blob']
1426
+ assert row['tinyblob'] is None, row['tinyblob']
1427
+ assert row['json'] is None, row['json']
1428
+ assert row['enum'] is None, row['enum']
1429
+ assert row['set'] is None, row['set']
1430
+ assert row['bit'] is None, row['bit']
1431
+
1432
+ conn.close()
1433
+
1434
+ def test_alltypes_polars(self):
1435
+ if self.conn.driver in ['http', 'https']:
1436
+ self.skipTest('Data API does not surface unsigned int information')
1437
+
1438
+ conn = s2.connect(database=type(self).dbname, results_type='polars')
1439
+ cur = conn.cursor()
1440
+
1441
+ cur.execute('select * from alltypes where id = 0')
1442
+ names = [x[0] for x in cur.description]
1443
+ out = cur.fetchone()
1444
+ row = dict(zip(names, out.row(0)))
1445
+
1446
+ dtypes = [
1447
+ ('id', 'Int32'),
1448
+ ('tinyint', 'Int8'),
1449
+ ('unsigned_tinyint', 'UInt8'),
1450
+ ('bool', 'Int8'),
1451
+ ('boolean', 'Int8'),
1452
+ ('smallint', 'Int16'),
1453
+ ('unsigned_smallint', 'UInt16'),
1454
+ ('mediumint', 'Int32'),
1455
+ ('unsigned_mediumint', 'UInt32'),
1456
+ ('int24', 'Int32'),
1457
+ ('unsigned_int24', 'UInt32'),
1458
+ ('int', 'Int32'),
1459
+ ('unsigned_int', 'UInt32'),
1460
+ ('integer', 'Int32'),
1461
+ ('unsigned_integer', 'UInt32'),
1462
+ ('bigint', 'Int64'),
1463
+ ('unsigned_bigint', 'UInt64'),
1464
+ ('float', 'Float32'),
1465
+ ('double', 'Float64'),
1466
+ ('real', 'Float64'),
1467
+ ('decimal', 'Decimal(precision=22, scale=6)'),
1468
+ ('dec', 'Decimal(precision=22, scale=6)'),
1469
+ ('fixed', 'Decimal(precision=22, scale=6)'),
1470
+ ('numeric', 'Decimal(precision=22, scale=6)'),
1471
+ ('date', 'Date'),
1472
+ ('time', "Duration(time_unit='us')"),
1473
+ ('time_6', "Duration(time_unit='us')"),
1474
+ ('datetime', "Datetime(time_unit='us', time_zone=None)"),
1475
+ ('datetime_6', "Datetime(time_unit='us', time_zone=None)"),
1476
+ ('timestamp', "Datetime(time_unit='us', time_zone=None)"),
1477
+ ('timestamp_6', "Datetime(time_unit='us', time_zone=None)"),
1478
+ ('year', 'Int16'),
1479
+ ('char_100', 'String'),
1480
+ ('binary_100', 'Binary'),
1481
+ ('varchar_200', 'String'),
1482
+ ('varbinary_200', 'Binary'),
1483
+ ('longtext', 'String'),
1484
+ ('mediumtext', 'String'),
1485
+ ('text', 'String'),
1486
+ ('tinytext', 'String'),
1487
+ ('longblob', 'Binary'),
1488
+ ('mediumblob', 'Binary'),
1489
+ ('blob', 'Binary'),
1490
+ ('tinyblob', 'Binary'),
1491
+ ('json', 'Object'),
1492
+ ('enum', 'String'),
1493
+ ('set', 'String'),
1494
+ ('bit', 'Binary'),
1495
+ ]
1496
+
1497
+ assert [(x, str(y)) for x, y in zip(out.columns, out.dtypes)] == dtypes
1498
+
1499
+ bits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
1500
+
1501
+ assert row['id'] == 0, row['id']
1502
+ assert row['tinyint'] == 80, row['tinyint']
1503
+ assert row['unsigned_tinyint'] == 85, row['unsigned_tinyint']
1504
+ assert row['bool'] == 0, row['bool']
1505
+ assert row['boolean'] == 1, row['boolean']
1506
+ assert row['smallint'] == -27897, row['smallint']
1507
+ assert row['unsigned_smallint'] == 27897, row['unsigned_smallint']
1508
+ assert row['mediumint'] == 104729, row['mediumint']
1509
+ assert row['unsigned_mediumint'] == 120999, row['unsigned_mediumint']
1510
+ assert row['int24'] == -200899, row['int24']
1511
+ assert row['unsigned_int24'] == 407709, row['unsigned_int24']
1512
+ assert row['int'] == -1295369311, row['int']
1513
+ assert row['unsigned_int'] == 3872362332, row['unsigned_int']
1514
+ assert row['integer'] == -1741727421, row['integer']
1515
+ assert row['unsigned_integer'] == 3198387363, row['unsigned_integer']
1516
+ assert row['bigint'] == -266883847, row['bigint']
1517
+ assert row['unsigned_bigint'] == 980007287362, row['unsigned_bigint']
1518
+ assert row['float'] - -146487000.0 < 0.00001, row['float']
1519
+ assert row['double'] == -474646154.719356, row['double']
1520
+ assert row['real'] == -901409776.279346, row['real']
1521
+ assert row['decimal'] == decimal.Decimal(
1522
+ '28111097.610822',
1523
+ ), row['decimal']
1524
+ assert row['dec'] == decimal.Decimal('389451155.931428'), row['dec']
1525
+ assert row['fixed'] == decimal.Decimal(
1526
+ '-143773416.044092',
1527
+ ), row['fixed']
1528
+ assert row['numeric'] == decimal.Decimal(
1529
+ '866689461.300046',
1530
+ ), row['numeric']
1531
+ assert row['date'] == datetime.date(8524, 11, 10), row['date']
1532
+ assert row['time'] == datetime.timedelta(minutes=7), row['time']
1533
+ assert row['datetime'] == datetime.datetime(
1534
+ 9948, 3, 11, 15, 29, 22,
1535
+ ), row['datetime']
1536
+ assert row['datetime_6'] == datetime.datetime(
1537
+ 1756, 10, 29, 2, 2, 42, 8,
1538
+ ), row['datetime_6']
1539
+ assert row['timestamp'] == datetime.datetime(
1540
+ 1980, 12, 31, 1, 10, 23,
1541
+ ), row['timestamp']
1542
+ assert row['timestamp_6'] == datetime.datetime(
1543
+ 1991, 1, 2, 22, 15, 10, 6,
1544
+ ), row['timestamp_6']
1545
+ assert row['year'] == 1923, row['year']
1546
+ assert row['char_100'] == \
1547
+ 'This is a test of a 100 character column.', row['char_100']
1548
+ assert row['binary_100'] == bytearray(
1549
+ bits + [0] * 84,
1550
+ ), row['binary_100']
1551
+ assert row['varchar_200'] == \
1552
+ 'This is a test of a variable character column.', row['varchar_200']
1553
+ assert row['varbinary_200'] == bytearray(
1554
+ bits * 2,
1555
+ ), row['varbinary_200']
1556
+ assert row['longtext'] == 'This is a longtext column.', row['longtext']
1557
+ assert row['mediumtext'] == 'This is a mediumtext column.', row['mediumtext']
1558
+ assert row['text'] == 'This is a text column.', row['text']
1559
+ assert row['tinytext'] == 'This is a tinytext column.'
1560
+ assert row['longblob'] == bytearray(bits * 3), row['longblob']
1561
+ assert row['mediumblob'] == bytearray(bits * 2), row['mediumblob']
1562
+ assert row['blob'] == bytearray(bits), row['blob']
1563
+ assert row['tinyblob'] == bytearray(
1564
+ [10, 11, 12, 13, 14, 15],
1565
+ ), row['tinyblob']
1566
+ assert row['json'] == {
1567
+ 'a': 10, 'b': 2.75,
1568
+ 'c': 'hello world',
1569
+ }, row['json']
1570
+ assert row['enum'] == 'one', row['enum']
1571
+ assert row['set'] == 'two', row['set']
1572
+ assert row['bit'] == b'\x00\x00\x00\x00\x00\x00\x00\x80', row['bit']
1573
+
1574
+ conn.close()
1575
+
1576
+ def test_alltypes_no_nulls_polars(self):
1577
+ if self.conn.driver in ['http', 'https']:
1578
+ self.skipTest('Data API does not surface unsigned int information')
1579
+
1580
+ conn = s2.connect(database=type(self).dbname, results_type='polars')
1581
+ cur = conn.cursor()
1582
+
1583
+ cur.execute('select * from alltypes_no_nulls where id = 0')
1584
+ names = [x[0] for x in cur.description]
1585
+ out = cur.fetchone()
1586
+ row = dict(zip(names, out.row(0)))
1587
+
1588
+ dtypes = [
1589
+ ('id', 'Int32'),
1590
+ ('tinyint', 'Int8'),
1591
+ ('unsigned_tinyint', 'UInt8'),
1592
+ ('bool', 'Int8'),
1593
+ ('boolean', 'Int8'),
1594
+ ('smallint', 'Int16'),
1595
+ ('unsigned_smallint', 'UInt16'),
1596
+ ('mediumint', 'Int32'),
1597
+ ('unsigned_mediumint', 'UInt32'),
1598
+ ('int24', 'Int32'),
1599
+ ('unsigned_int24', 'UInt32'),
1600
+ ('int', 'Int32'),
1601
+ ('unsigned_int', 'UInt32'),
1602
+ ('integer', 'Int32'),
1603
+ ('unsigned_integer', 'UInt32'),
1604
+ ('bigint', 'Int64'),
1605
+ ('unsigned_bigint', 'UInt64'),
1606
+ ('float', 'Float32'),
1607
+ ('double', 'Float64'),
1608
+ ('real', 'Float64'),
1609
+ ('decimal', 'Decimal(precision=22, scale=6)'),
1610
+ ('dec', 'Decimal(precision=22, scale=6)'),
1611
+ ('fixed', 'Decimal(precision=22, scale=6)'),
1612
+ ('numeric', 'Decimal(precision=22, scale=6)'),
1613
+ ('date', 'Date'),
1614
+ ('time', "Duration(time_unit='us')"),
1615
+ ('time_6', "Duration(time_unit='us')"),
1616
+ ('datetime', "Datetime(time_unit='us', time_zone=None)"),
1617
+ ('datetime_6', "Datetime(time_unit='us', time_zone=None)"),
1618
+ ('timestamp', "Datetime(time_unit='us', time_zone=None)"),
1619
+ ('timestamp_6', "Datetime(time_unit='us', time_zone=None)"),
1620
+ ('year', 'Int16'),
1621
+ ('char_100', 'String'),
1622
+ ('binary_100', 'Binary'),
1623
+ ('varchar_200', 'String'),
1624
+ ('varbinary_200', 'Binary'),
1625
+ ('longtext', 'String'),
1626
+ ('mediumtext', 'String'),
1627
+ ('text', 'String'),
1628
+ ('tinytext', 'String'),
1629
+ ('longblob', 'Binary'),
1630
+ ('mediumblob', 'Binary'),
1631
+ ('blob', 'Binary'),
1632
+ ('tinyblob', 'Binary'),
1633
+ ('json', 'Object'),
1634
+ ('enum', 'String'),
1635
+ ('set', 'String'),
1636
+ ('bit', 'Binary'),
1637
+ ]
1638
+
1639
+ assert [(x, str(y)) for x, y in zip(out.columns, out.dtypes)] == dtypes
1640
+
1641
+ bits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
1642
+
1643
+ assert row['id'] == 0, row['id']
1644
+ assert row['tinyint'] == 80, row['tinyint']
1645
+ assert row['unsigned_tinyint'] == 85, row['unsigned_tinyint']
1646
+ assert row['bool'] == 0, row['bool']
1647
+ assert row['boolean'] == 1, row['boolean']
1648
+ assert row['smallint'] == -27897, row['smallint']
1649
+ assert row['unsigned_smallint'] == 27897, row['unsigned_smallint']
1650
+ assert row['mediumint'] == 104729, row['mediumint']
1651
+ assert row['unsigned_mediumint'] == 120999, row['unsigned_mediumint']
1652
+ assert row['int24'] == -200899, row['int24']
1653
+ assert row['unsigned_int24'] == 407709, row['unsigned_int24']
1654
+ assert row['int'] == -1295369311, row['int']
1655
+ assert row['unsigned_int'] == 3872362332, row['unsigned_int']
1656
+ assert row['integer'] == -1741727421, row['integer']
1657
+ assert row['unsigned_integer'] == 3198387363, row['unsigned_integer']
1658
+ assert row['bigint'] == -266883847, row['bigint']
1659
+ assert row['unsigned_bigint'] == 980007287362, row['unsigned_bigint']
1660
+ assert row['float'] - -146487000.0 < 0.00001, row['float']
1661
+ assert row['double'] == -474646154.719356, row['double']
1662
+ assert row['real'] == -901409776.279346, row['real']
1663
+ assert row['decimal'] == decimal.Decimal(
1664
+ '28111097.610822',
1665
+ ), row['decimal']
1666
+ assert row['dec'] == decimal.Decimal('389451155.931428'), row['dec']
1667
+ assert row['fixed'] == decimal.Decimal(
1668
+ '-143773416.044092',
1669
+ ), row['fixed']
1670
+ assert row['numeric'] == decimal.Decimal(
1671
+ '866689461.300046',
1672
+ ), row['numeric']
1673
+ assert row['date'] == datetime.date(8524, 11, 10), row['date']
1674
+ assert row['time'] == datetime.timedelta(minutes=7), row['time']
1675
+ assert row['datetime'] == datetime.datetime(
1676
+ 9948, 3, 11, 15, 29, 22,
1677
+ ), row['datetime']
1678
+ assert row['datetime_6'] == datetime.datetime(
1679
+ 1756, 10, 29, 2, 2, 42, 8,
1680
+ ), row['datetime_6']
1681
+ assert row['timestamp'] == datetime.datetime(
1682
+ 1980, 12, 31, 1, 10, 23,
1683
+ ), row['timestamp']
1684
+ assert row['timestamp_6'] == datetime.datetime(
1685
+ 1991, 1, 2, 22, 15, 10, 6,
1686
+ ), row['timestamp_6']
1687
+ assert row['year'] == 1923, row['year']
1688
+ assert row['char_100'] == \
1689
+ 'This is a test of a 100 character column.', row['char_100']
1690
+ assert row['binary_100'] == bytearray(
1691
+ bits + [0] * 84,
1692
+ ), row['binary_100']
1693
+ assert row['varchar_200'] == \
1694
+ 'This is a test of a variable character column.', row['varchar_200']
1695
+ assert row['varbinary_200'] == bytearray(
1696
+ bits * 2,
1697
+ ), row['varbinary_200']
1698
+ assert row['longtext'] == 'This is a longtext column.', row['longtext']
1699
+ assert row['mediumtext'] == 'This is a mediumtext column.', row['mediumtext']
1700
+ assert row['text'] == 'This is a text column.', row['text']
1701
+ assert row['tinytext'] == 'This is a tinytext column.'
1702
+ assert row['longblob'] == bytearray(bits * 3), row['longblob']
1703
+ assert row['mediumblob'] == bytearray(bits * 2), row['mediumblob']
1704
+ assert row['blob'] == bytearray(bits), row['blob']
1705
+ assert row['tinyblob'] == bytearray(
1706
+ [10, 11, 12, 13, 14, 15],
1707
+ ), row['tinyblob']
1708
+ assert row['json'] == {
1709
+ 'a': 10, 'b': 2.75,
1710
+ 'c': 'hello world',
1711
+ }, row['json']
1712
+ assert row['enum'] == 'one', row['enum']
1713
+ assert row['set'] == 'two', row['set']
1714
+ assert row['bit'] == b'\x00\x00\x00\x00\x00\x00\x00\x80', row['bit']
1715
+
1716
+ conn.close()
1717
+
1718
+ def test_alltypes_min_max_polars(self):
1719
+ if self.conn.driver in ['http', 'https']:
1720
+ self.skipTest('Data API does not surface unsigned int information')
1721
+
1722
+ conn = s2.connect(database=type(self).dbname, results_type='polars')
1723
+ cur = conn.cursor()
1724
+
1725
+ cur.execute('select * from alltypes_no_nulls')
1726
+ cur.fetchall()
1727
+
1728
+ cur.execute('select * from alltypes')
1729
+ cur.fetchall()
1730
+
1731
+ conn.close()
1732
+
1733
+ def test_alltypes_nulls_polars(self):
1734
+ conn = s2.connect(database=type(self).dbname, results_type='polars')
1735
+ cur = conn.cursor()
1736
+
1737
+ cur.execute('select * from alltypes where id = 1')
1738
+ names = [x[0] for x in cur.description]
1739
+ out = cur.fetchone()
1740
+ row = dict(zip(names, out.row(0)))
1741
+
1742
+ assert row['id'] == 1, row['id']
1743
+ assert row['tinyint'] is None, row['tinyint']
1744
+ assert row['bool'] is None, row['bool']
1745
+ assert row['boolean'] is None, row['boolean']
1746
+ assert row['smallint'] is None, row['smallint']
1747
+ assert row['mediumint'] is None, row['mediumint']
1748
+ assert row['int24'] is None, row['int24']
1749
+ assert row['int'] is None, row['int']
1750
+ assert row['integer'] is None, row['integer']
1751
+ assert row['bigint'] is None, row['bigint']
1752
+ assert row['float'] is None, row['float']
1753
+ assert row['double'] is None, row['double']
1754
+ assert row['real'] is None, row['real']
1755
+ assert row['decimal'] is None, row['decimal']
1756
+ assert row['dec'] is None, row['dec']
1757
+ assert row['fixed'] is None, row['fixed']
1758
+ assert row['numeric'] is None, row['numeric']
1759
+ assert row['date'] is None, row['date']
1760
+ assert row['time'] is None, row['time']
1761
+ assert row['time'] is None, row['time']
1762
+ assert row['datetime'] is None, row['datetime']
1763
+ assert row['datetime_6'] is None, row['datetime_6']
1764
+ assert row['timestamp'] is None, row['timestamp']
1765
+ assert row['timestamp_6'] is None, row['timestamp_6']
1766
+ assert row['year'] is None, row['year']
1767
+ assert row['char_100'] is None, row['char_100']
1768
+ assert row['binary_100'] is None, row['binary_100']
1769
+ assert row['varchar_200'] is None, row['varchar_200']
1770
+ assert row['varbinary_200'] is None, row['varbinary_200']
1771
+ assert row['longtext'] is None, row['longtext']
1772
+ assert row['mediumtext'] is None, row['mediumtext']
1773
+ assert row['text'] is None, row['text']
1774
+ assert row['tinytext'] is None, row['tinytext']
1775
+ assert row['longblob'] is None, row['longblob']
1776
+ assert row['mediumblob'] is None, row['mediumblob']
1777
+ assert row['blob'] is None, row['blob']
1778
+ assert row['tinyblob'] is None, row['tinyblob']
1779
+ assert row['json'] is None, row['json']
1780
+ assert row['enum'] is None, row['enum']
1781
+ assert row['set'] is None, row['set']
1782
+ assert row['bit'] is None, row['bit']
1783
+
1784
+ conn.close()
1785
+
1786
+ def test_alltypes_arrow(self):
1787
+ if self.conn.driver in ['http', 'https']:
1788
+ self.skipTest('Data API does not surface unsigned int information')
1789
+
1790
+ conn = s2.connect(database=type(self).dbname, results_type='arrow')
1791
+ cur = conn.cursor()
1792
+
1793
+ cur.execute('select * from alltypes where id = 0')
1794
+ out = cur.fetchone()
1795
+ row = out.to_pylist()[0]
1796
+
1797
+ dtypes = [
1798
+ ('id', 'int32'),
1799
+ ('tinyint', 'int8'),
1800
+ ('unsigned_tinyint', 'uint8'),
1801
+ ('bool', 'int8'),
1802
+ ('boolean', 'int8'),
1803
+ ('smallint', 'int16'),
1804
+ ('unsigned_smallint', 'uint16'),
1805
+ ('mediumint', 'int32'),
1806
+ ('unsigned_mediumint', 'uint32'),
1807
+ ('int24', 'int32'),
1808
+ ('unsigned_int24', 'uint32'),
1809
+ ('int', 'int32'),
1810
+ ('unsigned_int', 'uint32'),
1811
+ ('integer', 'int32'),
1812
+ ('unsigned_integer', 'uint32'),
1813
+ ('bigint', 'int64'),
1814
+ ('unsigned_bigint', 'uint64'),
1815
+ ('float', 'float'),
1816
+ ('double', 'double'),
1817
+ ('real', 'double'),
1818
+ ('decimal', 'decimal128(22, 6)'),
1819
+ ('dec', 'decimal128(22, 6)'),
1820
+ ('fixed', 'decimal128(22, 6)'),
1821
+ ('numeric', 'decimal128(22, 6)'),
1822
+ ('date', 'date64[ms]'),
1823
+ ('time', 'duration[us]'),
1824
+ ('time_6', 'duration[us]'),
1825
+ ('datetime', 'timestamp[us]'),
1826
+ ('datetime_6', 'timestamp[us]'),
1827
+ ('timestamp', 'timestamp[us]'),
1828
+ ('timestamp_6', 'timestamp[us]'),
1829
+ ('year', 'int16'),
1830
+ ('char_100', 'string'),
1831
+ ('binary_100', 'binary'),
1832
+ ('varchar_200', 'string'),
1833
+ ('varbinary_200', 'binary'),
1834
+ ('longtext', 'string'),
1835
+ ('mediumtext', 'string'),
1836
+ ('text', 'string'),
1837
+ ('tinytext', 'string'),
1838
+ ('longblob', 'binary'),
1839
+ ('mediumblob', 'binary'),
1840
+ ('blob', 'binary'),
1841
+ ('tinyblob', 'binary'),
1842
+ ('json', 'string'),
1843
+ ('enum', 'string'),
1844
+ ('set', 'string'),
1845
+ ('bit', 'binary'),
1846
+ ]
1847
+
1848
+ assert [(x.name, str(x.type)) for x in out.schema] == dtypes
1849
+
1850
+ bits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
1851
+
1852
+ print(row)
1853
+
1854
+ assert row['id'] == 0, row['id']
1855
+ assert row['tinyint'] == 80, row['tinyint']
1856
+ assert row['unsigned_tinyint'] == 85, row['unsigned_tinyint']
1857
+ assert row['bool'] == 0, row['bool']
1858
+ assert row['boolean'] == 1, row['boolean']
1859
+ assert row['smallint'] == -27897, row['smallint']
1860
+ assert row['unsigned_smallint'] == 27897, row['unsigned_smallint']
1861
+ assert row['mediumint'] == 104729, row['mediumint']
1862
+ assert row['unsigned_mediumint'] == 120999, row['unsigned_mediumint']
1863
+ assert row['int24'] == -200899, row['int24']
1864
+ assert row['unsigned_int24'] == 407709, row['unsigned_int24']
1865
+ assert row['int'] == -1295369311, row['int']
1866
+ assert row['unsigned_int'] == 3872362332, row['unsigned_int']
1867
+ assert row['integer'] == -1741727421, row['integer']
1868
+ assert row['unsigned_integer'] == 3198387363, row['unsigned_integer']
1869
+ assert row['bigint'] == -266883847, row['bigint']
1870
+ assert row['unsigned_bigint'] == 980007287362, row['unsigned_bigint']
1871
+ assert row['float'] - -146487000.0 < 0.00001, row['float']
1872
+ assert row['double'] == -474646154.719356, row['double']
1873
+ assert row['real'] == -901409776.279346, row['real']
1874
+ assert row['decimal'] == decimal.Decimal(
1875
+ '28111097.610822',
1876
+ ), row['decimal']
1877
+ assert row['dec'] == decimal.Decimal('389451155.931428'), row['dec']
1878
+ assert row['fixed'] == decimal.Decimal(
1879
+ '-143773416.044092',
1880
+ ), row['fixed']
1881
+ assert row['numeric'] == decimal.Decimal(
1882
+ '866689461.300046',
1883
+ ), row['numeric']
1884
+ assert row['date'] == datetime.date(8524, 11, 10), row['date']
1885
+ assert row['time'] == datetime.timedelta(minutes=7), row['time']
1886
+ assert row['datetime'] == datetime.datetime(
1887
+ 9948, 3, 11, 15, 29, 22,
1888
+ ), row['datetime']
1889
+ assert row['datetime_6'] == datetime.datetime(
1890
+ 1756, 10, 29, 2, 2, 42, 8,
1891
+ ), row['datetime_6']
1892
+ assert row['timestamp'] == datetime.datetime(
1893
+ 1980, 12, 31, 1, 10, 23,
1894
+ ), row['timestamp']
1895
+ assert row['timestamp_6'] == datetime.datetime(
1896
+ 1991, 1, 2, 22, 15, 10, 6,
1897
+ ), row['timestamp_6']
1898
+ assert row['year'] == 1923, row['year']
1899
+ assert row['char_100'] == \
1900
+ 'This is a test of a 100 character column.', row['char_100']
1901
+ assert row['binary_100'] == bytearray(
1902
+ bits + [0] * 84,
1903
+ ), row['binary_100']
1904
+ assert row['varchar_200'] == \
1905
+ 'This is a test of a variable character column.', row['varchar_200']
1906
+ assert row['varbinary_200'] == bytearray(
1907
+ bits * 2,
1908
+ ), row['varbinary_200']
1909
+ assert row['longtext'] == 'This is a longtext column.', row['longtext']
1910
+ assert row['mediumtext'] == 'This is a mediumtext column.', row['mediumtext']
1911
+ assert row['text'] == 'This is a text column.', row['text']
1912
+ assert row['tinytext'] == 'This is a tinytext column.'
1913
+ assert row['longblob'] == bytearray(bits * 3), row['longblob']
1914
+ assert row['mediumblob'] == bytearray(bits * 2), row['mediumblob']
1915
+ assert row['blob'] == bytearray(bits), row['blob']
1916
+ assert row['tinyblob'] == bytearray(
1917
+ [10, 11, 12, 13, 14, 15],
1918
+ ), row['tinyblob']
1919
+ assert row['json'] == '{"a":10,"b":2.75,"c":"hello world"}', row['json']
1920
+ assert row['enum'] == 'one', row['enum']
1921
+ assert row['set'] == 'two', row['set']
1922
+ assert row['bit'] == b'\x00\x00\x00\x00\x00\x00\x00\x80', row['bit']
1923
+
1924
+ conn.close()
532
1925
 
533
- def test_exception(self):
534
- with self.assertRaises(s2.ProgrammingError) as cm:
535
- self.cur.execute('garbage syntax')
536
- exc = cm.exception
537
- assert 'You have an error in your SQL syntax' in exc.errmsg, exc.errmsg
1926
+ def test_alltypes_no_nulls_arrow(self):
1927
+ if self.conn.driver in ['http', 'https']:
1928
+ self.skipTest('Data API does not surface unsigned int information')
1929
+
1930
+ conn = s2.connect(database=type(self).dbname, results_type='arrow')
1931
+ cur = conn.cursor()
1932
+
1933
+ cur.execute('select * from alltypes_no_nulls where id = 0')
1934
+ out = cur.fetchone()
1935
+
1936
+ row = out.to_pylist()[0]
1937
+
1938
+ dtypes = [
1939
+ ('id', 'int32'),
1940
+ ('tinyint', 'int8'),
1941
+ ('unsigned_tinyint', 'uint8'),
1942
+ ('bool', 'int8'),
1943
+ ('boolean', 'int8'),
1944
+ ('smallint', 'int16'),
1945
+ ('unsigned_smallint', 'uint16'),
1946
+ ('mediumint', 'int32'),
1947
+ ('unsigned_mediumint', 'uint32'),
1948
+ ('int24', 'int32'),
1949
+ ('unsigned_int24', 'uint32'),
1950
+ ('int', 'int32'),
1951
+ ('unsigned_int', 'uint32'),
1952
+ ('integer', 'int32'),
1953
+ ('unsigned_integer', 'uint32'),
1954
+ ('bigint', 'int64'),
1955
+ ('unsigned_bigint', 'uint64'),
1956
+ ('float', 'float'),
1957
+ ('double', 'double'),
1958
+ ('real', 'double'),
1959
+ ('decimal', 'decimal128(22, 6)'),
1960
+ ('dec', 'decimal128(22, 6)'),
1961
+ ('fixed', 'decimal128(22, 6)'),
1962
+ ('numeric', 'decimal128(22, 6)'),
1963
+ ('date', 'date64[ms]'),
1964
+ ('time', 'duration[us]'),
1965
+ ('time_6', 'duration[us]'),
1966
+ ('datetime', 'timestamp[us]'),
1967
+ ('datetime_6', 'timestamp[us]'),
1968
+ ('timestamp', 'timestamp[us]'),
1969
+ ('timestamp_6', 'timestamp[us]'),
1970
+ ('year', 'int16'),
1971
+ ('char_100', 'string'),
1972
+ ('binary_100', 'binary'),
1973
+ ('varchar_200', 'string'),
1974
+ ('varbinary_200', 'binary'),
1975
+ ('longtext', 'string'),
1976
+ ('mediumtext', 'string'),
1977
+ ('text', 'string'),
1978
+ ('tinytext', 'string'),
1979
+ ('longblob', 'binary'),
1980
+ ('mediumblob', 'binary'),
1981
+ ('blob', 'binary'),
1982
+ ('tinyblob', 'binary'),
1983
+ ('json', 'string'),
1984
+ ('enum', 'string'),
1985
+ ('set', 'string'),
1986
+ ('bit', 'binary'),
1987
+ ]
538
1988
 
539
- def test_alltypes(self):
540
- self.cur.execute('select * from alltypes where id = 0')
541
- names = [x[0] for x in self.cur.description]
542
- types = [x[1] for x in self.cur.description]
543
- out = self.cur.fetchone()
544
- row = dict(zip(names, out))
545
- typ = dict(zip(names, types))
1989
+ assert [(x.name, str(x.type)) for x in out.schema] == dtypes
546
1990
 
547
1991
  bits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
548
1992
 
549
- def otype(x):
550
- return x
551
-
552
1993
  assert row['id'] == 0, row['id']
553
- assert typ['id'] == otype(3), typ['id']
554
-
555
1994
  assert row['tinyint'] == 80, row['tinyint']
556
- assert typ['tinyint'] == otype(1), typ['tinyint']
557
-
558
1995
  assert row['unsigned_tinyint'] == 85, row['unsigned_tinyint']
559
- assert typ['unsigned_tinyint'] == otype(1), typ['unsigned_tinyint']
560
-
561
1996
  assert row['bool'] == 0, row['bool']
562
- assert typ['bool'] == otype(1), typ['bool']
563
-
564
1997
  assert row['boolean'] == 1, row['boolean']
565
- assert typ['boolean'] == otype(1), typ['boolean']
566
-
567
1998
  assert row['smallint'] == -27897, row['smallint']
568
- assert typ['smallint'] == otype(2), typ['smallint']
569
-
570
1999
  assert row['unsigned_smallint'] == 27897, row['unsigned_smallint']
571
- assert typ['unsigned_smallint'] == otype(2), typ['unsigned_smallint']
572
-
573
2000
  assert row['mediumint'] == 104729, row['mediumint']
574
- assert typ['mediumint'] == otype(9), typ['mediumint']
575
-
576
2001
  assert row['unsigned_mediumint'] == 120999, row['unsigned_mediumint']
577
- assert typ['unsigned_mediumint'] == otype(9), typ['unsigned_mediumint']
578
-
579
2002
  assert row['int24'] == -200899, row['int24']
580
- assert typ['int24'] == otype(9), typ['int24']
581
-
582
2003
  assert row['unsigned_int24'] == 407709, row['unsigned_int24']
583
- assert typ['unsigned_int24'] == otype(9), typ['unsigned_int24']
584
-
585
2004
  assert row['int'] == -1295369311, row['int']
586
- assert typ['int'] == otype(3), typ['int']
587
-
588
2005
  assert row['unsigned_int'] == 3872362332, row['unsigned_int']
589
- assert typ['unsigned_int'] == otype(3), typ['unsigned_int']
590
-
591
2006
  assert row['integer'] == -1741727421, row['integer']
592
- assert typ['integer'] == otype(3), typ['integer']
593
-
594
2007
  assert row['unsigned_integer'] == 3198387363, row['unsigned_integer']
595
- assert typ['unsigned_integer'] == otype(3), typ['unsigned_integer']
596
-
597
2008
  assert row['bigint'] == -266883847, row['bigint']
598
- assert typ['bigint'] == otype(8), typ['bigint']
599
-
600
2009
  assert row['unsigned_bigint'] == 980007287362, row['unsigned_bigint']
601
- assert typ['unsigned_bigint'] == otype(8), typ['unsigned_bigint']
602
-
603
- assert row['float'] == -146487000.0, row['float']
604
- assert typ['float'] == otype(4), typ['float']
605
-
2010
+ assert row['float'] - -146487000.0 < 0.00001, row['float']
606
2011
  assert row['double'] == -474646154.719356, row['double']
607
- assert typ['double'] == otype(5), typ['double']
608
-
609
2012
  assert row['real'] == -901409776.279346, row['real']
610
- assert typ['real'] == otype(5), typ['real']
611
-
612
2013
  assert row['decimal'] == decimal.Decimal(
613
2014
  '28111097.610822',
614
2015
  ), row['decimal']
615
- assert typ['decimal'] == otype(246), typ['decimal']
616
-
617
2016
  assert row['dec'] == decimal.Decimal('389451155.931428'), row['dec']
618
- assert typ['dec'] == otype(246), typ['dec']
619
-
620
2017
  assert row['fixed'] == decimal.Decimal(
621
2018
  '-143773416.044092',
622
2019
  ), row['fixed']
623
- assert typ['fixed'] == otype(246), typ['fixed']
624
-
625
2020
  assert row['numeric'] == decimal.Decimal(
626
2021
  '866689461.300046',
627
2022
  ), row['numeric']
628
- assert typ['numeric'] == otype(246), typ['numeric']
629
-
630
2023
  assert row['date'] == datetime.date(8524, 11, 10), row['date']
631
- assert typ['date'] == 10, typ['date']
632
-
633
2024
  assert row['time'] == datetime.timedelta(minutes=7), row['time']
634
- assert typ['time'] == 11, typ['time']
635
-
636
- assert typ['time_6'] == 11, typ['time_6']
637
-
638
2025
  assert row['datetime'] == datetime.datetime(
639
2026
  9948, 3, 11, 15, 29, 22,
640
2027
  ), row['datetime']
641
- assert typ['datetime'] == 12, typ['datetime']
642
-
643
2028
  assert row['datetime_6'] == datetime.datetime(
644
2029
  1756, 10, 29, 2, 2, 42, 8,
645
2030
  ), row['datetime_6']
646
- assert typ['datetime_6'] == 12, typ['datetime_6']
647
-
648
2031
  assert row['timestamp'] == datetime.datetime(
649
2032
  1980, 12, 31, 1, 10, 23,
650
2033
  ), row['timestamp']
651
- assert typ['timestamp'] == otype(7), typ['timestamp']
652
-
653
2034
  assert row['timestamp_6'] == datetime.datetime(
654
2035
  1991, 1, 2, 22, 15, 10, 6,
655
2036
  ), row['timestamp_6']
656
- assert typ['timestamp_6'] == otype(7), typ['timestamp_6']
657
-
658
2037
  assert row['year'] == 1923, row['year']
659
- assert typ['year'] == otype(13), typ['year']
660
-
661
2038
  assert row['char_100'] == \
662
2039
  'This is a test of a 100 character column.', row['char_100']
663
- assert typ['char_100'] == otype(254), typ['char_100']
664
-
665
2040
  assert row['binary_100'] == bytearray(
666
2041
  bits + [0] * 84,
667
2042
  ), row['binary_100']
668
- assert typ['binary_100'] == otype(254), typ['binary_100']
669
-
670
2043
  assert row['varchar_200'] == \
671
2044
  'This is a test of a variable character column.', row['varchar_200']
672
- assert typ['varchar_200'] == otype(
673
- 253,
674
- ), typ['varchar_200'] # why not 15?
675
-
676
2045
  assert row['varbinary_200'] == bytearray(
677
2046
  bits * 2,
678
2047
  ), row['varbinary_200']
679
- assert typ['varbinary_200'] == otype(
680
- 253,
681
- ), typ['varbinary_200'] # why not 15?
682
-
683
2048
  assert row['longtext'] == 'This is a longtext column.', row['longtext']
684
- assert typ['longtext'] == otype(251), typ['longtext']
685
-
686
2049
  assert row['mediumtext'] == 'This is a mediumtext column.', row['mediumtext']
687
- assert typ['mediumtext'] == otype(250), typ['mediumtext']
688
-
689
2050
  assert row['text'] == 'This is a text column.', row['text']
690
- assert typ['text'] == otype(252), typ['text']
691
-
692
2051
  assert row['tinytext'] == 'This is a tinytext column.'
693
- assert typ['tinytext'] == otype(249), typ['tinytext']
694
-
695
2052
  assert row['longblob'] == bytearray(bits * 3), row['longblob']
696
- assert typ['longblob'] == otype(251), typ['longblob']
697
-
698
2053
  assert row['mediumblob'] == bytearray(bits * 2), row['mediumblob']
699
- assert typ['mediumblob'] == otype(250), typ['mediumblob']
700
-
701
2054
  assert row['blob'] == bytearray(bits), row['blob']
702
- assert typ['blob'] == otype(252), typ['blob']
703
-
704
2055
  assert row['tinyblob'] == bytearray(
705
2056
  [10, 11, 12, 13, 14, 15],
706
2057
  ), row['tinyblob']
707
- assert typ['tinyblob'] == otype(249), typ['tinyblob']
2058
+ assert row['json'] == '{"a":10,"b":2.75,"c":"hello world"}', row['json']
2059
+ assert row['enum'] == 'one', row['enum']
2060
+ assert row['set'] == 'two', row['set']
2061
+ assert row['bit'] == b'\x00\x00\x00\x00\x00\x00\x00\x80', row['bit']
708
2062
 
709
- assert row['json'] == {
710
- 'a': 10, 'b': 2.75,
711
- 'c': 'hello world',
712
- }, row['json']
713
- assert typ['json'] == otype(245), typ['json']
2063
+ conn.close()
714
2064
 
715
- assert row['enum'] == 'one', row['enum']
716
- assert typ['enum'] == otype(253), typ['enum'] # mysql code: 247
2065
+ def test_alltypes_min_max_arrow(self):
2066
+ if self.conn.driver in ['http', 'https']:
2067
+ self.skipTest('Data API does not surface unsigned int information')
717
2068
 
718
- assert row['set'] == 'two', row['set']
719
- assert typ['set'] == otype(253), typ['set'] # mysql code: 248
2069
+ conn = s2.connect(database=type(self).dbname, results_type='arrow')
2070
+ cur = conn.cursor()
720
2071
 
721
- assert row['bit'] == b'\x00\x00\x00\x00\x00\x00\x00\x80', row['bit']
722
- assert typ['bit'] == otype(16), typ['bit']
2072
+ cur.execute('select * from alltypes_no_nulls')
2073
+ cur.fetchall()
2074
+
2075
+ cur.execute('select * from alltypes')
2076
+ cur.fetchall()
2077
+
2078
+ conn.close()
2079
+
2080
+ def test_alltypes_nulls_arrow(self):
2081
+ conn = s2.connect(database=type(self).dbname, results_type='arrow')
2082
+ cur = conn.cursor()
2083
+
2084
+ cur.execute('select * from alltypes where id = 1')
2085
+ out = cur.fetchone()
2086
+ row = out.to_pylist()[0]
2087
+
2088
+ assert row['id'] == 1, row['id']
2089
+ assert row['tinyint'] is None, row['tinyint']
2090
+ assert row['bool'] is None, row['bool']
2091
+ assert row['boolean'] is None, row['boolean']
2092
+ assert row['smallint'] is None, row['smallint']
2093
+ assert row['mediumint'] is None, row['mediumint']
2094
+ assert row['int24'] is None, row['int24']
2095
+ assert row['int'] is None, row['int']
2096
+ assert row['integer'] is None, row['integer']
2097
+ assert row['bigint'] is None, row['bigint']
2098
+ assert row['float'] is None, row['float']
2099
+ assert row['double'] is None, row['double']
2100
+ assert row['real'] is None, row['real']
2101
+ assert row['decimal'] is None, row['decimal']
2102
+ assert row['dec'] is None, row['dec']
2103
+ assert row['fixed'] is None, row['fixed']
2104
+ assert row['numeric'] is None, row['numeric']
2105
+ assert row['date'] is None, row['date']
2106
+ assert row['time'] is None, row['time']
2107
+ assert row['time'] is None, row['time']
2108
+ assert row['datetime'] is None, row['datetime']
2109
+ assert row['datetime_6'] is None, row['datetime_6']
2110
+ assert row['timestamp'] is None, row['timestamp']
2111
+ assert row['timestamp_6'] is None, row['timestamp_6']
2112
+ assert row['year'] is None, row['year']
2113
+ assert row['char_100'] is None, row['char_100']
2114
+ assert row['binary_100'] is None, row['binary_100']
2115
+ assert row['varchar_200'] is None, row['varchar_200']
2116
+ assert row['varbinary_200'] is None, row['varbinary_200']
2117
+ assert row['longtext'] is None, row['longtext']
2118
+ assert row['mediumtext'] is None, row['mediumtext']
2119
+ assert row['text'] is None, row['text']
2120
+ assert row['tinytext'] is None, row['tinytext']
2121
+ assert row['longblob'] is None, row['longblob']
2122
+ assert row['mediumblob'] is None, row['mediumblob']
2123
+ assert row['blob'] is None, row['blob']
2124
+ assert row['tinyblob'] is None, row['tinyblob']
2125
+ assert row['json'] is None, row['json']
2126
+ assert row['enum'] is None, row['enum']
2127
+ assert row['set'] is None, row['set']
2128
+ assert row['bit'] is None, row['bit']
2129
+
2130
+ conn.close()
723
2131
 
724
2132
  def test_alltypes_nulls(self):
725
2133
  self.cur.execute('select * from alltypes where id = 1')
@@ -1468,6 +2876,180 @@ class TestConnection(unittest.TestCase):
1468
2876
 
1469
2877
  # out = self.conn.show.create_view('vname')
1470
2878
 
2879
+ def test_f32_vectors(self):
2880
+ if self.conn.driver in ['http', 'https']:
2881
+ self.skipTest('Data API does not surface vector information')
2882
+
2883
+ self.cur.execute('show variables like "enable_extended_types_metadata"')
2884
+ out = list(self.cur)
2885
+ if not out or out[0][1].lower() == 'off':
2886
+ self.skipTest('Database engine does not support extended types metadata')
2887
+
2888
+ self.cur.execute('select a from f32_vectors order by id')
2889
+ out = list(self.cur)
2890
+
2891
+ assert out[0][0].dtype is np.dtype('float32')
2892
+ assert out[1][0].dtype is np.dtype('float32')
2893
+ assert out[2][0].dtype is np.dtype('float32')
2894
+
2895
+ np.testing.assert_array_equal(
2896
+ out[0][0],
2897
+ np.array([0.267261237, 0.534522474, 0.801783681], dtype=np.float32),
2898
+ )
2899
+ np.testing.assert_array_equal(
2900
+ out[1][0],
2901
+ np.array([0.371390671, 0.557085991, 0.742781341], dtype=np.float32),
2902
+ )
2903
+ np.testing.assert_array_equal(
2904
+ out[2][0],
2905
+ np.array([-0.424264073, -0.565685451, 0.707106829], dtype=np.float32),
2906
+ )
2907
+
2908
+ def test_f64_vectors(self):
2909
+ if self.conn.driver in ['http', 'https']:
2910
+ self.skipTest('Data API does not surface vector information')
2911
+
2912
+ self.cur.execute('show variables like "enable_extended_types_metadata"')
2913
+ out = list(self.cur)
2914
+ if not out or out[0][1].lower() == 'off':
2915
+ self.skipTest('Database engine does not support extended types metadata')
2916
+
2917
+ self.cur.execute('select a from f64_vectors order by id')
2918
+ out = list(self.cur)
2919
+
2920
+ assert out[0][0].dtype is np.dtype('float64')
2921
+ assert out[1][0].dtype is np.dtype('float64')
2922
+ assert out[2][0].dtype is np.dtype('float64')
2923
+
2924
+ np.testing.assert_array_equal(
2925
+ out[0][0],
2926
+ np.array([0.267261237, 0.534522474, 0.801783681], dtype=np.float64),
2927
+ )
2928
+ np.testing.assert_array_equal(
2929
+ out[1][0],
2930
+ np.array([0.371390671, 0.557085991, 0.742781341], dtype=np.float64),
2931
+ )
2932
+ np.testing.assert_array_equal(
2933
+ out[2][0],
2934
+ np.array([-0.424264073, -0.565685451, 0.707106829], dtype=np.float64),
2935
+ )
2936
+
2937
+ def test_i8_vectors(self):
2938
+ if self.conn.driver in ['http', 'https']:
2939
+ self.skipTest('Data API does not surface vector information')
2940
+
2941
+ self.cur.execute('show variables like "enable_extended_types_metadata"')
2942
+ out = list(self.cur)
2943
+ if not out or out[0][1].lower() == 'off':
2944
+ self.skipTest('Database engine does not support extended types metadata')
2945
+
2946
+ self.cur.execute('select a from i8_vectors order by id')
2947
+ out = list(self.cur)
2948
+
2949
+ assert out[0][0].dtype is np.dtype('int8')
2950
+ assert out[1][0].dtype is np.dtype('int8')
2951
+ assert out[2][0].dtype is np.dtype('int8')
2952
+
2953
+ np.testing.assert_array_equal(
2954
+ out[0][0],
2955
+ np.array([1, 2, 3], dtype=np.int8),
2956
+ )
2957
+ np.testing.assert_array_equal(
2958
+ out[1][0],
2959
+ np.array([4, 5, 6], dtype=np.int8),
2960
+ )
2961
+ np.testing.assert_array_equal(
2962
+ out[2][0],
2963
+ np.array([-1, -4, 8], dtype=np.int8),
2964
+ )
2965
+
2966
+ def test_i16_vectors(self):
2967
+ if self.conn.driver in ['http', 'https']:
2968
+ self.skipTest('Data API does not surface vector information')
2969
+
2970
+ self.cur.execute('show variables like "enable_extended_types_metadata"')
2971
+ out = list(self.cur)
2972
+ if not out or out[0][1].lower() == 'off':
2973
+ self.skipTest('Database engine does not support extended types metadata')
2974
+
2975
+ self.cur.execute('select a from i16_vectors order by id')
2976
+ out = list(self.cur)
2977
+
2978
+ assert out[0][0].dtype is np.dtype('int16')
2979
+ assert out[1][0].dtype is np.dtype('int16')
2980
+ assert out[2][0].dtype is np.dtype('int16')
2981
+
2982
+ np.testing.assert_array_equal(
2983
+ out[0][0],
2984
+ np.array([1, 2, 3], dtype=np.int16),
2985
+ )
2986
+ np.testing.assert_array_equal(
2987
+ out[1][0],
2988
+ np.array([4, 5, 6], dtype=np.int16),
2989
+ )
2990
+ np.testing.assert_array_equal(
2991
+ out[2][0],
2992
+ np.array([-1, -4, 8], dtype=np.int16),
2993
+ )
2994
+
2995
+ def test_i32_vectors(self):
2996
+ if self.conn.driver in ['http', 'https']:
2997
+ self.skipTest('Data API does not surface vector information')
2998
+
2999
+ self.cur.execute('show variables like "enable_extended_types_metadata"')
3000
+ out = list(self.cur)
3001
+ if not out or out[0][1].lower() == 'off':
3002
+ self.skipTest('Database engine does not support extended types metadata')
3003
+
3004
+ self.cur.execute('select a from i32_vectors order by id')
3005
+ out = list(self.cur)
3006
+
3007
+ assert out[0][0].dtype is np.dtype('int32')
3008
+ assert out[1][0].dtype is np.dtype('int32')
3009
+ assert out[2][0].dtype is np.dtype('int32')
3010
+
3011
+ np.testing.assert_array_equal(
3012
+ out[0][0],
3013
+ np.array([1, 2, 3], dtype=np.int32),
3014
+ )
3015
+ np.testing.assert_array_equal(
3016
+ out[1][0],
3017
+ np.array([4, 5, 6], dtype=np.int32),
3018
+ )
3019
+ np.testing.assert_array_equal(
3020
+ out[2][0],
3021
+ np.array([-1, -4, 8], dtype=np.int32),
3022
+ )
3023
+
3024
+ def test_i64_vectors(self):
3025
+ if self.conn.driver in ['http', 'https']:
3026
+ self.skipTest('Data API does not surface vector information')
3027
+
3028
+ self.cur.execute('show variables like "enable_extended_types_metadata"')
3029
+ out = list(self.cur)
3030
+ if not out or out[0][1].lower() == 'off':
3031
+ self.skipTest('Database engine does not support extended types metadata')
3032
+
3033
+ self.cur.execute('select a from i64_vectors order by id')
3034
+ out = list(self.cur)
3035
+
3036
+ assert out[0][0].dtype is np.dtype('int64')
3037
+ assert out[1][0].dtype is np.dtype('int64')
3038
+ assert out[2][0].dtype is np.dtype('int64')
3039
+
3040
+ np.testing.assert_array_equal(
3041
+ out[0][0],
3042
+ np.array([1, 2, 3], dtype=np.int64),
3043
+ )
3044
+ np.testing.assert_array_equal(
3045
+ out[1][0],
3046
+ np.array([4, 5, 6], dtype=np.int64),
3047
+ )
3048
+ np.testing.assert_array_equal(
3049
+ out[2][0],
3050
+ np.array([-1, -4, 8], dtype=np.int64),
3051
+ )
3052
+
1471
3053
 
1472
3054
  if __name__ == '__main__':
1473
3055
  import nose2