Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ Parts that remain recognizable in PyAthena:
(pyhive/sqlalchemy_presto.py).
- tests/pyathena/test_cursor.py: test cases including the escaping input of
`test_escape`, the Unicode input of `test_unicode`, and the NULL patterns of
`test_null` follow PyHive's pyhive/tests/dbapi_test_case.py.
`test_null` follow PyHive's pyhive/tests/dbapi_test_case.py. The cursor
tests of the other cursor classes under tests/pyathena/ repeat some of
these test cases, such as `test_arraysize` and `test_fetchone`.
- tests/pyathena/sqlalchemy/test_base.py: test cases including

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (relayed), finding 2 (P2), same reviewer and session as the review on tests/pyathena/s3fs/test_async_cursor.py: deleting the whole reference to tests/pyathena/aio/sqlalchemy/test_base.py leaves recognizable PyHive material unlisted. Its test_basic_query runs SELECT * FROM one_row and checks one row, number_of_rows == 1, and one column, as PyHive's SqlAlchemyTestCase.test_basic_query does. Replace the obsolete example with the surviving test instead of removing the file's attribution.

Author verification: confirmed; the aio test_reflect_schemas also checks the test schema and default as PyHive's does. Checking the same question for the DB API tests found that test_arraysize (arraysize = 5, SELECT * FROM many_rows LIMIT 20, len(fetchmany()) == 5) and the aio test_fetchone remain PyHive's test cases in the cursor tests of the other cursor classes, which NOTICE did not mention before this change either.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repaired in 8e85cb2: NOTICE states that tests/pyathena/aio/sqlalchemy/test_base.py ports test_basic_query and test_reflect_schemas to the asynchronous dialect, and that the cursor tests of the other cursor classes under tests/pyathena/ repeat some of PyHive's DB API test cases, such as test_arraysize and test_fetchone. Self-review of the repair: both statements were checked against the remaining tests and PyHive ae3c9a96 (SqlAlchemyTestCase.test_basic_query/test_reflect_schemas, DBAPITestCase.test_arraysize/test_fetchone); the PR body now describes the NOTICE change.

`test_unicode`, `test_char_length`, and `test_reflect_no_such_table` follow
PyHive's pyhive/tests/sqlalchemy_test_case.py.
tests/pyathena/aio/sqlalchemy/test_base.py ports `test_unicode` to the
asynchronous dialect.
tests/pyathena/aio/sqlalchemy/test_base.py ports `test_basic_query` and
`test_reflect_schemas` to the asynchronous dialect.

Parts that have since been replaced:

Expand Down
6 changes: 0 additions & 6 deletions tests/pyathena/aio/pandas/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ async def test_fetchone(self, aio_pandas_cursor):
assert aio_pandas_cursor.rownumber == 1
assert await aio_pandas_cursor.fetchone() is None

async def test_fetchall(self, aio_pandas_cursor):
await aio_pandas_cursor.execute("SELECT * FROM one_row")
assert await aio_pandas_cursor.fetchall() == [(1,)]
await aio_pandas_cursor.execute("SELECT a FROM many_rows ORDER BY a")
assert await aio_pandas_cursor.fetchall() == [(i,) for i in range(10000)]

async def test_as_pandas(self, aio_pandas_cursor):
await aio_pandas_cursor.execute("SELECT * FROM one_row")
df = aio_pandas_cursor.as_pandas()
Expand Down
2 changes: 0 additions & 2 deletions tests/pyathena/aio/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ async def test_fetchmany(self, aio_cursor):
assert actual2 == [(i,) for i in range(10, 15)]

async def test_fetchall(self, aio_cursor):
await aio_cursor.execute("SELECT * FROM one_row")
assert await aio_cursor.fetchall() == [(1,)]
await aio_cursor.execute("SELECT a FROM many_rows ORDER BY a")
assert await aio_cursor.fetchall() == [(i,) for i in range(10000)]

Expand Down
56 changes: 0 additions & 56 deletions tests/pyathena/arrow/test_async_cursor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import contextlib
import random
import string
import time
Expand Down Expand Up @@ -34,57 +33,6 @@ def test_binary_null_vs_empty(self, async_arrow_cursor):
]
assert [row[3] for row in rows] == ["", "", "NULL"]

@pytest.mark.parametrize(
"async_arrow_cursor",
[{"cursor_kwargs": {"unload": False}}, {"cursor_kwargs": {"unload": True}}],
indirect=["async_arrow_cursor"],
)
def test_fetchone(self, async_arrow_cursor):
query_id, future = async_arrow_cursor.execute("SELECT * FROM one_row")
result_set = future.result()
assert result_set.rownumber == 0
assert result_set.fetchone() == (1,)
assert result_set.rownumber == 1
assert result_set.fetchone() is None

