簡體   English   中英

cube.js 加入編譯錯誤與任何允許的類型都不匹配

[英]cube.js join compile error does not match any of the allowed types

我是cube.js 的新手,一直在研究文檔,但似乎無法弄清楚為什么會出現此錯誤。 有任何想法嗎? 我加入了兩個表,一個包含日常數據,另一個表包含我想用於分割數據的屬性。

我幾乎可以完全從 postgres 表中生成模式,唯一要做的更改是將列標記為主鍵。

postgres ddl

drop table if exists daily_volumes;
drop table if exists wells;

create table if not exists wells (
    id integer not null,
    well_name varchar(255),
    api_10 varchar(13),
    area varchar(255),
    run varchar(255),
    engineering_id varchar(50),
    accounting_id varchar(50),
    active_flag int,
    primary key (id)
);

create table if not exists daily_volumes(   
    well_id integer not null,
    record_date timestamp not null, 
    oil_prod_bbl float not null,
    water_prod_bbl float not null,
    gas_prod_mcf float not null,
    primary key (well_id, record_date),
    constraint fk_well_id foreign key (well_id) references wells(id)
);


cube.js 錯誤

Error: Error: Compile errors:
DailyVolumes cube: "dimensions.wellId" does not match any of the allowed types
Possible reasons (one of):
    * (dimensions.wellId.case) is required
    * (dimensions.wellId.sql = () => `well_id`) is not allowed
    * (dimensions.wellId.primary_key = true) is not allowed

架構/Wells.js

cube(`Wells`, {
  sql: `SELECT * FROM public.wells`,
  
  preAggregations: {
    // Pre-Aggregations definitions go here
    // Learn more here: https://cube.dev/docs/caching/pre-aggregations/getting-started  
  },
  
  joins: {
    
  },
  
  measures: {
    count: {
      type: `count`,
      drillMembers: [id, wellName, engineeringId, accountingId]
    }
  },
  
  dimensions: {
    id: {
      sql: `id`,
      type: `number`,
      primaryKey: true
    },
    
    wellName: {
      sql: `well_name`,
      type: `string`
    },
    
    api10: {
      sql: `api_10`,
      type: `string`,
      title: `Api 10`
    },
    
    area: {
      sql: `area`,
      type: `string`
    },
    
    run: {
      sql: `run`,
      type: `string`
    },
    
    engineeringId: {
      sql: `engineering_id`,
      type: `string`
    },
    
    accountingId: {
      sql: `accounting_id`,
      type: `string`
    }
  },
  
  dataSource: `default`
});

架構/DailyVolumes.js

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

  preAggregations: {
    // Pre-Aggregations definitions go here
    // Learn more here: https://cube.dev/docs/caching/pre-aggregations/getting-started
  },

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

  measures: {
    count: {
      type: `count`,
      sql: `id`,
      // drillMembers: [recordDate],
    },
  },

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

  dataSource: `default`,
});

將 primaryKey 設置為 true 會將顯示參數的默認值更改為 false。 如果您仍然希望顯示為真 - 手動設置。

摘自文檔頁面

我認為問題在於您使用了primary_key (蛇形外殼)而不是primaryKey (駱駝形外殼),如文檔中所述: https : primaryKey

我也不得不承認錯誤信息現在不是很有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM