如何在 BigQuery 上以与 CSV 相同的顺序加载数据 [英] How can I load data in same order as CSV on BigQuery

查看:19
本文介绍了如何在 BigQuery 上以与 CSV 相同的顺序加载数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以按照与原始输入 CSV 文件相同的行顺序加载数据?这些文件没有按任何特定顺序或任何特定列排序.看起来 BigQuery 加载是分布式的,顺序是不可预测的,但倾向于先对空值进行分组.

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.

推荐答案

鉴于 BigQuery 在幕后的工作方式,实现这一目标的唯一方法是向 csv 添加一个额外的列来定义所需的顺序.BigQuery 在后台混洗数据以优化存储和查询速度,因此不可能依赖任何顺序.

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.

这篇关于如何在 BigQuery 上以与 CSV 相同的顺序加载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