@pytest.mark.parametrize(
"async_arrow_cursor",
[{"cursor_kwargs": {"unload": False}}, {"cursor_kwargs": {"unload": True}}],
indirect=["async_arrow_cursor"],
)
def test_fetchmany(self, async_arrow_cursor):
query_id, future = async_arrow_cursor.execute("SELECT * FROM many_rows LIMIT 15")
result_set = future.result()
assert len(result_set.fetchmany(10)) == 10
assert len(result_set.fetchmany(10)) == 5

@pytest.mark.parametrize(
"async_arrow_cursor",
[{"cursor_kwargs": {"unload": False}}, {"cursor_kwargs": {"unload": True}}],
indirect=["async_arrow_cursor"],
)
def test_fetchall(self, async_arrow_cursor):
query_id, future = async_arrow_cursor.execute("SELECT * FROM one_row")
result_set = future.result()
assert result_set.fetchall() == [(1,)]
query_id, future = async_arrow_cursor.execute("SELECT a FROM many_rows ORDER BY a")
result_set = future.result()
if async_arrow_cursor._unload:
assert sorted(result_set.fetchall()) == [(i,) for i in range(10000)]
else:
assert result_set.fetchall() == [(i,) for i in range(10000)]

@pytest.mark.parametrize(
"async_arrow_cursor",
[{"cursor_kwargs": {"unload": False}}, {"cursor_kwargs": {"unload": True}}],
indirect=["async_arrow_cursor"],
)
def test_iterator(self, async_arrow_cursor):
query_id, future = async_arrow_cursor.execute("SELECT * FROM one_row")
result_set = future.result()
assert list(result_set) == [(1,)]
pytest.raises(StopIteration, result_set.__next__)

@pytest.mark.parametrize(
"async_arrow_cursor",
[{"cursor_kwargs": {"unload": False}}, {"cursor_kwargs": {"unload": True}}],
Expand Down Expand Up @@ -274,10 +222,6 @@ def test_cancel(self, async_arrow_cursor):
assert result_set.fetchmany() == []
assert result_set.fetchall() == []

def test_open_close(self):
with contextlib.closing(connect()) as conn, conn.cursor(AsyncArrowCursor):
pass

def test_no_ops(self):
conn = connect()
cursor = conn.cursor(AsyncArrowCursor)
Expand Down
50 changes: 0 additions & 50 deletions tests/pyathena/arrow/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,52 +109,6 @@ def test_temporal_text_null_with_binary(self, arrow_cursor):
]
assert arrow_cursor.fetchall() == [(None, None, None, "", None)]

@pytest.mark.parametrize(
"arrow_cursor",
[{"cursor_kwargs": {"unload": False}}, {"cursor_kwargs": {"unload": True}}],
indirect=["arrow_cursor"],
)
def test_fetchone(self, arrow_cursor):
arrow_cursor.execute("SELECT * FROM one_row")
assert arrow_cursor.rownumber == 0
assert arrow_cursor.fetchone() == (1,)
assert arrow_cursor.rownumber == 1
assert arrow_cursor.fetchone() is None

@pytest.mark.parametrize(
"arrow_cursor",
[{"cursor_kwargs": {"unload": False}}, {"cursor_kwargs": {"unload": True}}],
indirect=["arrow_cursor"],
)
def test_fetchmany(self, arrow_cursor):
arrow_cursor.execute("SELECT * FROM many_rows LIMIT 15")
assert len(arrow_cursor.fetchmany(10)) == 10
assert len(arrow_cursor.fetchmany(10)) == 5

@pytest.mark.parametrize(
"arrow_cursor",
[{"cursor_kwargs": {"unload": False}}, {"cursor_kwargs": {"unload": True}}],
indirect=["arrow_cursor"],
)
def test_fetchall(self, arrow_cursor):
arrow_cursor.execute("SELECT * FROM one_row")
assert arrow_cursor.fetchall() == [(1,)]
arrow_cursor.execute("SELECT a FROM many_rows ORDER BY a")
if arrow_cursor._unload:
assert sorted(arrow_cursor.fetchall()) == [(i,) for i in range(10000)]
else:
assert arrow_cursor.fetchall() == [(i,) for i in range(10000)]

@pytest.mark.parametrize(
"arrow_cursor",
[{"cursor_kwargs": {"unload": False}}, {"cursor_kwargs": {"unload": True}}],
indirect=["arrow_cursor"],
)
def test_iterator(self, arrow_cursor):
arrow_cursor.execute("SELECT * FROM one_row")
assert list(arrow_cursor) == [(1,)]
pytest.raises(StopIteration, arrow_cursor.__next__)

