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

fix: remove convert to leaf before showing #221

Merged
merged 1 commit into from
Dec 18, 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
4 changes: 1 addition & 3 deletions sqlframe/base/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1624,9 +1624,7 @@ def show(
raise NotImplementedError("Vertical show is not yet supported")
if truncate:
logger.warning("Truncate is ignored so full results will be displayed")
# Make sure that the limit we add doesn't affect the results
df = self._convert_leaf_to_cte()
result = df.limit(n).collect()
result = self.limit(n).collect()
table = PrettyTable()
if row := seq_get(result, 0):
table.field_names = row._unique_field_names
Expand Down
10 changes: 10 additions & 0 deletions tests/fixtures/issue_219.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
kind,price,make
standard,30,emcsquare
capsule,40,emcsquare
candle,10,emcsquare
standard,20,maxwells
capsule,45,maxwells
candle,11,maxwells
standard,90,voltaires
capsule,95,voltaires
candle,80,voltaires
8 changes: 8 additions & 0 deletions tests/integration/engines/duck/test_duckdb_reader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from sqlframe.base.types import Row
from sqlframe.duckdb import DuckDBSession
from sqlframe.duckdb import functions as F

pytest_plugins = ["tests.common_fixtures"]

Expand Down Expand Up @@ -114,3 +115,10 @@ def test_employee_delta(duckdb_session: DuckDBSession):
),
Row(**{"employee_id": 5, "fname": "Hugo", "lname": "Reyes", "age": 29, "store_id": 100}),
]


def test_issue_219(duckdb_session: DuckDBSession):
df1 = duckdb_session.read.csv("tests/fixtures/issue_219.csv")
df2 = df1.groupBy("kind", "make").agg(F.min("price"))
# Just making sure this doesn't raise like it did before
df2.show()
Loading