Skip to content

Commit dc6c2dc

Browse files
authored
Merge pull request #112 from posit-dev/fix-preview-ibis-backends
fix: revise `preview()` for better operability in Ibis PySpark backend
2 parents 0eb4d41 + 65f4b99 commit dc6c2dc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pointblank/validate.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,8 @@ def _generate_display_table(
543543
# - get the row numbers for the table
544544
# - convert the table to a Polars or Pandas DF
545545
if ibis_tbl:
546+
import ibis
547+
546548
# Get the Schema of the table
547549
tbl_schema = Schema(tbl=data)
548550

@@ -558,13 +560,15 @@ def _generate_display_table(
558560
if row_number_list is None:
559561
row_number_list = range(1, n_rows + 1)
560562
else:
561-
# Get the first and last n rows of the table
563+
# Get the first n and last n rows of the table
562564
data_head = data.head(n_head)
563-
row_numbers_head = range(1, n_head + 1)
564-
data_tail = data[(n_rows - n_tail) : n_rows]
565-
row_numbers_tail = range(n_rows - n_tail + 1, n_rows + 1)
565+
data_tail = data.filter(
566+
[ibis.row_number() >= (n_rows - n_tail), ibis.row_number() <= n_rows]
567+
)
566568
data_subset = data_head.union(data_tail)
567569

570+
row_numbers_head = range(1, n_head + 1)
571+
row_numbers_tail = range(n_rows - n_tail + 1, n_rows + 1)
568572
if row_number_list is None:
569573
row_number_list = list(row_numbers_head) + list(row_numbers_tail)
570574

0 commit comments

Comments
 (0)