cube.js data-blending一些说明

cube.js 的data-blending 理论上是可以支持多种查询的的聚合的,但是因为目前有一些限制,使用起来不是很方便

参考代码

gateway.ts 文件
async getNormalizedQueries(query, context) {
        query = this.parseQueryParam(query);
        let queryType = query_1.QUERY_TYPE.REGULAR_QUERY;
        if (!Array.isArray(query)) {
            query = this.compareDateRangeTransformer(query);
            if (Array.isArray(query)) {
                queryType = query_1.QUERY_TYPE.COMPARE_DATE_RANGE_QUERY;
            }
        }
        else {
            queryType = query_1.QUERY_TYPE.BLENDING_QUERY;
        }
        const queries = Array.isArray(query) ? query : [query];
        const normalizedQueries = await Promise.all(queries.map((currentQuery) => this.queryTransformer(query_1.normalizeQuery(currentQuery), context)));
        if (normalizedQueries.find((currentQuery) => !currentQuery)) {
            throw new Error('queryTransformer returned null query. Please check your queryTransformer implementation');
        }
        if (queryType === query_1.QUERY_TYPE.BLENDING_QUERY) {
           //  此处限制了必须使用包含时间区间数据的,参考如下禁用就可以临时解决
            // const queryGranularity = query_1.getQueryGranularity(normalizedQueries);
            // if (queryGranularity.length > 1) {
            //     throw new UserError_1.UserError('Data blending query granularities must match');
            // }
            // if (queryGranularity.filter(Boolean).length === 0) {
            //     throw new UserError_1.UserError('Data blending query without granularity is not supported');
            // }
        }
        return [queryType, normalizedQueries];
    }

参考查询

query 参数传递一个数组(url编码)同时添加queryType=multi 参考

http://localhost:4000/cubejs-api/v1/load?query=%5B%7B%22measures%22%3A%5B%22CallCenter.count%22%5D%2C%22timeDimensions%22%3A%5B%5D%2C%22order%22%3A%7B%22CallCenter.count%22%3A%22desc%22%7D%2C%22dimensions%22%3A%5B%22CallCenter.ccName%22%5D%2C%22limit%22%3A50%7D%2C%7B%22measures%22%3A%5B%22Customer.count%22%5D%2C%22timeDimensions%22%3A%5B%5D%2C%22order%22%3A%7B%22Customer.count%22%3A%22desc%22%7D%2C%22dimensions%22%3A%5B%22Customer.cLastName%22%5D%2C%22limit%22%3A50%7D%5D&queryType=multi

query 实际为

[{"measures":["CallCenter.count"],"timeDimensions":[],"order":{"CallCenter.count":"desc"},"dimensions":["CallCenter.ccName"],"limit":50},{"measures":["Customer.count"],"timeDimensions":[],"order":{"Customer.count":"desc"},"dimensions":["Customer.cLastName"],"limit":50}]

解决方法

可以参考上边的删除限制,目前已经提交了一个issue,期待后边官方的回复

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

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2020-04-20 AxonFrameworksAxonFramework jvm 上强大的演进式事件驱动的微服务框架
2020-04-20 earthly 通用容器构建工具
2020-04-20 ff4j web console 配置说明
2020-04-20 ff4j aop模式动态bean 切换
2020-04-20 ff4j Flipping Strategies
2020-04-20 ff4j 一些高级概念
2020-04-20 ff4j spring boot jdbc 基本试用

导航

< 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
点击右上角即可分享
微信分享提示