cube.js 集成cubestore 时间格式问题

目前cubestore 进行时间的处理是有点问题的(主要是依赖的DataFusion)

现象

  • 参考日志
Error: Error: Internal: Error during planning: Coercion from [Utf8, Utf8] to the signature Exact([Timestamp(Nanosecond, None), Utf8]) failed. 0: <cubestore::CubeError as core::convert::From<datafusion::error::DataFusionError>>
  • 我的表结构
CREATE TABLE demoapp (
    id integer,
    name character varying,
    startdate date,
    insertdata time without time zone,
    myinfo timestamp without time zone
);

分析原因

  • 修改cube driver 添加日志
    需要修改的几个地方,cube/node_modules/@cubejs-backend/cubestore-driver/dist/src/CubeStoreDriver.js
    cube/node_modules/@cubejs-backend/query-orchestrator/dist/src/driver/BaseDriver.js 添加了一些日志,发现一些问题
    参考如下:
 
create sql for cubestore CREATE TABLE dev_pre_aggregations.demoapp_main_jyxgyoq1_z1wvp4lr_1g93vl1 (`id` int, `name` varchar(255), `startdate` timestamp, `insertdata` varchar(255), `myinfo` timestamp)
cubestore query CREATE TABLE dev_pre_aggregations.demoapp_main_jyxgyoq1_z1wvp4lr_1g93vl1 (`id` int, `name` varchar(255), `startdate` timestamp, `insertdata` varchar(255), `myinfo` timestamp)
cubestore query INSERT INTO dev_pre_aggregations.demoapp_main_jyxgyoq1_z1wvp4lr_1g93vl1
        (`id`, `name`, `startdate`, `insertdata`, `myinfo`)
        VALUES (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?)
  • 大致原因
    因为数据类型映射的问题
    BaseDriver 对于time 转为string,对于time without time zone 为映射为string,同时触发了cubestore 内部依赖的datafusion 对于时间处理的bug(新版本的好像已经修改了,但是因为cubestore 使用了自己的fork所有没有更新)

参考修改

注意只能处理数据date类型的

  • CubeStoreDriver
 
const GenericTypeToCubeStore = {
    string: 'varchar(255)',
    text: 'varchar(255)',
    'time without time zone':'timestamp',
    date: 'timestamp',
    time:'timestamp',
};
  • 运行效果
    数据类型正确了

     

     

说明

以上是通过直接修改npm包源码的模式,issue已经反馈官方了,后期提交下pr

posted on   荣锋亮  阅读(108)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2019-05-05 PostGraphile 4.4 发布,支持real time 查询
2014-05-05 SQL Server中如何实现遍历表的记录
2014-05-05 sql 变量赋值
2014-05-05 mysql 行号 获取指定行数据
2014-05-05 SQL Server获取指定行的数据
2014-05-05 sql server 创建内联表值函数
2014-05-05 sql server 表变量存储临时查询数据

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示