Google bigquery 正在尝试将历元代码字段(字符串类型)转换为时间戳
尝试从历元代码转换为时间戳,在遗留SQL中工作正常,而在标准SQL中我遇到了一个错误。 字段名custom_Field_6(字符串类型字段)表示纪元时间,我想将其转换为时间戳(在标准SQL中) 在遗留SQL中,我执行了以下操作:Google bigquery 正在尝试将历元代码字段(字符串类型)转换为时间戳,google-bigquery,Google Bigquery,尝试从历元代码转换为时间戳,在遗留SQL中工作正常,而在标准SQL中我遇到了一个错误。 字段名custom_Field_6(字符串类型字段)表示纪元时间,我想将其转换为时间戳(在标准SQL中) 在遗留SQL中,我执行了以下操作: 挑选 自定义_字段_6作为自定义_字段_6, 将时间戳(自定义字段)转换为自定义字段 来自[yellowhead visionbi rivery:yellowhead\u产品附加\u转换] 在标准sql中: 选择 自定义_字段_6作为自定义_字段_6, 转换为自定义字
挑选
自定义_字段_6作为自定义_字段_6,
将时间戳(自定义字段)转换为自定义字段
来自[yellowhead visionbi rivery:yellowhead\u产品附加\u转换]
在标准sql中:
选择
自定义_字段_6作为自定义_字段_6,
转换为自定义字段的强制转换(自定义字段为日期)
从
yellowhead-visionbi-rivery.yellowhead\u prod.affise\u转换``
:“无效日期”位于BigQuery标准SQL的id下方
#standardSQL
SELECT
custom_field_6,
TIMESTAMP_SECONDS(CAST(custom_field_6 AS INT64)) custom_field_6_convert
FROM `yellowhead-visionbi-rivery.yellowhead_prod.affise_conversions`
您可以使用以下虚拟数据对其进行测试
#standardSQL
WITH `project.dataset.table` AS (
SELECT '1540051185' custom_field_6 UNION ALL
SELECT '1540252572'
)
SELECT
custom_field_6,
TIMESTAMP_SECONDS(CAST(custom_field_6 AS INT64)) custom_field_6_convert
FROM `project.dataset.table`
结果
Row custom_field_6 custom_field_6_convert
1 1540051185 2018-10-20 15:59:45 UTC
2 1540252572 2018-10-22 23:56:12 UTC
这是我得到的错误:查询失败错误:错误int64值:{installed_at}作业ID:yellowhead visionbi rivery:US.bquijob_70505117_1673A6CFA50提供数据示例