Skip to content

Conversation

@chernser
Copy link
Contributor

@chernser chernser commented Sep 30, 2024

Summary

BinaryFormatReader implementation is stateful and hold current record to be accessible before calling next(). Data is provided as stream and because of this reason handling hasNext() is complex because reader should read data upfront without affect current own position to avoid skipping records.
This PR fixes detecting if no data is present in data stream.

Note

There are two cases of empty result:

  • SELECT 1 LIMIT 0 - has no result data but has column name and type
  • CREATE TABLE test - has nothing at all, so readers that expect schema before data should also handle it correctly.

Closes #1788

Checklist

Delete items not relevant to your PR:

@sonarqubecloud
Copy link


@Override
public boolean hasNext() {
if (initialState) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to have no results? IE can we be sure it SHOULD always be true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is possible to have no results: empty dataset or completely no data in a response body.
Both cases are handled. The initialState is changed once any bytes are read from input stream).

@chernser chernser changed the title fixes handling empty results while using reader [client-v2] Fixes handling empty results while using reader Oct 1, 2024
@chernser chernser merged commit 38fe7fb into main Oct 1, 2024
@chernser chernser deleted the clientv2_fix_emptyresponse_error branch October 1, 2024 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[client-v2] Exception when trying to read data from an empty result GenericRecord

3 participants