@@ -460,3 +460,69 @@ def test_to_sql_cast(parameters, db_type):
460460 )
461461 df2 = wr .db .read_sql_query (sql = f"SELECT * FROM { schema } .{ table } " , con = engine )
462462 assert df .equals (df2 )
463+
464+
465+ def test_uuid (parameters ):
466+ table = "test_uuid"
467+ schema = parameters ["postgresql" ]["schema" ]
468+ engine = wr .catalog .get_engine (connection = f"aws-data-wrangler-postgresql" )
469+ df = pd .DataFrame (
470+ {
471+ "id" : [1 , 2 , 3 ],
472+ "uuid" : [
473+ "ec0f0482-8d3b-11ea-8b27-8c859043dd95" ,
474+ "f56ff7c0-8d3b-11ea-be94-8c859043dd95" ,
475+ "fa043e90-8d3b-11ea-b7e7-8c859043dd95" ,
476+ ],
477+ }
478+ )
479+ wr .db .to_sql (
480+ df = df ,
481+ con = engine ,
482+ name = table ,
483+ schema = schema ,
484+ if_exists = "replace" ,
485+ index = False ,
486+ index_label = None ,
487+ chunksize = None ,
488+ method = None ,
489+ dtype = {"uuid" : sqlalchemy .dialects .postgresql .UUID },
490+ )
491+ df2 = wr .db .read_sql_table (table = table , schema = schema , con = engine )
492+ df ["id" ] = df ["id" ].astype ("Int64" )
493+ df ["uuid" ] = df ["uuid" ].astype ("string" )
494+ assert df .equals (df2 )
495+
496+
497+ @pytest .mark .parametrize ("db_type" , ["mysql" , "redshift" , "postgresql" ])
498+ def test_null (parameters , db_type ):
499+ table = "test_null"
500+ schema = parameters [db_type ]["schema" ]
501+ engine = wr .catalog .get_engine (connection = f"aws-data-wrangler-{ db_type } " )
502+ df = pd .DataFrame ({"id" : [1 , 2 , 3 ], "nothing" : [None , None , None ]})
503+ wr .db .to_sql (
504+ df = df ,
505+ con = engine ,
506+ name = table ,
507+ schema = schema ,
508+ if_exists = "replace" ,
509+ index = False ,
510+ index_label = None ,
511+ chunksize = None ,
512+ method = None ,
513+ dtype = {"nothing" : sqlalchemy .types .Integer },
514+ )
515+ wr .db .to_sql (
516+ df = df ,
517+ con = engine ,
518+ name = table ,
519+ schema = schema ,
520+ if_exists = "append" ,
521+ index = False ,
522+ index_label = None ,
523+ chunksize = None ,
524+ method = None ,
525+ )
526+ df2 = wr .db .read_sql_table (table = table , schema = schema , con = engine )
527+ df ["id" ] = df ["id" ].astype ("Int64" )
528+ assert pd .concat (objs = [df , df ], ignore_index = True ).equals (df2 )
0 commit comments