Skip to content

[client-v2] Allow QuerySettings in POJO queryAll overloads #3112

Description

@Nex1332

Hi! This is my first issue in this repository, so apologies if I did not formulate the idea perfectly.

I'm also not completely sure whether this API change is technically appropriate or possible. There may be a reason why QuerySettings cannot or should not be passed to the POJO queryAll overloads. If so, I would be happy to understand the reasoning.

Description

The experimental POJO queryAll API currently does not provide an overload that accepts QuerySettings.

Current overloads:

queryAll(String sqlQuery, Class<T> clazz, TableSchema schema)

queryAll(
    String sqlQuery,
    Class<T> clazz,
    TableSchema schema,
    Supplier<T> allocator
)

Internally, the method creates its own QuerySettings:

QuerySettings settings =
    new QuerySettings()
        .setFormat(ClickHouseFormat.RowBinaryWithNamesAndTypes);

Because of that, callers cannot provide query/server settings such as:

  • limit
  • page
  • max_execution_time
  • query id
  • database
  • other operation-level server settings

At the same time, queryAll for GenericRecord already accepts QuerySettings and copies the supplied settings while forcing the response format to RowBinaryWithNamesAndTypes.

It would be useful if the POJO overloads supported the same behavior.

Proposed API

For example:

public <T> List<T> queryAll(
    String sqlQuery,
    Class<T> clazz,
    TableSchema schema,
    QuerySettings settings
)

public <T> List<T> queryAll(
    String sqlQuery,
    Class<T> clazz,
    TableSchema schema,
    QuerySettings settings,
    Supplier<T> allocator
)

The response format should still be controlled internally by queryAll, since POJO deserialization depends on RowBinaryWithNamesAndTypes.

In other words, the provided settings could be copied and then:

requestSettings.setFormat(
    ClickHouseFormat.RowBinaryWithNamesAndTypes
);

This would keep POJO deserialization safe while allowing callers to use settings such as pagination, execution limits, query id, database, etc.

Why

This would make the POJO queryAll API consistent with the existing GenericRecord queryAll API and would avoid forcing callers to reimplement the POJO deserialization path only to pass custom QuerySettings.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions