Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change limit behavor. #82

Merged
merged 1 commit into from
Feb 15, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ async def fetch_pandas_all(self, **kwargs) -> "PandasDataFrame":

if isinstance(self._recorder, turu.core.record.CsvRecorder):
if limit := self._recorder._options.get("limit"):
record_df = df.head(limit)
df = df.head(limit)

else:
record_df = df

record_df.to_csv(
df.to_csv(
self._recorder.file,
index=False,
header=self._recorder._options.get("header", True),
Expand Down
7 changes: 2 additions & 5 deletions turu-snowflake/src/turu/snowflake/record/record_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ def fetch_pandas_all(self, **kwargs) -> "PandasDataFrame":

if isinstance(self._recorder, turu.core.record.CsvRecorder):
if limit := self._recorder._options.get("limit"):
record_df = df.head(limit)
df = df.head(limit)

else:
record_df = df

record_df.to_csv(
df.to_csv(
self._recorder.file,
index=False,
header=self._recorder._options.get("header", True),
Expand Down
2 changes: 1 addition & 1 deletion turu-snowflake/tests/turu/test_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def test_record_pandas_dataframe_with_limit_option(
),
limit=2,
) as cursor:
expected = pd.DataFrame({"ID": list(range(1, 10))}, dtype="object")
expected = pd.DataFrame({"ID": [1, 2]}, dtype="object")

assert_frame_equal(cursor.fetch_pandas_all(), expected)

Expand Down
2 changes: 1 addition & 1 deletion turu-snowflake/tests/turu/test_snowflake_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ async def test_record_pandas_dataframe_with_limit_option(
),
limit=2,
) as cursor:
expected = pd.DataFrame({"ID": list(range(1, 10))}, dtype="object")
expected = pd.DataFrame({"ID": [1, 2]}, dtype="object")

assert_frame_equal(await cursor.fetch_pandas_all(), expected)

Expand Down
Loading