Skip to content

Commit

Permalink
Lift a couple of suppressed features now that the Data API has implem…
Browse files Browse the repository at this point in the history
…ented them (#329)

* lifted temporary test workarouns for pending issues

* bring the py3.8+3.9 fix and update changesfile
  • Loading branch information
hemidactylus authored Dec 17, 2024
1 parent af491fc commit aed8c63
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 61 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
main
====
restore support for Python 3.8, 3.9
(reinstated some Data API functionalities being tested after the API got patched re: sorting on PK and pagination with that sorting)

v 2.0.0-preview
===============
Introduction of full Tables support.
Expand Down
3 changes: 0 additions & 3 deletions tests/tables/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@
dimension=3,
service=None,
),
"p_int_regular": TableScalarColumnTypeDescriptor(
column_type="int"
), # TODO: remove->p_int after #1718
},
primary_key=TablePrimaryKeyDescriptor(
partition_by=["p_text"],
Expand Down
39 changes: 10 additions & 29 deletions tests/tables/integration/test_table_dml_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from astrapy.results import TableInsertManyResult

from ..conftest import (
IS_ASTRA_DB,
DefaultAsyncTable,
_repaint_NaNs,
_typify_tuple,
Expand Down Expand Up @@ -98,7 +97,6 @@ async def test_table_insert_one_find_one_async(
{
"p_text": "pA",
"p_int": i,
"p_int_regular": i,
"p_vector": DataAPIVector([i, 1, 0]),
}
for i in range(3)
Expand All @@ -109,7 +107,6 @@ async def test_table_insert_one_find_one_async(
{
"p_text": "pB",
"p_int": 100 - i,
"p_int_regular": 100 - i,
"p_vector": DataAPIVector([i + 0.1, 1, 0]),
}
for i in range(3)
Expand All @@ -129,18 +126,14 @@ async def test_table_insert_one_find_one_async(
assert (fo_fil_ann_row["p_text"], fo_fil_ann_row["p_int"]) == ("pB", 100)
# just regular sort
fo_unf_srt_row = await async_empty_table_composite.find_one(
sort={
"p_int_regular": SortMode.DESCENDING
} # TODO: replace with p_int when ok
sort={"p_int": SortMode.DESCENDING}
)
assert fo_unf_srt_row is not None
assert (fo_unf_srt_row["p_text"], fo_unf_srt_row["p_int"]) == ("pB", 100)
# regular sort, filtered
fo_fil_srt_row = await async_empty_table_composite.find_one(
filter={"p_text": "pA"},
sort={
"p_int_regular": SortMode.DESCENDING
}, # TODO: replace with p_int when ok
sort={"p_int": SortMode.DESCENDING},
)
assert fo_fil_srt_row is not None
assert (fo_fil_srt_row["p_text"], fo_fil_srt_row["p_int"]) == ("pA", 2)
Expand Down Expand Up @@ -636,26 +629,14 @@ async def test_table_find_async(
# (nonvector) sorting
await async_empty_table_all_returns.insert_many(INSMANY_AR_ROWS)
# sorting as per clustering column
if IS_ASTRA_DB: # TODO, reinstate full find once fix deployed
# (i.e. remove this branching point in favour of local)
srows_in_part = await async_empty_table_all_returns.find(
filter={"p_ascii": "A", "p_bigint": 100},
sort={"p_int": SortMode.DESCENDING},
limit=20,
).to_list()
assert len(srows_in_part) == 20
srows_in_part_pints = [row["p_int"] for row in srows_in_part]
assert sorted(srows_in_part_pints) == srows_in_part_pints[::-1]
else:
# Latest Data API:
srows_in_part = await async_empty_table_all_returns.find(
filter={"p_ascii": "A", "p_bigint": 100},
sort={"p_int": SortMode.DESCENDING},
limit=INSMANY_AR_ROW_HALFN + 1,
).to_list()
assert len(srows_in_part) == INSMANY_AR_ROW_HALFN
srows_in_part_pints = [row["p_int"] for row in srows_in_part]
assert sorted(srows_in_part_pints) == srows_in_part_pints[::-1]
srows_in_part = await async_empty_table_all_returns.find(
filter={"p_ascii": "A", "p_bigint": 100},
sort={"p_int": SortMode.DESCENDING},
limit=INSMANY_AR_ROW_HALFN + 1,
).to_list()
assert len(srows_in_part) == INSMANY_AR_ROW_HALFN
srows_in_part_pints = [row["p_int"] for row in srows_in_part]
assert sorted(srows_in_part_pints) == srows_in_part_pints[::-1]
# sorting by any regular column
srows_anycol = await async_empty_table_all_returns.find(
filter={"p_ascii": "A", "p_bigint": 100},
Expand Down
39 changes: 10 additions & 29 deletions tests/tables/integration/test_table_dml_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from astrapy.results import TableInsertManyResult

from ..conftest import (
IS_ASTRA_DB,
DefaultTable,
_repaint_NaNs,
_typify_tuple,
Expand Down Expand Up @@ -98,7 +97,6 @@ def test_table_insert_one_find_one_sync(
{
"p_text": "pA",
"p_int": i,
"p_int_regular": i,
"p_vector": DataAPIVector([i, 1, 0]),
}
for i in range(3)
Expand All @@ -109,7 +107,6 @@ def test_table_insert_one_find_one_sync(
{
"p_text": "pB",
"p_int": 100 - i,
"p_int_regular": 100 - i,
"p_vector": DataAPIVector([i + 0.1, 1, 0]),
}
for i in range(3)
Expand All @@ -129,18 +126,14 @@ def test_table_insert_one_find_one_sync(
assert (fo_fil_ann_row["p_text"], fo_fil_ann_row["p_int"]) == ("pB", 100)
# just regular sort
fo_unf_srt_row = sync_empty_table_composite.find_one(
sort={
"p_int_regular": SortMode.DESCENDING
} # TODO: replace with p_int when ok
sort={"p_int": SortMode.DESCENDING}
)
assert fo_unf_srt_row is not None
assert (fo_unf_srt_row["p_text"], fo_unf_srt_row["p_int"]) == ("pB", 100)
# regular sort, filtered
fo_fil_srt_row = sync_empty_table_composite.find_one(
filter={"p_text": "pA"},
sort={
"p_int_regular": SortMode.DESCENDING
}, # TODO: replace with p_int when ok
sort={"p_int": SortMode.DESCENDING},
)
assert fo_fil_srt_row is not None
assert (fo_fil_srt_row["p_text"], fo_fil_srt_row["p_int"]) == ("pA", 2)
Expand Down Expand Up @@ -622,26 +615,14 @@ def test_table_find_sync(
# (nonvector) sorting
sync_empty_table_all_returns.insert_many(INSMANY_AR_ROWS)
# sorting as per clustering column
if IS_ASTRA_DB: # TODO, reinstate full find once fix deployed
# (i.e. remove this branching point in favour of local)
srows_in_part = sync_empty_table_all_returns.find(
filter={"p_ascii": "A", "p_bigint": 100},
sort={"p_int": SortMode.DESCENDING},
limit=20,
).to_list()
assert len(srows_in_part) == 20
srows_in_part_pints = [row["p_int"] for row in srows_in_part]
assert sorted(srows_in_part_pints) == srows_in_part_pints[::-1]
else:
# Latest Data API:
srows_in_part = sync_empty_table_all_returns.find(
filter={"p_ascii": "A", "p_bigint": 100},
sort={"p_int": SortMode.DESCENDING},
limit=INSMANY_AR_ROW_HALFN + 1,
).to_list()
assert len(srows_in_part) == INSMANY_AR_ROW_HALFN
srows_in_part_pints = [row["p_int"] for row in srows_in_part]
assert sorted(srows_in_part_pints) == srows_in_part_pints[::-1]
srows_in_part = sync_empty_table_all_returns.find(
filter={"p_ascii": "A", "p_bigint": 100},
sort={"p_int": SortMode.DESCENDING},
limit=INSMANY_AR_ROW_HALFN + 1,
).to_list()
assert len(srows_in_part) == INSMANY_AR_ROW_HALFN
srows_in_part_pints = [row["p_int"] for row in srows_in_part]
assert sorted(srows_in_part_pints) == srows_in_part_pints[::-1]
# sorting by any regular column
srows_anycol = sync_empty_table_all_returns.find(
filter={"p_ascii": "A", "p_bigint": 100},
Expand Down

0 comments on commit aed8c63

Please sign in to comment.