cube.js加入编译"error does not match any of the allowed types"
cube.js join compile "error does not match any of the allowed types"
我有 2 个表,一个包含每日数据,另一个包含我想用于分段数据的属性。
当我尝试编译我的 cube.js 架构时出现以下错误。
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
以下是我的表 DDL 和 cube.js 模式:
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)
);
schema/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`
});
schema/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`,
});
Setting primaryKey to true will change the default value of the shown
parameter to false. If you still want shown to be true — set it
manually.
我认为问题是您使用了 primary_key
(蛇形)而不是 primaryKey
(驼峰),如文档中所述:https://cube.dev/docs/schema/reference/dimensions#primary-key
我也不得不承认错误信息现在不是很有帮助。
我有 2 个表,一个包含每日数据,另一个包含我想用于分段数据的属性。
当我尝试编译我的 cube.js 架构时出现以下错误。
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
以下是我的表 DDL 和 cube.js 模式:
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)
);
schema/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`
});
schema/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`,
});
Setting primaryKey to true will change the default value of the shown parameter to false. If you still want shown to be true — set it manually.
我认为问题是您使用了 primary_key
(蛇形)而不是 primaryKey
(驼峰),如文档中所述:https://cube.dev/docs/schema/reference/dimensions#primary-key
我也不得不承认错误信息现在不是很有帮助。