@@ -1417,7 +1417,9 @@ def test_read_parquet_dataset(session, bucket):
14171417 preserve_index = False ,
14181418 procs_cpu_bound = 4 ,
14191419 partition_cols = ["partition" ])
1420+ sleep (15 )
14201421 df2 = session .pandas .read_parquet (path = path )
1422+ wr .s3 .delete_objects (path = path )
14211423 assert len (list (df .columns )) == len (list (df2 .columns ))
14221424 assert len (df .index ) == len (df2 .index )
14231425
@@ -2068,3 +2070,102 @@ def test_read_sql_athena_empty(ctas_approach):
20682070 """
20692071 df = wr .pandas .read_sql_athena (sql = sql , ctas_approach = ctas_approach )
20702072 print (df )
2073+
2074+
2075+ def test_aurora_postgres_load_special2 (bucket , postgres_parameters ):
2076+ dt = lambda x : datetime .strptime (x , "%Y-%m-%d %H:%M:%S.%f" )
2077+ df = pd .DataFrame ({
2078+ "integer1" : [0 , 1 , np .NaN , 3 ],
2079+ "integer2" : [8986 , 9735 , 9918 , 9150 ],
2080+ "string1" : ["O" , "P" , "P" , "O" ],
2081+ "string2" : ["050100" , "010101" , "010101" , "050100" ],
2082+ "string3" : ["A" , "R" , "A" , "R" ],
2083+ "string4" : ["SGD" , "SGD" , "SGD" , "SGD" ],
2084+ "float1" : [0.0 , 1800000.0 , np .NaN , 0.0 ],
2085+ "string5" : ["0000296722" , "0000199396" , "0000298592" , "0000196380" ],
2086+ "string6" : [None , "C" , "C" , None ],
2087+ "timestamp1" : [dt ("2020-01-07 00:00:00.000" ), None , dt ("2020-01-07 00:00:00.000" ),
2088+ dt ("2020-01-07 00:00:00.000" )],
2089+ "string7" : ["XXX" , "XXX" , "XXX" , "XXX" ],
2090+ "timestamp2" : [dt ("2020-01-10 10:34:55.863" ), dt ("2020-01-10 10:34:55.864" ), dt ("2020-01-10 10:34:55.865" ),
2091+ dt ("2020-01-10 10:34:55.866" )],
2092+ })
2093+ df = pd .concat ([df for _ in range (10_000 )])
2094+ path = f"s3://{ bucket } /test_aurora_postgres_special"
2095+ wr .pandas .to_aurora (dataframe = df ,
2096+ connection = "aws-data-wrangler-postgres" ,
2097+ schema = "public" ,
2098+ table = "test_aurora_postgres_load_special2" ,
2099+ mode = "overwrite" ,
2100+ temp_s3_path = path ,
2101+ engine = "postgres" ,
2102+ procs_cpu_bound = 1 )
2103+ conn = Aurora .generate_connection (database = "postgres" ,
2104+ host = postgres_parameters ["PostgresAddress" ],
2105+ port = 3306 ,
2106+ user = "test" ,
2107+ password = postgres_parameters ["Password" ],
2108+ engine = "postgres" )
2109+ with conn .cursor () as cursor :
2110+ cursor .execute ("SELECT count(*) FROM public.test_aurora_postgres_load_special2" )
2111+ assert cursor .fetchall ()[0 ][0 ] == len (df .index )
2112+ cursor .execute ("SELECT timestamp2 FROM public.test_aurora_postgres_load_special2 limit 4" )
2113+ rows = cursor .fetchall ()
2114+ assert rows [0 ][0 ] == dt ("2020-01-10 10:34:55.863" )
2115+ assert rows [1 ][0 ] == dt ("2020-01-10 10:34:55.864" )
2116+ assert rows [2 ][0 ] == dt ("2020-01-10 10:34:55.865" )
2117+ assert rows [3 ][0 ] == dt ("2020-01-10 10:34:55.866" )
2118+ cursor .execute ("SELECT integer1, float1, string6, timestamp1 FROM public.test_aurora_postgres_load_special2 limit 4" )
2119+ rows = cursor .fetchall ()
2120+ assert rows [2 ][0 ] is None
2121+ assert rows [2 ][1 ] is None
2122+ assert rows [0 ][2 ] is None
2123+ assert rows [1 ][3 ] is None
2124+ conn .close ()
2125+
2126+
2127+ def test_aurora_mysql_load_special2 (bucket , mysql_parameters ):
2128+ dt = lambda x : datetime .strptime (x , "%Y-%m-%d %H:%M:%S.%f" )
2129+ df = pd .DataFrame ({
2130+ "integer1" : [0 , 1 , np .NaN , 3 ],
2131+ "integer2" : [8986 , 9735 , 9918 , 9150 ],
2132+ "string1" : ["O" , "P" , "P" , "O" ],
2133+ "string2" : ["050100" , "010101" , "010101" , "050100" ],
2134+ "string3" : ["A" , "R" , "A" , "R" ],
2135+ "string4" : ["SGD" , "SGD" , "SGD" , "SGD" ],
2136+ "float1" : [0.0 , 1800000.0 , np .NaN , 0.0 ],
2137+ "string5" : ["0000296722" , "0000199396" , "0000298592" , "0000196380" ],
2138+ "string6" : [None , "C" , "C" , None ],
2139+ "timestamp1" : [dt ("2020-01-07 00:00:00.000" ), None , dt ("2020-01-07 00:00:00.000" ),
2140+ dt ("2020-01-07 00:00:00.000" )],
2141+ "string7" : ["XXX" , "XXX" , "XXX" , "XXX" ],
2142+ "timestamp2" : [dt ("2020-01-10 10:34:55.863" ), dt ("2020-01-10 10:34:55.864" ), dt ("2020-01-10 10:34:55.865" ),
2143+ dt ("2020-01-10 10:34:55.866" )],
2144+ })
2145+ df = pd .concat ([df for _ in range (10_000 )])
2146+ path = f"s3://{ bucket } /test_aurora_mysql_load_special2"
2147+ wr .pandas .to_aurora (dataframe = df ,
2148+ connection = "aws-data-wrangler-mysql" ,
2149+ schema = "test" ,
2150+ table = "test_aurora_mysql_load_special2" ,
2151+ mode = "overwrite" ,
2152+ temp_s3_path = path ,
2153+ engine = "mysql" ,
2154+ procs_cpu_bound = 1 )
2155+ conn = Aurora .generate_connection (database = "mysql" ,
2156+ host = mysql_parameters ["MysqlAddress" ],
2157+ port = 3306 ,
2158+ user = "test" ,
2159+ password = mysql_parameters ["Password" ],
2160+ engine = "mysql" )
2161+ with conn .cursor () as cursor :
2162+ cursor .execute ("SELECT count(*) FROM test.test_aurora_mysql_load_special2" )
2163+ assert cursor .fetchall ()[0 ][0 ] == len (df .index )
2164+ cursor .execute (
2165+ "SELECT integer1, float1, string6, timestamp1 FROM test.test_aurora_mysql_load_special2 limit 4" )
2166+ rows = cursor .fetchall ()
2167+ assert rows [2 ][0 ] is None
2168+ assert rows [2 ][1 ] is None
2169+ assert rows [0 ][2 ] is None
2170+ assert rows [1 ][3 ] is None
2171+ conn .close ()
0 commit comments