[英]cube.js join compile error does not match any of the allowed types
I am new to cube.js and have been working through the documentation and can't seem to figure out why I get this error.我是cube.js 的新手,一直在研究文档,但似乎无法弄清楚为什么会出现此错误。 Any ideas?有任何想法吗? I am joining two tables, one contains daily data and the other table contains attributes that I would like to use for segmenting data.我加入了两个表,一个包含日常数据,另一个表包含我想用于分割数据的属性。
I was able to generate the schema nearly entirely from the postgres tables, the only changed I had to make were to tag the columns as primary key.我几乎可以完全从 postgres 表中生成模式,唯一要做的更改是将列标记为主键。
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)
);
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
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`
});
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`,
});
Setting primaryKey to true will change the default value of the shown parameter to false.将 primaryKey 设置为 true 会将显示参数的默认值更改为 false。 If you still want shown to be true — set it manually.如果您仍然希望显示为真 - 手动设置。
Extracted from Documentation Page .摘自文档页面。
I think the issue was that you used primary_key
(snake case) instead of primaryKey
(camel case), as described in docs: https://cube.dev/docs/schema/reference/dimensions#primary-key我认为问题在于您使用了primary_key
(蛇形外壳)而不是primaryKey
(骆驼形外壳),如文档中所述: https : primaryKey
I also have to admit that the error message is not very helpful now.我也不得不承认错误信息现在不是很有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.