@@ -56,6 +56,11 @@ def _get_text_type(conn):
56
56
return "STRING"
57
57
return "varchar(100)"
58
58
59
+ def _get_float_type (conn ):
60
+ if isinstance (conn , db .BigQuery ):
61
+ return "FLOAT64"
62
+ return "float"
63
+
59
64
60
65
class TestUtils (unittest .TestCase ):
61
66
def test_split_space (self ):
@@ -207,11 +212,13 @@ class TestDiffTables(TestPerDatabase):
207
212
def setUp (self ):
208
213
super ().setUp ()
209
214
215
+ float_type = _get_float_type (self .connection )
216
+
210
217
self .connection .query (
211
- f"create table { self .table_src } (id int, userid int, movieid int, rating float , timestamp timestamp)" , None
218
+ f"create table { self .table_src } (id int, userid int, movieid int, rating { float_type } , timestamp timestamp)" , None
212
219
)
213
220
self .connection .query (
214
- f"create table { self .table_dst } (id int, userid int, movieid int, rating float , timestamp timestamp)" , None
221
+ f"create table { self .table_dst } (id int, userid int, movieid int, rating { float_type } , timestamp timestamp)" , None
215
222
)
216
223
# self.preql(
217
224
# f"""
@@ -374,8 +381,10 @@ class TestUUIDs(TestPerDatabase):
374
381
def setUp (self ):
375
382
super ().setUp ()
376
383
384
+ text_type = _get_text_type (self .connection )
385
+
377
386
queries = [
378
- f"CREATE TABLE { self .table_src } (id varchar(100) , text_comment varchar(1000) )" ,
387
+ f"CREATE TABLE { self .table_src } (id { text_type } , text_comment { text_type } )" ,
379
388
]
380
389
for i in range (100 ):
381
390
queries .append (f"INSERT INTO { self .table_src } VALUES ('{ uuid .uuid1 (i )} ', '{ i } ')" )
@@ -414,8 +423,10 @@ class TestAlphanumericKeys(TestPerDatabase):
414
423
def setUp (self ):
415
424
super ().setUp ()
416
425
426
+ text_type = _get_text_type (self .connection )
427
+
417
428
queries = [
418
- f"CREATE TABLE { self .table_src } (id varchar(100) , text_comment varchar(1000) )" ,
429
+ f"CREATE TABLE { self .table_src } (id { text_type } , text_comment { text_type } )" ,
419
430
]
420
431
for i in range (0 , 10000 , 1000 ):
421
432
queries .append (f"INSERT INTO { self .table_src } VALUES ('{ ArithAlphanumeric (int = i , max_len = 10 )} ', '{ i } ')" )
@@ -480,8 +491,10 @@ class TestTableUUID(TestPerDatabase):
480
491
def setUp (self ):
481
492
super ().setUp ()
482
493
494
+ text_type = _get_text_type (self .connection )
495
+
483
496
queries = [
484
- f"CREATE TABLE { self .table_src } (id varchar(100) , text_comment varchar(1000) )" ,
497
+ f"CREATE TABLE { self .table_src } (id { text_type } , text_comment { text_type } )" ,
485
498
]
486
499
for i in range (10 ):
487
500
uuid_value = uuid .uuid1 (i )
@@ -512,9 +525,11 @@ class TestTableNullRowChecksum(TestPerDatabase):
512
525
def setUp (self ):
513
526
super ().setUp ()
514
527
528
+ text_type = _get_text_type (self .connection )
529
+
515
530
self .null_uuid = uuid .uuid1 (1 )
516
531
queries = [
517
- f"CREATE TABLE { self .table_src } (id varchar(100) , text_comment varchar(1000) )" ,
532
+ f"CREATE TABLE { self .table_src } (id { text_type } , text_comment { text_type } )" ,
518
533
f"INSERT INTO { self .table_src } VALUES ('{ uuid .uuid1 (1 )} ', '1')" ,
519
534
f"CREATE TABLE { self .table_dst } AS SELECT * FROM { self .table_src } " ,
520
535
# Add a row where a column has NULL value
@@ -624,10 +639,12 @@ class TestTableTableEmpty(TestPerDatabase):
624
639
def setUp (self ):
625
640
super ().setUp ()
626
641
642
+ text_type = _get_text_type (self .connection )
643
+
627
644
self .null_uuid = uuid .uuid1 (1 )
628
645
queries = [
629
- f"CREATE TABLE { self .table_src } (id varchar(100) , text_comment varchar(1000) )" ,
630
- f"CREATE TABLE { self .table_dst } (id varchar(100) , text_comment varchar(1000) )" ,
646
+ f"CREATE TABLE { self .table_src } (id { text_type } , text_comment { text_type } )" ,
647
+ f"CREATE TABLE { self .table_dst } (id { text_type } , text_comment { text_type } )" ,
631
648
]
632
649
633
650
self .diffs = [(uuid .uuid1 (i ), i ) for i in range (100 )]
0 commit comments