Skip to content

Commit 9ce2aec

Browse files
authored
Merge pull request #104 from awslabs/aurora
Improving Aurora tests
2 parents 1de6510 + 55a6292 commit 9ce2aec

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

awswrangler/aurora.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ def _get_load_sql(path: str, schema_name: str, table_name: str, engine: str, reg
201201
sql: str = ("-- AWS DATA WRANGLER\n"
202202
"SELECT aws_s3.table_import_from_s3(\n"
203203
f"'{schema_name}.{table_name}',\n"
204+
"'',\n"
204205
"'(FORMAT CSV, DELIMITER '','', QUOTE ''\"'', ESCAPE ''\"'')',\n"
205206
f"'({bucket},{key},{region})')")
206207
elif "mysql" in engine.lower():

testing/test_awswrangler/test_pandas.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,10 +1925,12 @@ def test_aurora_postgres_load_special(bucket, postgres_parameters):
19251925
df = pd.DataFrame({
19261926
"id": [1, 2, 3, 4],
19271927
"value": ["foo", "boo", "bar", "abc"],
1928-
"special": ["\\", "\"", "\\\\\\\\", "\"\"\"\""]
1928+
"slashes": ["\\", "\"", "\\\\\\\\", "\"\"\"\""],
1929+
"floats": [1.0, 2.0, 3.0, 4.0],
1930+
"decimals": [Decimal((0, (1, 9, 9), -2)), Decimal((0, (1, 9, 9), -2)), Decimal((0, (1, 9, 0), -2)), Decimal((0, (3, 1, 2), -2))]
19291931
})
19301932

1931-
path = f"s3://{bucket}/test_aurora_postgres_slash"
1933+
path = f"s3://{bucket}/test_aurora_postgres_special"
19321934
wr.pandas.to_aurora(dataframe=df,
19331935
connection="aws-data-wrangler-postgres",
19341936
schema="public",
@@ -1958,14 +1960,25 @@ def test_aurora_postgres_load_special(bucket, postgres_parameters):
19581960
assert rows[1][2] == "\""
19591961
assert rows[2][2] == "\\\\\\\\"
19601962
assert rows[3][2] == "\"\"\"\""
1963+
assert (rows[0][3] == 1.0) and (str(type(rows[0][3])) == str(type(1.0)))
1964+
assert rows[1][3] == 2.0
1965+
assert rows[2][3] == 3.0
1966+
assert rows[3][3] == 4.0
1967+
assert rows[0][4] == Decimal((0, (1, 9, 9), -2))
1968+
assert rows[1][4] == Decimal((0, (1, 9, 9), -2))
1969+
assert rows[2][4] == Decimal((0, (1, 9, 0), -2))
1970+
assert rows[3][4] == Decimal((0, (3, 1, 2), -2))
19611971
conn.close()
19621972

19631973

19641974
def test_aurora_mysql_load_special(bucket, mysql_parameters):
19651975
df = pd.DataFrame({
19661976
"id": [1, 2, 3, 4],
19671977
"value": ["foo", "boo", "bar", "abc"],
1968-
"special": ["\\", "\"", "\\\\\\\\", "\"\"\"\""]
1978+
"slashes": ["\\", "\"", "\\\\\\\\", "\"\"\"\""],
1979+
"floats": [1.0, 2.0, 3.0, 4.0],
1980+
"decimals": [Decimal((0, (1, 9, 9), -2)), Decimal((0, (1, 9, 9), -2)), Decimal((0, (1, 9, 0), -2)),
1981+
Decimal((0, (3, 1, 2), -2))]
19691982
})
19701983

19711984
path = f"s3://{bucket}/test_aurora_mysql_special"
@@ -1998,6 +2011,14 @@ def test_aurora_mysql_load_special(bucket, mysql_parameters):
19982011
assert rows[1][2] == "\""
19992012
assert rows[2][2] == "\\\\\\\\"
20002013
assert rows[3][2] == "\"\"\"\""
2014+
assert (rows[0][3] == 1.0) and (str(type(rows[0][3])) == str(type(1.0)))
2015+
assert rows[1][3] == 2.0
2016+
assert rows[2][3] == 3.0
2017+
assert rows[3][3] == 4.0
2018+
assert rows[0][4] == Decimal((0, (1, 9, 9), -2))
2019+
assert rows[1][4] == Decimal((0, (1, 9, 9), -2))
2020+
assert rows[2][4] == Decimal((0, (1, 9, 0), -2))
2021+
assert rows[3][4] == Decimal((0, (3, 1, 2), -2))
20012022
conn.close()
20022023

20032024

0 commit comments

Comments
 (0)