Skip to content

Conversation

@kailash360
Copy link

@kailash360 kailash360 commented Feb 9, 2026

Summary

This PR standardizes boolean parsing across modules so configuration values accept both true/false and 1/0 (with null/unrecognized values treated as false). This improves compatibility with tools and environments that only emit numeric booleans.

Closes

Checklist

Delete items not relevant to your PR:


Note

Medium Risk
Behavior changes for boolean parsing in config and value conversion paths could alter outcomes for previously non-standard string values, though the change is small and well-covered by new tests.

Overview
Standardizes boolean parsing across clickhouse-data, client-v2, and jdbc-v2 by introducing ClickHouseUtils.parseBoolean(String) (supports true/false and 1/0, defaults to false for null/unknown) and routing existing boolean parsing through it.

Updates client config parsing (ClientConfigProperties.parseValue), string-to-boolean conversions in serialization/value conversion helpers (SerializerUtils, ValueConverters), and JDBC driver flags (JdbcConfiguration) to use the new parser, and adds targeted unit tests covering numeric and textual boolean inputs.

Written by Cursor Bugbot for commit 3128606. This will update automatically on new commits. Configure here.

@CLAassistant
Copy link

CLAassistant commented Feb 9, 2026

CLA assistant check
All committers have signed the CLA.

Assert.assertTrue(ClickHouseUtils.parseBoolean("true"));
Assert.assertFalse(ClickHouseUtils.parseBoolean("false"));

// unrecognized values should be parsed as false
Copy link
Member

Choose a reason for hiding this comment

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

@chernser shouldn't we throw an exception for unrecognized values?

Copy link
Author

Choose a reason for hiding this comment

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

If there is an unrecognized value, then we should also follow the behavior pattern of other configs in this case.

For example, the default_query_settings config accepts a set of settings, else null by default. Now, if someone sets a random setting that is not used by Clickhouse then does it throw an error, or simply ignores that?

Similarly, jdbc_sql_parser accepts 1 of 3 enum constants. Does it throw an error if any other value is passed?

If we throw an exception only for boolean types and simply ignore for other types, then it will create inconsistent behaviour. Please let me know your thoughts on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kailash360 both mentioned settings are not validated but should.
jdbc_sql_parser will throw exception later while creating connection. That is not correct and we will fix it.
Most Client configurations validated in the Builder.

Please add throwing exception if boolean value is not what we expect.

Thanks!

@chernser
Copy link
Contributor

@kailash360
thank you for the contribution - I will review PR this week.

@chernser
Copy link
Contributor

@kailash360
There are some compilation errors

Error:  /home/runner/work/clickhouse-java/clickhouse-java/client-v2/src/test/java/com/clickhouse/client/api/ClientConfigPropertiesTest.java:[24,1] class, interface, or enum expected
Error:  /home/runner/work/clickhouse-java/clickhouse-java/client-v2/src/test/java/com/clickhouse/client/api/ClientConfigPropertiesTest.java:[27,1] class, interface, or enum expected
Error:  /home/runner/work/clickhouse-java/clickhouse-java/client-v2/src/test/java/com/clickhouse/client/api/ClientConfigPropertiesTest.java:[28,1] class, interface, or enum expected
Error:  /home/runner/work/clickhouse-java/clickhouse-java/client-v2/src/test/java/com/clickhouse/client/api/ClientConfigPropertiesTest.java:[30,1] class, interface, or enum expected

We currently still supporting java 8.

* @param value string value
* @return parsed boolean, or {@code false} if value is null or unrecognized
*/
public static boolean parseBoolean(String value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this method to client-v2
I suggest utilizing ValueConverters.

Copy link
Contributor

Choose a reason for hiding this comment

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

PS: clickhouse-data is an old package that we may deprecate so V2 should minimize dependencies on it. Besides clickhouse-data relates to client-v1 and this method is not used there.

Copy link
Contributor

@chernser chernser left a comment

Choose a reason for hiding this comment

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

Please apply suggested changes.
Thanks!

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.

[jdbc-v2, client-v2] Accept 1 and 0 for boolean properties

4 participants