Skip to content

Commit

Permalink
Merge pull request #82 from yassun7010/change_record_limit
Browse files Browse the repository at this point in the history
feat: change limit behavor.
  • Loading branch information
yassun7010 authored Feb 15, 2024
2 parents 4127080 + 6544fc9 commit f96ff6c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
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

0 comments on commit f96ff6c

Please sign in to comment.