cube.js dremio-odbc-cubejs-driver TypeError: Do not know how to serialize a BigInt 问题

因为cube.js cache 部分使用了json 进行key 的存储,但是因为odbc 部分数据类型会有bigint,cube.js 会报错

解决方法

通过hack 的模式

const CubejsServer = require('@cubejs-backend/server');
const cubejs = require("./cube")
const server = new CubejsServer(cubejs);
BigInt.prototype.toJSON = function() { return this.toString() }
function start(){
    server
    .listen()
    .then(({ version, port }) => {
      console.log(`🚀 Cube.js server (${version}) is listening on ${port}`);
    })
    .catch((e) => {
      console.error('Fatal error during server start: ');
      console.error(e.stack || e);
    });
}
 
start()

说明

以上是关于bigint 的,因为没有经过完整的测试,其他类型可能会有类似的问题,可以参考解决

参考资料

https://github.com/GoogleChromeLabs/jsbi/issues/30
https://github.com/rongfengliang/cubejs-dremio-odbc-driver
https://docs.dremio.com/software/drivers/arrow-flight-sql-odbc-driver/#downloading-and-installing-on-macos
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json

posted on 2023-03-02 19:47  荣锋亮  阅读(304)  评论(0编辑  收藏  举报

导航