Skip to content

Conversation

@mzitnik
Copy link
Contributor

@mzitnik mzitnik commented Sep 30, 2025

Summary

Closes

Checklist

Delete items not relevant to your PR:

  • Closes #
  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG
  • For significant changes, documentation in https://github.com/ClickHouse/clickhouse-docs was updated with further explanations or tutorials

}

// write data
BinaryStreamUtils.writeVarInt(out, 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like we have array of data and doing it in the loop - it keep test code compact.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 3, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
43.4% Coverage on New Code (required ≥ 80%)
4.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@mzitnik mzitnik marked this pull request as ready for review October 5, 2025 07:51
@mzitnik mzitnik merged commit 1e525e7 into main Oct 5, 2025
17 of 22 checks passed
Copy link

@windsurf-bot windsurf-bot bot left a comment

Choose a reason for hiding this comment

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

Other comments (1)

💡 To request another review, post a new comment with "/windsurf-review".

Comment on lines +642 to +656
public String[] getStringArray(String colName) {
Object value = readValue(colName);
if (value instanceof BinaryStreamReader.ArrayValue) {
BinaryStreamReader.ArrayValue array = (BinaryStreamReader.ArrayValue) value;
int length = array.length;
if (!array.itemType.equals(String.class))
throw new ClientException("Not A String type.");
String [] values = new String[length];
for (int i = 0; i < length; i++) {
values[i] = (String)((BinaryStreamReader.ArrayValue) value).get(i);
}
return values;
}
throw new ClientException("Not ArrayValue type.");
}
Copy link

Choose a reason for hiding this comment

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

The getStringArray implementation should follow the same pattern as other array getters by using the getPrimitiveArray method. This would make the code more consistent and reduce duplication.

Suggested change
public String[] getStringArray(String colName) {
Object value = readValue(colName);
if (value instanceof BinaryStreamReader.ArrayValue) {
BinaryStreamReader.ArrayValue array = (BinaryStreamReader.ArrayValue) value;
int length = array.length;
if (!array.itemType.equals(String.class))
throw new ClientException("Not A String type.");
String [] values = new String[length];
for (int i = 0; i < length; i++) {
values[i] = (String)((BinaryStreamReader.ArrayValue) value).get(i);
}
return values;
}
throw new ClientException("Not ArrayValue type.");
}
@Override
public String[] getStringArray(String colName) {
try {
return getPrimitiveArray(colName, String.class);
} catch (ClassCastException | IllegalArgumentException e) {
throw new ClientException("Value cannot be converted to an array of strings", e);
}
}

throw new ClientException("Not A String type.");
String [] values = new String[length];
for (int i = 0; i < length; i++) {
values[i] = (String)((BinaryStreamReader.ArrayValue) value).get(i);
Copy link

Choose a reason for hiding this comment

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

Unnecessary cast in the loop when accessing array elements. The value is already cast to BinaryStreamReader.ArrayValue earlier.

Suggested change
values[i] = (String)((BinaryStreamReader.ArrayValue) value).get(i);
values[i] = (String)array.get(i);

Comment on lines +296 to +308
/**
*
* @param colName
* @return
*/
short[] getShortArray(String colName);

/**
*
* @param colName
* @return
*/
String[] getStringArray(String colName);
Copy link

Choose a reason for hiding this comment

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

The JavaDoc comments for the new methods are incomplete. Consider adding descriptions of what these methods do, similar to other array getter methods in the interface.

Suggested change
/**
*
* @param colName
* @return
*/
short[] getShortArray(String colName);
/**
*
* @param colName
* @return
*/
String[] getStringArray(String colName);
/**
* Reads column with name `colName` as a short array.
*
* @param colName
* @return
*/
short[] getShortArray(String colName);
/**
* Reads column with name `colName` as a string array.
*
* @param colName
* @return
*/
String[] getStringArray(String colName);

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants