singlestoredb 1.0.3__cp38-abi3-win_amd64.whl → 1.1.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.
- _singlestoredb_accel.pyd +0 -0
- singlestoredb/__init__.py +1 -1
- singlestoredb/config.py +125 -0
- singlestoredb/functions/dtypes.py +5 -198
- singlestoredb/functions/ext/__init__.py +0 -1
- singlestoredb/functions/ext/asgi.py +665 -153
- singlestoredb/functions/ext/json.py +2 -2
- singlestoredb/functions/ext/mmap.py +174 -67
- singlestoredb/functions/ext/rowdat_1.py +2 -2
- singlestoredb/functions/ext/utils.py +169 -0
- singlestoredb/fusion/handler.py +109 -9
- singlestoredb/fusion/handlers/stage.py +150 -0
- singlestoredb/fusion/handlers/workspace.py +265 -4
- singlestoredb/fusion/registry.py +69 -1
- singlestoredb/http/connection.py +40 -2
- singlestoredb/management/utils.py +30 -0
- singlestoredb/management/workspace.py +209 -35
- singlestoredb/mysql/connection.py +69 -0
- singlestoredb/mysql/cursors.py +176 -4
- singlestoredb/tests/test.sql +210 -0
- singlestoredb/tests/test_connection.py +1408 -0
- singlestoredb/tests/test_ext_func.py +2 -2
- singlestoredb/tests/test_ext_func_data.py +1 -1
- singlestoredb/utils/dtypes.py +205 -0
- singlestoredb/utils/results.py +367 -14
- {singlestoredb-1.0.3.dist-info → singlestoredb-1.1.0.dist-info}/METADATA +2 -1
- {singlestoredb-1.0.3.dist-info → singlestoredb-1.1.0.dist-info}/RECORD +31 -29
- {singlestoredb-1.0.3.dist-info → singlestoredb-1.1.0.dist-info}/LICENSE +0 -0
- {singlestoredb-1.0.3.dist-info → singlestoredb-1.1.0.dist-info}/WHEEL +0 -0
- {singlestoredb-1.0.3.dist-info → singlestoredb-1.1.0.dist-info}/entry_points.txt +0 -0
- {singlestoredb-1.0.3.dist-info → singlestoredb-1.1.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
|
|
|
@@ -721,6 +733,1402 @@ class TestConnection(unittest.TestCase):
|
|
|
721
733
|
assert row['bit'] == b'\x00\x00\x00\x00\x00\x00\x00\x80', row['bit']
|
|
722
734
|
assert typ['bit'] == otype(16), typ['bit']
|
|
723
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()
|
|
1925
|
+
|
|
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
|
+
]
|
|
1988
|
+
|
|
1989
|
+
assert [(x.name, str(x.type)) for x in out.schema] == dtypes
|
|
1990
|
+
|
|
1991
|
+
bits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
|
|
1992
|
+
|
|
1993
|
+
assert row['id'] == 0, row['id']
|
|
1994
|
+
assert row['tinyint'] == 80, row['tinyint']
|
|
1995
|
+
assert row['unsigned_tinyint'] == 85, row['unsigned_tinyint']
|
|
1996
|
+
assert row['bool'] == 0, row['bool']
|
|
1997
|
+
assert row['boolean'] == 1, row['boolean']
|
|
1998
|
+
assert row['smallint'] == -27897, row['smallint']
|
|
1999
|
+
assert row['unsigned_smallint'] == 27897, row['unsigned_smallint']
|
|
2000
|
+
assert row['mediumint'] == 104729, row['mediumint']
|
|
2001
|
+
assert row['unsigned_mediumint'] == 120999, row['unsigned_mediumint']
|
|
2002
|
+
assert row['int24'] == -200899, row['int24']
|
|
2003
|
+
assert row['unsigned_int24'] == 407709, row['unsigned_int24']
|
|
2004
|
+
assert row['int'] == -1295369311, row['int']
|
|
2005
|
+
assert row['unsigned_int'] == 3872362332, row['unsigned_int']
|
|
2006
|
+
assert row['integer'] == -1741727421, row['integer']
|
|
2007
|
+
assert row['unsigned_integer'] == 3198387363, row['unsigned_integer']
|
|
2008
|
+
assert row['bigint'] == -266883847, row['bigint']
|
|
2009
|
+
assert row['unsigned_bigint'] == 980007287362, row['unsigned_bigint']
|
|
2010
|
+
assert row['float'] - -146487000.0 < 0.00001, row['float']
|
|
2011
|
+
assert row['double'] == -474646154.719356, row['double']
|
|
2012
|
+
assert row['real'] == -901409776.279346, row['real']
|
|
2013
|
+
assert row['decimal'] == decimal.Decimal(
|
|
2014
|
+
'28111097.610822',
|
|
2015
|
+
), row['decimal']
|
|
2016
|
+
assert row['dec'] == decimal.Decimal('389451155.931428'), row['dec']
|
|
2017
|
+
assert row['fixed'] == decimal.Decimal(
|
|
2018
|
+
'-143773416.044092',
|
|
2019
|
+
), row['fixed']
|
|
2020
|
+
assert row['numeric'] == decimal.Decimal(
|
|
2021
|
+
'866689461.300046',
|
|
2022
|
+
), row['numeric']
|
|
2023
|
+
assert row['date'] == datetime.date(8524, 11, 10), row['date']
|
|
2024
|
+
assert row['time'] == datetime.timedelta(minutes=7), row['time']
|
|
2025
|
+
assert row['datetime'] == datetime.datetime(
|
|
2026
|
+
9948, 3, 11, 15, 29, 22,
|
|
2027
|
+
), row['datetime']
|
|
2028
|
+
assert row['datetime_6'] == datetime.datetime(
|
|
2029
|
+
1756, 10, 29, 2, 2, 42, 8,
|
|
2030
|
+
), row['datetime_6']
|
|
2031
|
+
assert row['timestamp'] == datetime.datetime(
|
|
2032
|
+
1980, 12, 31, 1, 10, 23,
|
|
2033
|
+
), row['timestamp']
|
|
2034
|
+
assert row['timestamp_6'] == datetime.datetime(
|
|
2035
|
+
1991, 1, 2, 22, 15, 10, 6,
|
|
2036
|
+
), row['timestamp_6']
|
|
2037
|
+
assert row['year'] == 1923, row['year']
|
|
2038
|
+
assert row['char_100'] == \
|
|
2039
|
+
'This is a test of a 100 character column.', row['char_100']
|
|
2040
|
+
assert row['binary_100'] == bytearray(
|
|
2041
|
+
bits + [0] * 84,
|
|
2042
|
+
), row['binary_100']
|
|
2043
|
+
assert row['varchar_200'] == \
|
|
2044
|
+
'This is a test of a variable character column.', row['varchar_200']
|
|
2045
|
+
assert row['varbinary_200'] == bytearray(
|
|
2046
|
+
bits * 2,
|
|
2047
|
+
), row['varbinary_200']
|
|
2048
|
+
assert row['longtext'] == 'This is a longtext column.', row['longtext']
|
|
2049
|
+
assert row['mediumtext'] == 'This is a mediumtext column.', row['mediumtext']
|
|
2050
|
+
assert row['text'] == 'This is a text column.', row['text']
|
|
2051
|
+
assert row['tinytext'] == 'This is a tinytext column.'
|
|
2052
|
+
assert row['longblob'] == bytearray(bits * 3), row['longblob']
|
|
2053
|
+
assert row['mediumblob'] == bytearray(bits * 2), row['mediumblob']
|
|
2054
|
+
assert row['blob'] == bytearray(bits), row['blob']
|
|
2055
|
+
assert row['tinyblob'] == bytearray(
|
|
2056
|
+
[10, 11, 12, 13, 14, 15],
|
|
2057
|
+
), row['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']
|
|
2062
|
+
|
|
2063
|
+
conn.close()
|
|
2064
|
+
|
|
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')
|
|
2068
|
+
|
|
2069
|
+
conn = s2.connect(database=type(self).dbname, results_type='arrow')
|
|
2070
|
+
cur = conn.cursor()
|
|
2071
|
+
|
|
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()
|
|
2131
|
+
|
|
724
2132
|
def test_alltypes_nulls(self):
|
|
725
2133
|
self.cur.execute('select * from alltypes where id = 1')
|
|
726
2134
|
names = [x[0] for x in self.cur.description]
|