You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support all Aggregate Functions as parameter for columns of type AggregateFunction #1232
clientModule: the client (client-v2; with legacy: the v1 client)data-typesArea: type names, value encoding and decoding, row mapping, data formatsduplicateenhancementjdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)native-formatNative code: the Native format codec (blocks, type names, column bytes)stale
changed the title [-]Support Aggregate Functions as parameter for columns of type AggregateFunction[/-][+]Support all Aggregate Functions as parameter for columns of type AggregateFunction[/+]on Feb 10, 2023
It's in roadmap but we haven't completed refactoring yet. In v0.4.0, serialization/deserialization was refactored with some performance improvement but still not easy to extend. On the other hand, in order to support more AggregateFunction types, since there's no document about the data structures for read and write, we have to dig into ClickHouse code to figure it out one by one, which is going to take a while. Would be great if someone from the server team can document all the details, so that not only Java but all other clients will benefit from that.
I just ran into this issue as well. I have a AggregatingMergeTree table with a column of type AggregateFunction(argMin, Decimal(18, 4), DateTime).
The working around for now seems to be:
Create a new table with Engine = MergeTree and create a materialized view on top of the table if one has any AggregateFunction functions and wants to insert those columns.
@den-crane Thanks for the neat trick that is cool but unfortunately that does not work for me as I use the JDBC driver in a Flink pipeline, I am getting the error:
Caused by: java.sql.SQLException: External table, input function, and query parameter cannot be used together in PreparedStatement.
at com.clickhouse.jdbc.SqlExceptionUtils.clientError(SqlExceptionUtils.java:73)
at com.clickhouse.jdbc.internal.ClickHouseConnectionImpl.prepareStatement(ClickHouseConnectionImpl.java:743)
at com.clickhouse.jdbc.ClickHouseConnection.prepareStatement(ClickHouseConnection.java:121)
at org.apache.flink.connector.jdbc.internal.executor.SimpleBatchStatementExecutor.prepareStatements(SimpleBatchStatementExecutor.java:58)
at org.apache.flink.connector.jdbc.internal.JdbcBatchingOutputFormat.createAndOpenStatementExecutor(JdbcBatchingOutputFormat.java:144)
... 12 more
So I assume I have to go with 2 tables for now or write my own sink function
This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!
This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!
Recommendation: Close — duplicate of #2599 #2599 asks for the same in client-v2 and jdbc-v2, with a newer analysis on main. Keep #2599 open.
Category: Feature
Classification: impact: none · area: Data types & formats (AggregateFunction) · native: format
Status on main: Not supported on main — at 8480ca001, ClickHouse 26.11.4.11, a read of a column AggregateFunction(argMin, Decimal(18, 4), DateTime) (the type in the thread) fails in jdbc-v2, and in client-v2 with RowBinaryWithNamesAndTypes and with Native: Failed to read value for column m.
Breaking change: No — can be done without a break, if groupBitmap states still read as ClickHouseBitmap.
Analysis: The client-v2 reader decodes each AggregateFunction state as groupBitmap (BinaryStreamReader.java:292), and the writer rejects all other functions (SerializerUtils.java:1052). The v1 code of the issue link has the same limit on main (ClickHouseRowBinaryProcessor.java:574 and :734).
Automated triage by Polyglot AI. A maintainer makes the final decision.
clientModule: the client (client-v2; with legacy: the v1 client)data-typesArea: type names, value encoding and decoding, row mapping, data formatsduplicateenhancementjdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)native-formatNative code: the Native format codec (blocks, type names, column bytes)stale
Activity
[-]Support Aggregate Functions as parameter for columns of type AggregateFunction[/-][+]Support all Aggregate Functions as parameter for columns of type AggregateFunction[/+]zhicwu commentedon Feb 10, 2023
It's in roadmap but we haven't completed refactoring yet. In v0.4.0, serialization/deserialization was refactored with some performance improvement but still not easy to extend. On the other hand, in order to support more AggregateFunction types, since there's no document about the data structures for read and write, we have to dig into ClickHouse code to figure it out one by one, which is going to take a while. Would be great if someone from the server team can document all the details, so that not only Java but all other clients will benefit from that.
Zarathustra2 commentedon Apr 28, 2023
I just ran into this issue as well. I have a
AggregatingMergeTreetable with a column of typeAggregateFunction(argMin, Decimal(18, 4), DateTime).The working around for now seems to be:
Create a new table with
Engine = MergeTreeand create a materialized view on top of the table if one has any AggregateFunction functions and wants to insert those columns.den-crane commentedon Apr 30, 2023
@Zarathustra2 see https://kb.altinity.com/altinity-kb-schema-design/ingestion-aggregate-function/
Zarathustra2 commentedon May 1, 2023
@den-crane Thanks for the neat trick that is cool but unfortunately that does not work for me as I use the JDBC driver in a Flink pipeline, I am getting the error:
So I assume I have to go with 2 tables for now or write my own sink function
zhicwu commentedon May 2, 2023
Hi @Zarathustra2, you don't have to specify parameters when using input function. Just added below test case for demonstration.
Zarathustra2 commentedon May 2, 2023
oh wow, @zhicwu, I thought I had to specify the params as well. Now it works!!! :)
Thanks so much!
github-actions commentedon Jan 8, 2025
This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!
github-actions commentedon Nov 15, 2026
This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!
polyglotAI-bot commentedon Nov 28, 2026
Recommendation: Close — duplicate of #2599
#2599 asks for the same in client-v2 and jdbc-v2, with a newer analysis on
main. Keep #2599 open.main: Not supported on main — at8480ca001, ClickHouse 26.11.4.11, a read of a columnAggregateFunction(argMin, Decimal(18, 4), DateTime)(the type in the thread) fails in jdbc-v2, and in client-v2 withRowBinaryWithNamesAndTypesand withNative:Failed to read value for column m.groupBitmapstates still read asClickHouseBitmap.groupBitmapwith no error.Analysis: The client-v2 reader decodes each
AggregateFunctionstate asgroupBitmap(BinaryStreamReader.java:292), and the writer rejects all other functions (SerializerUtils.java:1052). The v1 code of the issue link has the same limit onmain(ClickHouseRowBinaryProcessor.java:574and:734).Automated triage by Polyglot AI. A maintainer makes the final decision.