cube icon indicating copy to clipboard operation
cube copied to clipboard

Internal: Error during planning: Coercion from [Int64Decimal(5), Int64]

Open kal1f opened this issue 1 year ago • 6 comments

Describe the bug I'm trying to query a cube from from playground and get an error.

The interesting point is that when i change granularity all works(added screenshots for comparison).

Works

{
  "measures": [
    "backoffice.in_out"
  ],
  "timeDimensions": [
    {
      "dimension": "backoffice.as_of_date",
      "granularity": "day",
      "dateRange": "Yesterday"
    }
  ],
  "order": {
    "backoffice.as_of_date": "asc"
  }
} 

Does not work

  "measures": [
    "backoffice.in_out"
  ],
  "timeDimensions": [
    {
      "dimension": "backoffice.as_of_date",
      "granularity": "hour",
      "dateRange": "Yesterday"
    }
  ],
  "order": {
    "backoffice.as_of_date": "asc"
  }
}

To Reproduce Steps to reproduce the behavior:

  1. Go to playground
  2. select measures and time

Expected behavior

Screenshots Screenshot 2023-07-13 at 13 20 15 Screenshot 2023-07-13 at 13 23 18

Minimally reproducible Cube Schema my cube:

cube(`backoffice`,
    {
        public: isPublic(`backoffice`, COMPILE_CONTEXT),
        sql_table: `aggregate.backoffice`,
        measures: {
            deposit_amount_eur: {
                sql: `deposit_amount_eur`,
                type: `sum`
            },
            withdrawal_amount_eur: {
                sql: `withdrawal_amount_eur`,
                type: `sum`
            },
            in_out: {
                sql: `1.0 * ${withdrawal_amount_eur} / NULLIF(${deposit_amount_eur}, 0)`,
                type: `number`
            },
        },
        dimensions: {
            as_of_date: {
                sql: `as_of_date`,
                type: `time`
            },
            brand: {
                sql: `brand`,
                type: `string`
            },
            channel: {
                sql: `channel`,
                type: `string`
            },
            operator_id: {
                sql: `operator_id`,
                type: `string`
            },
            currency: {
                sql: `currency`,
                type: `string`,
                format: `currency`
            },
            risk_business_segment: {
                sql: `risk_business_segment`,
                type: `string`,
            },
            player_uid: {
                sql: `player_uid`,
                type: `string`,
            },
            traffic: {
                sql: `traffic`,
                type: `string`,
            },
        },
        dataSource: `default`
    }
);

Version: [e.g. 0.33.30]

kal1f avatar Jul 13 '23 10:07 kal1f

I'm facing the same problem. And it can be reproduced only when pre-aggregation is enabled. Once it's disabled, everything works good.

svdimchenko avatar Jul 19 '23 14:07 svdimchenko

however the following hack fixes the issue

${withdrawal_amount_eur} / NULLIF(CAST(${deposit_amount_eur} AS REAL), 0))

is it a problem on datafusion or cubestore level ?

svdimchenko avatar Jul 20 '23 07:07 svdimchenko

@svdimchenko Yep. If you're using calculations on the Cube Store side, you should make sure types will match there.

paveltiunov avatar Aug 10 '23 17:08 paveltiunov

@paveltiunov Something has been surely broken on Cube lately. I am getting this error on the new table when I am trying to create a ratio metric of two metrics of type sum. I have around 100 other cubes where I use the same syntax to add the ratio metric and they work fine. Can u please point me in the right direction as to what could have been broken here?

anshjain18 avatar Apr 03 '24 14:04 anshjain18

@anshjain18 It would help us track down this issue if you'd provide more info.

Which Cube and Cube Store versions do you run? What is the data source? What is the data model for the cube in question? Do you use pre-aggregations? What is the exact error message? Does it reproduce consistently? Can you reproduce it with a cube that has its sql property defined as SELECT "some_value" AS column_1, "some_value" AS column_2, ...?

igorlukanin avatar Apr 04 '24 13:04 igorlukanin

@anshjain18 Is your issue still relevant? Would be great to get more info then.

igorlukanin avatar May 14 '24 10:05 igorlukanin