When you read in a Google BigQuery table using code that includes an ORDER BY clause or a BY statement, the data might not be in sorted order.
This issue might occur when you use the READ_MODE=STORAGE option. With READ_MODE=STORAGE, the data is broken into groups that are read in parallel. Each group is appended one after another in the order in which they finish. If the order of the reads that are finished is not the same order as the sorted data, records that are later in the sort order might appear before records that are earlier in the sort order. As a result, the data is no longer sorted.
If the data must be sorted, use one of the following workarounds: