How can I load data in same order as CSV on BigQuery

允我心安 提交于 2020-01-22 02:57:48

问题


Is it possible to load data in the same row order as in the original input CSV file? These files are not sorted in any particular order or by any particular column. Looks like as BigQuery loading is distributed, the order is not predictible, however tends to group nulls first.


回答1:


The only way to achieve this given the way BigQuery works behind the scenes would be to add an extra column to the csv that defines the desired order. BigQuery shuffles data around behind the scenes to optimise storage and query speed so relying on any order is impossible.

But sorting is easy, so if your dataset contains the equivalent of a rownumber, you can always recover any ordering of rows with a simple sort.




回答2:


No, it is not possible. Moreover - once data is loaded into BigQuery table, and doesn't preserve static order, as BigQuery may reshuffle rows in order to optimize storage and future query performance. Result rows of any SELECT query without outermost ORDER BY may come in different order on different invocations.



来源:https://stackoverflow.com/questions/38908537/how-can-i-load-data-in-same-order-as-csv-on-bigquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!