16
16
17
17
from __future__ import annotations
18
18
19
- from typing import Optional
19
+ from enum import Enum
20
+ from typing import Literal , Optional
20
21
import warnings
21
22
22
23
import google .api_core .exceptions
26
27
import bigframes .constants
27
28
import bigframes .exceptions
28
29
30
+
31
+ class OrderingMode (Enum ):
32
+ STRICT = "strict"
33
+ PARTIAL = "partial"
34
+
35
+
29
36
SESSION_STARTED_MESSAGE = (
30
37
"Cannot change '{attribute}' once a session has started. "
31
38
"Call bigframes.pandas.close_session() first, if you are using the bigframes.pandas API."
@@ -57,6 +64,14 @@ def _validate_location(value: Optional[str]):
57
64
)
58
65
59
66
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
+
60
75
class BigQueryOptions :
61
76
"""Encapsulates configuration for working with a session."""
62
77
@@ -71,7 +86,7 @@ def __init__(
71
86
kms_key_name : Optional [str ] = None ,
72
87
skip_bq_connection_check : bool = False ,
73
88
* ,
74
- _strictly_ordered : bool = True ,
89
+ ordering_mode : Literal [ "strict" , "partial" ] = "strict" ,
75
90
):
76
91
self ._credentials = credentials
77
92
self ._project = project
@@ -82,8 +97,8 @@ def __init__(
82
97
self ._kms_key_name = kms_key_name
83
98
self ._skip_bq_connection_check = skip_bq_connection_check
84
99
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 )
87
102
88
103
@property
89
104
def application_name (self ) -> Optional [str ]:
@@ -241,6 +256,10 @@ def kms_key_name(self, value: str):
241
256
self ._kms_key_name = value
242
257
243
258
@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