33import random
44import string
55from decimal import Decimal
6+ from typing import Any , Dict
67
78import boto3
89import numpy as np
@@ -164,7 +165,12 @@ def test_copy_unload(path, redshift_table, redshift_con, databases_parameters):
164165 ensure_data_types (df = chunk , has_list = False )
165166
166167
167- def test_copy_upsert (path , redshift_table , redshift_con , databases_parameters ):
168+ def generic_test_copy_upsert (
169+ path : str ,
170+ redshift_table : str ,
171+ redshift_con : redshift_connector .Connection ,
172+ databases_parameters : Dict [str , Any ],
173+ ) -> None :
168174 df = pd .DataFrame ({"id" : list ((range (1_000 ))), "val" : list (["foo" if i % 2 == 0 else "boo" for i in range (1_000 )])})
169175 df3 = pd .DataFrame (
170176 {"id" : list ((range (1_000 , 1_500 ))), "val" : list (["foo" if i % 2 == 0 else "boo" for i in range (500 )])}
@@ -185,7 +191,7 @@ def test_copy_upsert(path, redshift_table, redshift_con, databases_parameters):
185191 )
186192 path = f"{ path } upsert/test_redshift_copy_upsert2/"
187193 df2 = wr .redshift .unload (
188- sql = f" SELECT * FROM public.{ redshift_table } " ,
194+ sql = f' SELECT * FROM public." { redshift_table } "' ,
189195 con = redshift_con ,
190196 iam_role = databases_parameters ["redshift" ]["role" ],
191197 path = path ,
@@ -209,7 +215,7 @@ def test_copy_upsert(path, redshift_table, redshift_con, databases_parameters):
209215 )
210216 path = f"{ path } upsert/test_redshift_copy_upsert4/"
211217 df4 = wr .redshift .unload (
212- sql = f" SELECT * FROM public.{ redshift_table } " ,
218+ sql = f' SELECT * FROM public." { redshift_table } "' ,
213219 con = redshift_con ,
214220 iam_role = databases_parameters ["redshift" ]["role" ],
215221 path = path ,
@@ -232,7 +238,7 @@ def test_copy_upsert(path, redshift_table, redshift_con, databases_parameters):
232238 )
233239 path = f"{ path } upsert/test_redshift_copy_upsert4/"
234240 df4 = wr .redshift .unload (
235- sql = f" SELECT * FROM public.{ redshift_table } " ,
241+ sql = f' SELECT * FROM public." { redshift_table } "' ,
236242 con = redshift_con ,
237243 iam_role = databases_parameters ["redshift" ]["role" ],
238244 path = path ,
@@ -242,6 +248,14 @@ def test_copy_upsert(path, redshift_table, redshift_con, databases_parameters):
242248 assert len (df .columns ) == len (df4 .columns )
243249
244250
251+ def test_copy_upsert (path , redshift_table , redshift_con , databases_parameters ):
252+ generic_test_copy_upsert (path , redshift_table , redshift_con , databases_parameters )
253+
254+
255+ def test_copy_upsert_hyphenated_name (path , redshift_table_with_hyphenated_name , redshift_con , databases_parameters ):
256+ generic_test_copy_upsert (path , redshift_table_with_hyphenated_name , redshift_con , databases_parameters )
257+
258+
245259@pytest .mark .parametrize (
246260 "diststyle,distkey,exc,sortstyle,sortkey" ,
247261 [
0 commit comments