File tree 1 file changed +20
-4
lines changed
bigquery/google/cloud/bigquery
1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change 46
46
_DONE_STATE = "DONE"
47
47
_STOPPED_REASON = "stopped"
48
48
_TIMEOUT_BUFFER_SECS = 0.1
49
+ _CONTAINS_ORDER_BY = re .compile (r"ORDER\s+BY" , re .IGNORECASE )
49
50
50
51
_ERROR_REASON_TO_EXCEPTION = {
51
52
"accessDenied" : http_client .FORBIDDEN ,
@@ -94,11 +95,26 @@ def _error_result_to_exception(error_result):
94
95
95
96
96
97
def _contains_order_by (query ):
97
- """Do we need to preserve the order of the query results?"""
98
- if query is None :
99
- return False
98
+ """Do we need to preserve the order of the query results?
100
99
101
- return re .search (r"ORDER\s+BY" , query , re .IGNORECASE ) is not None
100
+ This function has known false positives, such as with ordered window
101
+ functions:
102
+
103
+ .. code-block:: sql
104
+
105
+ SELECT SUM(x) OVER (
106
+ window_name
107
+ PARTITION BY...
108
+ ORDER BY...
109
+ window_frame_clause)
110
+ FROM ...
111
+
112
+ This false positive failure case means the behavior will be correct, but
113
+ downloading results with the BigQuery Storage API may be slower than it
114
+ otherwise would. This is preferable to the false negative case, where
115
+ results are expected to be in order but are not (due to parallel reads).
116
+ """
117
+ return query and _CONTAINS_ORDER_BY .search (query )
102
118
103
119
104
120
class Compression (object ):
You can’t perform that action at this time.
0 commit comments