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

client v2 query result get by reader.next() error #2098

Closed
YoKv opened this issue Jan 21, 2025 · 1 comment · Fixed by #2105
Closed

client v2 query result get by reader.next() error #2098

YoKv opened this issue Jan 21, 2025 · 1 comment · Fixed by #2105
Assignees
Milestone

Comments

@YoKv
Copy link

YoKv commented Jan 21, 2025

in my case (BI),column is not certain

error result

query by reader.next() data repeat
list data id is 5,4,5,4,5

Expected behaviour

list data id is 1,2,3,4,5

Code example

        List<Map<String, Object>> list = new ArrayList<>();
        var response = client.query("select id,timestamp_column from `ods_table_datetime_table` limit 0,10", querySettings).get();
        var reader = new RowBinaryWithNamesAndTypesFormatReader(response.getInputStream(), response.getSettings(), new BinaryStreamReader.DefaultByteBufferAllocator());
        while (reader.hasNext()) {
            final Map<String, Object> next = reader.next();
            list.add(next);
            System.out.println(next);
            System.out.println(reader.getString("id"));
        }

Error log

Image

Image

Configuration

Environment

  • Client version: 0.7.2
  • Language version: java 17
@YoKv YoKv added the bug label Jan 21, 2025
@chernser
Copy link
Contributor

chernser commented Jan 21, 2025

Good day, @YoKv!

The next() will return a reference to a map that stores current record. I will add a warning about it to javadoc of this method.
After getting map from next() you need to copy values to another map.
You can achieve this by calling com.clickhouse.client.api.data_formats.internal.AbstractBinaryFormatReader#readRecord which accepts user created map.

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

Successfully merging a pull request may close this issue.

2 participants