数据中的BigQuery自动转换字段 [英] Bigquery autoconverting fields in data

查看:317
本文介绍了数据中的BigQuery自动转换字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

在Bigquery自动检测中,我将以下json数据加载到BQ表中.

In Bigquery autodetect,i have following json data being loaded to BQ table.

"a":","b":"q"

"a":"","b":"q"

"a":","b":"q1"

"a":"","b":"q1"

"a":"1","b":"w2"

"a":"1","b":"w2"

现在,当上传此json时,BQ引发错误,无法将字段"a"转换为整数.

Now,when this json is uploaded,BQ throws error cannot convert field "a" to integer.

想法

我猜BQ,在读取两行之后,BQ推断字段"a"为字符串,然后稍后在"a":"1"出现时,BQ尝试将其转换为整数(但是为什么?).

I guess BQ,after reading two rows,BQ infers field "a" as string and then later when "a":"1" comes ,BQ tries to convert it to integer(But why?).

因此,为了进行更多调查,我对json进行了如下修改.

So,to investigate more,i modified the json as follows.

"a":"f","b":"q"

"a":"f","b":"q"

"a":"v","b":"q1"

"a":"v","b":"q1"

"a":"1","b":"w2"

"a":"1","b":"w2"

现在,当我使用此json时,没有错误,数据已顺利加载到表中.

Now,when i use this json,no errors,data is smoothly loaded to table.

我不知道为什么在这种情况下,如果BQ将字段"a"推断为字符串,为什么它不会引发任何错误(为什么它不尝试将"a":"1"转换为整数)?

I don't see as to why in this scenario,if BQ infers field "a" as string,how come it throws no error (why does it not try to convert "a":"1" to integer)?

查询

我假设是,BQ仅在看到字段中的数据时才将字段推断为特定类型("a":"1"或"a":"f"),但是我没有得到这就是为什么BQ尝试自动将字符串类型的("a":"1")转换为整数.

What i assume is,BQ infers a field to a particular type ,only when it sees data in the field("a":"1" or "a":"f"),but what i don't get is why is BQ trying to automatically converting ("a":"1") to integer when it is of type string.

此自动转换可能会引起问题.

This autoconversion could create issues.

请让我知道,如果我的假设是正确的,并且由于实时数据不在我的控制范围之内,该如何避免此类错误,我只能控制我的代码(使用自动检测).

Please let me know,if my assumptions are correct and what could be done to avoid such errors because realtime data isnot in my control,i can only control my code(using autodetect).

推荐答案

这是自动检测的错误.我们正在努力解决.

It is a bug with autodetect. We are working on a fix.

这篇关于数据中的BigQuery自动转换字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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