cube-js/cube

Clickhouse: incorrect query when filtering on 'string' measure with 'equals' operator

Open

#7,328 创建于 2023年10月27日

在 GitHub 查看
 (4 评论) (0 反应) (0 负责人)Rust (1,965 fork)batch import
driver:clickhousehelp wanted

仓库指标

Star
 (19,563 star)
PR 合并指标
 (平均合并 5天 16小时) (30 天内合并 138 个 PR)

描述

Describe the bug Cube generates incorrect query when measure of type 'string' is used as a filter with operator 'equals'. This applies to Clickhouse driver. Despite the measure being of type 'string', the generated HAVING clause tries to compare string value to the value of toFloat64(?).

To Reproduce Steps to reproduce the behavior:

  1. Use Clickhouse driver
  2. Use the Cube schema that I provided below
  3. Run the query with a filter on 'string' measure and operator 'equals' (see attached screenshots)

Expected behavior The correct query should be generated. Cube should not use the toFloat64 function.

Screenshots image

image

Minimally reproducible Cube Schema

cube(`cubeA`, {
    
    sql: `
        select 1 as id, 100 as number
    `,

    dimensions: {
        id: {
            type: 'number',
            sql: 'id',
            primary_key: true
        },
        number: {
            type: 'number',
            sql: 'number'
        }
    },
   
    measures: {
      high_or_low: {
        type: `string`,
        sql: `CASE WHEN ${CUBE.number} > 100 THEN 'high' ELSE 'low' END`
      },
    },
  });

Version: 0.34.10

贡献者指南