Skip to content

Commit 88c451e

Browse files
committed
display page 1 of many
1 parent b2c99a2 commit 88c451e

File tree

3 files changed

+23
-45
lines changed

3 files changed

+23
-45
lines changed

bigframes/display/table_widget.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,14 @@ function render({ model, el }) {
8989
if (rowCount === null) {
9090
// Unknown total rows
9191
rowCountLabel.textContent = "Total rows unknown";
92-
paginationLabel.textContent = `Page ${(currentPage + 1).toLocaleString()}`;
92+
paginationLabel.textContent = `Page ${(currentPage + 1).toLocaleString()} of many`;
9393
prevPage.disabled = currentPage === 0;
9494
nextPage.disabled = false; // Allow navigation until we hit the end
9595
} else {
9696
// Known total rows
9797
const totalPages = Math.ceil(rowCount / pageSize);
9898
rowCountLabel.textContent = `${rowCount.toLocaleString()} total rows`;
99-
paginationLabel.textContent = `Page ${(
100-
currentPage + 1
101-
).toLocaleString()} of ${(totalPages || 1).toLocaleString()}`;
99+
paginationLabel.textContent = `Page ${(currentPage + 1).toLocaleString()} of ${rowCount.toLocaleString()}`;
102100
prevPage.disabled = currentPage === 0;
103101
nextPage.disabled = currentPage >= totalPages - 1;
104102
}

notebooks/dataframes/anywidget_mode.ipynb

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,7 @@
3535
"execution_count": 2,
3636
"id": "ca22f059",
3737
"metadata": {},
38-
"outputs": [
39-
{
40-
"name": "stderr",
41-
"output_type": "stream",
42-
"text": [
43-
"/usr/local/google/home/shuowei/src/python-bigquery-dataframes/venv/lib/python3.10/site-packages/google/api_core/_python_version_support.py:266: FutureWarning: You are using a Python version (3.10.15) which Google will stop supporting in new releases of google.api_core once it reaches its end of life (2026-10-04). Please upgrade to the latest Python version, or at least Python 3.11, to continue receiving updates for google.api_core past that date.\n",
44-
" warnings.warn(message, FutureWarning)\n"
45-
]
46-
}
47-
],
38+
"outputs": [],
4839
"source": [
4940
"import bigframes.pandas as bpd"
5041
]
@@ -151,7 +142,7 @@
151142
{
152143
"data": {
153144
"application/vnd.jupyter.widget-view+json": {
154-
"model_id": "47795eaa10f149aeb99574232c0936eb",
145+
"model_id": "710b4e9c06df4faf82011dd676e9d9a5",
155146
"version_major": 2,
156147
"version_minor": 1
157148
},
@@ -214,7 +205,7 @@
214205
{
215206
"data": {
216207
"application/vnd.jupyter.widget-view+json": {
217-
"model_id": "8354ce0f82d3495a9b630dfc362f73ee",
208+
"model_id": "62661c02a1a742d79e53dcb047343e86",
218209
"version_major": 2,
219210
"version_minor": 1
220211
},
@@ -293,27 +284,8 @@
293284
{
294285
"data": {
295286
"text/html": [
296-
"\n",
297-
" Query started with request ID bigframes-dev:US.c45952fb-01b4-409c-9da4-f7c5bfc0d47d.<details><summary>SQL</summary><pre>SELECT\n",
298-
"`state` AS `state`,\n",
299-
"`gender` AS `gender`,\n",
300-
"`year` AS `year`,\n",
301-
"`name` AS `name`,\n",
302-
"`number` AS `number`\n",
303-
"FROM\n",
304-
"(SELECT\n",
305-
" *\n",
306-
"FROM (\n",
307-
" SELECT\n",
308-
" `state`,\n",
309-
" `gender`,\n",
310-
" `year`,\n",
311-
" `name`,\n",
312-
" `number`\n",
313-
" FROM `bigquery-public-data.usa_names.usa_1910_2013` FOR SYSTEM_TIME AS OF TIMESTAMP(&#x27;2025-10-30T21:48:48.979701+00:00&#x27;)\n",
314-
") AS `t0`)\n",
315-
"ORDER BY `name` ASC NULLS LAST ,`year` ASC NULLS LAST ,`state` ASC NULLS LAST\n",
316-
"LIMIT 5</pre></details>\n",
287+
"✅ Completed. \n",
288+
" Query processed 171.4 MB in a moment of slot time.\n",
317289
" "
318290
],
319291
"text/plain": [
@@ -333,7 +305,7 @@
333305
{
334306
"data": {
335307
"application/vnd.jupyter.widget-view+json": {
336-
"model_id": "59461286a17d4a42b6be6d9d9c7bf7e3",
308+
"model_id": "b92000a35d0c4b8a9a8aaef4784e94dd",
337309
"version_major": 2,
338310
"version_minor": 1
339311
},
@@ -360,7 +332,7 @@
360332
"metadata": {},
361333
"source": [
362334
"### Handling of Invalid Row Count\n",
363-
"In cases where the total number of rows cannot be determined, `row_count` will be `None`. The widget will display 'Total rows unknown', and you can navigate forward until you reach the end of the available data. If you navigate beyond the last page, the widget will automatically return to the last valid page."
335+
"In cases where the total number of rows cannot be determined, `row_count` will be `None`. The widget will display 'Page X of many', and you can navigate forward until you reach the end of the available data. If you navigate beyond the last page, the widget will automatically return to the last valid page."
364336
]
365337
},
366338
{
@@ -382,7 +354,7 @@
382354
"data": {
383355
"text/html": [
384356
"✅ Completed. \n",
385-
" Query processed 85.9 kB in 14 seconds of slot time.\n",
357+
" Query processed 85.9 kB in 13 seconds of slot time.\n",
386358
" "
387359
],
388360
"text/plain": [
@@ -396,7 +368,7 @@
396368
"name": "stderr",
397369
"output_type": "stream",
398370
"text": [
399-
"/usr/local/google/home/shuowei/src/python-bigquery-dataframes/bigframes/dtypes.py:969: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
371+
"/usr/local/google/home/shuowei/src/python-bigquery-dataframes/bigframes/dtypes.py:987: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
400372
"instead of using `db_dtypes` in the future when available in pandas\n",
401373
"(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
402374
" warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n"
@@ -417,7 +389,7 @@
417389
{
418390
"data": {
419391
"application/vnd.jupyter.widget-view+json": {
420-
"model_id": "d1794b42579542a8980bd158e521bd3e",
392+
"model_id": "2620318ca07e405fa7ce950a2d931e6a",
421393
"version_major": 2,
422394
"version_minor": 1
423395
},

tests/system/small/test_anywidget.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,12 +591,12 @@ def test_widget_with_unknown_row_count_should_auto_navigate_to_last_page(
591591
assert "row_0" not in html # First row should not be visible
592592

593593

594-
def test_widget_with_unknown_row_count_should_display_correct_ui_text(
594+
def test_widget_with_unknown_row_count_should_set_none_state_for_frontend(
595595
session: bf.Session,
596596
):
597597
"""
598-
Given a widget with unknown row count, the JavaScript frontend should
599-
display appropriate text indicating the total is unknown.
598+
Given a widget with unknown row count, its `row_count` traitlet should be
599+
`None`, which signals the frontend to display 'Page X of many'.
600600
"""
601601
from bigframes.display import TableWidget
602602

@@ -621,6 +621,10 @@ def test_widget_with_unknown_row_count_should_display_correct_ui_text(
621621
assert widget.page == 0
622622
assert widget.page_size == 2
623623

624+
# Force data loading by accessing table_html. This also ensures that
625+
# rendering does not raise an exception.
626+
_ = widget.table_html
627+
624628

625629
def test_widget_with_unknown_row_count_should_allow_forward_navigation(
626630
session: bf.Session,
@@ -688,5 +692,9 @@ def test_widget_with_unknown_row_count_empty_dataframe(
688692

689693

690694
# TODO(shuowei): Add tests for custom index and multiindex
695+
696+
691697
# This may not be necessary for the SQL Cell use case but should be
698+
699+
692700
# considered for completeness.

0 commit comments

Comments
 (0)