Skip to content

new parser doesn't parse parameters in certain circumstances #2422

@dpsutton

Description

@dpsutton

This is a P1 for us at metabase.

Description

The new parser introduced in #2351 seems to not recognize parameters in some circumstances

Steps to reproduce

The query is similarly shaped to

  select
    *
  from
    a_table
  where
    some_thing = ?::UUID
    and `timestamp01` >= `parseDateTimeBestEffort`(?, ?)

In 0.8.6:

❯ clj -Sdeps '{:deps {com.clickhouse/clickhouse-jdbc {:mvn/version "0.8.6"}}}'
Clojure 1.12.0
user=> (with-open [conn (java.sql.DriverManager/getConnection "jdbc:clickhouse://localhost:8123" "default" "password")
                               stmt (.prepareStatement conn "
  select
    *
  from
    a_table
  where
    some_thing = ?::UUID
    and `timestamp01` >= `parseDateTimeBestEffort`(?, ?)
")]
                     (when-let [md (.getParameterMetaData stmt)]
                       (.getParameterCount md)))
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
1

contrast against:

user=>   (with-open [conn (java.sql.DriverManager/getConnection "jdbc:clickhouse://localhost:8123" "default" "password")
              stmt (.prepareStatement conn "
  select
    *
  from
    a_table
  where
    some_thing = 1
    and `timestamp01` >= `parseDateTimeBestEffort`(?, ?)
")]
    (when-let [md (.getParameterMetaData stmt)]
      (.getParameterCount md)))
2

Here it finds both parameters with the above where clause has a concrete 1 rather than a ?::UUID

In 0.8.4:

❯ clj -Sdeps '{:deps {com.clickhouse/clickhouse-jdbc {:mvn/version "0.8.4"}}}'
Clojure 1.12.0
user=>     (with-open [conn (java.sql.DriverManager/getConnection "jdbc:clickhouse://localhost:8123" "default" "password")
                stmt (.prepareStatement conn "
  select
    *
  from
    a_table
  where
    some_thing = ?::UUID
    and `timestamp01` >= `parseDateTimeBestEffort`(?, ?)
")]
      (when-let [md (.getParameterMetaData stmt)]
        (.getParameterCount md)))
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
3

It correctly sees all 3 parameters.

Expected Behaviour

The new parser should identify all parameters in the query

Configuration

Client Configuration

0.8.4 vs 0.8.6

Environment

  • Cloud
  • Client version:
  • Language version:
  • OS:

ClickHouse Server

running clickhouse latest. no tables required

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions