BigQuery无法将'null'解析为字段的int [英] BigQuery Could not parse 'null' as int for field

查看:91
本文介绍了BigQuery无法将'null'解析为字段的int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图将csv文件加载到bigquery表中.在某些列中,类型为INTEGER,但某些缺少的值为NULL.因此,当我使用命令bq load进行加载时,出现以下错误:

Tried to load csv files into bigquery table. There are columns where the types are INTEGER, but some missing values are NULL. So when I use the command bq load to load, got the following error:

无法将'null'解析为字段的int

Could not parse 'null' as int for field

所以我想知道最好的解决方案是什么,必须先重新处理数据才能加载bq?

So I am wondering what are the best solutions to deal with this, have to reprocess the data first for bq to load?

推荐答案

您将需要转换数据以最终获得预期的架构和数据.代替INTEGER,将列指定为STRING类型.将CSV文件加载到您不打算长期使用的表中,例如YourTempTable.在BigQuery用户界面中,单击显示选项",然后选择具有所需表名的目标表.现在运行查询:

You'll need to transform the data in order to end up with the expected schema and data. Instead of INTEGER, specify the column as having type STRING. Load the CSV file into a table that you don't plan to use long-term, e.g. YourTempTable. In the BigQuery UI, click "Show Options", then select a destination table with the table name that you want. Now run the query:

#standardSQL
SELECT * REPLACE(SAFE_CAST(x AS INT64) AS x)
FROM YourTempTable;

这会将字符串值转换为整数,其中将'null'视为null.

This will convert the string values to integers where 'null' is treated as null.

这篇关于BigQuery无法将'null'解析为字段的int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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