@pytest.mark.parametrize(
"arrow_cursor",
[{"cursor_kwargs": {"unload": False}}, {"cursor_kwargs": {"unload": True}}],
Expand Down Expand Up @@ -593,10 +547,6 @@ def cancel(c):
def test_cancel_initial(self, arrow_cursor):
pytest.raises(ProgrammingError, arrow_cursor.cancel)

def test_open_close(self):
with contextlib.closing(connect()) as conn, conn.cursor(ArrowCursor):
pass

def test_no_ops(self):
conn = connect()
cursor = conn.cursor(ArrowCursor)
Expand Down
83 changes: 0 additions & 83 deletions tests/pyathena/pandas/test_async_cursor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import contextlib
import time
from datetime import datetime
from random import randint
Expand Down Expand Up @@ -32,44 +31,6 @@ def test_binary_null_vs_empty(self, async_pandas_cursor):
(3, b"\x00\xff'\\%", 'comma, quote" and\nnewline'),
]

@pytest.mark.parametrize(
("async_pandas_cursor", "parquet_engine", "chunksize"),
[
({"cursor_kwargs": {"unload": False}}, "auto", None),
({"cursor_kwargs": {"unload": False}}, "auto", 1_000),
({"cursor_kwargs": {"unload": True}}, "auto", None),
],
indirect=["async_pandas_cursor"],
)
def test_fetchone(self, async_pandas_cursor, parquet_engine, chunksize):
query_id, future = async_pandas_cursor.execute(
"SELECT * FROM one_row", engine=parquet_engine, chunksize=chunksize
)
result_set = future.result()
assert result_set.rownumber == 0
assert result_set.fetchone() == (1,)
assert result_set.rownumber == 1
assert result_set.fetchone() is None

@pytest.mark.parametrize(
("async_pandas_cursor", "parquet_engine", "chunksize"),
[
({"cursor_kwargs": {"unload": False}}, "auto", None),
({"cursor_kwargs": {"unload": False}}, "auto", 1_000),
({"cursor_kwargs": {"unload": True}}, "auto", None),
],
indirect=["async_pandas_cursor"],
)
def test_fetchmany(self, async_pandas_cursor, parquet_engine, chunksize):
query_id, future = async_pandas_cursor.execute(
"SELECT * FROM many_rows LIMIT 15",
engine=parquet_engine,
chunksize=chunksize,
)
result_set = future.result()
assert len(result_set.fetchmany(10)) == 10
assert len(result_set.fetchmany(10)) == 5

