question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JDBC Driver marks Nullable Column as non-nullable

See original GitHub issue

Hello,

This is my first question here, so apologies in advance if I missed any information and pls let me know if more info is needed.

We have a table with a column defined as such

 `my_custom_column`                       SimpleAggregateFunction(anyLast, Nullable(DateTime64(3, 'UTC'))),

However, when we attempt to write a row with the column set to a null value, we are getting errors and on debugging it seems like the ClickhouseColumn is set as nullable=false.

Caused by: java.sql.SQLException: Cannot set null to non-nullable column #1 [my_custom_column SimpleAggregateFunction(anyLast, Nullable(DateTime64(3, 'UTC')))]
	at com.clickhouse.jdbc.SqlExceptionUtils.clientError(SqlExceptionUtils.java:73)
	at com.clickhouse.jdbc.internal.InputBasedPreparedStatement.addBatch(InputBasedPreparedStatement.java:328)
	at com.clickhouse.jdbc.internal.InputBasedPreparedStatement.executeAny(InputBasedPreparedStatement.java:110)
	at com.clickhouse.jdbc.internal.InputBasedPreparedStatement.executeLargeUpdate(InputBasedPreparedStatement.java:185)
	at com.clickhouse.jdbc.internal.AbstractPreparedStatement.executeUpdate(AbstractPreparedStatement.java:135)
	at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197)

I am able to insert a NULL value for the column via the clickhouse client CLI - so this seems like an issue with the Java driver. More specifically - an error parsing the column definition from the Database.

Can you please help? Thanks!

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
zhicwucommented, Nov 9, 2022

Good point but LowCardinality is simply ignored(because the column only keeps one single value?):

-- [NULL]	LowCardinality(Nullable(String))
select null::LowCardinality(Nullable(String)) v , toTypeName(v) t

-- [NULL]	Nullable(SimpleAggregateFunction(anyLast, String))
select anyLastSimpleState(v) x, toTypeName(x) y
from (select null::LowCardinality(Nullable(String)) v , toTypeName(v) t)

Having said that, I’ve just verified the local changes and it works well 😃

1reaction
zhicwucommented, Nov 8, 2022

Hi @nym3r0s, thanks for the bug report. For SimpleAggregateFunction, we should use the inner type, so it’s actually nullable column in this case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JDBC Sqlite trying to get Nullable Columns - Stack Overflow
I am trying to retrieve all nullable columns from an SQLite Database in Java. I don't know why JDBC is returning that only...
Read more >
Issues · ClickHouse/clickhouse-jdbc - GitHub
Java client and JDBC driver for ClickHouse. ... JDBC Driver marks Nullable Column as non-nullable bug. #1119 opened on Nov 8 by nym3r0s....
Read more >
- Teradata JDBC Driver returns the wrong schema / column ...
columnNullable indicates that a column allows NULL values. columnNullableUnknown indicates that the nullability of a column's values is unknown.
Read more >
The Connect for JDBC Greenplum driver returns incorrect ...
The Connect for JDBC Greenplum driver returns incorrect value for a not nullable column or expression.
Read more >
Hibernate @NotNull vs @Column(nullable = false) - Baeldung
A quick and practical overview of @NotNull and @Column(nullable = false) in Java.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found