17
17
from __future__ import annotations
18
18
19
19
import functools
20
- from typing import Protocol , TYPE_CHECKING
20
+ from typing import Optional , Protocol , TYPE_CHECKING
21
21
22
22
import bigframes .constants
23
23
import bigframes .exceptions
@@ -32,20 +32,23 @@ def _session(self) -> Session:
32
32
...
33
33
34
34
35
- def requires_strict_ordering ():
35
+ def requires_strict_ordering (suggestion : Optional [ str ] = None ):
36
36
def decorator (meth ):
37
37
@functools .wraps (meth )
38
38
def guarded_meth (object : HasSession , * args , ** kwargs ):
39
- enforce_ordered (object , meth .__name__ )
39
+ enforce_ordered (object , meth .__name__ , suggestion )
40
40
return meth (object , * args , ** kwargs )
41
41
42
42
return guarded_meth
43
43
44
44
return decorator
45
45
46
46
47
- def enforce_ordered (object : HasSession , opname : str ) -> None :
47
+ def enforce_ordered (
48
+ object : HasSession , opname : str , suggestion : Optional [str ] = None
49
+ ) -> None :
48
50
if not object ._session ._strictly_ordered :
51
+ suggestion_substr = suggestion + " " if suggestion else ""
49
52
raise bigframes .exceptions .OrderRequiredError (
50
- f"Op { opname } not supported when strict ordering is disabled. { bigframes .constants .FEEDBACK_LINK } "
53
+ f"Op { opname } not supported when strict ordering is disabled. { suggestion_substr } { bigframes .constants .FEEDBACK_LINK } "
51
54
)
0 commit comments