1616
1717from __future__ import annotations
1818
19- from typing import Optional
19+ from enum import Enum
20+ from typing import Literal , Optional
2021import warnings
2122
2223import google .api_core .exceptions
2627import bigframes .constants
2728import bigframes .exceptions
2829
30+
31+ class OrderingMode (Enum ):
32+ STRICT = "strict"
33+ PARTIAL = "partial"
34+
35+
2936SESSION_STARTED_MESSAGE = (
3037 "Cannot change '{attribute}' once a session has started. "
3138 "Call bigframes.pandas.close_session() first, if you are using the bigframes.pandas API."
@@ -57,6 +64,14 @@ def _validate_location(value: Optional[str]):
5764 )
5865
5966
67+ def _validate_ordering_mode (value : str ) -> OrderingMode :
68+ if value .casefold () == OrderingMode .STRICT .value .casefold ():
69+ return OrderingMode .STRICT
70+ if value .casefold () == OrderingMode .PARTIAL .value .casefold ():
71+ return OrderingMode .PARTIAL
72+ raise ValueError ("Ordering mode must be one of 'strict' or 'partial'." )
73+
74+
6075class BigQueryOptions :
6176 """Encapsulates configuration for working with a session."""
6277
@@ -71,7 +86,7 @@ def __init__(
7186 kms_key_name : Optional [str ] = None ,
7287 skip_bq_connection_check : bool = False ,
7388 * ,
74- _strictly_ordered : bool = True ,
89+ ordering_mode : Literal [ "strict" , "partial" ] = "strict" ,
7590 ):
7691 self ._credentials = credentials
7792 self ._project = project
@@ -82,8 +97,8 @@ def __init__(
8297 self ._kms_key_name = kms_key_name
8398 self ._skip_bq_connection_check = skip_bq_connection_check
8499 self ._session_started = False
85- # Determines the ordering strictness for the session. For internal use only.
86- self ._strictly_ordered_internal = _strictly_ordered
100+ # Determines the ordering strictness for the session.
101+ self ._ordering_mode = _validate_ordering_mode ( ordering_mode )
87102
88103 @property
89104 def application_name (self ) -> Optional [str ]:
@@ -241,6 +256,10 @@ def kms_key_name(self, value: str):
241256 self ._kms_key_name = value
242257
243258 @property
244- def _strictly_ordered (self ) -> bool :
245- """Internal use only. Controls whether total row order is always maintained for DataFrame/Series."""
246- return self ._strictly_ordered_internal
259+ def ordering_mode (self ) -> Literal ["strict" , "partial" ]:
260+ """Controls whether total row order is always maintained for DataFrame/Series."""
261+ return self ._ordering_mode .value
262+
263+ @ordering_mode .setter
264+ def ordering_mode (self , ordering_mode : Literal ["strict" , "partial" ]) -> None :
265+ self ._ordering_mode = _validate_ordering_mode (ordering_mode )
0 commit comments