@@ -112,26 +112,32 @@ def __init__(self, dataframe: bigframes.dataframe.DataFrame):
112112 self .page_size = initial_page_size
113113 self .max_columns = initial_max_columns
114114
115- # TODO(b/469861913): Nested columns from structs (e.g., 'struct_col.name') are not currently sortable.
116- # TODO(b/463754889): Support non-string column labels for sorting.
117- if all (isinstance (col , str ) for col in dataframe .columns ):
118- with warnings .catch_warnings ():
119- warnings .simplefilter ("ignore" , bigframes .exceptions .JSONDtypeWarning )
120- warnings .simplefilter ("ignore" , category = FutureWarning )
121- self .orderable_columns = [
122- str (col_name )
123- for col_name , dtype in dataframe .dtypes .items ()
124- if dtypes .is_orderable (dtype )
125- ]
126- else :
127- self .orderable_columns = []
115+ self .orderable_columns = self ._get_orderable_columns (dataframe )
128116
129117 self ._initial_load ()
130118
131119 # Signals to the frontend that the initial data load is complete.
132120 # Also used as a guard to prevent observers from firing during initialization.
133121 self ._initial_load_complete = True
134122
123+ def _get_orderable_columns (
124+ self , dataframe : bigframes .dataframe .DataFrame
125+ ) -> list [str ]:
126+ """Determine which columns can be used for client-side sorting."""
127+ # TODO(b/469861913): Nested columns from structs (e.g., 'struct_col.name') are not currently sortable.
128+ # TODO(b/463754889): Support non-string column labels for sorting.
129+ if not all (isinstance (col , str ) for col in dataframe .columns ):
130+ return []
131+
132+ with warnings .catch_warnings ():
133+ warnings .simplefilter ("ignore" , bigframes .exceptions .JSONDtypeWarning )
134+ warnings .simplefilter ("ignore" , category = FutureWarning )
135+ return [
136+ str (col_name )
137+ for col_name , dtype in dataframe .dtypes .items ()
138+ if dtypes .is_orderable (dtype )
139+ ]
140+
135141 def _initial_load (self ) -> None :
136142 """Get initial data and row count."""
137143 # obtain the row counts
0 commit comments