将CSV加载到BigQuery表中时出现问题

将CSV加载到BigQuery表中时出现问题

本文介绍了将CSV加载到BigQuery表中时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用我存储在 GCS 中的一个非常简单的csv文件创建一个 BigQuery 表.我一遍又一遍地得到相同的错误:

Im trying to create a BigQuery table using a pretty simple csv file I have stored in GCS.I keep getting the same error over and over again:

Could not parse '1/1/2008' as datetime for field XXX

我检查了csv文件是否未损坏,并且设法将所有内容上传到一列,以便 BigQuery 可以读取该文件.

I've checked that the csv file isn't corrupted, and I've managed to upload everything into one column so the file is readable by BigQuery.

我已经在任何空字段中添加了 NULL 一词,以为连续的分隔符可能会导致问题,但我仍然面临着同样的问题.

I've added the word NULL to any empty fields thinking consecutive delimiters may be causing the issues but I am still facing the same issue.

我了解数据,我了解数据和CSV文件.

I know data, I understand data and CSV files.

推荐答案

BigQuery不能将'1/1/2008'转换为DATETIME,而是期望像'2008-1-1'

BigQuery cannot cast '1/1/2008' as DATETIME and rather would expecting something like '2008-1-1'

因此,您可以修改CSV文件,也可以仅将STRING用于该XXX字段,然后在查询中将其转换为DATETIME-如下

So, you can either modify your CSV file or just use STRING for that XXX field and than translate it into DATETIME in your queries - like below

#standardSQL
SELECT PARSE_DATETIME('%d/%m/%Y', '1/1/2008')

这篇关于将CSV加载到BigQuery表中时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 00:38