@@ -56,6 +56,11 @@ def _get_text_type(conn):
5656 return "STRING"
5757 return "varchar(100)"
5858
59+ def _get_float_type (conn ):
60+ if isinstance (conn , db .BigQuery ):
61+ return "FLOAT64"
62+ return "float"
63+
5964
6065class TestUtils (unittest .TestCase ):
6166 def test_split_space (self ):
@@ -207,11 +212,13 @@ class TestDiffTables(TestPerDatabase):
207212 def setUp (self ):
208213 super ().setUp ()
209214
215+ float_type = _get_float_type (self .connection )
216+
210217 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
212219 )
213220 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
215222 )
216223 # self.preql(
217224 # f"""
@@ -374,8 +381,10 @@ class TestUUIDs(TestPerDatabase):
374381 def setUp (self ):
375382 super ().setUp ()
376383
384+ text_type = _get_text_type (self .connection )
385+
377386 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 } )" ,
379388 ]
380389 for i in range (100 ):
381390 queries .append (f"INSERT INTO { self .table_src } VALUES ('{ uuid .uuid1 (i )} ', '{ i } ')" )
@@ -414,8 +423,10 @@ class TestAlphanumericKeys(TestPerDatabase):
414423 def setUp (self ):
415424 super ().setUp ()
416425
426+ text_type = _get_text_type (self .connection )
427+
417428 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 } )" ,
419430 ]
420431 for i in range (0 , 10000 , 1000 ):
421432 queries .append (f"INSERT INTO { self .table_src } VALUES ('{ ArithAlphanumeric (int = i , max_len = 10 )} ', '{ i } ')" )
@@ -480,8 +491,10 @@ class TestTableUUID(TestPerDatabase):
480491 def setUp (self ):
481492 super ().setUp ()
482493
494+ text_type = _get_text_type (self .connection )
495+
483496 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 } )" ,
485498 ]
486499 for i in range (10 ):
487500 uuid_value = uuid .uuid1 (i )
@@ -512,9 +525,11 @@ class TestTableNullRowChecksum(TestPerDatabase):
512525 def setUp (self ):
513526 super ().setUp ()
514527
528+ text_type = _get_text_type (self .connection )
529+
515530 self .null_uuid = uuid .uuid1 (1 )
516531 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 } )" ,
518533 f"INSERT INTO { self .table_src } VALUES ('{ uuid .uuid1 (1 )} ', '1')" ,
519534 f"CREATE TABLE { self .table_dst } AS SELECT * FROM { self .table_src } " ,
520535 # Add a row where a column has NULL value
@@ -624,10 +639,12 @@ class TestTableTableEmpty(TestPerDatabase):
624639 def setUp (self ):
625640 super ().setUp ()
626641
642+ text_type = _get_text_type (self .connection )
643+
627644 self .null_uuid = uuid .uuid1 (1 )
628645 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 } )" ,
631648 ]
632649
633650 self .diffs = [(uuid .uuid1 (i ), i ) for i in range (100 )]
0 commit comments