我正在使用nodejs client将记录流到bigquery,除了我的时间戳字段上的某些错误外,一切都很好,似乎附加了一堆数字。
错误:
Cannot return an invalid timestamp value of 1551711230131000064 microseconds relative to the Unix epoch. The range of valid timestamp values is [0001-01-1 00:00:00, 9999-12-31 23:59:59.999999]; error in writing field ts
代码生成 timestamp
:
const ts = Date.now().toString(); // tried without toString()
代码存储在bigquery :
function insertIntoTable(id, ts, url, domain) {
console.log('ts: ', ts) // this logs the correct format
table.insert({
id : id,
ts : ts,
url : url,
domain : domain,
})
.then(data => {
console.log(data);
})
.catch(err => {
console.log(err);
})
}
在此示例i中,记录了正确的尺寸时间戳 -> ts: 1551711230131
该字段在表中设置为TIMESTAMP
类型。
对问题可能有什么想法?
尝试使用此
Date.now() / 1000
而不是这个
Date.now().toString()