-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Hi,
A few weeks ago our Cubedev REST api, which is run as a Docker container on a Linux server, started returning integers as decimals. This happens with dimensions. For example, year, which is "number" in the domain model, turns from 2001 to 2001.0. "0" is added everywhere. It seems that this is a problem with a changed version, but unfortunately now I can't tell from which version exactly it changed. Currently we are using the version in this image "CUBEJS_DOCKER_IMAGE_VERSION=v1.2.24". Such a problem does not exist in an older version, for example "CUBEJS_DOCKER_IMAGE_VERSION=v0.36.6". Maybe there is a fix or workaround for the problem?
I am attaching a .JS file that I used in tests, but the same problem is with data from SQL server databases too.
Here is the model:
cube(`Fact`, {
sql: `
SELECT * FROM (VALUES
(1, 1001, 500, '2024-02-01'),
(2, 1002, 700, '2024-02-02'),
(3, 1001, 800, '2024-02-03'),
(4, 1003, 600, '2024-02-04')
) AS t(sale_id, product_id, sales_value, sale_date)
`,
joins: {
Dim: {
sql: `${CUBE}.product_id = ${Dim}.product_id`,
relationship: `belongsTo`
}
},
measures: {
totalSales: {
type: `sum`,
sql: `sales_value`
}
},
dimensions: {
saleId: {
sql: `sale_id`,
type: `number`,
primaryKey: true
},
productId: {
sql: `product_id`,
type: `string`
},
saleDate: {
sql: `sale_date`,
type: `time`
}
}
});
cube(`Dim`, {
sql: `
SELECT * FROM (VALUES
(1001, 'Laptop', 'Electronics', 2001),
(1002, 'Phone', 'Electronics', 2002),
(1003, 'Desk', 'Furniture', 2003)
) AS t(product_id, product_name, category, year)
`,
joins: {
Fact: {
sql: `${CUBE}.product_id = ${Fact}.product_id`,
relationship: `hasMany`
}
},
dimensions: {
productId: {
sql: `product_id`,
type: `string`,
primaryKey: true
},
productName: {
sql: `product_name`,
type: `string`
},
category: {
sql: `category`,
type: `string`
},
year: {
sql: `year`,
type: `number`
}
}
});And here is the query:
{
"limit": 5000,
"dimensions": [
"Dim.year"
],
"measures": [
"Fact.totalSales"
]
}Thanks,
Marius