Skip to content

Commit c6f10f7

Browse files
committed
fix the double click for next page
1 parent 98468fa commit c6f10f7

4 files changed

Lines changed: 36 additions & 7 deletions

File tree

packages/bigframes/bigframes/display/anywidget.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ def update_ui():
256256
self._batch_iter = batch_iter
257257
self._cached_batches = cached_batches
258258
self._all_data_loaded = all_data_loaded
259+
self._last_sort_state = _SortState((), ())
259260
self.row_count = total_rows
260261
self.table_html = initial_html
261262
self.is_deferred_mode = False

packages/bigframes/notebooks/streaming/streaming_dataframe.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# BigFrames StreamingDataFrame",
8-
"bigframes.streaming.StreamingDataFrame is a special DataFrame type that allows simple operations and can create streaming jobs to process real-time data and reverse ETL output to Bigtable and Pub/Sub using [BigQuery continuous queries](https://cloud.google.com/bigquery/docs/continuous-queries-introduction).\n",
7+
"# BigFrames StreamingDataFramebigframes.streaming.StreamingDataFrame is a special DataFrame type that allows simple operations and can create streaming jobs to process real-time data and reverse ETL output to Bigtable and Pub/Sub using [BigQuery continuous queries](https://cloud.google.com/bigquery/docs/continuous-queries-introduction).\n",
98
"\n",
109
"In this notebook, we will:\n",
1110
"* Create a StreamingDataFrame from a BigQuery table\n",
@@ -31,6 +30,7 @@
3130
],
3231
"source": [
3332
"import bigframes\n",
33+
"\n",
3434
"# make sure bigframes version >= 1.12.0\n",
3535
"bigframes.__version__"
3636
]
@@ -43,6 +43,7 @@
4343
"source": [
4444
"import bigframes.pandas as bpd\n",
4545
"import bigframes.streaming as bst\n",
46+
"\n",
4647
"bigframes.options._bigquery_options.project = \"bigframes-load-testing\" # Change to your own project ID\n",
4748
"job_id_prefix = \"test_streaming_\""
4849
]
@@ -97,8 +98,7 @@
9798
"cell_type": "markdown",
9899
"metadata": {},
99100
"source": [
100-
"## Create, select, filter and preview",
101-
"Create the StreamingDataFrame from a BigQuery table, select certain columns, filter rows and preview the output"
101+
"## Create, select, filter and previewCreate the StreamingDataFrame from a BigQuery table, select certain columns, filter rows and preview the output"
102102
]
103103
},
104104
{
@@ -559,7 +559,7 @@
559559
],
560560
"metadata": {
561561
"kernelspec": {
562-
"display_name": "venv",
562+
"display_name": "Python 3 (ipykernel)",
563563
"language": "python",
564564
"name": "python3"
565565
},
@@ -573,9 +573,9 @@
573573
"name": "python",
574574
"nbconvert_exporter": "python",
575575
"pygments_lexer": "ipython3",
576-
"version": "3.12.1"
576+
"version": "3.10.19"
577577
}
578578
},
579579
"nbformat": 4,
580-
"nbformat_minor": 2
580+
"nbformat_minor": 4
581581
}

packages/bigframes/tests/js/table_widget_angular.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ describe('TableWidgetAngular', () => {
141141

142142
// Act (Click Run Query)
143143
runButton.click();
144+
await new Promise((resolve) => setTimeout(resolve, 50));
144145

145146
// Assert (Execution requested)
146147
expect(model.set).toHaveBeenCalledWith('start_execution', true);

packages/bigframes/tests/unit/display/test_anywidget.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,3 +485,30 @@ def test_deferred_mode_execution_error(mock_deferred_df):
485485

486486
assert widget.is_deferred_mode is True
487487
assert widget._error_message == "Query Failed"
488+
489+
490+
def test_deferred_mode_execution_does_not_reset_page_on_navigation(
491+
mock_deferred_df, mock_df_deferred
492+
):
493+
from bigframes.display.anywidget import TableWidget
494+
495+
mock_deferred_df.execute.return_value = mock_df_deferred
496+
497+
batches = mock.MagicMock()
498+
batch_df = pd.DataFrame({"A": [1], "B": ["a"], "C": [1.0], "D": [True]})
499+
batches.__iter__.return_value = iter([batch_df])
500+
batches.total_rows = 50
501+
mock_df_deferred.to_pandas_batches.return_value = batches
502+
503+
with bigframes.option_context("display.render_mode", "anywidget"):
504+
widget = TableWidget(mock_deferred_df)
505+
widget.page_size = 10
506+
widget.start_execution = True
507+
508+
thread = getattr(widget, "_execution_thread", None)
509+
if thread is not None:
510+
thread.join(timeout=5)
511+
512+
assert widget.page == 0
513+
widget.page = 1
514+
assert widget.page == 1

0 commit comments

Comments
 (0)