Skip to content

Question marks '?' break queries with filters #2290

@luizarakaki

Description

@luizarakaki

Describe the bug

When a query, which contains a question mark ? and a Metabase filter is executed agaisnt a Clickhouse database, the ? is replaced by null and the query execution fails.

A similar query on Postgres JDBC doesn't fail

To Reproduce

  1. Prepare the following query in Metabase (using new SQL Query) and select a Clickhouse database
WITH 
data as (SELECT '1' as `field?`)
SELECT *
FROM data
WHERE `field?` = {{data_filter}}
  1. Set the data_filter to type string and value 1
  2. Execute the query
  3. Query fails with the following error
Code: 47. DB::Exception: Unknown expression or function identifier `fieldnull` in scope WITH data AS (SELECT '1' AS `field'1'`) SELECT * FROM data WHERE fieldnull = NULL. (UNKNOWN_IDENTIFIER) (version 24.9.3.128 (official build))

When either the ? or WHERE clause is removed, the query is executed successfully.
This behavior cannot be reproduced with a similar query against a PostgreSQL database.

Expected behavior

The Query returns '1'

Configuration

Environment

  • Client version: metabase-clickhouse-driver 1.53.3, used JDBC-v2 0.8.2
  • Language version:
  • OS:

related to metabase/metabase#56364

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions