apache-kafka - 如何在 Kafka 连接中将微秒时间戳转换为毫秒?
问题描述
在使用confluentinc/kafka-connect-bigquery从 Kafka 填充 BigQuery 时,我想使用我们的域 (Avro) 事件的时间戳来 (day-) 对表进行分区。
我的connector.properties
样子如下:
[...]
transforms=ConvertTimestamp
transforms.ConvertTimestamp.type=org.apache.kafka.connect.transforms.TimestampConverter$Value
transforms.ConvertTimestamp.field=metadata_date
transforms.ConvertTimestamp.target.type=Timestamp
timestampPartitionFieldName=metadata_date
[...]
Exception in thread "pool-5-thread-522" com.wepay.kafka.connect.bigquery.exception.BigQueryConnectException: table insertion failed for the following rows:
[row index 0]: invalid: Timestamp field value is out of range:1597279521000000000
[row index 1]: invalid: Timestamp field value is out of range:1597279523000000000
[...]
问题似乎是,我们的时间戳以微秒为单位(UTC Unix 纪元)
"type": {
"type": "long",
"logicalType": "timestamp-micros"
}
而 BigQuery 需要毫秒(或秒?)。
有没有办法直接使用连接器转换时间戳?
解决方案
推荐阅读
- python - 如何在 python 中读取实时视频提要或视频点播提要?
- angular - 对无声的路线变化做出反应
- node.js - 如何在nodejs中发出get请求
- javascript - 如何将一个集合字段合并到另一个集合字段而不重复
- sql - Pivot 中的参数
- bash - Grep - 获取每次出现的行中的字符位置
- python - 保存生成的矢量图层 QGIS 3.6 python 脚本
- reactjs - 父组件状态改变后重新渲染子组件
- vue.js - 如何从非 vue 类调用 vue i18n?
- javascript - 为什么我不能从此链接获取 XML 文档,为什么在字符串中我可以让所有标签括号都变成引号?