@pytest.mark.parametrize(
("async_pandas_cursor", "chunksize"),
[
Expand All @@ -91,46 +52,6 @@ def test_get_chunk(self, async_pandas_cursor, chunksize):
else:
assert len(df) == 15

@pytest.mark.parametrize(
("async_pandas_cursor", "parquet_engine", "chunksize"),
[
({"cursor_kwargs": {"unload": False}}, "auto", None),
({"cursor_kwargs": {"unload": False}}, "auto", 1_000),
({"cursor_kwargs": {"unload": True}}, "auto", None),
],
indirect=["async_pandas_cursor"],
)
def test_fetchall(self, async_pandas_cursor, parquet_engine, chunksize):
query_id, future = async_pandas_cursor.execute(
"SELECT * FROM one_row",
engine=parquet_engine,
chunksize=chunksize,
)
result_set = future.result()
assert result_set.fetchall() == [(1,)]
query_id, future = async_pandas_cursor.execute("SELECT a FROM many_rows ORDER BY a")
result_set = future.result()
assert result_set.fetchall() == [(i,) for i in range(10000)]

@pytest.mark.parametrize(
("async_pandas_cursor", "parquet_engine", "chunksize"),
[
({"cursor_kwargs": {"unload": False}}, "auto", None),
({"cursor_kwargs": {"unload": False}}, "auto", 1_000),
({"cursor_kwargs": {"unload": True}}, "auto", None),
],
indirect=["async_pandas_cursor"],
)
def test_iterator(self, async_pandas_cursor, parquet_engine, chunksize):
query_id, future = async_pandas_cursor.execute(
"SELECT * FROM one_row",
engine=parquet_engine,
chunksize=chunksize,
)
result_set = future.result()
assert list(result_set) == [(1,)]
pytest.raises(StopIteration, result_set.__next__)

@pytest.mark.parametrize(
("async_pandas_cursor", "parquet_engine", "chunksize"),
[
Expand Down Expand Up @@ -349,10 +270,6 @@ def test_cancel(self, async_pandas_cursor):
assert result_set.fetchmany() == []
assert result_set.fetchall() == []

def test_open_close(self):
with contextlib.closing(connect()) as conn, conn.cursor(AsyncPandasCursor):
pass

def test_no_ops(self):
conn = connect()
cursor = conn.cursor(AsyncPandasCursor)
Expand Down
67 changes: 0 additions & 67 deletions tests/pyathena/pandas/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,22 +313,6 @@ def test_binary_single_null(self, pandas_cursor):
pandas_cursor.execute("SELECT CAST(NULL AS VARBINARY) AS value")
assert pandas_cursor.fetchall() == [(None,)]

@pytest.mark.parametrize(
("pandas_cursor", "parquet_engine", "chunksize"),
[
({"cursor_kwargs": {"unload": False}}, "auto", None),
({"cursor_kwargs": {"unload": False}}, "auto", 1_000),
({"cursor_kwargs": {"unload": True}}, "auto", None),
],
indirect=["pandas_cursor"],
)
def test_fetchone(self, pandas_cursor, parquet_engine, chunksize):
pandas_cursor.execute("SELECT * FROM one_row", engine=parquet_engine, chunksize=chunksize)
assert pandas_cursor.rownumber == 0
assert pandas_cursor.fetchone() == (1,)
assert pandas_cursor.rownumber == 1
assert pandas_cursor.fetchone() is None

@pytest.mark.parametrize(
"pandas_cursor",
[{"cursor_kwargs": {"unload": False}}, {"cursor_kwargs": {"unload": True}}],
Expand Down Expand Up @@ -386,24 +370,6 @@ def test_csv_storage_options(self, pandas_cursor, query, expected):
},
)

@pytest.mark.parametrize(
("pandas_cursor", "parquet_engine", "chunksize"),
[
({"cursor_kwargs": {"unload": False}}, "auto", None),
({"cursor_kwargs": {"unload": False}}, "auto", 1_000),
({"cursor_kwargs": {"unload": True}}, "auto", None),
],
indirect=["pandas_cursor"],
)
def test_fetchmany(self, pandas_cursor, parquet_engine, chunksize):
pandas_cursor.execute(
"SELECT * FROM many_rows LIMIT 15",
engine=parquet_engine,
chunksize=chunksize,
)
assert len(pandas_cursor.fetchmany(10)) == 10
assert len(pandas_cursor.fetchmany(10)) == 5

@pytest.mark.parametrize(
("pandas_cursor", "ordered"),
[
Expand Down Expand Up @@ -454,35 +420,6 @@ def test_get_chunk(self, pandas_cursor, chunksize):
else:
assert len(df) == 15

@pytest.mark.parametrize(
("pandas_cursor", "parquet_engine", "chunksize"),
[
({"cursor_kwargs": {"unload": False}}, "auto", None),
({"cursor_kwargs": {"unload": False}}, "auto", 1_000),
({"cursor_kwargs": {"unload": True}}, "auto", None),
],
indirect=["pandas_cursor"],
)
def test_fetchall(self, pandas_cursor, parquet_engine, chunksize):
pandas_cursor.execute("SELECT * FROM one_row", engine=parquet_engine, chunksize=chunksize)
assert pandas_cursor.fetchall() == [(1,)]
pandas_cursor.execute("SELECT a FROM many_rows ORDER BY a", engine=parquet_engine)
assert pandas_cursor.fetchall() == [(i,) for i in range(10000)]

@pytest.mark.parametrize(
("pandas_cursor", "parquet_engine", "chunksize"),
[
({"cursor_kwargs": {"unload": False}}, "auto", None),
({"cursor_kwargs": {"unload": False}}, "auto", 1_000),
({"cursor_kwargs": {"unload": True}}, "auto", None),
],
indirect=["pandas_cursor"],
)
def test_iterator(self, pandas_cursor, parquet_engine, chunksize):
pandas_cursor.execute("SELECT * FROM one_row", engine=parquet_engine, chunksize=chunksize)
assert list(pandas_cursor) == [(1,)]
pytest.raises(StopIteration, pandas_cursor.__next__)

@pytest.mark.parametrize(
("pandas_cursor", "parquet_engine", "chunksize"),
[
Expand Down Expand Up @@ -1170,10 +1107,6 @@ def cancel(c):
def test_cancel_initial(self, pandas_cursor):
pytest.raises(ProgrammingError, pandas_cursor.cancel)

def test_open_close(self):
with contextlib.closing(connect()) as conn, conn.cursor(PandasCursor):
pass

def test_no_ops(self):
conn = connect()
cursor = conn.cursor(PandasCursor)
Expand Down
Loading
Loading