cube-js / cube

📊 Cube — The Semantic Layer for Building Data Applications
https://cube.dev
Other
17.95k stars 1.78k forks source link

missing data is always forced to 0 #4604

Open vprus opened 2 years ago

vprus commented 2 years ago

Since commit https://github.com/cube-js/cube.js/pull/3664/files if a pivot does not have any values for particular combination of dimensions, '0' is returned. This is suboptimal, because in a number of contexts, missing data and zero have different meaning. For example, I use cubejs to visualize certain business predictions, where missing data can indicate a technical problem, while "0" indicates a business problem.

To reproduce

Start cubejs with docker with

% docker run -p 4000:4000 \
  -v ${PWD}:/cube/conf \
  -e CUBEJS_DEV_MODE=true \
  cubejs/cube

Make sure the version is 0.30.7 (the current one as of today) or later.

Connect to a database (I've used clickhouse)

Define schema as

cube('Test', {
    sql: `
SELECT * FROM VALUES('x Int64, y Int64, value Int64', (1, 1, 7), (2, 2, 19))
`,

    measures: {
    value: {
        sql: `value`,
        type: `sum`
        }
    },

    dimensions: {
    x: {
        sql: `x`,
        type: `number`
    },
    y: {
        sql: `y`,
        type: `number`
    }
    }
})

Go to the build tab, and build the query as follows:

Run the query.

Observed effect

Each table cell we have no values for shows "0"

Expected effect

Each table cell we have no value for is empty. Previously (at least in version 0.27.35), that's exactly what happened.

Version: 0.30.7

vasilev-alex commented 2 years ago

Hi @vprus!

Yeah, we missed that part out. But reverting this will cause a breaking change, which we only can do in the next minor release.

vprus commented 2 years ago

Thank you, as soon as it is fixed eventually, I'll be happy, no rush.