BigQuery - 主导函数将时间戳字段转换为整数 [英] BigQuery - lead function converts timestamp field to integer

查看:209
本文介绍了BigQuery - 主导函数将时间戳字段转换为整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 

在时间戳字段中,引导函数(或任何分析函数)看起来像是一个整数类型的列,而不是时间戳字段。 code> select
transaction,
lead(time,1)over(按时间排序)nextTime,
from [fh-bigquery:bigdataspain.aggr_transaction_clean]
limit 1000

有没有办法解决这个问题,而不用另外的查询包装?

解决方案

这是BigQuery中的一个错误,它在分析函数中丢失了类型信息。虽然它已经得到解决,但是解决方法确实包含以下内容:

 选择事务,usec_to_timestamp(nextTime)from(
选择
交易,
领先(时间,1)结束(按时间排序)nextTime,
from [fh-bigquery:bigdataspain.aggr_transaction_clean]
limit 1000)


It seems like lead function (or any analytic function) on a timestamp field results in a column of type integer instead of a timestamp field.

select 
transaction,
  lead(time,1) over (order by time) nextTime,
  from [fh-bigquery:bigdataspain.aggr_transaction_clean]
  limit 1000

Is there any way to solve this without wrapping with another query?

解决方案

This is a bug in BigQuery, it loses type information in analytic functions. While it is getting fixed, the workaround is indeed to wrap with the following:

select transaction, usec_to_timestamp(nextTime) from (
select 
transaction,
  lead(time,1) over (order by time) nextTime,
  from [fh-bigquery:bigdataspain.aggr_transaction_clean]
  limit 1000)

这篇关于BigQuery - 主导函数将时间戳字段转换为整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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