Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
elqx opened this issue Oct 27, 2023 · 3 comments
Labels
bug Something isn't working driver:clickhouse Issues related to the ClickHouse driver help wanted Community contributions are welcome.

Comments

@elqx
Copy link

elqx commented Oct 27, 2023

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

@paveltiunov paveltiunov added bug Something isn't working help wanted Community contributions are welcome. labels Oct 31, 2023
@github-actions
Copy link

If you are interested in working on this issue, please leave a comment below and we will be happy to assign the issue to you.
If this is the first time you are contributing a Pull Request to Cube.js, please check our contribution guidelines.
You can also post any questions while contributing in the #contributors channel in the Cube.js Slack.

@paveltiunov
Copy link
Member

@elqx Yep. I guess we need to revisit measure string filters.

@igorlukanin igorlukanin added the driver:clickhouse Issues related to the ClickHouse driver label Oct 8, 2024
@igorlukanin
Copy link
Member

I was able to reproduce this with Cube v0.36.3 (latest), same behavior as reported:

Screenshot 2024-10-08 at 23 18 25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working driver:clickhouse Issues related to the ClickHouse driver help wanted Community contributions are welcome.
Projects
None yet
Development

No branches or pull requests

3 participants