-
Notifications
You must be signed in to change notification settings - Fork 62
feat: Implement column sorting for interactive table widget #2255
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
base: main
Are you sure you want to change the base?
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
bigframes/display/anywidget.py
Outdated
| except KeyError: | ||
| logging.warning( | ||
| f"Attempted to sort by unknown column: {self.sort_column}" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we catching this exception and dropping it? If we get to this state something bad has happened and the user should know about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is my plan:
When a KeyError is caught, the current implementation does the following:
- Notifies the user: It sets self._error_message to a user-friendly message like "Column '...' not found.". The frontend will then display this error.
- Reverts to unsorted: It resets self.sort_column = "".
- Displays the unsorted table: The function then continues, but since sort_column is now empty, it fetches and displays the data in its original, unsorted order.
bigframes/display/table_widget.js
Outdated
| const headers = tableContainer.querySelectorAll("th"); | ||
| headers.forEach((header) => { | ||
| const columnName = header.textContent.trim(); | ||
| if (columnName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all data types are sortable. See the orderable property in our dtypes.
| orderable: bool = False |
We should not add the handler or arrow to columns that we can't sort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the plan:
- Display a dot (●) indicator for all sortable columns by default
- Allow users to cycle through three states: unsorted (●) → ascending (▲) → descending (▼) → unsorted (●)
- Only show sorting UI for columns with orderable data types
|
@tswast Upon checking, the failed e2e tests |
This PR introduces column sorting functionality to the interactive table widget.
Updated Python backend and JS/CSS frontend to allow sorting by columns.
Three-State Sorting UI:
●) is now hidden by default and only appears when the user hovers the mouse over a column header●) → ascending (▲) → descending (▼) → unsorted (●).●, ▲, ▼) are displayed in column headers to reflect the current sort state.Tests
2.1) Updated
paginated_pandas_dffixture for better sorting test coverage2.2) Added new system tests to verify ascending, descending, and multi-column sorting.
Docs has been updated to document the new features. The main description now mentions column sorting and adjustable widths, and a new section has been added to explain how to use the column resizing feature. The sorting section was also updated to mention that the indicators are only visible on hover.
Fixes #<459835971> 🦕