zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    软件杯-题目和插件
    基于《河北省重大技术需求征集系统》的可用性和可修改性战术分析
    基于淘宝网的系统质量属性六大场景
    架构漫谈读后感
    06掌握需求过程阅读笔记之一
    大道至简读后感以及JAVA伪代码
    K8S学习笔记
    事务的七种传播类型、及案例
    香港身份证规则
    oracle函数
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/14731173.html
Copyright © 2011-2022 走看看