You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Cube.js schema编译报错dimensions.wellId不符合允许类型解决方案咨询

问题根源

你在DailyVolumes cube的schema定义中存在3处语法和逻辑错误,触发了编译校验失败:

  • 主键属性名拼写错误:Cube.js schema 要求主键标记使用驼峰属性名primaryKey,你写的是下划线格式的primary_key,属于非法属性,因此触发校验报错。
  • 联合主键配置错误:daily_volumes表的主键是well_id和record_date的联合主键,不能单独将wellId维度标记为主键。
  • 度量字段不存在:count度量中指定的sql: id对应的字段在daily_volumes表中不存在,运行时也会触发查询错误。

修复方案

将schema/DailyVolumes.js替换为以下代码即可:

cube(`DailyVolumes`, {
  sql: `SELECT * FROM public.daily_volumes`,

  preAggregations: {
    // 预聚合定义写在这里
  },

  joins: {
    Wells: {
      sql: `${CUBE}.well_id = ${Wells}.id`,
      relationship: `belongsTo`,
    },
  },

  measures: {
    count: {
      type: `count`,
      // count类型不指定sql时默认统计行数,也可指定任意非空字段如well_id
      drillMembers: [wellId, recordDate],
    },
    // 可根据业务需要补充产量指标,示例如下
    oilProdBbl: {
      sql: `oil_prod_bbl`,
      type: `sum`
    },
    waterProdBbl: {
      sql: `water_prod_bbl`,
      type: `sum`
    },
    gasProdMcf: {
      sql: `gas_prod_mcf`,
      type: `sum`
    }
  },

  dimensions: {
    recordDate: {
      sql: `record_date`,
      type: `time`,
      primaryKey: true
    },
    wellId: {
      sql: `well_id`,
      type: `number`,
      primaryKey: true,
    },
  },

  dataSource: `default`,
});

内容的提问来源于stack exchange,提问作者bfmcneill

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.26 05:24:04