cube icon indicating copy to clipboard operation
cube copied to clipboard

The greater than numeric comparison does not work properly against mysql/starrocks

Open chrisfw opened this issue 11 months ago • 4 comments

Bug Description Using the mysql/starrocks dialect, a simple select with a numeric greater than comparison returns incorrect results. I tried using both a simple select with a where clause and wrapping it in an outer select and neither worked correctly.

select * from (
select balance_amount from cibalancedetailhistory) a
where a.balance_amount > 100;

balance_amount is a decimal64 (11,2) in the underlying mysql/Starrocks database

To Reproduce Steps to reproduce the behavior:

  1. Create a table in starrocks with the decimal datatype specified above
  2. Populate the table BALANCEAMOUNT column with a range of decimal amounts
  3. Run a select query as provided above

Expected behavior Only values greater than the specified where clause comparison value should be returned.

Screenshots cube-dev-problem

Minimally reproducible Cube Schema In case your bug report is data modelling related please put your minimally reproducible Cube Schema here. You can use selects without tables in order to achieve that as follows.

cube(`cibalancedetailhistory`, {
  sql_table: `db.cibalancedetailhistory`,

  data_source: `default`,

  joins: {

  },

  dimensions: {
    balance_detail_history_id: {
      sql: `BALANCEDETAILHISTORYID`,
      type: `number`
    },
 	history_date: {
      sql: `HISTORYDATE`,
      type: `time`
    },
	balance_amount: {
      sql: `BALANCEAMOUNT`,
      type: `number`
    },
  },
  measures: {
    count: {
      sql: `BALANCEDETAILHISTORYID`,
      type: `count`,
    }
  },

  pre_aggregations: {
    // Pre-aggregation definitions go here.
    // Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started
  }
});

Version: [e.g. 0.35.0]

chrisfw avatar Mar 21 '24 21:03 chrisfw

@chrisfw are you using SQL API to query Cube? It'd be also helpful to see SQL executed in starrocks. You can find it in logs.

paveltiunov avatar Mar 24 '24 22:03 paveltiunov

Hi @paveltiunov , yes I am using the SQL API. The query + results screen capture I provided is from the DBeaver SQL connection to cube. I will get the Starrocks executed sql for you when I resume work on Tuesday. Regards, Chris

chrisfw avatar Mar 24 '24 23:03 chrisfw

@chrisfw By any chance, are you able to provide the "Starrocks executed sql"?

igorlukanin avatar May 14 '24 10:05 igorlukanin

@igorlukanin , the sql is in the bug description above:

select * from (
select balance_amount from cibalancedetailhistory) a
where a.balance_amount > 100;

chrisfw avatar May 14 '24 13:05 chrisfw