Skip to content

Commit

Permalink
SNOW-1016748 Fixed a bug that Session.range returns empty result when… (
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-azhan authored Feb 7, 2024
1 parent f47c158 commit 24a7ae3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Fixed a bug in `DataFrame.to_pandas` that caused an error when evaluating on a dataframe with an IntergerType column with null values.
- Fixed a bug in `DataFrame.to_local_iterator` where the iterator could yield wrong results if another query is executed before the iterator finishes due to wrong isolation level. For details, please see #945.
- Fixed a bug that truncated table names in error messages while running a plan with local testing enabled.
- Fixed a bug that `Session.range` returns empty result when the range is large.

## 1.12.0 (2024-01-30)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def sort_statement(order: List[str], child: str) -> str:
def range_statement(start: int, end: int, step: int, column_name: str) -> str:
range = end - start

if range * step < 0:
if (range > 0 > step) or (range < 0 < step):
count = 0
else:
count = math.ceil(range / step)
Expand Down
11 changes: 11 additions & 0 deletions tests/integ/scala/test_dataframe_range_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from snowflake.snowpark import Row
from snowflake.snowpark.functions import col, count, sum as sum_
from tests.integ.test_packaging import is_pandas_and_numpy_available


@pytest.mark.localtest
Expand Down Expand Up @@ -108,3 +109,13 @@ def test_range_with_max_and_min(session):
end = MIN_VALUE + 2
assert session.range(start, end, 1).collect() == []
assert session.range(start, start, 1).collect() == []


@pytest.mark.skipif(not is_pandas_and_numpy_available, reason="requires numpy")
@pytest.mark.localtest
def test_range_with_large_range_and_step(session):
import numpy as np

ints = np.array([691200000000000], dtype="int64")
# Use a numpy int64 range with a python int step
assert session.range(0, ints[0], 86400000000000).collect() != []

0 comments on commit 24a7ae3

Please sign in to comment.