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

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

问题描述

是否可以按照与原始输入CSV文件相同的行顺序加载数据?这些文件不按任何特定顺序或任何特定列进行排序。
看起来像BigQuery的加载是分布式的,顺序是不可预测的,然而往往会先将空值组合。

以BigQuery在幕后工作的方式实现此目的的唯一方法是向csv添加一个额外的列,以定义所需的顺序。 BigQuery在幕后对数据进行混洗,以优化存储和查询速度,因此依靠任何订单是不可能的。但是排序很简单,所以如果你的数据集包含相当于一个rownumber,你可以随时用一个简单的排序来恢复任何行的排序。

$ b



$ b

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.

解决方案

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天全站免登陆