Skip to content

Passing a List<String> as a query parameter in client-v2 requires to single quote every element #2407

Closed

Description

@jnd77

Description

The API for query parameters could be more user-friendly for List<String>, and not require to manually surround every string element with a single quote.

Steps to reproduce

See test below.

Error Log or Exception StackTrace

Code: 26. DB::Exception: Cannot parse quoted string: expected opening quote ''', got 'C': value [COLLATIONS, ENGINES] cannot be parsed as Array(String) for query parameter 'table_names'. (CANNOT_PARSE_QUOTED_STRING) (version 25.3.3.42 (official build))

Expected Behaviour

Code Example

  @Test
  void testParamsWithStringList() throws Exception {
    final Client client = new Client.Builder()
        .addEndpoint(Protocol.HTTP, "localhost", 8123, false)
        .setUsername("default")
        .setPassword("")
        .build();
    final Map<String, Object> params = Map.of("table_names", List.of("COLLATIONS", "ENGINES"));
    // This query should not throw an exception
    client.query("SELECT database, name FROM system.tables WHERE name in {table_names:Array(String)}", params).get();
  }

Test is passing when using Map.of("table_names", List.of("'COLLATIONS'", "'ENGINES'")) as params.

Configuration

Client Configuration

See above.

Environment

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

ClickHouse Server

  • ClickHouse Server version: 25.3.3.42
  • ClickHouse Server non-default settings, if any:
  • CREATE TABLE statements for tables involved:
  • Sample data for all these tables, use clickhouse-obfuscator if necessary

Activity

  1. changed the title [-]Passing a `List<String>` as a query parameter requires to sinle quote every element[/-] [+]Passing a `List<String>` as a query parameter in client-v2 requires to single quote every element[/+] on Jun 3, 2025
  2. added
    client
    on Jun 5, 2025
  3. chernser commented on Jun 5, 2025

    @chernser
    Contributor

    @jnd77 thank you for reporting!
    We will look into it.

  4. added
    data-types
    on Jul 12, 2025
  5. usatenko commented on Feb 20, 2026

    @usatenko

    is there any update?

  6. chernser commented on Feb 20, 2026

    @chernser
    Contributor

    Good day, @usatenko!

    Currently no. We will see if can schedule on a release in March.

  7. juliomejia97 commented on Apr 7, 2026

    @juliomejia97

    Is there any update?

  8. chernser commented on Apr 7, 2026

    @chernser
    Contributor

    @juliomejia97
    Good day, we will try in the next release I think. It should be in the May.

  9. added this to the 0.9.10 milestone on Apr 7, 2026
  10. polyglotAI-bot commented on Jul 9, 2026

    @polyglotAI-bot
    Collaborator

    Verified against current main (f862dfd): this is already fixed by #2898 (merged 2026-07-08), so passing a List<String> for an Array(String) parameter no longer needs manual per-element quoting. The fix is unreleased as of 0.8.6 / 0.9.8 — it lands in 0.10.0-rc1.

    What changed

    #2898 added a container-aware parameter formatter (DataTypeConverter#convertParameterToString) that Client.query(...) now applies to every parameter value before it is sent. A Collection / array / Map bound to an Array / Map placeholder is rendered as ClickHouse array/map text with String/temporal leaves single-quoted and numeric/boolean leaves left unquoted — exactly what the server's param_<name> parser expects. So List.of("COLLATIONS", "ENGINES") is now sent as ['COLLATIONS','ENGINES'] instead of [COLLATIONS, ENGINES]. (Your two-arg client.query(sql, params) call routes through the same formatter.)

    Verification on current main

    Your exact reproduction, run against a live server, comparing the two param_table_names encodings for:

    SELECT database, name FROM system.tables WHERE name IN {table_names:Array(String)}
    
    • before (old client output) param_table_names=[COLLATIONS, ENGINES] → Code: 26. DB::Exception: Cannot parse quoted string: expected opening quote ''', got 'C' ... (CANNOT_PARSE_QUOTED_STRING) — the exact error you reported
    • after (current-main client output) param_table_names=['COLLATIONS','ENGINES'] → returns the expected rows

    Regression tests covering List<String> → Array(String) are already merged and green on main:

    • unit — DataTypeConverterTest#testConvertParameterToString asserts List.of("a","b") → ['a','b']
    • integration — QueryTests#testContainerQueryParamsQuoteInnerValues round-trips Array(String) end-to-end through client.queryAll

    Recommendation

    No further code change is needed. @chernser — this can be closed as fixed by #2898.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugclientdata-types

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions